Newer
Older
function parseIdleTime($idletime) {
$idlearray = preg_split("/[hms]/",$idletime);
if (strstr('h', $idletime)) {
$hours = $idlearray[0];
$minutes = $idlearray[1];
$seconds = 0;
} elseif (strstr('m', $idletime)) {
$hours = 0;
$minutes = $idlearray[0];
$seconds = $idlearray[1];
} else {
$hours = 0;
$minutes = 0;
$seconds = $idlearray[0];
}
return ($hours * 3600) + ($minutes * 60) + $seconds;
}
function compare_idletime($a, $b) {
return strnatcmp($a['idleseconds'], $b['idleseconds']);
}
exec("/usr/bin/mw -who", $wholist, $ret);
$people = array();
foreach ($wholist as $person) {
$pid = strtok($person, " ");
if ($pid == "" || $pid == "Name" || substr($pid,0,5)=="-----") continue;
$person = array(
"username" => trim(substr($person, 1, 16)),
"idle" => trim(substr($person, 18, 6)),
"idleseconds" => parseIdleTime(trim(substr($person, 18, 6))),
if ($person['idleseconds'] > 3600) {
$idlers[] = $person;
} else {
$people[] = $person;
}
usort($people, 'compare_idletime');
usort($idlers, 'compare_idletime');
$smarty->assign("idlers",$idlers);
$output = $smarty->fetch($base."templates/milliways.tpl");
$smarty->assign("title", "Milliways");
Graham Cole
committed
$smarty->assign("body", file_get_contents($base."static/fragments/Milliways.txt"));
$smarty->assign("secondary", $output);
$smarty->assign("refresh", 120);
?>