ashers
09-29-2003, 06:18 AM
Hi,
Does anyone know how to go about putting a hit counter on a website?
Thanks
Does anyone know how to go about putting a hit counter on a website?
Thanks
|
Click to See Complete Forum and Search --> : Hit Counter ashers 09-29-2003, 06:18 AM Hi, Does anyone know how to go about putting a hit counter on a website? Thanks pyro 09-29-2003, 08:20 AM You have a couple of options. If you server supports some sort of server-side language (such as PHP, Perl, etc) you could either write you own, or download one from a script archive. If it does not, you could use a site that allows you to add their hit counter to your site, such as extreme tracking (http://www.extreme-dm.com/tracking/?home). PeOfEo 09-29-2003, 05:23 PM A basic hit counter that records page views is extremaly simple but If you want one that logs unique visits instead of just views it will be more work. Also you might want to log some server variables, this is pretty simple in itself but it will mean an additional feild in your data base. Jupac 09-29-2003, 07:30 PM here a simple counter script in php <?php $file = fopen("counter.txt",(is_file("counter.txt"))?"r+":"w+"); $count = fread($file, filesize("counter.txt")); rewind($file); $count +=1; fputs($file, $count); fclose($file); echo "You are visitor : $count"; ?> then make a file called counter.txt chmode it to 777 inside put the number you want it to start with (e.g-200000000000000000) pyro 09-29-2003, 07:45 PM Or even better, use something like this, as it locks the file, which will help prevent corrupted data: <?php $file = "counter.txt"; # CHMOD to 666 $count = file($file); $fp = fopen($file, "w+"); flock($fp, LOCK_EX); $count[0]++; fwrite($fp, $count[0]); flock($fp, LOCK_UN); fclose($fp); echo "You are visitor : $count[0]"; ?> webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |