View Source: /source/stats.php

Click here for the source, OR
Other files that you may wish to view the source of:

Source of: /source/stats.php

<?
require_once "common.php";
page_header("Stats");
addnav("Return to the grotto","superuser.php");
addnav("Return to the mundane","village.php");
addnav("Refresh the stats","stats.php");

$sql "SELECT sum(gentimecount) AS c, sum(gentime) AS t, sum(gensize) AS s, count(*) AS a FROM accounts";
$result db_query($sql);
$row db_fetch_assoc($result);
output("`b`%For existing accounts:`b`n");
output("`@Total Accounts: `^".number_format($row['a'])."`n");
output("`@Total Hits: `^".number_format($row['c'])."`n");
output("`@Total Page Gen Time: `^".dhms($row['t'])."`n");
output("`@Total Page Gen Size: `^".number_format($row['s'])."b`n");
output("`@Average Page Gen Time: `^".dhms($row['t']/$row['c'],true)."`n");
output("`@Average Page Gen Size: `^".number_format($row['s']/$row['c'])."`n");
$sql "SELECT count(*) AS c, substring(laston,1,10) AS d FROM accounts GROUP BY d DESC";
$result db_query($sql);
output("`n`%`bDate accounts last logged on:`b");
$output.="<table border='0' cellpadding='0' cellspacing='5'>";
$class="trlight";
$odate=date("Y-m-d");
$j=0;
for (
$i=0;$i<db_num_rows($result);$i++){
    
$row db_fetch_assoc($result);
    
$diff = (strtotime($odate)-strtotime($row['d']))/86400;
    for (
$x=1;$x<$diff;$x++){
        
//if ($j%7==0) $class=($class=="trlight"?"trdark":"trlight");
        //$j++;
        
$class=(date("W",strtotime("$odate -$x days"))%2?"trlight":"trdark");
        
$output.="<tr class='$class'><td>".date("Y-m-d",strtotime("$odate -$x days"))."</td><td>0</td><td>$cumul</td></tr>";
    }
//    if ($j%7==0) $class=($class=="trlight"?"trdark":"trlight");
//    $j++;
    
$class=(date("W",strtotime($row['d']))%2?"trlight":"trdark");
    
$cumul+=$row['c'];
    
$output.="<tr class='$class'><td>{$row['d']}</td><td><img src='images/trans.gif' width='{$row['c']}' border='1' height='5'>{$row['c']}</td><td>$cumul</td></tr>";
    
$odate $row['d'];
}
$output.="</table>";
page_footer();
?>