Newsdas BuchLeseprobeGalerieAutorLinksHome
Bestellinfo | Kontakt | Impressum | Datenschutz
// ***************************************************************************************** // STATISTIK ERSTELLEN // ***************************************************************************************** $layout="tr"; $bot = FALSE; $hosttest = gethostbyaddr($_SERVER['REMOTE_ADDR']); if(preg_match("googlebot.com",$hosttest)) { $bot = TRUE; } if(preg_match("/143.198./",$hosttest)) { $bot = TRUE; } if(preg_match("/crawl/",$hosttest)) { $bot = TRUE; } if(preg_match("/216.244.66.240/",$hosttest)) { $bot = TRUE; } if(preg_match("/googlebot/",$hosttest)) { $bot = TRUE; } if(preg_match("/spider/",$hosttest)) { $bot = TRUE; } if(preg_match("/msnbot/",$hosttest)) { $bot = TRUE; } if(preg_match("/Bot/",$hosttest)) { $bot = TRUE; } if(preg_match("/bot/",$hosttest)) { $bot = TRUE; } if(preg_match("/BOT/",$hosttest)) { $bot = TRUE; } if(preg_match("/WOW/",$hosttest)) { $bot = TRUE; } if(preg_match("/Crawl/",$hosttest)) { $bot = TRUE; } $bottest = $_SERVER['HTTP_USER_AGENT']; if(preg_match("/Bot/",$bottest)) { $bot = TRUE; } if(preg_match("/bot/",$bottest)) { $bot = TRUE; } if(preg_match("/BOT/",$bottest)) { $bot = TRUE; } if(preg_match("/WOW/",$bottest)) { $bot = TRUE; } if(preg_match("/Crawl/",$bottest)) { $bot = TRUE; } if (!$bot) { $counterDatei = "../statblog/counter.txt"; $ipDatei = "../statblog/ip.txt"; $logDatei = "../statblog/logfile.txt"; $sperre = 1800; // Zeit in Sekunden $anzahl = 7; // Anzahl der Counterstellen $pruefmax = 10; // maximale Anzahl von zu testenden IP-Adressen $logmax = 150; // maximale Anzahl der zu loggenden Informationen $datum1 = date("Ymd"); $datum2 = date("Ym"); $datum3 = date("Y"); $counterD = "../statblog/data/".$datum1.".txt"; $counterM = "../statblog/data/".$datum2.".txt"; $counterY = "../statblog/data/".$datum3.".txt"; $testD=FALSE; $testM=FALSE; $testY=FALSE; $gefunden=FALSE; $startwert=1; if(!(is_file($counterD))) { $counterDhandle = fopen($counterD, "w+"); fwrite($counterDhandle, $startwert); fclose($counterDhandle); $testD=TRUE; } if(!(is_file($counterM))) { $counterMhandle = fopen($counterM, "w+"); fwrite($counterMhandle, $startwert); fclose($counterMhandle); $testM=TRUE; } if(!(is_file($counterY))) { $counterYhandle = fopen($counterY, "w+"); fwrite($counterYhandle, $startwert); fclose($counterYhandle); $testY=TRUE; } // IP testen: // ********** $ipliste = file($ipDatei); foreach($ipliste as $zeile) { $element = explode("|", $zeile); $zeit = time(); $zeitlimit = trim($element[0])+$sperre; if(($zeit < $zeitlimit) AND (trim($element[1]) == $_SERVER['REMOTE_ADDR'])) { $gefunden=TRUE; } } $ipblock = file("https://www.traluna.com/ipblock.txt"); $testip = trim($ipblock[0]); $zeittip = trim($blockip[1]) + 7200; $zeitt = time(); if(($testip == $_SERVER['REMOTE_ADDR']) AND ($zeittip < $zeitt)) { $gefunden=TRUE; } $iphandle = fopen($ipDatei, "a+"); if(!$gefunden) { $zeit=time(); fputs($iphandle, $zeit."|".$_SERVER['REMOTE_ADDR']."\n"); $loghandle = fopen($logDatei, "a+"); $userhost = gethostbyaddr($_SERVER['REMOTE_ADDR']); fputs($loghandle, $layout."|".$zeit."|".$_SERVER['REMOTE_ADDR']."|".$_SERVER['HTTP_USER_AGENT']."|".$_SERVER["HTTP_ACCEPT_LANGUAGE"]."|".$userhost."\n"); fclose($loghandle); } fclose($iphandle); // alte Referrerdatei fuellen // ************************* $seite = $_SERVER["HTTP_REFERER"]; if ((strlen($seite)>1000)) { $seite="Referrer_zu_lang"; } $zeitstempel=time(); $logfile_tb=fopen("../statblog/logfile_ref.txt","a+"); $datum=date("d.m.Y H:i"); $ip=getenv("REMOTE_ADDR"); $logeintrag=$layout."|".$zeitstempel."|".$ip."|".$datum."|".$seite."\n"; fputs($logfile_tb,$logeintrag); fclose($logfile_tb); $logmax = 500; $logDatei = "../statblog/logfile_ref.txt"; $logs = file($logDatei); $anzahl = count($logs); if ($anzahl > $logmax) { $logshandle = fopen($logDatei, "w+"); $start = $anzahl-$logmax; for($i=$start;$i<=$logmax;$i++) { $zeile = $logs[$i]; fputs($logshandle, $zeile); } fclose($logshandle); } // Counter erstellen: // ****************** $counterhandle = fopen($counterDatei, "r+"); $counterstand = fread($counterhandle, filesize($counterDatei)); if(!$gefunden) { $counterstand++; rewind($counterhandle); fwrite($counterhandle, $counterstand); if (!$testD) { $counterDhandle = fopen($counterD, "r+"); $counterstandD = fread($counterDhandle, filesize($counterD)); $counterstandD++; rewind($counterDhandle); fwrite($counterDhandle, $counterstandD); fclose($counterDhandle); } if (!$testM) { $counterMhandle = fopen($counterM, "r+"); $counterstandM = fread($counterMhandle, filesize($counterM)); $counterstandM++; rewind($counterMhandle); fwrite($counterMhandle, $counterstandM); fclose($counterMhandle); } if (!$testY) { $counterYhandle = fopen($counterY, "r+"); $counterstandY = fread($counterYhandle, filesize($counterY)); $counterstandY++; rewind($counterYhandle); fwrite($counterYhandle, $counterstandY); fclose($counterYhandle); } } fclose($counterhandle); // Liste kuerzen: //************** $ips = file($ipDatei); $anzahl = count($ips); if ($anzahl > $pruefmax) { $ipshandle = fopen($ipDatei, "w+"); $start = $anzahl-$pruefmax; for($i=$start;$i<=$anzahl;$i++) { $zeile = $ips[$i]; fputs($ipshandle, $zeile); } fclose($ipshandle); } $logs = file($logDatei); $anzahl2 = count($logs); if ($anzahl2 > $logmax) { $logshandle = fopen($logDatei, "w+"); $start = $anzahl2-$logmax; for($i=$start;$i<=$anzahl2;$i++) { $zeile = $logs[$i]; fputs($logshandle, $zeile); } fclose($logshandle); } } // ***************************************************************************************** // ENDE STATISTIK ERSTELLEN // *****************************************************************************************