Mega Code Archive

 
Categories / Php / Statistics and Counters
 

Counter

Very simple PHP text based counter. to use it simple add this code to your html. <script language="javascript" src="http://yourdomain.com/counter.php"></script> Simply add the below code into a notepad document and save it as counter.php Then upload counter.php to ouyr directory in ascii mode. -----Beginning of Script----- <? $log="counter.txt"; //counter log file. //nothing else to change leave it as is. $open=@fopen($log,'r+'); $counter=@fread($open,filesize($log)); @fclose($open); $counter++; $write=fopen($log,'w'); fputs($write,$counter); fclose($write); echo "document.write($counter)"; ?> -----End Of Script----- note: if you want to change your counter number from 1 to any just create or change counter.txt to proper counts and upload to your directory.