Titel: logdb_backup.dta analysieren
Beitrag von hr3 am 22.09.11 um 13:16:46
Sind die Daten in dieser Text-Datei bzw. Datenbank fehlerfrei und wieviele Zeilen sind in welcher Periode aufgezeichnet worden? Zitat:Fehler in Zeile 303127 ungültige Anzahl Felder 303128 Timestamp nicht aufsteigend 303129 browser nicht numerisch 303129 operating_system nicht numerisch 303129 site_name nicht numerisch 303129 referrer nicht numerisch 303129 resolution nicht numerisch 303129 color_depth nicht numerisch 303129 ungültiger Timestamp
Anzahl Zeilen pro Zeitraum in log/logdb_backup.dta
Array ( [2007] => 47649 [2008] => 87047 [2009] => 66654 [2010] => 79016 [2011] => 22761 ) Array ( [ 9.2007] => 23807 [10.2007] => 12213 [11.2007] => 6178 [12.2007] => 5451 [ 1.2008] => 10001 [ 2.2008] => 7033 [ 3.2008] => 10034 [ 4.2008] => 8616 [ 5.2008] => 6732 [ 6.2008] => 4803 [ 7.2008] => 4160 [ 8.2008] => 19020 [ 9.2008] => 4652 [10.2008] => 4464 [11.2008] => 3035 [12.2008] => 4497 [ 1.2009] => 9844 [ 2.2009] => 5806 [ 3.2009] => 4703 [ 4.2009] => 3344 [ 5.2009] => 4733 [ 6.2009] => 4322 [ 7.2009] => 3623 [ 8.2009] => 10632 [ 9.2009] => 4692 [10.2009] => 4315 [11.2009] => 4308 [12.2009] => 6332 [ 1.2010] => 7840 [ 2.2010] => 6681 [ 3.2010] => 6075 [ 4.2010] => 5562 [ 5.2010] => 6595 [ 6.2010] => 5875 [ 7.2010] => 7123 [ 8.2010] => 7486 [ 9.2010] => 6757 [10.2010] => 6004 [11.2010] => 7276 [12.2010] => 5742 [ 1.2011] => 5347 [ 2.2011] => 5718 [ 3.2011] => 6205 [ 4.2011] => 5484 [ 5.2011] => 7 ) *** Ende *** Verarbeitungszeit: 18 Sekunden |
| Code (]<?php $start_time=time(); ### letzte Änderung 23.06.11 11:40 ### logdb_backup.dta analysieren ### http://www.php-web-statistik.de/cgi-bin/yabb/YaBB.pl?num=1298491676/0#2
#set_time_limit(0); $x=0; $f1=false; $f2=false; $f3=false; $lts=0; $path='../'; // ggf. anpassen
include($path.'config/config.php'); # $db_active=1; // Test if ($db_active==1) { include($path.'config/config_db.php'); $db_suffix='_main'; $file='DB('.$db_host.' '.$db_name.' '.$db_prefix.$db_suffix.')'; if (!mysql_pconnect($db_host,$db_user,$db_password)) {die(mysql_error());} if (!mysql_select_db($db_name)) {die(mysql_error());} $result=mysql_query('SELECT timestamp FROM '.$db_prefix.$db_suffix.';'); if (!$result) {die(mysql_error());} } else { $file='log/logdb_backup.dta'; $handle=fopen($path.$file,'r'); }
do { $x++;
if ($db_active==1) {if (!$a=mysql_fetch_array($result)) {break;}} else { if (feof($handle)) {break;} $buffer=fgets($handle,6000); $buffer=str_replace(array("\r","\n"),array('',''),$buffer); if ($buffer=='') {continue;} $a=explode('|',$buffer); if (substr_count($buffer,'|')!=8) {fehler('ungültige Anzahl Felder');continue;} if (($a[2):)&&(!is_numeric($a[2]))) {fehler('browser nicht numerisch');} if (($a[3])&&(!is_numeric($a[3]))) {fehler('operating_system nicht numerisch');} if (($a[4])&&(!is_numeric($a[4]))) {fehler('site_name nicht numerisch');} if (($a[5])&&(!is_numeric($a[5]))) {fehler('referrer nicht numerisch');} if (($a[6])&&(!is_numeric($a[6]))) {fehler('resolution nicht numerisch');} if (($a[7])&&(!is_numeric($a[7]))) {fehler('color_depth nicht numerisch');} if ((strlen($a[0])!=10)||(!is_numeric($a[0]))) {fehler('ungültiger Timestamp');continue;} if ($a[0]<$lts) {fehler('Timestamp nicht aufsteigend');} $lts=$a[0]; }
$d=getdate($a[0]);
$z=$d['year']; if (!isset($y[$z])) {$y[$z]=0;} $y[$z]++;
if ($d['mon']<10) {$d['mon']=' '.$d['mon'];} $z=$d['mon'].'.'.$d['year']; if (!isset($m[$z])) {$m[$z]=0;} $m[$z]++; } while (true);
if ($db_active!=1) {fclose($handle);} if (isset($kz_f)) {echo '<br><br>';} echo 'Anzahl Zeilen pro Zeitraum in '.$file.'<hr><pre>'; print_r($y); print_r($m); echo '*** Ende *** Verarbeitungszeit: '.(time()-$start_time).' Sekunden';
function fehler($f) { global $x,$kz_f; if (!$kz_f) {$kz_f=true; echo 'Fehler in Zeile<hr>';} echo $x.' '.$f.'<br>';} ?> |
|
|