[Openfirst-cvscommit] logger stats.php,NONE,1.1
Brought to you by:
xtimg
From: <i-...@us...> - 2003-09-30 23:41:43
|
Update of /cvsroot/openfirst/logger In directory sc8-pr-cvs1:/tmp/cvs-serv29370/logger Added Files: stats.php Log Message: New file. Displays statistical data and a usage graph. --- NEW FILE: stats.php --- <?php /* * openFIRST.logger - stats.php * * Copyright (C) 2003, * openFIRST Project * Original Author: Greg Inozemtsev <gr...@si...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ include("../config/globals.php"); include("$header"); //check if outputting a graph if(isset($_GET["graph"])){ //output caption switch($_GET["graph"]){ //yearly case 3:{ echo("<h1>Yearly Usage Graph</h1>"); break; } //monthly case 2:{ echo("<h1>Monthly Usage Graph</h1>"); break; } //weekly default:{ echo("<h1>Weekly Usage Graph</h1>"); break; } } //start the table echo("<table width=500><tr><td><div>"); //check if GDlib is installed if (function_exists("imagecreatefrompng")){ //show a graph echo('<img src="'.$basepath.'/logger/graph.php?graph='.$_GET["graph"].'">'); } else { //no GDlib - show error message echo('<b>GDlib</b> extension for PHP is required for this functionality. GDlib is included in PHP 4.2.3 and up. For more information consult the openFIRST manual or visit <a href="http://www.boutell.com/gd/" target="_blank">GDlib homepage</a> or <a href="http://www.php.net/" target="_blank">PHP.net</a>'); } //finish the table echo('</div></td></tr> <tr><td background="'.$basepath.'/images/back-light.gif"> <div align=right><a href="'.$_SERVER["PHP_SELF"].'?graph=1">Weekly Graph</a> | <a href="'.$_SERVER["PHP_SELF"].'?graph=2">Monthly Graph</a> | <a href="'.$_SERVER["PHP_SELF"].'?graph=3">Yearly Graph</a></div></td></tr></table><hr><br>'); } ?> <h1>Usage Statistics for <?php echo($title); ?></h1> <table cols=2 width=400> <tr align=left valign=bottom> <td colspan=2 background="<?php echo($basepath); ?>/images/back-light.gif"> <h3 style="margin-bottom:0px">Pages</h3><div align=right>(Total Requests)</div></td> </tr> <tr> <td><b>Total Pages Served</b> </td><td align=right> <?php if (function_exists("get_totalpages")){ echo (get_totalpages()); } else { echo ("User counter not installed"); } ?> </td> </tr> <tr> <td><b>Logger Entries</b> </td><td align=right> <?php $query=ofirst_dbquery("SELECT * FROM ofirst_logger;") or die(ofirst_dberror()); $pages=ofirst_dbnum_rows($query); echo($pages); ?> </td> </tr> <?php $query=ofirst_dbquery("SELECT * FROM ofirst_hitcount ORDER BY Value DESC;") or die(ofirst_dberror()); $useragents=ofirst_dbnum_rows($query); $browsers=array(); $platforms=array(); $total=0; if ($useragents != 0){ while($useragent = ofirst_dbfetch_object($query)){ $browser=$useragent->Name; if($browser=="total"){ $total=$useragent->Value; } else{ if($browser!="totalpages"){ $browse=identify_browser($useragent->Name); if(isset($browsers[$browse])){ $browsers[$browse]+=$useragent->Value; } else { $browsers[$browse]=$useragent->Value; } $platform=identify_platform($useragent->Name); if(isset($platforms[$platform])){ $platforms[$platform]+=$useragent->Value; } else { $platforms[$platform]=$useragent->Value; } } } } } ?> <tr> <td><b>Total Visitors</b> </td><td align=right><?php echo($total); ?> </td> </tr> <tr align=left valign=bottom> <td colspan=2 background="<?php echo($basepath); ?>/images/back-light.gif"> <h3 style="margin-bottom:0px">Browsers</h3><div align=right>Items: <?php echo(sizeof($browsers)); ?> </div></td></tr> <?php foreach ($browsers as $i => $value){ echo("<tr><td><b>".$i."</b></td><td align=right>".$value." visitors (".round(($value/$total)*100,1)."%)</td></tr>"); echo('<tr><td colspan=2 align=right><img src="'.$basepath.'/images/back.gif" height=6 width='.round(($value/$total)*150).'></td></tr>'); } ?> <tr align=left valign=bottom> <td colspan=2 background="<?php echo($basepath); ?>/images/back-light.gif"> <h3 style="margin-bottom:0px">Platforms</h3><div align=right>Items: <?php echo(sizeof($platforms)); ?> </div></td></tr> <?php foreach ($platforms as $i => $value) { echo("<tr><td><b>".$i."</b></td><td align=right>".$value." visitors (".round(($value/$total)*100,1)."%)</td></tr>"); echo('<tr><td colspan=2 align=right><img src="'.$basepath.'/images/back.gif" height=6 width='.round(($value/$total)*150).'></td></tr>'); } ?> <tr><td colspan=2><br><hr><div align=right><b><a href="<?php echo($_SERVER["PHP_SELF"]); ?>?graph=1">Usage Graph</a></b></div></td></tr> </table> <p align=left style="margin-left:60%;align:left;font-weight:normal;font-size:8pt;"><b>Notice</b>: This statistical data is not guaranteed to be accurate. The browser and platform information is displayed as supplied by the web server. Consult the openFIRST manual for more information.</p> <?php include("$footer"); ?> |