<?php
/*
This script is the on I use at my site. So consider is
just as an example an get what you want from the DB. I
will add some nice looking graphs one day...
*/
$ptitle="phpMyCoCo - statistics";
include("include/header.inc");
?>
<!-- my content starts here -->
<div class="doc">
<h1 class="centered"><b>phpMyCoCo</b> statistics mode</h1>
<?php
if(@mysql_connect("","","")) // Your db-Credentials here
{
$COCOPATH = ""; // You know what PATH you're on.
if(!include
("$COCOPATH/coco.main.php4"))
{echo "Cannot include coco!\n";}
$coco = new phpMyCoCo;
$coco -> init();
$STATS = array(
"count_pages" => "select count(*) from coco_counter;",
"sum_hits" => "select sum(hits) from coco_counter;",
"distinct_ips" => "select count(distinct ip) from coco_access;",
"distinct_browser" => "select count(distinct browser) from coco_access where browser != '';",
"browsers" => "select browser, count(browser) as anzahl from coco_access where browser != \"\" group by browser order by anzahl desc LIMIT 0,20;",
"top20ip" => "select ip, count(ip) as anzahl from coco_access where ip!='127.0.0.1' and ip != '139.18.184.107' group by ip order by anzahl desc LIMIT 0,20;",
"top20referer" => "select referer, count(referer) as anzahl from coco_access where referer != '' and referer not like '%comment.php4?action=%' group by referer order by anzahl desc LIMIT 0,20;",
"top20hits" => "select name,hits from coco_counter order by hits DESC LIMIT 0,20;",
"top20comments" => "select name,comments from coco_counter order by comments DESC LIMIT 0,20;"
);
$answer = $coco -> cocodb -> db_query($STATS[count_pages]);
$result = $coco -> cocodb -> db_fetch_array($answer);
$count_pages = $result[0];
$answer = $coco -> cocodb -> db_query($STATS[sum_hits]);
$result = $coco -> cocodb -> db_fetch_array($answer);
$sum_hits = $result[0];
$answer = $coco -> cocodb -> db_query($STATS[distinct_ips]);
$result = $coco -> cocodb -> db_fetch_array($answer);
$distinct_ips = $result[0];
$answer = $coco -> cocodb -> db_query($STATS[distinct_browser]);
$result = $coco -> cocodb -> db_fetch_array($answer);
$distinct_browser = $result[0];
echo "<p>This phpMyCoCo is watching $count_pages pages and has recorded a total of $sum_hits hits from $distinct_ips distinct IPs using $distinct_browser distinct browsers (the last two Numbers are small, because they were not monitored previous to March 10th 2001).</p>\n";
echo "<p>Top browsers:</p>\n";
echo "<table cellpadding=2 cellspacing=0 border=0><tr bgcolor=\"#dddddd\"><td><p>Browser</p></td><td align=\"right\"><p># logentries</p></td></tr>\n";
$answer = $coco -> cocodb -> db_query($STATS[browsers]);
while($result = $coco -> cocodb -> db_fetch_array($answer))
{echo "<tr bgcolor=\"#eeeeee\"><td><p>$result[browser]</p></td><td align=\"right\"><p>$result[anzahl]</p></td></tr>\n";}
echo "</table>\n";
echo "<p>Top IPs:</p>\n";
echo "<table cellpadding=2 cellspacing=0 border=0><tr bgcolor=\"#dddddd\"><td><p>IP</p></td><td align=\"right\"><p># logentries</p></td></tr>\n";
$answer = $coco -> cocodb -> db_query($STATS[top20ip]);
while($result = $coco -> cocodb -> db_fetch_array($answer))
{echo "<tr bgcolor=\"#eeeeee\"><td><p>$result[ip]</p></td><td align=\"right\"><p>$result[anzahl]</p></td></tr>\n";}
echo "</table>\n";
echo "<p>Top referers:</p>\n";
echo "<table cellpadding=2 cellspacing=0 border=0><tr bgcolor=\"#dddddd\"><td><p>referer</p></td><td align=\"right\"><p># logentries</p></td></tr>\n";
$answer = $coco -> cocodb -> db_query($STATS[top20referer]);
while($result = $coco -> cocodb -> db_fetch_array($answer))
{echo "<tr bgcolor=\"#eeeeee\"><td><p><a href=\"$result[referer]\">$result[referer]</a></p></td><td align=\"right\"><p>$result[anzahl]</p></td></tr>\n";}
echo "</table>\n";
echo "<p>Top pages by hits:</p>\n";
echo "<table cellpadding=2 cellspacing=0 border=0><tr bgcolor=\"#dddddd\"><td><p>Page</p></td><td align=\"right\"><p># hits</p></td></tr>\n";
$answer = $coco -> cocodb -> db_query($STATS[top20hits]);
while($result = $coco -> cocodb -> db_fetch_array($answer))
{echo "<tr bgcolor=\"#eeeeee\"><td><p><a href=\"$result[name]\">$result[name]</a></p></td><td align=\"right\"><p>$result[hits]</p></td></tr>\n";}
echo "</table>\n";
echo "<p>Top pages by comments:</p>\n";
echo "<table cellpadding=2 cellspacing=0 border=0><tr bgcolor=\"#dddddd\"><td><p>Page</p></td><td align=\"right\"><p># comments</p></td></tr>\n";
$answer = $coco -> cocodb -> db_query($STATS[top20comments]);
while($result = $coco -> cocodb -> db_fetch_array($answer))
{echo "<tr bgcolor=\"#eeeeee\"><td><p><a href=\"$result[name]\">$result[name]</a></p></td><td align=\"right\"><p>$result[comments]</p></td></tr>\n";}
echo "</table>\n";
?>
</div>
<!-- my content ends here -->
<?php
$coco -> includePageComments();
}
?>
<?php include("include/footer.inc"); ?>
|