// just run me from a browser.
// if anyone thinks of other good stats, let me know.
?>
Phorum Stats
include "./common.inc"; // adjust if neccasary.
reset($forums);
$forum=current($forums);
while($forum){
$sSQL="Select max(datestamp) as max from ".$forum["table"];
$q->query($DB, $sSQL);
$max=$q->field("max", 0);
if(substr($max,0,10)==date("Y-m-d")){
$last_full_day=date("Y-m-d", mktime(0,0,0,substr($max, 5,2),substr($max, 8,2)-1,substr($max, 0,4)));
}
else{
$last_full_day=substr($max, 0,10);
}
$sSQL="Select min(datestamp) as min from ".$forum["table"];
$q->query($DB, $sSQL);
$first_day=substr($q->field("min", 0), 0,10);
$sSQL="Select count(*) as total from ".$forum["table"]." where datestamp < '$last_full_day 23:59:59'";
$q->query($DB, $sSQL);
$total=$q->field("total", 0);
echo "".$forum["name"]."
\n";
echo "
\n";
if($total){
$time1=mktime(0,0,0,substr($last_full_day, 5,2),substr($last_full_day, 8,2)-1,substr($last_full_day, 0,4));
$time2=mktime(0,0,0,substr($first_day, 5,2),substr($first_day, 8,2)-1,substr($first_day, 0,4));
$date_diff=($time1 - $time2)/84600;
if($date_diff==0) $date_diff=1;
$avg=number_format($total/$date_diff, 1, '.', '');
echo "Analyzed posts from $first_day through $last_full_day
\n";
echo "Total messages: $total ($avg/day)
\n";
if($date_diff>10){
$ten_days_ago=date("Y-m-d", mktime(0,0,0,substr($last_full_day, 5,2),substr($last_full_day, 8,2)-10,substr($last_full_day, 0,4)));
$sSQL="Select count(*) as total from ".$forum["table"]." where datestamp < '$last_full_day 23:59:59' and datestamp > '$ten_days_ago'";
$q->query($DB, $sSQL);
$last_ten=$q->field("total", 0);
$ten_avg=number_format($last_ten/10, 1, '.', '');
echo "Last 10 days: $last_ten ($ten_avg/day)
\n";
}
$sSQL="select author,email,count(*) as cnt from ".$forum["table"]." group by author,email order by cnt desc limit 10";
$q->query($DB, $sSQL);
if ($q->numrows()>0){
if ($q->numrows()>10){
$num_authors=$max_authors;
} else {
$num_authors=$q->numrows();
}
$row=$q->getrow();
echo "Top $num_authors posters:
\n";
while($row){
echo $row["author"];
if($row["email"]) echo " <".$row["email"].">";
echo " (".$row["cnt"].")
\n";
$row=$q->getrow();
}
}
}
else{
echo "No messages.
\n";
}
echo "
\n";
$forum=next($forums);
}
?>