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
|
<?PHP
setlocale (LC_TIME, 'fr-FR');
$f = fopen("ipintra.html", "a+");
$Jour = array("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi","Samedi");
$Mois = array("Janvier", "Février", "Mars", "Avril", "Juin", "Mai", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre");
$datefr = $Jour[date("w")]." ".date("d")." ".$Mois[date("n")]." ".date("Y");
$filename = "ipintra.html";
$pattern = "$datefr";
$handle = fopen($filename, "r");
$file = fread($handle,filesize($filename));
if (preg_match('#' . $pattern . '#', $file, $match)) {
echo $pattern . " found in ipintra.html.";
$log = ' <span style="color: #ff0000">IP=</span>' . $_SERVER['REMOTE_ADDR'];
$log .= ' <span style="color: #ff0000">Heure=</span>' . date('H:i:s');
$log .= ' <span style="color: #ff0000">Agent=</span>' . $_SERVER['HTTP_USER_AGENT'] . "\n";
fwrite($f, $log);
fwrite($f, '<br /><br />');
}
else {
echo $pattern . " was not found";
//le } était placé ici
fwrite($f, $datefr . "<br />");
$log = ' <span style="color: #ff0000">IP=</span>' . $_SERVER['REMOTE_ADDR'];
$log .= ' <span style="color: #ff0000">Heure=</span>' . date('H:i:s');
$log .= ' <span style="color: #ff0000">Agent=</span>' . $_SERVER['HTTP_USER_AGENT'] . "\n";
fwrite($f, $log);
fwrite($f, '<br /><br />');
fclose($f);
fclose($handle);
//} <---ce } doit être ici et non plus haut comme commenté
?> |
Partager