1) text counter
<? Php
$ Countfile = "/count.txt"; // sets the file for saving data
If (! File_exists ($ countfile) {// checks whether the file exists.
Exec ("echo 0> $ countfile ");
}
$ Fp = fopen ($ countfile, "rw ");
$ Length = filesize ($ countfile );
$ Num = fgets ($ fp, $ length );
$ Num + = 1;
Exec ("rm-rf $ countfile ");
Exec ("echo $ num> $ countfile ");
Print "total visits:". "$ num". "times"; // display the number of visits
?>
2) graphic counters
<?
$ Countfile = "/count-num.txt"; // sets the file for saving the data
If (! File_exists ($ countfile) // checks whether a file exists.
{Exec ("echo 0> $ countfile ");}
$ Fp = fopen ($ countfile, "rw ");
$ Length = filesize ($ countfile );
$ Num = fgets ($ fp, $ length );
$ Num + = 1;
Exec ("rm-rf $ countfile ");
Exec ("echo $ num> $ countfile ");
$ Len_str = strlen ($ num );
For ($ I = 0; $ I <$ len_str; $ I ++ ){
$ Each_num = substr ($ num, $ I, 1 );
$ Out_str = $ out_str. " ";
}
Print "total visits:". "$ out_str". "times"; // display the number of visits
?>