| px | top | add code | search | signup | login | help |
<?
/*
simple access counter for php3
(c)1998 David W. Bettis
dbettis@eyeintegrated.com
modified to use images
1999 Kevin Clevenger
ksc@wanetwork.net
modified by Gerwin
gerwin@teddysoft.at
*/
// file for the counter
$counterFile = "counter.txt";
// maximum number of digits used
$maxlen = 6;
// images dir
$imgdir = "./image/";
function displayCounter($counterFile) {
global $imgdir, $maxlen;
$fp = fopen($counterFile,rw);
$num = fgets($fp,$maxlen);
$num += 1;
for ($i=0; $i<strlen($num); $i++) {
$val = substr($num, $i, 1);
// to do a vertical counter add <br> to the end of this line
$imgstring = $imgstring . "<img src=$imgdir$val.gif>";
}
print " $imgstring";
$fp = fopen($counterFile,w);
fputs($fp,$num);
fclose($fp);
}
if (!file_exists($counterFile)) {
$num = 0;
fputs($fp,$num);
}
displayCounter($counterFile);
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.