Contatore che permette al webmaster di ricevere un report giornaliero delle visite via mail.
<?php
$counter_file = "/path/to/your/dir/to/yourfile.txt";
function counter($counter_file) {
$aprif = fopen($counter_file,"r+");
$hits = fgets($aprif, 16);
$hits += 1;
rewind($aprif);
fputs($aprif,$hits);
fputs($aprif,"\n");
fclose($aprif);
$address = "your@email.here";
$name_website = "name of your website";
$date_start= "31/12/1999";
$hit_check = bcdiv($hits, 10, 5);
if (ereg("[0-9]+\.[0]+$", $hit_check)) {
mail($address, "Log hits from $name_website", "Number of hits
from $date_start: $hits");
print "$hits \n";
} else {
print "$hits \n";
}
}
counter($counter_file);
?>
![]()
![]()