コード例 #1
0
ファイル: run.php プロジェクト: adambrunner/aloa
$country = array();
$alp = new ApacheLogParser($config['format']);
$i = 1;
$log = array();
echo str_repeat(' ', 31);
while (!feof($fp)) {
    if (!($logLine = trim(fgets($fp, 4096)))) {
        continue;
    }
    $save = $logLine;
    echo str_repeat(chr(8), 31) . str_pad($i++, 9, ' ', STR_PAD_LEFT) . ' ' . str_pad(memory_get_usage(), 15, ' ', STR_PAD_LEFT) . ' bytes';
    $logData = $alp->parse($logLine);
    $userId = $logData['host'];
    if (!empty($logData['reqHeader___useragent'])) {
        $userId .= $logData['reqHeader___useragent'];
        $ua = UserAgent::parse($logData['reqHeader___useragent']);
    }
    $request = trim($logData['request']);
    $path = substr($request, $a = strpos($request, ' ') + 1, strpos($request, ' ', $a) - $a);
    $path = explode('?', $path);
    $path = $path[0];
    $time = strtotime($logData['time']);
    $year = date('Y', $time);
    $month = date('n', $time);
    $day = date('j', $time);
    $hour = date('G', $time);
    $fileSize = $logData['lengthCLF'];
    if (!isset($log[$year][$month][$day][$hour])) {
        $log[$year][$month][$day][$hour] = array('country' => array(), 'browser' => array(), 'spider' => array(), 'os' => array(), 'page' => array(), 'status' => array());
    }
    $logItem =& $log[$year][$month][$day][$hour];