View Full Version : why does basic counter reset itself?
eva2000
Sun 26th Aug '01, 4:54pm
okay i put a basic counter on my vb forums, i placed this in phpinclude template
$counterfile = "counterfile.txt";
if(!($fp = @fopen($counterfile,"r"))) die ("cannot open counter file");
$thecounter = (int) fread($fp, 20);
fclose($fp);
$thecounter++;
$fp = fopen($counterfile, "w");
fwrite($fp , $thecounter);
fclose($fp);
and referenced in my footer template
$thecounter
works for a while but resets itself ???
would changing to
fread($fp, 1024*1024); help?
The Prohacker
Sun 26th Aug '01, 7:23pm
Make sure counterfile.txt is chmod'd 777, other than that it works just fine:
www.virix.com.kg/counter/
eva2000
Sun 26th Aug '01, 7:26pm
i chmodded it to 666 isn't that sufficient?
The Prohacker
Sun 26th Aug '01, 7:31pm
That can depend on your server configuration, usually 666 will do, but sometimes depending on apache usually you have to chmod 777, its worth a try if your on a dedicated server, so its not a big insecurity....
I would also not suggest you install this on your anime forums, because of their high usage, this scirpt can run up your cpu and hdd usage horribly. For it to work effectivly, you would want it to not only log the hit, but also the IP, so only one hit is recorded per IP, you would want to do this with MySql of course...
eva2000
Sun 26th Aug '01, 7:36pm
Originally posted by The Prohacker
That can depend on your server configuration, usually 666 will do, but sometimes depending on apache usually you have to chmod 777, its worth a try if your on a dedicated server, so its not a big insecurity....
I would also not suggest you install this on your anime forums, because of their high usage, this scirpt can run up your cpu and hdd usage horribly. For it to work effectivly, you would want it to not only log the hit, but also the IP, so only one hit is recorded per IP, you would want to do this with MySql of course...
yeah just messing around trying to learn some php :)
for now my dual p3 866, 768mb server can handle the load hehe
next step is learning to put that into a mysql database :D
eva2000
Sun 26th Aug '01, 9:47pm
nevermind.. mysql counter -> http://vbulletin.com/forum/showthread.php?s=&threadid=26527 :D
vBulletin® v3.8.0 Beta 4, Copyright ©2000-2008, Jelsoft Enterprises Ltd.