Update of /cvsroot/openfirst/logger
In directory sc8-pr-cvs1:/tmp/cvs-serv30009/logger
Modified Files:
logger.php
Log Message:
Added user counter code. Also logs hits by useragent. Requires table ofirst_hitcount.
Index: logger.php
===================================================================
RCS file: /cvsroot/openfirst/logger/logger.php,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** logger.php 23 Aug 2003 20:30:12 -0000 1.6
--- logger.php 30 Sep 2003 23:45:29 -0000 1.7
***************
*** 54,56 ****
,'".$MEMBER."')") or die(ofirst_dberror());
! ?>
\ No newline at end of file
--- 54,122 ----
,'".$MEMBER."')") or die(ofirst_dberror());
! //Total Pages Served counter
!
! //Get current value and increment
! $totalpg=get_totalpages()+1;
! if ($totalpg==1){
! //First hit ever - add record to table
! ofirst_dbquery("INSERT INTO ofirst_hitcount (Name,Value) values ('totalpages','1');");
! }
! else {
! //Write new value to DB
! ofirst_dbquery('UPDATE ofirst_hitcount SET Value="'.$totalpg.'" WHERE Name="totalpages";');
! }
! unset($totalpg);
!
! //Visitor counter
!
! if(!isset($_SESSION["FirstHit"])){
! //Set session var for this visitor
! $_SESSION["FirstHit"]=1;
!
! //Get current value and increment
! $total=get_visitors()+1;
! if ($total==1){
! //First hit ever - add record to table
! ofirst_dbquery("INSERT INTO ofirst_hitcount (Name,Value) values ('total','1');");
! }
! else {
! //Write new value to DB
! ofirst_dbquery('UPDATE ofirst_hitcount SET Value="'.$total.'" WHERE Name="total";');
! }
!
! //Browser individual hit counter
! $query=ofirst_dbquery('SELECT Value FROM ofirst_hitcount WHERE Name="'.$BROWSER.'"');
! //Get current value
! $total=ofirst_dbfetch_object($query);
! //Increment
! $total=($total->Value)+1;
! if ($total==1){
! //First hit by this useragent - add record to table
! ofirst_dbquery("INSERT INTO ofirst_hitcount (Name,Value) values ('".$BROWSER."','1');");
! }
! else {
! //Write new value to DB
! ofirst_dbquery('UPDATE ofirst_hitcount SET Value="'.$total.'" WHERE Name="'.$BROWSER.'";');
! }
! unset($total);
! }
!
!
! function get_visitors()
! {
! $query=ofirst_dbquery('SELECT Value FROM ofirst_hitcount WHERE Name="total"');
! //Get current value
! $visits=ofirst_dbfetch_object($query);
! //Return
! return ($visits->Value);
! }
!
! function get_totalpages()
! {
! $query=ofirst_dbquery('SELECT Value FROM ofirst_hitcount WHERE Name="totalpages"');
! //Get current value
! $visits=ofirst_dbfetch_object($query);
! //Return
! return ($visits->Value);
! }
! ?>
|