2013-09-03 18:01:42 +04:00
|
|
|
#!/usr/bin/php -Cq
|
|
|
|
<?php
|
|
|
|
|
2017-10-26 22:21:21 +03:00
|
|
|
$sFile = 'sample.log.txt'; // Apache log file
|
2016-09-04 04:19:48 +03:00
|
|
|
$sHost1 = 'http://mq-open-search-lm02.ihost.aol.com:8000/nominatim/v1';
|
|
|
|
$sHost2 = 'http://mq-open-search-lm03.ihost.aol.com:8000/nominatim/v1';
|
2013-09-03 18:01:42 +04:00
|
|
|
|
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$sHost1Escaped = str_replace('/', '\\/', $sHost1);
|
|
|
|
$sHost2Escaped = str_replace('/', '\\/', $sHost2);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$aToDo = array(251, 293, 328, 399.1, 455.1, 479, 496, 499, 574, 609, 702, 790, 846, 865, 878, 894, 902, 961, 980);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2017-10-26 22:21:21 +03:00
|
|
|
$hFile = @fopen($sFile, 'r');
|
2016-09-08 04:16:22 +03:00
|
|
|
if (!$hFile) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo "Unable to open file: $sFile\n";
|
|
|
|
exit;
|
|
|
|
}
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$i = 0;
|
2016-09-08 04:16:22 +03:00
|
|
|
while (($sLine = fgets($hFile, 10000)) !== false) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$i++;
|
|
|
|
if (!in_array($i, $aToDo)) continue;
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-08 04:16:22 +03:00
|
|
|
if (preg_match('#"GET (.*) HTTP/1.[01]"#', $sLine, $aResult)) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$sURL1 = $sHost1.$aResult[1];
|
|
|
|
$sURL2 = $sHost2.$aResult[1];
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$sRes1 = '';
|
|
|
|
$k = 0;
|
2016-09-08 04:16:22 +03:00
|
|
|
while (!$sRes1 && $k < 10) {
|
2016-09-04 04:19:48 +03:00
|
|
|
$sRes1 = file_get_contents($sURL1);
|
|
|
|
$k++;
|
|
|
|
if (!$sRes1) sleep(10);
|
|
|
|
}
|
|
|
|
$sRes2 = file_get_contents($sURL2);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
// Strip out the things that will always change
|
|
|
|
$sRes1 = preg_replace('# timestamp=\'[^\']*\'#', '', $sRes1);
|
|
|
|
$sRes1 = str_replace($sHost1, '', $sRes1);
|
|
|
|
$sRes1 = str_replace($sHost1Escaped, '', $sRes1);
|
|
|
|
$sRes2 = preg_replace('# timestamp=\'[^\']*\'#', '', $sRes2);
|
|
|
|
$sRes2 = str_replace($sHost2, '', $sRes2);
|
|
|
|
$sRes2 = str_replace($sHost2Escaped, '', $sRes2);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-08 04:16:22 +03:00
|
|
|
if ($sRes1 != $sRes2) {
|
2016-09-04 04:19:48 +03:00
|
|
|
echo "$i:\n";
|
|
|
|
var_dump($sURL1, $sURL2);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$sRes = $sURL1.":\n";
|
2016-09-08 04:16:22 +03:00
|
|
|
for ($j = 0; $j < strlen($sRes1); $j+=40) {
|
2016-09-14 04:16:46 +03:00
|
|
|
$sRes .= substr($sRes1, $j, 40)."\n";
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
file_put_contents('log/'.$i.'.1', $sRes);
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
$sRes = $sURL2.":\n";
|
2016-09-08 04:16:22 +03:00
|
|
|
for ($j = 0; $j < strlen($sRes2); $j+=40) {
|
2016-09-14 04:16:46 +03:00
|
|
|
$sRes .= substr($sRes2, $j, 40)."\n";
|
2016-09-04 04:19:48 +03:00
|
|
|
}
|
|
|
|
file_put_contents('log/'.$i.'.2', $sRes);
|
|
|
|
}
|
|
|
|
echo ".\n";
|
2016-09-08 04:16:22 +03:00
|
|
|
} else {
|
2016-09-04 04:19:48 +03:00
|
|
|
var_dump($sLine);
|
|
|
|
}
|
|
|
|
}
|
2013-09-03 18:01:42 +04:00
|
|
|
|
2016-09-04 04:19:48 +03:00
|
|
|
fclose($hFile);
|