Quick Search:
 
 PHP Code: Flat file counter Jump to:  
Category: >> PHP Code >> Flat file counter  

<< lastnext >>

Snippet Name: Flat file counter

Description: Simple demo of a flat file counter.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

<?PHP
 
$visitor_ip = $HTTP_COOKIE_VARS["user_ip"]; 
$counter = "counter.txt"; 
$counter_file_line = FILE($counter); 
 
IF(!$vistor_ip) 
{ 
  SETCOOKIE("user_ip", $REMOTE_ADDR, TIME()+360000); 
  $counter_file_line[0]++; 
  $cf = FOPEN($counter, "w+"); 
  FPUTS($cf, "$counter_file_line[0]"); 
  FCLOSE($cf); 
} 
ELSEIF($vistor_ip != $REMOTE_ADDR) 
{ 
  $counter_file_line[0]++; 
  $cf = FOPEN($counter, "w+"); 
  FPUTS($cf, "$counter_file_line[0]"); 
  FCLOSE($cf); 
} 
?>
 


 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org