hey ich möchte dieses script per fwrite oder etwas anderes in jede datei die geschrieben werden soll per script hineinkopieren
PHP-Code:
<?php
$serialized_counterData = 'a:6:{s:9:"yesterDay";s:10:"04-08-2007";s:7:"currDay";s:10:"01-01-
2002";s:5:"toDay";i:2;s:6:"visits";i:0;s:4:"hits";i:2;s:11:"whoIsOnline";
a:1:{s:9:"127.0.0.1";i:1009840268;}}';
$counterData = unserialize($serialized_counterData);
if($counterData['currDay'] != date('d-m-Y'))
{
$counterData['yesterDay'] = $counterData['currDay'];
$counterData['currDay'] = date('d-m-Y');
$counterData['toDay'] = 0;
}
if(!isset($counterData['whoIsOnline'][$_SERVER['REMOTE_ADDR']]))
{
$counterData['visits']++;
$counterData['toDay']++;
}
$counterData['hits']++;
$counterData['whoIsOnline'][$_SERVER['REMOTE_ADDR']] = time();
foreach($counterData['whoIsOnline'] as $key => $time)
if($time + 500 < time()) unset($counterData['whoIsOnline']);
$myData = file_get_contents(__FILE__);
$myData = preg_replace('/\$serialized_counterData = \'.*\';/siU',
'$serialized_counterData = \''.serialize($counterData).'\';', $myData);
$myFile = fopen(__FILE__, 'wb');
fwrite($myFile, $myData);
fclose($myFile);
echo('Hits: '.$counterData['hits'].'<br />');
echo('Visiters: '.$counterData['visits'].'<br />');
echo('Yesterday: '.$counterData['yesterDay'].'<br />');
echo('Today: '.$counterData['toDay'].'<br />');
echo('Online: '.count($counterData['whoIsOnline']).'<br />');
?>
Kommentar