$diffsecs = strtotime("now")-strtotime($row['last']); output((int)($diffsecs/86400)."d ".(int)($diffsecs/3600%3600)."h ".(int)($diffsecs/60%60)."m ".(int)($diffsecs%60)."s"); output("`b</td><td>`b".HTMLEntities($row['site']==""?"`iNone`i":$row['site'])."`b</td></tr>",true); $sql = "SELECT count,last,uri FROM referers WHERE site='".addslashes($row['site'])."' ORDER BY {$order}"; $result1 = db_query($sql); $skippedcount=0; $skippedtotal=0; for ($k=0;$k<db_num_rows($result1);$k++){ $row1=db_fetch_assoc($result1); $diffsecs = strtotime("now")-strtotime($row1['last']); if ($diffsecs<=604800){ output("<tr class='trlight'><td>",true); output($row1['count']); output("</td><td valign='top'>",true); //output((int)($diffsecs/86400)."d".(int)($diffsecs/3600%3600)."h".(int)($diffsecs/60%60)."m".(int)($diffsecs%60)."s"); output(dhms($diffsecs)); output("</td><td valign='top'>",true); if ($row1['uri']>"") output("<a href='".HTMLEntities($row1['uri'])."' target='_blank'>".HTMLEntities(substr($row1['uri'],0,150))."</a>`n",true); else output("`i`bNone`b`i`n"); output("</td></tr>",true); }else{ $skippedcount++; $skippedtotal+=$row1['count']; } } if ($skippedcount>0){ output("<tr class='trlight'><td>$skippedtotal</td><td valign='top' colspan='2'>`i$skippedcount records skipped (over a week old)`i</td></tr>",true); } //output("</td></tr>",true);
$yourpeti = translate_mail("Your Petition", 0); $peti = translate_mail("Petition", 0); $row['body'] = str_replace("[charname]", translate_mail("[charname]", 0), $row['body']); $row['body'] = str_replace("[email]", translate_mail("[email]", 0), $row['body']); $row['body'] = str_replace("[description]", translate_mail("[description]", 0), $row['body']); // For email replies, make sure we don't overflow the URI buffer. $reppet = substr(stripslashes($row['body']), 0, 2000); output("`@From: "); if ($row['login'] > "") { rawoutput("<a href=\"mail.php?op=write&to=" . rawurlencode($row['login']) . "&body=" . rawurlencode("\n\n----- {$yourpeti} -----\n{$reppet}") . "&subject=RE:+{$peti}\" target=\"_blank\" onClick=\"" . popup("mail.php?op=write&to=" . rawurlencode($row['login']) . "&body=" . rawurlencode("\n\n----- {$yourpeti} -----\n{$reppet}") . "&subject=RE:+{$peti}") . ";return false;\"><img src='images/newscroll.GIF' width='16' height='16' alt='{$write}' border='0'></a>"); } output_notl("`^`b%s`b`n", $row['name']); output("`@Date: `^`b%s`b (%s)`n", $row['date'], relativedate($row['date'])); output("`@Status: %s`n", $statuses[$row['status']]); if ($row['closedate'] != '0000-00-00 00:00:00') { output("`@Last Update: `^%s`@ on `^%s (%s)`n", $row['closer'], $row['closedate'], dhms(strtotime('now') - strtotime($row['closedate']), true)); } output("`@Body:`^`n"); $body = htmlentities(stripslashes($row['body']), ENT_COMPAT, getsetting("charset", "ISO-8859-1")); $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: {$peti}&body=" . str_replace("+", " ", URLEncode("\n\n----- {$yourpeti} -----\n" . $row['body'])) . "'>\\1</a>", $body); $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body); rawoutput("<span style='font-family: fixed-width'>" . nl2br($body) . "</span>"); commentdisplay("`n`@Commentary:`0`n", "pet-{$id}", "Add information", 200); if ($viewpageinfo) { output("`n`n`@Page Info:`&`n"); $row['pageinfo'] = stripslashes($row['pageinfo']); $body = HTMLEntities($row['pageinfo'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")); $body = preg_replace("'([[:alnum:]_.-]+[@][[:alnum:]_.-]{2,}([.][[:alnum:]_.-]{2,})+)'i", "<a href='mailto:\\1?subject=RE: {$peti}&body=" . str_replace("+", " ", URLEncode("\n\n----- {$yourpeti} -----\n" . $row['body'])) . "'>\\1</a>", $body); $body = preg_replace("'([\\[][[:alnum:]_.-]+[\\]])'i", "<span class='colLtRed'>\\1</span>", $body); rawoutput("<pre>" . nl2br($body) . "</pre>"); }
//addnav("Refresh the stats","stats.php"); addnav("Stats Types"); addnav("Totals & Averages", "stats.php?op=stats"); addnav("Top Referers", "stats.php?op=referers"); addnav("Logon Graph", "stats.php?op=graph"); $op = httpget("op"); if ($op == "stats" || $op == "") { $sql = "SELECT sum(gentimecount) AS c, sum(gentime) AS t, sum(gensize) AS s, count(acctid) AS a FROM " . db_prefix("accounts"); $result = db_query($sql); $row = db_fetch_assoc($result); output("`b`%For existing accounts:`b`n"); output("`@Total Accounts: `^%s`n", number_format($row['a'])); output("`@Total Hits: `^%s`n", number_format($row['c'])); output("`@Total Page Gen Time: `^%s`n", dhms($row['t'])); output("`@Total Page Gen Size: `^%sb`n", number_format($row['s'])); output("`@Average Page Gen Time: `^%s`n", dhms($row['t'] / $row['c'], true)); output("`@Average Page Gen Size: `^%s`n", number_format($row['s'] / $row['c'])); } elseif ($op == "referers") { output("`n`%`bTop Referers:`b`0`n"); rawoutput("<table border='0' cellpadding='2' cellspacing='1' bgcolor='#999999'>"); $name = translate_inline("Name"); $refs = translate_inline("Referrals"); rawoutput("<tr class='trhead'><td><b>{$name}</b></td><td><b>{$refs}</b></td></tr>"); $sql = "SELECT count(*) AS c, acct.acctid,acct.name AS referer FROM " . db_prefix("accounts") . " INNER JOIN " . db_prefix("accounts") . " AS acct ON acct.acctid = " . db_prefix("accounts") . ".referer WHERE " . db_prefix("accounts") . ".referer>0 GROUP BY " . db_prefix("accounts") . ".referer DESC ORDER BY c DESC"; $result = db_query($sql); $number = db_num_rows($result); for ($i = 0; $i < $number; $i++) { $row = db_fetch_assoc($result); rawoutput("<tr class='" . ($i % 2 ? "trdark" : "trlight") . "'><td>"); output_notl("`@{$row['referer']}`0"); rawoutput("</td><td>");
isnewday(2); page_header("Stats"); addnav("G?Return to the Grotto","superuser.php"); addnav("M?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"); output("`n`%`bTop Referers:`b`0`n"); output("<table border='0' cellpadding='2' cellspacing='1' bgcolor='#999999'>",true); output("<tr class='trhead'><td><b>Name</b></td><td><b>Referrals</b></td></tr>",true); $sql = "SELECT count(*) AS c, acct.acctid,acct.name AS referer FROM accounts INNER JOIN accounts AS acct ON acct.acctid = accounts.referer WHERE accounts.referer>0 GROUP BY accounts.referer DESC ORDER BY c DESC"; $result = db_query($sql); for ($i=0;$i<db_num_rows($result);$i++){ $row = db_fetch_assoc($result); output("<tr class='".($i%2?"trdark":"trlight")."'><td>",true); output("`@{$row['referer']}`0</td><td>`^{$row['c']}:`0 ", true); $sql = "SELECT name,refererawarded from accounts WHERE referer = ${row['acctid']} ORDER BY acctid ASC"; $res2 = db_query($sql); for ($j = 0; $j < db_num_rows($res2); $j++) { $r = db_fetch_assoc($res2); output(($r['refererawarded']?"`&":"`$") . $r['name'] . "`0");
output_notl("`b" . ($row['site'] == "" ? $none : $row['site']) . "`b"); rawoutput("</td></tr>"); $sql = "SELECT count,last,uri,dest,ip FROM " . db_prefix("referers") . " WHERE site='" . addslashes($row['site']) . "' ORDER BY {$order} LIMIT 25"; $result1 = db_query($sql); $skippedcount = 0; $skippedtotal = 0; $number = db_num_rows($result1); for ($k = 0; $k < $number; $k++) { $row1 = db_fetch_assoc($result1); $diffsecs = strtotime("now") - strtotime($row1['last']); if ($diffsecs <= 604800) { rawoutput("<tr class='trlight'><td>"); output_notl($row1['count']); rawoutput("</td><td valign='top'>"); //output((int)($diffsecs/86400)."d".(int)($diffsecs/3600%3600)."h".(int)($diffsecs/60%60)."m".(int)($diffsecs%60)."s"); output_notl(dhms($diffsecs)); rawoutput("</td><td valign='top'>"); if ($row1['uri'] > "") { rawoutput("<a href='" . HTMLEntities($row1['uri'], ENT_COMPAT, getsetting("charset", "ISO-8859-1")) . "' target='_blank'>" . HTMLEntities(substr($row1['uri'], 0, 100)) . "</a>"); } else { output_notl($none); } output_notl("`n"); rawoutput("</td><td valign='top'>"); output_notl($row1['dest'] == '' ? $notset : $row1['dest']); rawoutput("</td><td valign='top'>"); output_notl($row1['ip'] == '' ? $notset : $row1['ip']); rawoutput("</td></tr>"); } else { $skippedcount++; $skippedtotal += $row1['count'];