Esempio n. 1
0
$data = $weblogreader->get_data(1000000, 13000000);
$index = 0;
foreach ($data as $each) {
    $ip = ip2long($each[2]);
    $time = strtotime($each[1]);
    $hour = (int) date('H', $time);
    // foreach ($iplist as $eachip) {
    // 	if($eachip[1]>=$ip) {
    // 		$ip_prov=$eachip[5];
    // 		break;
    // 	}
    // }
    // $sql = "select * from bxmap.lib where ipEnd_int >= '$ip'  limit 1";
    // $result = mysql_query($sql);
    // $result_row = mysql_fetch_array($result);
    $ip_prov = BinarySearch($ip);
    if ($ip_prov) {
        foreach ($prov as $prov_name) {
            if ($ip_prov === $prov_name) {
                $flow[$hour][$prov_name]++;
                break;
            }
        }
    }
    $index++;
    if ($index % 100000 == 0) {
        echo $index . "<br>";
    }
}
echo "Number of handled records is " . $index . "<br>";
$sum = 0;
Esempio n. 2
0
 function _processFile($type, $basename, $size, $date, $time)
 {
     if (PROCESS_PROFILING) {
         $this->_startProfile('_processFile');
     }
     if (PROCESS_PROFILING) {
         $this->_startProfile('_processFile a');
     }
     // 'ls' will output '-' instead of 'f' for files.
     if ($type == "-") {
         $type = "f";
     }
     if ($this->_verboseLevel == PROCESS_VERBOSE_HIGHEST) {
         $this->_raiseEvent(PROCESS_INFO_PROCESSING_FILE, $type, $basename, $size, $date, $time);
     }
     // Clear the size for special files types.
     if ($specialFile = $type != 'f' && $type != 'd' && $type != 'l') {
         $size = 0;
     }
     if (PROCESS_PROFILING) {
         $this->_endProfile('_processFile a');
     }
     if (PROCESS_PROFILING) {
         $this->_startProfile('_processFile b');
     }
     // Get the current directory in the stack (for code readability).
     $currDir =& $this->_dirStack[count($this->_dirStack) - 1];
     $newFile = array('name' => $basename, 'date' => $date, 'time' => $time, 'size' => BigVal($size));
     // Save the type only for non-files.
     if ($type != 'f') {
         $newFile['type'] = $type;
     }
     array_push($currDir['files'], $newFile);
     $currDir['bytes'] = BigAdd($currDir['bytes'], $size);
     $currDir['num']++;
     if (PROCESS_PROFILING) {
         $this->_endProfile('_processFile b');
     }
     if (PROCESS_PROFILING) {
         $this->_startProfile('_processFile c');
     }
     // Determine the root path for the 'top 100' paths.
     $rootPath = !isset($this->_header['basename']) || $this->_header['basename'] == '' ? '.' : ($this->_header['basename'] == $this->_ds ? '' : $this->_header['basename']);
     if (PROCESS_PROFILING) {
         $this->_endProfile('_processFile c');
     }
     if (PROCESS_PROFILING) {
         $this->_startProfile('_processFile for');
     }
     // Increment totals for directories in the stack.
     for ($i = 0; $i < count($this->_dirStack); $i++) {
         if (PROCESS_PROFILING) {
             $this->_startProfile('_processFile totals');
         }
         // Byte and file count totals.
         $this->_dirStack[$i]['totalbytes'] = BigAdd($this->_dirStack[$i]['totalbytes'], $size);
         $this->_dirStack[$i]['totalnum']++;
         // Increment the modified, sizes and extension totals.
         if ($i < $this->_totalsDepth) {
             for ($g = 0; $g < count($this->_sizeGroups); $g++) {
                 if (BigComp($this->_sizeGroups[$g]['size'], $size) <= 0) {
                     $this->_dirStack[$i]['sizes'][$g] = array_key_exists($g, $this->_dirStack[$i]['sizes']) ? array(BigAdd($this->_dirStack[$i]['sizes'][$g][0], $size), $this->_dirStack[$i]['sizes'][$g][1] + 1) : array(BigVal($size), 1);
                     break;
                 }
             }
             for ($g = 0; $g < count($this->_modifiedGroups); $g++) {
                 if (strcmp($this->_modifiedGroups[$g]['date'], $date) >= 0) {
                     $this->_dirStack[$i]['modified'][$g] = array_key_exists($g, $this->_dirStack[$i]['modified']) ? array(BigAdd($this->_dirStack[$i]['modified'][$g][0], $size), $this->_dirStack[$i]['modified'][$g][1] + 1) : array(BigVal($size), 1);
                     break;
                 }
             }
             $ext = $this->_getFileExtension($basename);
             $this->_dirStack[$i]['types'][$ext] = array_key_exists($ext, $this->_dirStack[$i]['types']) ? array(BigAdd($this->_dirStack[$i]['types'][$ext][0], $size), $this->_dirStack[$i]['types'][$ext][1] + 1) : array(BigVal($size), 1);
         }
         if (PROCESS_PROFILING) {
             $this->_endProfile('_processFile totals');
         }
         if (PROCESS_PROFILING) {
             $this->_startProfile('_processFile top100');
         }
         // Add the file to the top 100 lists, if it is greater than a file already in it.
         if ($i < $this->_top100Depth) {
             $index = BinarySearch($this->_dirStack[$i]['top100'], $size, array('Process', '_top100Comparator'));
             if ($index < 0) {
                 $index = abs($index + 1);
             }
             if (count($this->_dirStack[$i]['top100']) < 100 || $index < 100) {
                 array_splice($this->_dirStack[$i]['top100'], $index, 0, array(array('name' => $basename, 'size' => BigVal($size), 'hash' => md5($currDir['path']), 'path' => $rootPath . $this->_ds . $currDir['path'], 'date' => $date, 'time' => $time)));
                 if (count($this->_dirStack[$i]['top100']) > 100) {
                     array_pop($this->_dirStack[$i]['top100']);
                 }
             }
         }
         if (PROCESS_PROFILING) {
             $this->_endProfile('_processFile top100');
         }
     }
     if (PROCESS_PROFILING) {
         $this->_endProfile('_processFile for');
     }
     if (PROCESS_PROFILING) {
         $this->_endProfile('_processFile');
     }
 }