Beispiel #1
0
 function StatsDetailed($trade, $amount = 10)
 {
     $db = get_trade_db($trade);
     $stats_dir = get_trade_stats_dir($trade);
     $this->trade = $db->Retrieve($trade);
     // Process in log
     $fp = fopen("{$stats_dir}/{$trade}-in", 'r');
     while (!feof($fp)) {
         $line = trim(fgets($fp));
         if (empty($line)) {
             continue;
         }
         $data = explode('|', $line);
         $this->i_total++;
         $this->i_ip[$data[1]]++;
         $this->i_ctry[$data[4]]++;
         $this->i_ref[$data[5]]++;
         $this->i_land[$data[6]]++;
         $this->i_lang[$data[7]]++;
         if ($data[2]) {
             $this->i_proxy[$data[1]]++;
         }
         if (preg_match($this->browser_regex, $data[3], $matches)) {
             $browser = str_replace($this->browser_search, $this->browser_replace, $matches[1]);
             $this->i_agent[$browser]++;
         } else {
             $this->i_agent[$data[3]]++;
         }
     }
     fclose($fp);
     arsort($this->i_ip);
     arsort($this->i_proxy);
     arsort($this->i_agent);
     arsort($this->i_ctry);
     arsort($this->i_ref);
     arsort($this->i_land);
     arsort($this->i_lang);
     $this->i_ip = $this->_array_slice($this->i_ip, $amount);
     $this->i_proxy = $this->_array_slice($this->i_proxy, $amount);
     $this->i_agent = $this->_array_slice($this->i_agent, $amount);
     $this->i_ctry = $this->_array_slice($this->i_ctry, $amount);
     $this->i_ref = $this->_array_slice($this->i_ref, $amount);
     $this->i_land = $this->_array_slice($this->i_land, $amount);
     $this->i_lang = $this->_array_slice($this->i_lang, $amount);
     // Process out log
     $fp = fopen("{$stats_dir}/{$trade}-out", 'r');
     while (!feof($fp)) {
         $line = trim(fgets($fp));
         if (empty($line)) {
             continue;
         }
         $data = explode('|', $line);
         $this->o_total++;
         $this->o_ip[$data[1]]++;
         $this->o_ctry[$data[4]]++;
         $this->o_page[$data[5]]++;
         $this->o_link[$data[6]]++;
         $this->o_lang[$data[7]]++;
         if ($data[2]) {
             $this->o_proxy[$data[1]]++;
         }
         if (preg_match($this->browser_regex, $data[3], $matches)) {
             $browser = str_replace($this->browser_search, $this->browser_replace, $matches[1]);
             $this->o_agent[$browser]++;
         } else {
             $this->o_agent[$data[3]]++;
         }
     }
     fclose($fp);
     arsort($this->o_ip);
     arsort($this->o_proxy);
     arsort($this->o_agent);
     arsort($this->o_ctry);
     arsort($this->o_page);
     arsort($this->o_link);
     arsort($this->o_lang);
     $this->o_ip = $this->_array_slice($this->o_ip, $amount);
     $this->o_proxy = $this->_array_slice($this->o_proxy, $amount);
     $this->o_agent = $this->_array_slice($this->o_agent, $amount);
     $this->o_ctry = $this->_array_slice($this->o_ctry, $amount);
     $this->o_page = $this->_array_slice($this->o_page, $amount);
     $this->o_link = $this->_array_slice($this->o_link, $amount);
     $this->o_lang = $this->_array_slice($this->o_lang, $amount);
     // Process clicks log
     $fp = fopen("{$stats_dir}/{$trade}-clicks", 'r');
     while (!feof($fp)) {
         $line = trim(fgets($fp));
         if (empty($line)) {
             continue;
         }
         $data = explode('|', $line);
         $this->c_total++;
         $this->c_ip[$data[1]]++;
         $this->c_ctry[$data[4]]++;
         $this->c_page[$data[5]]++;
         $this->c_link[$data[6]]++;
         $this->c_lang[$data[7]]++;
         if ($data[2]) {
             $this->c_proxy[$data[1]]++;
         }
         if (preg_match($this->browser_regex, $data[3], $matches)) {
             $browser = str_replace($this->browser_search, $this->browser_replace, $matches[1]);
             $this->c_agent[$browser]++;
         } else {
             $this->c_agent[$data[3]]++;
         }
     }
     fclose($fp);
     arsort($this->c_ip);
     arsort($this->c_proxy);
     arsort($this->c_agent);
     arsort($this->c_ctry);
     arsort($this->c_page);
     arsort($this->c_link);
     arsort($this->c_lang);
     $this->c_ip = $this->_array_slice($this->c_ip, $amount);
     $this->c_proxy = $this->_array_slice($this->c_proxy, $amount);
     $this->c_agent = $this->_array_slice($this->c_agent, $amount);
     $this->c_ctry = $this->_array_slice($this->c_ctry, $amount);
     $this->c_page = $this->_array_slice($this->c_page, $amount);
     $this->c_link = $this->_array_slice($this->c_link, $amount);
     $this->c_lang = $this->_array_slice($this->c_lang, $amount);
 }
Beispiel #2
0
function get_trade_languages($trade, $log = 'in')
{
    $dir = get_trade_stats_dir($trade);
    $trade = file_sanitize($trade);
    return get_trade_log_stats("{$dir}/{$trade}-{$log}", 7);
}