// Dateiname
$filename = "logfile.csv";
// Trennzeichen
$col_separator = ";";
// Datum
$timestring = date("d.m.Y H:i:s");
// ein paar interessante Servervariablen :)
$adress = $_SERVER['REMOTE_ADDR'];
$referer = $_SERVER['HTTP_REFERER'];
// CSV-Header
$header = "TIME".$col_separator."REMOTE_ADDR".$col_separator."HTTP_REFERER\n";
// falls noch nicht vorhenden, Logfile erstellen
if (!file_exists($filename))
{
$fh = fopen($filename, 'w');
// Header schreiben
fwrite($fh, $header);
fclose($fh);
}
// Zeile anfügen
$fp = fopen($filename, "a");
fwrite($fp, implode(array($timestring, $adress, $referer), $col_separator)."\n");
fclose($fp);