Changeset 1397 for trunk/bin

Show
Ignore:
Timestamp:
05/02/05 02:32:45 (4 years ago)
Author:
anarcat
Message:

sortir des initialisations statiques de la boucle

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/bin/alternc_stats_web.php

    r1396 r1397  
    7272} 
    7373 
     74$months=array("Jan"=>"01","Feb"=>"02","Mar"=>"03","Apr"=>"04","May"=>"05","Jun"=>"06","Jul"=>"07","Aug"=>"08","Sep"=>"09","Oct"=>"10","Nov"=>"11","Dec"=>"12"); 
     75 
     76/** 
     77 * match "escaped quotes" or "everything except quotes" 
     78 * 
     79 * this might represent a significant performance hit 
     80 */ 
     81$noquote = '(?:(?:(?<=\\\)")|(?:[^"]))*'; 
     82 
     83// Exemple de ligne apache :  
     84// crawl18.dir.com - login [14/Jun/2004:06:38:47 +0200] "GET /modules/newbb?days=100 HTTP/1.0" 200 20156 "-" "Pompos/1.3 http://dir.com/pompos.html" 2 esperance-jeunes.org 
     85 
     86// this pattern should match it 
     87$pattern = '/^[^ ]* [^ ]* [^ ]* \\[([0-9]*)\\/([a-zA-Z]*)\\/([0-9]*):[0-9]*:[0-9]*:[0-9]* [^ ]* "'.$noquote.'" ([0-9-]*) ([0-9-]*) "'.$noquote.'" "'.$noquote.'" [0-9]* ([^ ]*)$/'; 
     88 
    7489$total_hits = $total_good = 0; 
    7590 
     
    101116  $domstat=array(); // On stocke sous forme de clé "dom/day" => "hit or bandwith" 
    102117  $domuid=array();  // Cache des uids associés aux domaines. 
    103  
    104  
    105   $months=array("Jan"=>"01","Feb"=>"02","Mar"=>"03","Apr"=>"04","May"=>"05","Jun"=>"06","Jul"=>"07","Aug"=>"08","Sep"=>"09","Oct"=>"10","Nov"=>"11","Dec"=>"12"); 
    106  
    107   /** 
    108    * match "escaped quotes" or "everything except quotes" 
    109    * 
    110    * this might represent a significant performance hit 
    111    */ 
    112   $noquote = '(?:(?:(?<=\\\)")|(?:[^"]))*'; 
    113  
    114   // Exemple de ligne apache :  
    115   // crawl18.dir.com - login [14/Jun/2004:06:38:47 +0200] "GET /modules/newbb?days=100 HTTP/1.0" 200 20156 "-" "Pompos/1.3 http://dir.com/pompos.html" 2 esperance-jeunes.org 
    116  
    117   // this pattern should match it 
    118   $pattern = '/^[^ ]* [^ ]* [^ ]* \\[([0-9]*)\\/([a-zA-Z]*)\\/([0-9]*):[0-9]*:[0-9]*:[0-9]* [^ ]* "'.$noquote.'" ([0-9-]*) ([0-9-]*) "'.$noquote.'" "'.$noquote.'" [0-9]* ([^ ]*)$/'; 
    119118 
    120119  // parse a line at a time 
     
    162161} 
    163162 
     163if ($verbose) echo "\n$total_hits lines read total ($total_good good)\n"; 
     164 
     165// check validity 
     166if ($full) { 
     167  list($res) = mysql_fetch_array(mysql_query("SELECT SUM(hit) FROM stat_http")); 
     168  if ($res == $total_good) { 
     169    echo "correct count: $res\n"; 
     170  } else { 
     171    echo "difference between database hits and lines read: $res => $total_good\n"; 
     172  } 
     173} 
     174 
    164175// handy function to avoid a copy-paste 
    165176function insert_lines($domstat, &$domuid) { 
     
    190201} 
    191202 
    192 if ($verbose) echo "\n$total_hits lines read total ($total_good good)\n"; 
    193  
    194 // check validity 
    195 if ($full) { 
    196   list($res) = mysql_fetch_array(mysql_query("SELECT SUM(hit) FROM stat_http")); 
    197   if ($res == $total_good) { 
    198     echo "correct count: $res\n"; 
    199   } else { 
    200     echo "difference between database hits and lines read: $res => $total_good\n"; 
    201   } 
    202 } 
    203  
    204203?>