/*
* PHP Freaks Code Library
* http://www.phpfreaks.com/quickcode.php
*
* Title: Hit counter
* Version: 1.0
* Author: LeoXavior
* Date: Tuesday, 12/17/2002 - 09:40 PM
*
*
*
* NOTICE: This code is available from PHPFreaks.com code Library.
* This code is not Copyrighted by PHP Freaks.
*
* PHP Freaks does not claim authorship of this code.
*
* This code was submitted to our website by a user.
*
* The user may or may not claim authorship of this code.
*
* If there are any questions about the origin of this code,
* please contact the person who submitted it, not PHPFreaks.com!
*
* USE THIS CODE AT YOUR OWN RISK! NO GUARANTEES ARE GIVEN!
*
* SHAMELESS PLUG: Need WebHosting? Checkout WebHost Freaks:
* http://www.webhostfreaks.com
* WebHosting by PHP Freaks / The Web Freaks!
*/
// * Description / Example:
// *
// * This counter logs ips of ppl that hit your site, and unlike alot of similar counters it checks if the ip is already listed
// * and skips re-adding it to keep filesize down.. Was a must do for me just fixed it
// * - Dec. 2002
?>
counter.hits #
Set Vars uptop to the file you want to make and your start date. #
-Updated so counter.hits only logs one instance of the same ip to keep filesize down #
######################################################################################
*/
/*
Core Variables
*/
$filename = "counter.hits" ;
$startdate = "Februari 2006" ;
$ip = getenv("REMOTE_ADDR") ;
$currentip = "$ip";
$file = file($filename);
$file = array_unique($file);
/*
This is the guts of the counter
*/
$file = "$filename";
$fd = fopen ($file, "r");
$fget= fread ($fd, filesize ($file));
fclose ($fd);
$totalips = htmlspecialchars($fget);
if (preg_match ("/$ip/i", "$totalips"))
{$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo "Visitors since, ";
echo "$startdate: 000$hits";}
else
{
$fd = fopen ($filename , "r");
$fstring = fread ($fd , filesize ($filename)) ;
fclose($fd) ;
$fd = fopen ($filename , "w");
$fcounted = $fstring.$currentip."\n";
$fout= fwrite ($fd , $fcounted);
fclose($fd);
$file = file($filename);
$file = array_unique($file);
$hits = count($file);
echo "Visitors since, ";
echo "$startdate: 000$hits";
}
?>