T4VN is an online PHP Help community that provides PHP Tutorials, PHP Examples, PHP Scripts, PHP Support
    HOME  |  HOSTING COUPON  |  TEMPLATE  |  PHP SCRIPTS  |  LINK TO US  |  LINK  |  REGISTER | CONTACT
::: Member Login :::
 Username
 Password
 
Forgot your password ?
::: PHP Tutotal :::
  PHP Basic (7)
  PHP Advanced (4)
  PHP Database (2)
  Coding Step By Step (8)
  PHP and AJAX (0)
::: PHP Example :::
  Arrays (1)
  Code Highlighters (3)
  Database Functions (12)
  Date & Time (5)
  E-Mail (6)
  Forms (5)
  Guestbooks (1)
  Logging (2)
  Miscellaneous (10)
  Password Generators (3)
  Randomizers (3)
  String Manipulation (10)
  User Authentication (6)
::: Search On T4VN :::
::: T4VN Statistics :::
  PHP Scripts : 61
  PHP Example : 67
  PHP Tutorials : 21
  PHP News : 93
  Total Coupon : 36
  Other Tutorials :
  Member : 209
  Visitor Online : 5
  Today Visit: 388
  Total Visitor : 262398
  Most Online : 31
::: Sponsored Links :::

PR 4 For This Webpage
Home Today :

Log Hits Per Page

Author : vinnie

Plain simple script to keep track of the page hits.

PHP Example :

<?
$STAT_HITS 
"../hitsperpage.txt";
$PAGE pathinfo($_SERVER["PHP_SELF"]);
$BASENAME substr($PAGE["basename"], 0strlen($PAGE["basename"]) - 4);
/*
$BASENAME is filename without directories and extension
$STAT_HITS is a flat text file with filenames without directories and extension and number of hits on that page (delimiter is "|") so for example:
index|199|

See the script in action on www.vincentpeters.nl
*/
logHitsperpage($STAT_HITS,$BASENAME);

function 
logPagehits($STAT_HITS,$BASENAME){
    
$file file("$STAT_HITS");
    
$match false;
    
$sOut "";
    for(
$x=0;$x<sizeof($file);$x++){
        
$arrRec explode("|",$file[$x]);
        
$t $arrRec[0];
        if(
$t == $BASENAME){
            
$match true;
            
$arrRec[1]++;
        }
        
$sOut .= $arrRec[0]."|".$arrRec[1]."|rn";
    }
    if(
$match == false){ // if entry does not exist add new entry with one (1) hit
        
$sOut .= $BASENAME."|1|rn";
    }
    
$outFile fopen("$STAT_HITS""w");
    
fputs($outFile,$sOut);
    
fclose($outFile);
}
?>


Other Example


::: Resources :::
  Links Directory
  Programming 2 3
  Webmaster 2 3
  Web Design 2 3
  Web Hosting 2 3
  Other Links 2 3
  Asian ShowBiz News
  Teach Seo For You
::: New Templates :::




::: Other Tutorials :::
 Program Design

  Powered By T4VN.NET - Version 2.0 - CopyRight © T4VN.NET 2005-2007