Changeset 1397 for trunk/bin/alternc_stats_web.php
- Timestamp:
- 05/02/05 02:32:45 (8 years ago)
- File:
-
- 1 edited
-
trunk/bin/alternc_stats_web.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/alternc_stats_web.php
r1396 r1397 72 72 } 73 73 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 74 89 $total_hits = $total_good = 0; 75 90 … … 101 116 $domstat=array(); // On stocke sous forme de clé "dom/day" => "hit or bandwith" 102 117 $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 hit111 */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.org116 117 // this pattern should match it118 $pattern = '/^[^ ]* [^ ]* [^ ]* \\[([0-9]*)\\/([a-zA-Z]*)\\/([0-9]*):[0-9]*:[0-9]*:[0-9]* [^ ]* "'.$noquote.'" ([0-9-]*) ([0-9-]*) "'.$noquote.'" "'.$noquote.'" [0-9]* ([^ ]*)$/';119 118 120 119 // parse a line at a time … … 162 161 } 163 162 163 if ($verbose) echo "\n$total_hits lines read total ($total_good good)\n"; 164 165 // check validity 166 if ($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 164 175 // handy function to avoid a copy-paste 165 176 function insert_lines($domstat, &$domuid) { … … 190 201 } 191 202 192 if ($verbose) echo "\n$total_hits lines read total ($total_good good)\n";193 194 // check validity195 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 204 203 ?>
Note: See TracChangeset
for help on using the changeset viewer.
