Version: 1.0
Type: Full Script
Category: Other
License: GNU General Public License
Description: This is a very simple counter. You can use it as a plain text counter, or as an image counter, without the need to modify anything in the script.
Look inside the script for details
<?PHP ////////////////////////////////////// // page counter by [email protected] // // use it, abuse it, whatever, just // // leave my name in here please :-) // ////////////////////////////////////// // check if directory is writable if(is_writeable('.')){ // create 'hits' if this is the first hit if(!file_exists('hits')){ $FH = fopen('hits', 'w'); fwrite($FH, 1); $hits = 1; } else{ // get current count and add one $hits = @file('hits'); $hits = $hits[0] + 1; // write new count $FH = fopen('hits', 'w'); fwrite($FH, $hits); fclose($FH); } // generate image tag $digit = strval($hits); for ($i = 0; $i < strlen($hits); $i++) { $tag = '<img src="img/'.$digit[$i].'.gif" width="12" height="16">'; $counter .= $tag; } } else{ $counter = $hits = '[error]'; } ?> <HTML> <HEAD> <TITLE>SimpleCounter</TITLE> <META name="author" content="DrTebi [[email protected]]"> </HEAD> <BODY> <PRE> In order to use this script you have to make sure that the directory in which you are using this script is writable, for UNIX that would be 777 To use this script as simple text counter do: <?PHP print $hits; ?> To use this script as an image counter, you will need to create 10 images, and these should be placed in a subdirectory called "img". Call the images 0.gif, 1.gif, 2.gif etc., until 9.gif. To display the image counter do: <?PHP print $counter; ?> That's it! </PRE> </BODY> </HTML>