PHP Hit Counter Generator

riverdrift says A data file name is required. i.e hits.dat All other fields are optional.
Once you have completed the script make a PHP document with it and name it whatever.php.
Then make a data file for the counter hits. Use the same name as you used to generate the script. i.e. (hits.dat)
If you want your counter to start at zero ('0') count, then leave the data file empty.
But if you want it to start with a higher initial number, you must enter your desired starting number in the data file.
{{ztext}} 99786



 

copy to clipboard
<?php
$vlog = "{{hits}}";
$fp = fopen($vlog, "r") or die("Cannot open to read $vlog!");
flock($fp, LOCK_EX);
$count = fgets($fp, 1024);
$count+=1;
flock($fp, LOCK_UN);
fclose($fp);
echo ("<div style='display:table;margin:auto;background-color:{{back}};background-image:url({{backurl}});color:{{fcolor}};font-size:{{fsize}};font-weight:{{fontw}};padding:{{padd}};'>{{ztext}} $count</div>");
$fp = fopen($vlog, "w") or die("Cannot open to write to $vlog!");
flock($fp, LOCK_EX);
fwrite($fp, $count);
flock($fp, LOCK_UN);
fclose($fp); ?>
Riverdrift.com   
2000 - 2024 Hand Made in the U.S.A