1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
<html>
<head>
<title>Accueil</title>
<?
$gcc_file = "Applets/Compteur.txt"; // name of the file where the number of visitors is kept
$gcc_cookie_name = "test"; // name of the cookie (eg: your site's name)
$gcc_cookie_value = "Sev"; // value of the cookie (eg: something about your site)
$gcc_cookie_life = "3600"; // cookie lifespan. Default is 900s (15min)
$IP = "Applets/IP.wri"; // nom du fichier de log des IP
// ------------------------- Creation of the counter and IP files ----------------------- //
if(!file_exists("$gcc_file"))
{
$gcc_fp=fopen("$gcc_file","a");
fputs($gcc_fp,"0");
fclose($gcc_fp); }
if(!file_exists("$IP"))
{
$fp=fopen("$IP","a");
fclose($fp); }
// -------------------------- Ne pas compter les IP suivantes -------------------------- //
if($REMOTE_ADDR == "127.0.0.1")
{
$gcc_fp=fopen($gcc_file,"r+");
$gcc_hits=fgets($gcc_fp,10);
fclose($gcc_fp);
$gcc_hits = "Off ($gcc_hits)";
}
else
{
// ----------------- Visitor already came : the cookie is here ------------------------- //
if(isset($_COOKIE["$gcc_cookie_name"]) && $_COOKIE["$gcc_cookie_name"] == "$gcc_cookie_value")
{
$gcc_fp=fopen($gcc_file,"r+");
$gcc_hits=fgets($gcc_fp,10);
fclose($gcc_fp);
}
// ----------------- A new visitor is coming: creation of a cookie ---------------------- //
else
{
setcookie($gcc_cookie_name, $gcc_cookie_value,time()+$gcc_cookie_life, "");
$gcc_fp=fopen($gcc_file,"r+");
$gcc_hits=fgets($gcc_fp,10);
$gcc_hits++;
fseek($gcc_fp,0);
fputs($gcc_fp,$gcc_hits);
fclose($gcc_fp);
// ------------------------------------ Log des IP -------------------------------------- //
$date = date ("d-m-y");
$heure = date ("H:i:s");
$fp = fopen("$IP","a");
$dom = gethostbyaddr($REMOTE_ADDR);
fputs ($fp, $gcc_hits.": Le $date à $heure : $REMOTE_ADDR ($dom)\n");
fclose($fp);
}
}
?>
</head>
<body>
</body>
</html> |
Partager