Witam, na mojej stronie mam licznik napisany w php, jednak przy odświeżaniu stronki dodaje do stanu jeden, czy jest możlwość zablokowania zwiększania się licznika wczasie odwiedzin przez tego samego internaute??
<?php $COUNT_FILE = “count_data.txt”; // En: Absolute path and name to count data file. // Fr: Chemin absolu (complet) et Nom du fichier compteur. $IMG_DIR_URL = “./digits/”; // En: URL Directory of digits (0.gif … 9.gif). // Fr: URL du repertoire des images (0.gif … 9.gif). $NB_DIGITS = 8; // En: Minimum number of digits to display (0, to not use 0 left). // Fr: Nombre minimum de chiffre à afficher (0 pour ne pas avoir de 0 devant). $EXPIRE_DATE = 86400; // En: Cookies Expiration date (second). // Fr: Date d’expiration du cookies (en seconde); // End Necessary Variables section /******************************************************************************/ if (file_exists($COUNT_FILE)) { // En: Open, read, increment, save and close file. // Fr: Ouvre, lit, incrémente, sauve et ferme le fichier. $fp = fopen("$COUNT_FILE", “r+”); flock($fp, 1); $count = fgets($fp, 4096); if ($visited == “”) { $count += 1; setcookie(“visited”, $count, time()+$EXPIRE_DATE , “/”, $SERVER_NAME); fseek($fp,0); fputs($fp, $count); } flock($fp, 3); fclose($fp); } else { // En: Display a error message if file does not exist. // Fr: Affiche un message d’erreur si le fichier n’existe pas. echo “Can’t find file, check ‘$file’ var…”; exit; } // En: Display count value // Fr: Affiche le nombre de visiteur. chop($count); $nb_digits = max(strlen($count), $NB_DIGITS); $count = substr(“0000000000”.$count, -$nb_digits); $digits = preg_split("//", $count); for($i = 0; $i = $nb_digits; $i++) { if ($digits[$i] != “”) { $html_result .= “”; } } // En: End PHP Code // Fr: Fin code PHP echo “$html_result”; ?
inz.Piniol
(inż. Piniol)
14 Sierpień 2005 18:42
#2
Hej,dzieki za linka, a czy mógłbyś mnie troszkę poinstruować, bo próbuję, ale nic mi nie wychodzi… co ewentualnie z tamtego przykładu przydałoby się do tego skryptu powyżej wkleić ??