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); }
function _xTradesGraphDataProdReturn() { require_once 'stats.php'; require_once 'dirdb.php'; $db = get_trade_db($_REQUEST['domain']); $trade = $db->Retrieve($_REQUEST['domain']); $stats = new StatsHourly($trade); include 'trades-graph-data-prod-return.php'; }
function get_trade_detailed_stats($trade) { require_once 'stats.php'; $db = get_trade_db($trade); $trade = $db->Retrieve($trade); $stats = load_overall_stats(get_trade_stats_dir($trade['domain']), array($trade)); $stats = array('overall' => $stats[0]); return $stats; }