Jump to content

Unique counter


perkins_dp

Recommended Posts

im using this and using an include in my main file,

 

<?

 

$filename = "counter.txt";

 

$file = file($filename);

$file = array_unique($file);

$hits = count($file);

echo $hits;

 

$fd = fopen ($filename , "r");

$fstring = fread ($fd , filesize ($filename));

fclose($fd);

$fd = fopen ($filename , "w");

$fcounted = $fstring."\n".getenv("REMOTE_ADDR");

$fout= fwrite ($fd , $fcounted );

fclose($fd);

 

?>

Link to comment
https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916861
Share on other sites

no no sorry if im not making much sense, the code works fine and increments by one for every unique hit, but I just put it on my new site and the hits started fresh at 0 where i had 13,500 on my older version of the site and im wondering if there is a way to make my new counter start at this number

Link to comment
https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916867
Share on other sites

What you use, basically in opens counter.txt and reads the amount of entries "IP's".

I dont think you can script it to know it should be 13,500 more unless you do

 

echo $hits + 13500;

 

so essentially you start with 13500 as opposed to 0; or rather you simply tack on 13500 to your $hits. It's cheating but it would work.

Link to comment
https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916887
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.