| px | top | add code | search | signup | login | help |
<?
/* This script enable you to insert graphic counters in your web pages.
Condition is, the graphic files names are in form - 0.gif .. 9.gif, but
it shouldn't be problem to make necessary edits in script to make this
script to work with other file names.
To put counter to yout page is necessary to load this script in the page
with require function, and then call function CounterDisplay with file name
like argument in this function */
function Counter($counterFile){ // Basic function for counting of the accesses
if (File_Exists($counterFile)):
$file= FOpen($counterFile,rw);
$acc= FGets($file,6);
$acc=$acc+1;
FClose($file);
else:
$acc=1;
endif;
$file= FOpen($counterFile,w);
FputS ($file,$acc);
FClose($file);
return $acc;};
function CounterDisplay($file){
$nuacc=Counter($file);
$string=StrVal($nuacc);
$n=StrLen($string);
for ($i=0;$i<$n;$i++) {
$s=SubStr($string,$i,1);
echo "<img src=\"countergifs/".$s.".gif\" border=0>"; //In this line are possibilites to change file form
};
};
?>
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.