Skip to content
Snippets Groups Projects
Commit 9b586f51 authored by Justin Mitchell's avatar Justin Mitchell
Browse files

add new uri support

parent cde733c0
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,66 @@ function compare_idletime($a, $b) { ...@@ -24,6 +24,66 @@ function compare_idletime($a, $b) {
return strnatcmp($a['idleseconds'], $b['idleseconds']); return strnatcmp($a['idleseconds'], $b['idleseconds']);
} }
$mwpath = array_search("Milliways", $pathlist);
$newpath = $baseurl;
for($i=0;$i<=$mwpath;$i++) {
if ($i!=0) $newpath .= "/";
$newpath .= $pathlist[$i];
}
$smarty->assign("mwpath", $newpath);
if (strtolower($pathlist[$mwpath+1]) == "uri") {
$today = FALSE;
if (isset($pathlist[$mwpath+2]))
$today = strtotime($pathlist[$mwpath+2]);
if ($today === FALSE)
$today = time();
$smarty->assign("extra_scripts", array(
'<meta name="ROBOTS" content="NOINDEX" />',
'<meta name="ROBOTS" content="NOFOLLOW" />'));
$mwdb = new PDO('sqlite:/var/lib/mw/mwuri.db');
$res = $mwdb->prepare("select *, time(added) as hour, date(added) as day from mwuri where date(added)=? order by added desc");
$res->execute(array(date("Y-m-d",$today)));
$data = $res->fetchAll(PDO::FETCH_ASSOC);
foreach($data as $k => $row)
{
if ($row['tags']) {
$json = json_decode($row['tags'], TRUE);
$data[$k]['taglist'] = $json[0]['top_tags'];
}
}
$smarty->assign("urilist", $data);
$res = $mwdb->prepare("select distinct strftime('%Y',added) from mwuri");
$res->execute();
$yearlist = $res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("yearlist",$yearlist);
$res= $mwdb->prepare("select distinct strftime('%m',added) from mwuri where strftime('%Y',added) = ?");
$res->execute(array(date("Y",$today)));
$monthlist = $res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("monthlist",$monthlist);
$res= $mwdb->prepare("select distinct strftime('%d',added) from mwuri where strftime('%Y-%m',added) = ?");
$res->execute(array(date("Y-m",$today)));
$daylist = $res->fetchAll(PDO::FETCH_COLUMN,0);
$smarty->assign("daylist",$daylist);
$smarty->assign("thisyear", date("Y",$today));
$smarty->assign("thismonth", date("m",$today));
$smarty->assign("thisday", date("d",$today));
$output = $smarty->fetch($base."templates/milliways_uri.tpl");
$smarty->assign("title", "Milliways URI");
$smarty->assign("body", $output);
$smarty->assign("extra_styles", "/css/milliways.css");
$smarty->assign("refresh", 120);
return;
}
exec("/usr/bin/mw -who", $wholist, $ret); exec("/usr/bin/mw -who", $wholist, $ret);
$people = array(); $people = array();
$idlers = array(); $idlers = array();
...@@ -46,6 +106,7 @@ foreach ($wholist as $person) { ...@@ -46,6 +106,7 @@ foreach ($wholist as $person) {
usort($people, 'compare_idletime'); usort($people, 'compare_idletime');
usort($idlers, 'compare_idletime'); usort($idlers, 'compare_idletime');
$output .= print_r($pathlist, true);
$smarty->assign("people",$people); $smarty->assign("people",$people);
$smarty->assign("idlers",$idlers); $smarty->assign("idlers",$idlers);
......
<table>
<tr>
<td nowrap="nowrap" class="date" colspan="3">
Year: {foreach from=$yearlist item=year}{if $year != $thisyear}<a href="{$mwpath}/uri/{$year}-01-01">{$year}</a> {else}{$year}{/if}{/foreach}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="date" colspan="3">
Month: {foreach from=$monthlist item=month}{if $month != $thismonth}<a href="{$mwpath}/uri/{$thisyear}-{$month}-01">{$month}</a> {else}{$month} {/if}{/foreach}
</td>
</tr>
<tr>
<td nowrap="nowrap" class="date" colspan="3">
Day: {foreach from=$daylist item=day}{if $day != $thisday}<a href="{$mwpath}/uri/{$thisyear}-{$thismonth}-{$day}">{$day}</a> {else}{$day}{/if}{/foreach}
</td>
</tr>
{assign var=lastday value=''}
{foreach from=$urilist item=row name=list}
{if $row.day != $lastday}
{assign var=lastday value=$row.day}
<tr>
<td nowrap="nowrap" class="date" colspan="3">{$row.added|date_format:'%d %b %Y'}</td>
</tr>
{/if}
{assign var=rows value=1}
{if $row.title}{assign var=rows value=$rows+1}{/if}
{if count($row.taglist)}{assign var=rows value=$rows+1}{/if}
<tr>
<td nowrap="nowrap" class="time" rowspan="{$rows}">{$row.hour}</td>
<td nowrap="nowrap" class="user" rowspan="{$rows}">{$row.user}</td>
<td ><a href="{$row.url|escape:"hexentity"}">{$row.url|truncate:80:" ... ":true:true|escape:"html"}</a></td>
</tr>
{if $row.title}
<tr><td>{$row.title|escape:"html"}</td></tr>
{/if}
{if count($row.taglist)}
<tr>
<td class="taglist">
Tags:
{foreach from=$row.taglist item=tcount key=tname name=tags}{$tname}{if !$smarty.foreach.tags.last}, {/if}{/foreach}
</td>
</tr>
{/if}
{/foreach}
</table>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment