/** * @return array * @access public */ function post() { if ($this->container['first_request']) { if (!@file(POT_CONFIG_PATH . 'countries.php')) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_CONFIG_PATH . 'countries.php'), E_USER_ERROR); } if (!@file(POT_CONFIG_PATH . 'ips.db')) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_CONFIG_PATH . 'ips.db'), E_USER_ERROR); } if (!@file(POT_CONFIG_PATH . 'ips.idx')) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_CONFIG_PATH . 'ips.idx'), E_USER_ERROR); } if (!@file(POT_INCLUDE_PATH . '/LoggingEngine/plugins/i2m.class.php')) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_INCLUDE_PATH . '/LoggingEngine/plugins/i2m.class.php'), E_USER_ERROR); } require_once 'i2m.class.php'; $i2m = new ip2more(null, true); $ip = $i2m->ip; $country = $i2m->country['name']; $iso2 = $i2m->country['iso2']; $iso3 = $i2m->country['iso3']; $fips104 = $i2m->country['fips104']; $iso_number = $i2m->country['isono']; $flag = substr($i2m->country['flag_small'], -6); $region = $i2m->country['region']; $capital = $i2m->country['capital']; $currency = $i2m->country['currency']; $currency_code = $i2m->country['currency_code']; if (isset($ip) && isset($country) && isset($iso2) && isset($iso3) && isset($fips104) && isset($iso_number) && isset($flag) && isset($region) && isset($capital) && isset($currency) && isset($currency_code)) { $this->db->query(sprintf("INSERT INTO %s\n (accesslog_id, client_id, ip, country, iso2, iso3, fips104, iso_number, flag, region, capital, currency, currency_code)\n VALUES ('%d', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')\n\t\t\t", $this->config['plugins']['localizer']['table'], $this->container['accesslog_id'], $this->container['client_id'], $this->db->prepareString($ip), $this->db->prepareString($country), $this->db->prepareString($iso2), $this->db->prepareString($iso3), $this->db->prepareString($fips104), $this->db->prepareString($iso_number), $this->db->prepareString($flag), $this->db->prepareString($region), $this->db->prepareString($capital), $this->db->prepareString($currency), $this->db->prepareString($currency_code))); } } return array(); }
/** * @return array * @access public */ function post() { $referer = $this->container['referer_orig']; if ($this->container['first_request'] && !empty($referer)) { if (!($ignoreRules = @file(POT_CONFIG_PATH . 'search_engines.ignore.ini'))) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_CONFIG_PATH . 'search_engines.ignore.ini'), E_USER_ERROR); } if (!($matchRules = @file(POT_CONFIG_PATH . 'search_engines.match.ini'))) { return phpOpenTracker::handleError(sprintf('Cannot open "%s".', POT_CONFIG_PATH . 'search_engines.match.ini'), E_USER_ERROR); } $ignore = false; foreach ($ignoreRules as $ignoreRule) { if (preg_match(trim($ignoreRule), $referer)) { $ignore = true; break; } } if (!$ignore) { foreach ($matchRules as $matchRule) { if (preg_match(trim($matchRule), $referer, $tmp)) { $keywords = $tmp[1]; } } $searchEngineName = phpOpenTracker_Parser::match($referer, phpOpenTracker_Parser::readRules(POT_CONFIG_PATH . 'search_engines.group.ini')); } if (isset($keywords) && isset($searchEngineName) && $searchEngineName != $referer) { $this->db->query(sprintf("INSERT INTO %s\n (accesslog_id,\n search_engine, keywords)\n VALUES ('%d',\n '%s', '%s')", $this->config['plugins']['search_engines']['table'], $this->container['accesslog_id'], $this->db->prepareString($searchEngineName), $this->db->prepareString($keywords))); $this->container['referer'] = ''; $this->container['referer_orig'] = ''; $this->container['referer_id'] = 0; } } return array(); }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $locale; $parameters['api_call'] = 'localizer'; $parameters['what'] = 'top_localizer'; $parameters['result_format'] = 'separate_result_arrays'; list($names, $values, $percent, $total) = phpOpenTracker::get($parameters); $title = $locale->get('admin_stat', 'field_top') . ' ' . $parameters['limit'] . ' ' . $locale->get('admin_stat', 'field_countries'); for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) { $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]); } $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto'); $graph->SetShadow(); $graph->title->Set($title); $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']); $graph->title->SetColor('black'); $graph->legend->Pos(0.1, 0.2); $plot = new PiePlot3d($values); $plot->SetTheme('sand'); $plot->SetCenter(0.4); $plot->SetAngle(30); $plot->value->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size'] - 2); $plot->SetLegends($legend); $graph->Add($plot); $graph->Stroke(); }
/** * Performs an SQL query. * * @param string $query * @param mixed $limit * @param boolean $warnOnFailure * @param boolean $tablesAlreadyCreated * @access public */ function query($query, $limit = false, $warnOnFailure = true, $tablesAlreadyCreated = false) { if ($this->isManip($query)) { if (!$tablesAlreadyCreated) { $query = $this->_replaceTableNames($query); } if (isset($this->result) && is_resource($this->result)) { @mysql_free_result($this->result); } if ($this->config['debug_level'] > 1) { $this->debugQuery($query); } $this->result = @mysql_query($query, $this->connection); if (!$this->result) { $throwError = $warnOnFailure ? true : false; if (!$tablesAlreadyCreated && mysql_errno($this->connection) == 1146) { $this->_createNewTables(); $this->query($query, $limit, $warnOnFailure, true); $throwError = false; } if ($throwError) { phpOpenTracker::handleError(@mysql_error($this->connection), E_USER_ERROR); } } } else { $query = $this->_rewriteSelectQuery($query); if ($limit != false) { $query .= ' LIMIT ' . $limit; } parent::query($query); } }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { if (!isset($parameters['what'])) { return phpOpenTracker::handleError('Required parameter "what" missing.'); } list($constraint, $selfJoin) = $this->_constraint($parameters['constraints'], true); if ($selfJoin) { $selfJoinConstraint = 'AND accesslog.accesslog_id = accesslog2.accesslog_id'; $selfJoinTable = sprintf('%s accesslog2,', $this->config['accesslog_table']); } else { $selfJoinConstraint = ''; $selfJoinTable = ''; } $timerange = $this->_whereTimerange($parameters['start'], $parameters['end']); if ($parameters["start"] > 0) { $this->whereString = "AND starttime > " . $parameters["start"] . " AND endtime < " . $parameters["end"] . " "; } if ($parameters['what'] == 'pi') { return $this->_run_pi($parameters); } if ($parameters['what'] == 'visits') { return $this->_run_visits($parameters); } if ($parameters['what'] == 'avg_clickstream') { return $this->_run_avg_clickstream($parameters); } if ($parameters['what'] == 'avg_time') { return $this->_run_avg_time($parameters); } }
/** * Return one time visitors. * @param mixed parameter array */ function _run_one_time_visitors($parameters) { $allParams = $parameters; $allParams["api_call"] = "visitors"; $visitors = phpOpenTracker::get($allParams); $returningParams = $parameters; $returningParams["api_call"] = "nxreturning_visitors"; $returningVisitors = phpOpenTracker::get($returningParams); return $visitors - $returningVisitors; }
function logAccess() { global $c, $page; if ($c["pagetracking"]) { if ($c["usewebbug"]) { echo "<img src=\"" . $c["livedocroot"] . "sys/image.php?document=$page\" width=\"1\" height=\"1\">"; } else { include_once $c["path"].'modules/stats/phpOpenTracker.php'; phpOpenTracker::log(array('document' => $page)); } } }
/** * Returns an instance of phpOpenTracker_DB. * * @access public * @return phpOpenTracker_DB * @static */ function &getInstance() { static $db; if (!isset($db)) { $config =& phpOpenTracker_Config::getConfig(); $dbClass = 'phpOpenTracker_DB_' . $config['db_type']; if (!@(include POT_INCLUDE_PATH . 'DB/' . $config['db_type'] . '.php')) { phpOpenTracker::handleError(sprintf('Unknown database handler "%s".', $config['db_type']), E_USER_ERROR); } $db = new $dbClass(); } return $db; }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { $parameters['api_call'] = 'top'; $parameters['result_format'] = 'separate_result_arrays'; list($names, $values, $percent, $total) = phpOpenTracker::get($parameters); $title = 'Top ' . $parameters['limit'] . ' '; switch ($parameters['what']) { case 'document': $title .= 'Pages'; break; case 'entry_document': $title .= 'Entry Pages'; break; case 'exit_document': $title .= 'Exit Pages'; break; case 'exit_target': $title .= 'Exit Targets'; break; case 'host': $title .= 'Hosts'; break; case 'operating_system': $title .= 'Operating Systems'; break; case 'referer': $title .= 'Referers'; break; case 'user_agent': $title .= 'User Agents'; break; } $title .= " (Total: {$total})"; for ($i = 0, $numValues = sizeof($values); $i < $numValues; $i++) { $legend[$i] = sprintf('%s (%s, %s%%%%)', $names[$i], $values[$i], $percent[$i]); } $graph = new PieGraph($parameters['width'], $parameters['height'], 'auto'); $graph->SetShadow(); $graph->title->Set($title); $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']); $graph->title->SetColor('black'); $graph->legend->Pos(0.1, 0.2); $plot = new PiePlot3d($values); $plot->SetTheme('sand'); $plot->SetCenter(0.4); $plot->SetAngle(30); $plot->value->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size'] - 2); $plot->SetLegends($legend); $graph->Add($plot); $graph->Stroke(); }
/** * Performs an SQL query. * * @param string $query * @param mixed $limit * @param boolean $warnOnFailure * @access public */ function query($query, $limit = false, $warnOnFailure = true) { if ($limit != false) { $query = str_replace('SELECT', 'SELECT TOP ' . $limit, $query); } if ($this->config['debug_level'] > 1) { $this->debugQuery($query); } @mssql_free_result($this->result); $this->result = @mssql_query($query, $this->connection); if (!$this->result && $warnOnFailure) { phpOpenTracker::handleError('Database query failed.', E_USER_ERROR); } }
/** * Performs an SQL query. * * @param string $query * @param mixed $limit * @param boolean $warnOnFailure * @access public */ function query($query, $limit = false, $warnOnFailure = true) { if ($limit != false) { $query .= ' LIMIT ' . $limit; } if ($this->config['debug_level'] > 1) { $this->debugQuery($query); } @pg_freeresult($this->result); $this->result = @pg_exec($this->connection, $query); if (!$this->result && $warnOnFailure) { phpOpenTracker::handleError(@pg_errormessage($this->connection), E_USER_ERROR); } }
/** * Top statisztikak * * @param int kliens azonosito * @param int limit * @param bool start * @param bool end */ function top($clientID, $limit, $start = false, $end = false) { global $libs_dir, $pear_dir; $batchKeys = array('pages', 'entry_pages', 'exit_pages', 'exit_targets', 'hosts', 'referers', 'operating_systems', 'user_agents'); $batchWhat = array('document', 'entry_document', 'exit_document', 'exit_target', 'host', 'referer', 'operating_system', 'user_agent'); $batchResult = array(); $batch = array(); // Loop through $batchKeys / $batchWhat for ($i = 0; $i < sizeof($batchKeys); $i++) { // Query Top <$limit> items of category <$batchWhat[$i]> $result = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'top', 'what' => $batchWhat[$i], 'start' => $start, 'end' => $end, 'limit' => $limit)); $batchResult[$batchKeys[$i]]['top_items'] = $result['top_items']; $batchResult[$batchKeys[$i]]['unique_items'] = $result['unique_items']; } return $batchResult; }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { if (!isset($parameters['accesslog_id'])) { return phpOpenTracker::handleError('Required parameter "accesslog_id" missing.'); } $parameters['resolve_ids'] = isset($parameters['resolve_ids']) ? $parameters['resolve_ids'] : true; if ($parameters['resolve_ids']) { $this->db->query(sprintf("SELECT data_values.string AS document,\r\n data_values.document_url AS document_url,\r\n accesslog.timestamp AS timestamp\r\n FROM %s accesslog,\r\n %s data_values\r\n WHERE accesslog.accesslog_id = '%d'\r\n AND accesslog.document_id = data_values.data_id\r\n ORDER BY timestamp", $this->config['accesslog_table'], $this->config['documents_table'], $parameters['accesslog_id'])); } else { $this->db->query(sprintf("SELECT accesslog.document_id AS document,\r\n accesslog.timestamp\r\n FROM %s accesslog\r\n WHERE accesslog.accesslog_id = '%d'\r\n ORDER BY timestamp", $this->config['accesslog_table'], $parameters['accesslog_id'])); } $i = 0; while ($row = $this->db->fetchRow()) { $documents[$i] = $row['document']; $documentURLs[$i] = $row['document_url']; if (isset($previousTimestamp)) { $timeSpent[$i - 1] = $row['timestamp'] - $previousTimestamp; } $previousTimestamp = $row['timestamp']; $i++; } if (!isset($documents)) { return new phpOpenTracker_Clickpath(array()); } $timeSpent[sizeof($documents) - 1] = 1; $clickpath = new phpOpenTracker_Clickpath($documents, $documentURLs, $timeSpent); switch ($parameters['result_format']) { case 'graphviz': return $clickpath->toGraph(); break; case 'graphviz_object': return $clickpath->toGraph(true); break; case 'xml': return $clickpath->toXML(); break; case 'xml_object': return $clickpath->toXML(true); break; default: return $clickpath; } }
/** * Performs an SQL query. * * @param string $query * @param mixed $limit * @param boolean $warnOnFailure * @access public */ function query($query, $limit = false, $warnOnFailure = true) { if ($limit != false) { $query = sprintf('SELECT * FROM (%s) WHERE ROWNUM <= %d', $query, $limit); } if ($this->config['debug_level'] > 1) { $this->debugQuery($query); } @OCIFreeStatement($this->result); $this->result = @OCIParse($this->connection, $query); if (!$this->result) { $error = OCIError($this->result); phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR); } @OCIExecute($this->result); if (!$this->result && $warnOnFailure) { $error = OCIError($this->result); phpOpenTracker::handleError($error['code'] . $error['message'], E_USER_ERROR); } }
header('Expires: Sat, 22 Apr 1978 02:19:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Cache-Control: no-store, no-cache, must-revalidate'); header('Cache-Control: post-check=0, pre-check=0', false); header('Pragma: no-cache'); require 'phpOpenTracker.php'; if (isset($_GET['document_url']) && !empty($_GET['document_url'])) { $parameters['document_url'] = base64_decode($_GET['document_url']); } else { if (isset($_SERVER['HTTP_REFERER'])) { $parameters['document_url'] = $_SERVER['HTTP_REFERER']; } } if (!isset($parameters['document_url'])) { exit; } if (isset($_GET['document']) && !empty($_GET['document'])) { $parameters['document'] = $_GET['document']; } else { $parameters['document'] = $parameters['document_url']; } $parameters['client_id'] = isset($_GET['client_id']) ? $_GET['client_id'] : 1; $parameters['referer'] = isset($_GET['referer']) ? base64_decode($_GET['referer']) : ''; if (isset($_GET['add_data']) && is_array($_GET['add_data'])) { foreach ($_GET['add_data'] as $data) { list($field, $value) = explode('::', $data); $parameters['add_data'][$field] = $value; } } phpOpenTracker::log($parameters); printf('%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%', 71, 73, 70, 56, 57, 97, 1, 0, 1, 0, 128, 255, 0, 192, 192, 192, 0, 0, 0, 33, 249, 4, 1, 0, 0, 0, 0, 44, 0, 0, 0, 0, 1, 0, 1, 0, 0, 2, 2, 68, 1, 0, 59);
$visitsSummary->addField($lang->get("avg_visit_length", "Average visit length"), date("i:s", phpOpenTracker::get(array_merge(array('api_call' =>'avg_visit_length'), $rangeArray )))." min"); $visitsSummary->addField($lang->get("avg_clickstream", "Average clickstream"), sprintf("%01.2f", phpOpenTracker::get(array_merge(array('api_call' =>'avg_clickstream'), $rangeArray )))); $visitsSummary->addField($lang->get("vis_onl", "Visitors online"), phpOpenTracker::get(array_merge(array('api_call' =>'num_visitors_online'), $rangeArray ))); $visitsSummary->addSpacer(); $visitsSummary->renderStatsData(array($lang->get("when", "When"), $lang->get("visits"))); $form->add($visitsSummary); $form->add(new StatsDiagram($lang->get("ret_vis", "Returning visitors"), "visitors,nxone_time_visitors,nxreturning_visitors", array($lang->get("visitors"), $lang->get("vis_first", "First time visitors"), $lang->get("vis_ret", "Returning visitors")))); $retSummary = new StatsSummary($lang->get("ret_vis"), "visitors", 3); $retSummary->addField($lang->get("visitors"), phpOpenTracker::get(array_merge(array('api_call' =>'visitors'), $rangeArray ))); $retSummary->addField($lang->get("vis_first", "First time visitors"), phpOpenTracker::get(array_merge(array('api_call' =>'nxone_time_visitors'), $rangeArray ))); $retSummary->addField($lang->get("vis_ret"), phpOpenTracker::get(array_merge(array('api_call' =>'nxreturning_visitors'), $rangeArray ))); $retSummary->addField($lang->get("time_betw_visits", "Average time between visits"), (date('m', phpOpenTracker::get(array_merge(array('api_call' =>'nxavg_time_between_visits'), $rangeArray )))-1)." months ". date('d', phpOpenTracker::get(array_merge(array('api_call' =>'nxavg_time_between_visits'), $rangeArray )))." days"); $retSummary->addField($lang->get("vis_per_vis", "Average visits per visitor"), sprintf("%01.2f", phpOpenTracker::get(array_merge(array('api_call' =>'nxavg_visits'), $rangeArray )))); $form->add($retSummary); $form->add(new StatsDiagram($lang->get("avg_vis_length", "Average visit length (seconds)"), "avg_visit_length", array($lang->get("avg_vis_length", "Average visit length (seconds)")))); $vls = new StatsSummary($lang->get("avg_vis_length"), "avg_visit_length", 3); $vls->addField($lang->get("minimum"), date('i:s', $vls->minTs[1]).' min'); $vls->addField($lang->get("maximum"), date('i:s', $vls->maxTs[1]).' min'); $form->add($vls); $form->add(new StatsDiagram($lang->get("avg_clickstream", "Average clickstream"), "avg_clickstream", array($lang->get("avg_clickstream", "Average clickstream")))); $clickstreamSummary = new StatsSummary($lang->get("avg_clickstream"), "avg_clickstream", 3); $clickstreamSummary->setMinimumFields(); $form->add($clickstreamSummary); $page->addMenu($menu); $page->add($form);
} //orszagok listaja if (!empty($_SESSION['site_stat_country'])) { if (phpOpenTracker_API::pluginLoaded('localizer')) { $countries = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'localizer', 'what' => 'top_localizer', 'start' => $start, 'end' => $end, 'limit' => $limit)); } $tpl->assign('countries', $countries['top_items']); } //visszatero latogatok statisztikaja if (!empty($_SESSION['site_stat_return_visitor'])) { $num_unique_visitors = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'num_unique_visitors', 'start' => $start, 'end' => $end)); $num_one_time_visitors = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'num_one_time_visitors', 'start' => $start, 'end' => $end)); $num_returning_visitors = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'num_returning_visitors', 'start' => $start, 'end' => $end)); $num_return_visits = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'num_return_visits', 'start' => $start, 'end' => $end)); $average_visits = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'average_visits', 'start' => $start, 'end' => $end)); $average_time_between_visits = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'average_time_between_visits', 'start' => $start, 'end' => $end)); $tpl->assign('num_unique_visitors', $num_unique_visitors); $tpl->assign('num_one_time_visitors', $num_one_time_visitors); $tpl->assign('num_returning_visitors', $num_returning_visitors); $tpl->assign('num_return_visits', $num_return_visits); $tpl->assign('average_visits', $average_visits); $tpl->assign('average_time_between_visits', $average_time_between_visits); } $tpl->assign('start', $start); $tpl->assign('end', $end); //Altalanos statisztika $tpl->assign('client', $config['clients'][$clientID]); $tpl->assign('client_id', $clientID); $tpl->assign('pi_total', $totalPageImpressions); $tpl->assign('pi_month', $totalPageImpressionsCurrentMonth); $tpl->assign('visits_total', $totalVisits);
/** * Retrieve the data needed for computation of this form */ function prepareStatsData() { global $statsinfo; $timeRange = $statsinfo->getRangeArray(); unset($timeRange['interval']); $timeRange['limit'] = (int) $statsinfo->limit; $paramArray = array('api_call' => $this->summaryType, 'result_format' => 'array'); $this->data = phpOpenTracker::get(array_merge($paramArray, $timeRange)); }
/** * Returns XML markup for the graph. * * @param boolean $returnObject * @return mixed * @access public */ function toXML($returnObject = false) { if (!@(include_once 'XML/Tree.php')) { phpOpenTracker::handleError('Could not find PEAR XML_Tree package, exiting.', E_USER_ERROR); } $tree = new XML_Tree(); $root =& $tree->addRoot('clickpath'); for ($i = 0; $i < $this->length; $i++) { $root->addChild('length', $this->length); $node =& $root->addChild('node'); $node->addChild('document', $this->documents[$i]); if (!isset($this->statistics[$i]['count'])) { $node->addChild('timespent', $this->statistics[$i]); } } if (!$returnObject) { return $root->get(); } else { return $root; } }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $lang, $c; $parameters['result_format'] = 'separate_result_arrays'; // hour or weeday analysis $apc = "weekdays"; if ($parameters['api_call'] == "nxhours") { $apc = "hours"; } $apicall = array('api_call' => $apc, 'what' => $parameters["what"], 'start' => $parameters["start"], 'end' => $parameters["end"]); $queryValues = phpOpenTracker::get($apicall); for ($i = 0; $i < count($queryValues); $i++) { $y[$i] = $queryValues[$i]["value"]; } $title = 'Analyse '; switch ($parameters['what']) { case 'visits': $title .= 'Visits'; break; case 'pi': $title .= 'Page Impressions'; break; case 'avg_clickstream': $title .= 'Average Clickstream'; break; case 'avg_time': $title .= 'Average Online Time'; break; } if ($apc == "hours") { for ($i = 0; $i < 24; $i++) { $x_label[$i] = sprintf("%02d", $i); } $angle = 50; } else { $x_label = array("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"); $angle = 30; } $graph = new Graph($parameters['width'], $parameters['height'], 'auto'); $graph->img->SetMargin(40, 10, 20, 50); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); $graph->SetFrame(0); $graph->xgrid->Show(); $plot[0] = new BarPlot($y); $plot[0]->SetFillColor(__RED); $plot[0]->SetShadow(); $plot[0]->SetWeight(0); $gbarplot = new GroupBarPlot($plot); $gbarplot->SetWidth(0.6); $graph->add($gbarplot); $graph->xaxis->SetTickLabels($x_label); if ($c["usettf"]) { $graph->xaxis->SetLabelAngle($angle); } if ($c["usettf"]) { $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->yaxis->SetColor('black'); if ($c["usettf"]) { $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->title->Set($title); if ($c["usettf"]) { $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->img->SetAntiAliasing("white"); $graph->Stroke(); }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { $parameters['session_lifetime'] = isset($parameters['session_lifetime']) ? $parameters['session_lifetime'] : 3; switch ($parameters['result_format']) { case 'xml': case 'xml_object': $tree = new XML_Tree(); $root =& $tree->addRoot('visitorsonline'); $children = array(); break; default: $result = array(); } $accesslogIDs = array(); $this->db->query(sprintf("SELECT DISTINCT(accesslog.accesslog_id) AS accesslog_id\r\n FROM %s accesslog,\r\n %s visitors\r\n WHERE visitors.client_id = '%d'\r\n AND visitors.accesslog_id = accesslog.accesslog_id\r\n AND accesslog.timestamp >= '%d'", $this->config['accesslog_table'], $this->config['visitors_table'], $parameters['client_id'], time() - $parameters['session_lifetime'] * 60)); while ($row = $this->db->fetchRow()) { $accesslogIDs[] = $row['accesslog_id']; } for ($i = 0, $max = sizeof($accesslogIDs); $i < $max; $i++) { switch ($parameters['result_format']) { case 'xml': case 'xml_object': $visitorNode =& $root->addChild('visitor'); $visitorNode->addChild(phpOpenTracker::get(array('client_id' => $parameters['client_id'], 'api_call' => 'individual_clickpath', 'accesslog_id' => $accesslogIDs[$i], 'result_format' => 'xml_object'))); break; default: $result[$i]['clickpath'] = phpOpenTracker::get(array('client_id' => $parameters['client_id'], 'api_call' => 'individual_clickpath', 'accesslog_id' => $accesslogIDs[$i])); } $this->db->query(sprintf("SELECT MAX(timestamp) as last_access\r\n FROM %s\r\n WHERE accesslog_id = '%s'", $this->config['accesslog_table'], $accesslogIDs[$i])); if ($row = $this->db->fetchRow()) { switch ($parameters['result_format']) { case 'xml': case 'xml_object': $visitorNode->addChild('last_access', $row['last_access']); break; default: $result[$i]['last_access'] = $row['last_access']; } } else { return phpOpenTracker::handleError('Database query failed.'); } $this->db->query(sprintf("SELECT hosts.string AS host,\r\n user_agents.string AS user_agent\r\n FROM %s visitors,\r\n %s hosts,\r\n %s user_agents\r\n WHERE visitors.accesslog_id = '%d'\r\n AND visitors.host_id = hosts.data_id\r\n AND visitors.user_agent_id = user_agents.data_id", $this->config['visitors_table'], $this->config['hostnames_table'], $this->config['user_agents_table'], $accesslogIDs[$i])); if ($row = $this->db->fetchRow()) { switch ($parameters['result_format']) { case 'xml': case 'xml_object': $visitorNode->addChild('host', $row['host']); $visitorNode->addChild('user_agent', $row['user_agent']); break; default: $result[$i]['host'] = $row['host']; $result[$i]['user_agent'] = $row['user_agent']; } } else { return phpOpenTracker::handleError('Database query failed.'); } $this->db->query(sprintf("SELECT referers.string AS referer\r\n FROM %s visitors,\r\n %s referers\r\n WHERE visitors.accesslog_id = '%d'\r\n AND visitors.referer_id = referers.data_id", $this->config['visitors_table'], $this->config['referers_table'], $accesslogIDs[$i])); if ($row = $this->db->fetchRow()) { $referer = $row['referer']; } else { $referer = ''; } switch ($parameters['result_format']) { case 'xml': case 'xml_object': $visitorNode->addChild('referer', $referer); break; default: $result[$i]['referer'] = $referer; } } switch ($parameters['result_format']) { case 'xml': return $root->get(); break; case 'xml_object': return $root; break; default: return $result; } }
/** * @param array $parameters * @return mixed * @access public */ function run($parameters) { if (!isset($parameters['what'])) { return phpOpenTracker::handleError('Required parameter "what" missing.'); } $constraint = $this->_constraint($parameters['constraints']); $timerange = $this->_whereTimerange($parameters['start'], $parameters['end']); switch ($parameters['what']) { case 'combined_statistics': $_parameters = $parameters; $_parameters['what'] = 'top_search_engines'; $searchEngines = phpOpenTracker::get($_parameters); $_parameters['what'] = 'top_search_keywords'; for ($i = 0; $i < sizeof($searchEngines['top_items']); $i++) { $_parameters['search_engine'] = $searchEngines['top_items'][$i]['string']; $searchKeywords = phpOpenTracker::get($_parameters); $searchEngines['top_items'][$i]['search_keywords'] = $searchKeywords['top_items']; } return $searchEngines['top_items']; break; case 'top_search_engines': case 'top_search_keywords': switch ($parameters['result_format']) { case 'csv': $csv = "Rank;Item;Count;Percent\n"; break; case 'xml': case 'xml_object': $tree = new XML_Tree(); $root = $tree->addRoot('top'); break; case 'separate_result_arrays': $names = array(); $values = array(); $percent = array(); break; default: $topItems = array(); } if (isset($parameters['search_engine'])) { $searchEngineConstraint = sprintf("AND search_engines.search_engine = '%s'", $parameters['search_engine']); } else { $searchEngineConstraint = ''; } $field = $parameters['what'] == 'top_search_engines' ? 'search_engine' : 'keywords'; $nestedQuery = sprintf("SELECT search_engines.%s AS item\r\n FROM %s accesslog,\r\n %s visitors,\r\n %s search_engines\r\n WHERE visitors.client_id = '%d'\r\n AND visitors.accesslog_id = accesslog.accesslog_id\r\n AND visitors.accesslog_id = search_engines.accesslog_id\r\n %s\r\n %s\r\n %s\r\n GROUP BY visitors.accesslog_id,\r\n search_engines.%s", $field, $this->config['accesslog_table'], $this->config['visitors_table'], $this->config['plugins']['search_engines']['table'], $parameters['client_id'], $searchEngineConstraint, $constraint, $timerange, $field); if ($this->db->supportsNestedQueries()) { $queryTotalUnique = sprintf('SELECT COUNT(item) AS total_items, COUNT(DISTINCT(item)) AS unique_items FROM (%s) items', $nestedQuery); $queryItems = sprintf('SELECT COUNT(item) AS item_count, item FROM (%s) items GROUP BY item ORDER BY item_count %s, item', $nestedQuery, $parameters['order']); } else { if ($this->config['db_type'] == 'mysql' || $this->config['db_type'] == 'mysql_merge') { $dropTemporaryTable = true; $this->db->query(sprintf('CREATE TEMPORARY TABLE pot_temporary_table %s', $nestedQuery)); $queryTotalUnique = sprintf('SELECT COUNT(item) AS total_items, COUNT(DISTINCT(item)) AS unique_items FROM pot_temporary_table', $nestedQuery); $queryItems = sprintf('SELECT COUNT(item) AS item_count, item FROM pot_temporary_table GROUP BY item ORDER BY item_count %s, item', $parameters['order']); } else { return phpOpenTracker::handleError('You need a database system capable of nested ' . 'queries to use the "search_engines" API calls.', E_USER_ERROR); } } $this->db->query($queryTotalUnique); if ($row = $this->db->fetchRow()) { $totalItems = intval($row['total_items']); $uniqueItems = intval($row['unique_items']); } else { return phpOpenTracker::handleError('Database query failed.'); } if ($totalItems > 0) { $this->db->query($queryItems, $parameters['limit']); $i = 0; while ($row = $this->db->fetchRow()) { $percentValue = doubleval(number_format(100 * $row['item_count'] / $totalItems, 2)); switch ($parameters['result_format']) { case 'csv': $csv = sprintf("%d;%s;%d;%d\n", $i + 1, $row['item'], intval($row['item_count']), $percentValue); break; case 'xml': case 'xml_object': $itemChild =& $root->addChild('item'); $itemChild->addChild('rank', $i + 1); $itemChild->addChild('string', $row['item']); $itemChild->addChild('count', intval($row['item_count'])); $itemChild->addChild('percent', $percentValue); break; case 'separate_result_arrays': $names[$i] = $row['item']; $values[$i] = intval($row['item_count']); $percent[$i] = $percentValue; break; default: $topItems[$i]['count'] = intval($row['item_count']); $topItems[$i]['string'] = $row['item']; $topItems[$i]['percent'] = $percentValue; } $i++; } } if (isset($dropTemporaryTable)) { $this->db->query('DROP TABLE pot_temporary_table'); } switch ($parameters['result_format']) { case 'csv': return $csv; break; case 'xml': case 'xml_object': $root->addChild('total', $totalItems); $root->addChild('unique', $uniqueItems); switch ($parameters['result_format']) { case 'xml': return $root->get(); break; case 'xml_object': return $root; break; } break; case 'separate_result_arrays': return array($names, $values, $percent, $uniqueItems); break; default: return array('top_items' => $topItems, 'unique_items' => $uniqueItems); } break; } }
/** * Returns the number of return visits. * * @param array $parameters * @return integer * @access private * @since phpOpenTracker 1.3.0 */ function _numReturnVisits($parameters) { $oneTimeVisitorsParameters = $parameters; $oneTimeVisitorsParameters['api_call'] = 'num_one_time_visitors'; $visitsParameters = $parameters; $visitsParameters['api_call'] = 'visits'; return phpOpenTracker::get($visitsParameters) - phpOpenTracker::get($oneTimeVisitorsParameters); }
/** * Run the api-call for average clickstream * * @param array $parameters * @return mixed * @access private */ function _avg_clickstream($parameters) { $pi_params = $parameters; $vi_params = $parameters; $pi_params['api_call'] = 'page_impressions'; $vi_params['api_call'] = 'visits'; $pi = phpOpenTracker::get($pi_params); $vi = phpOpenTracker::get($vi_params); if (is_array($pi)) { for ($i = 0; $i < count($pi); $i++) { $result[$i] = array('timestamp' => $pi[$i]["timestamp"], 'value' => $pi[$i]["value"] / ($vi[$i]["value"] == 0 ? 1 : $vi[$i]["value"])); } } else { if ($vi != 0) { return $pi / $vi; } else { return 0; } } return $result; }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { global $c; $parameters['interval'] = isset($parameters['interval']) ? $parameters['interval'] : false; $parameters['month_names'] = isset($parameters['month_names']) ? $parameters['month_names'] : false; if (!$parameters['month_names']) { $parameters['month_names'] = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); } $timestamp = time(); $steps = array('hour' => 3600, 'day' => 86400, 'week' => 604800, 'month' => 2592000, 'year' => 31536000); $starttitle = ''; $endtitle = ''; switch ($parameters['interval']) { case 'hour': $starthour = $hour = date('H', $parameters['start']); $endhour = date('H', $parameters['end']); $starttitle .= $starthour . ':00h '; $endtitle .= $endhour . ':59h '; case 'day': $startday = $day = date('d', $parameters['start']); $endday = date('d', $parameters['end']); $starttitle .= $startday . '. '; $endtitle .= $endday . '. '; case 'week': $week = date('W', $parameters['start']) + 2; case 'month': $startmonth = $month = date('m', $parameters['start']); $endmonth = date('m', $parameters['end']); $starttitle .= $parameters['month_names'][$startmonth - 1] . ' '; $endtitle .= $parameters['month_names'][$endmonth - 1] . ' '; case 'year': $startyear = $year = date('Y', $parameters['start']); $endyear = date('Y', $parameters['end']); $starttitle .= $startyear; $endtitle .= $endyear; } $title = $starttitle . ' - ' . $endtitle . ' in ' . $parameters['interval'] . "s."; $disp = true; $correct = 0; if ($parameters['interval'] == 'week') { $correct = 86400; } for ($start = $parameters['start']; $start < $parameters['end']; $start += $steps[$parameters['interval']]) { if ($parameters['interval'] == 'month') { $steps['month'] = $steps['day'] * date('t', $_start); } $end = $start + $steps[$parameters['interval']] - 1; if ($start <= $timestamp) { $apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start + $correct, 'end' => $end + $correct, 'constraints' => $parameters['constraints'], 'interval' => ''); for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters)); } } else { for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = 0; } } switch ($parameters['interval']) { case 'hour': $x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00'; $disp = !$disp; $hour++; break; case 'week': $x_label[] = date('W', mktime(0, 0, 0, 1, ($week - 2) * 7, $startyear)); $week++; break; case 'day': $x_label[] = date('d', mktime(0, 0, 0, $startmonth, $day, $startyear)); $day++; break; case 'month': $x_label[] = date('m', mktime(0, 0, 0, $month, 1, $startyear)); $month++; break; case 'year': $x_label[] = date('Y', mktime(0, 0, 0, 1, 1, $year)); $year++; break; } } if ($y == null) { $apiCallParameters = array('client_id' => $parameters['client_id'], 'start' => $start, 'end' => $end, 'constraints' => $parameters['constraints']); for ($j = 0; $j < count($parameters["what"]); $j++) { $y[$j][] = phpOpenTracker::get(array_merge(array('api_call' => $parameters["what"][$j]), $apiCallParameters)); } $x_label[] = ''; $title = "Total"; } if ($parameters['interval'] == 'hour') { $angle = 50; } else { $angle = 0; } $x_label = $this->clearLabels($x_label, $parameters); $graph = new Graph($parameters['width'], $parameters['height'], 'auto'); $graph->img->SetMargin(40, 10, 20, 10); $graph->SetScale('textlin'); $graph->SetMarginColor('white'); $graph->SetFrame(0); $graph->xgrid->Show(); for ($j = 0; $j < count($parameters["what"]); $j++) { $plot[$j] = new BarPlot($y[$j]); $plot[$j]->SetFillColor($parameters["whatcolors"][$j]); $plot[$j]->SetShadow(); $plot[$j]->SetWeight(0); } $gbarplot = new GroupBarPlot($plot); $gbarplot->SetWidth(0.6); $graph->add($gbarplot); $graph->xaxis->SetTickLabels($x_label); if ($c["usettf"]) { $graph->xaxis->SetLabelAngle($angle); } if ($c["usettf"]) { $graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->xaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->yaxis->SetColor('black'); if ($c["usettf"]) { $graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); } if ($c["usettf"]) { $graph->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->title->Set($title); if ($c["usettf"]) { $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8); } $graph->img->SetAntiAliasing("white"); $graph->Stroke(); }
/** * Performs an SQL query. * * @param string $query * @param mixed $limit * @param boolean $warnOnFailure * @access public */ function query($query, $limit = false, $warnOnFailure = true) { if ($limit != false) { $query .= ' LIMIT ' . $limit; } if ($this->config['debug_level'] > 1) { $this->debugQuery($query); } @mysql_free_result($this->result); $this->result = @mysql_unbuffered_query($query, $this->connection); if (!$this->result && $warnOnFailure) { phpOpenTracker::handleError(@mysql_error($this->connection), E_USER_ERROR); } }
/** * Runs the phpOpenTracker API call. * * @param array $parameters * @return mixed * @access public */ function run($parameters) { if (!isset($parameters['what'])) { return phpOpenTracker::handleError('Required parameter "what" missing.'); } list($constraint, $selfJoin) = $this->_constraint($parameters['constraints'], true); if ($selfJoin) { $selfJoinConstraint = 'AND accesslog.accesslog_id = accesslog2.accesslog_id'; $selfJoinTable = sprintf('%s accesslog2,', $this->config['accesslog_table']); } else { $selfJoinConstraint = ''; $selfJoinTable = ''; } $timerange = $this->_whereTimerange($parameters['start'], $parameters['end']); switch ($parameters['result_format']) { case 'csv': $csv = "Rank;Item;Count;Percent\n"; break; case 'xml': case 'xml_object': $tree = new XML_Tree(); $root =& $tree->addRoot('top'); break; case 'separate_result_arrays': $names = array(); $values = array(); $percent = array(); break; default: $topItems = array(); } switch ($parameters['what']) { case 'document': case 'exit_target': case 'host': case 'operating_system': case 'referer': case 'user_agent': case 'entry_document': case 'exit_document': $dataConstraint = ''; switch ($parameters['what']) { case 'document': $column = 'accesslog.document_id'; $dataTable = $this->config['documents_table']; break; case 'entry_document': $column = 'accesslog.document_id'; $dataConstraint = "AND accesslog.entry_document = '1'"; $dataTable = $this->config['documents_table']; break; case 'exit_document': $column = 'accesslog.document_id'; $dataConstraint = "AND accesslog.exit_target_id <> '0'"; $dataTable = $this->config['documents_table']; break; case 'exit_target': $column = 'accesslog.exit_target_id'; $dataConstraint = "AND accesslog.exit_target_id <> '0'"; $dataTable = $this->config['exit_targets_table']; break; case 'host': $column = 'visitors.host_id'; $dataTable = $this->config['hostnames_table']; break; case 'operating_system': $column = 'visitors.operating_system_id'; $dataTable = $this->config['operating_systems_table']; break; case 'referer': $column = 'visitors.referer_id'; $dataTable = $this->config['referers_table']; break; case 'user_agent': $column = 'visitors.user_agent_id'; $dataTable = $this->config['user_agents_table']; break; } $nestedQuery = sprintf("SELECT data_table.string AS item\n FROM %s accesslog,\n %s\n %s visitors,\n %s data_table\n WHERE visitors.client_id = '%d'\n AND visitors.accesslog_id = accesslog.accesslog_id\n AND data_table.data_id = %s\n %s\n %s\n %s\n %s\n GROUP BY visitors.accesslog_id,\n data_table.string", $this->config['accesslog_table'], $selfJoinTable, $this->config['visitors_table'], $dataTable, $parameters['client_id'], $column, $selfJoinConstraint, $dataConstraint, $constraint, $timerange); break; default: $nestedQuery = sprintf("SELECT add_data.data_value AS item\n FROM %s accesslog,\n %s\n %s visitors,\n %s add_data\n WHERE visitors.client_id = '%d'\n AND visitors.accesslog_id = accesslog.accesslog_id\n AND accesslog.accesslog_id = add_data.accesslog_id\n AND add_data.data_field = '%s'\n %s\n %s\n %s\n GROUP BY visitors.accesslog_id,\n add_data.data_value", $this->config['accesslog_table'], $selfJoinTable, $this->config['visitors_table'], $this->config['additional_data_table'], $parameters['client_id'], $parameters['what'], $selfJoinConstraint, $constraint, $timerange); } if ($this->db->supportsNestedQueries()) { $queryTotalUnique = sprintf('SELECT COUNT(item) AS total_items, COUNT(DISTINCT(item)) AS unique_items FROM (%s) items', $nestedQuery); $queryItems = sprintf('SELECT COUNT(item) AS item_count, item FROM (%s) items GROUP BY item ORDER BY item_count %s, item', $nestedQuery, $parameters['order']); if ($parameters['result_format'] == 'sql') { return $queryItems; } } else { if ($this->config['db_type'] == 'mysql' || $this->config['db_type'] == 'mysql_merge') { $queryCreateTemporaryTable = sprintf('CREATE TEMPORARY TABLE pot_temporary_table %s', $nestedQuery); $queryTotalUnique = sprintf('SELECT COUNT(item) AS total_items, COUNT(DISTINCT(item)) AS unique_items FROM pot_temporary_table', $nestedQuery); $queryItems = sprintf('SELECT COUNT(item) AS item_count, item FROM pot_temporary_table GROUP BY item ORDER BY item_count %s, item', $parameters['order']); if ($parameters['result_format'] != 'sql') { $dropTemporaryTable = true; $this->db->query($queryCreateTemporaryTable); } else { return $queryCreateTemporaryTable . ';' . $queryItems; } } else { return phpOpenTracker::handleError('You need a database system capable of nested queries.', E_USER_ERROR); } } $this->db->query($queryTotalUnique); if ($row = $this->db->fetchRow()) { $totalItems = intval($row['total_items']); $uniqueItems = intval($row['unique_items']); } else { return phpOpenTracker::handleError('Database query failed.'); } if ($totalItems > 0) { $this->db->query($queryItems, $parameters['limit']); $i = 0; while ($row = $this->db->fetchRow()) { $percentValue = doubleval(number_format(100 * $row['item_count'] / $totalItems, 2)); switch ($parameters['result_format']) { case 'csv': $csv .= sprintf("%d;%s;%d;%d\n", $i + 1, $row['item'], intval($row['item_count']), $percentValue); break; case 'xml': case 'xml_object': $itemChild =& $root->addChild('item'); $itemChild->addChild('rank', $i + 1); $itemChild->addChild('string', $row['item']); $itemChild->addChild('count', intval($row['item_count'])); $itemChild->addChild('percent', $percentValue); if (isset($row['document_url'])) { $itemChild->addChild('url', $row['document_url']); } break; case 'separate_result_arrays': $names[$i] = $row['item']; $values[$i] = intval($row['item_count']); $percent[$i] = $percentValue; break; default: $topItems[$i]['count'] = intval($row['item_count']); $topItems[$i]['string'] = $row['item']; $topItems[$i]['percent'] = $percentValue; if (isset($row['document_url'])) { $topItems[$i]['url'] = $row['document_url']; } } $i++; } } if (isset($dropTemporaryTable)) { $this->db->query('DROP TABLE pot_temporary_table'); } switch ($parameters['result_format']) { case 'csv': return $csv; break; case 'xml': case 'xml_object': $root->addChild('total', $totalItems); $root->addChild('unique', $uniqueItems); switch ($parameters['result_format']) { case 'xml': return $root->get(); break; case 'xml_object': return $root; break; } break; case 'separate_result_arrays': return array($names, $values, $percent, $uniqueItems); break; default: return array('top_items' => $topItems, 'unique_items' => $uniqueItems); } }
/** * Retrieve the data needed for computation of this form */ function prepareStatsData() { global $statsinfo; $timeRange = $statsinfo->getRangeArray(); $this->dateFormat = $statsinfo->getDateFormat($timeRange['interval']); $timeRange['interval'] = $statsinfo->getIntervalTicks($timeRange['interval']); $diagram = $this->summaryType; $paramArray = array('api_call' => $this->summaryType); if (substr($diagram, 0, 8) == "nxhours:") { $paramArray = array('what' => substr($diagram, 8), 'api_call' => "hours"); $this->hours = true; } else { if (substr($diagram, 0, 11) == "nxweekdays:") { $paramArray = array('what' => substr($diagram, 11), 'api_call' => "weekdays"); $this->weekdays = true; } } if (substr($diagram, 0, 11) == "nxweekdays:") { $weekdays = true; $diagram = substr($diagram, 11); } $constraint = array(); if ($this->spid != "") { $constraint["constraints"] = array('document_string' => $this->spid); } $this->data = phpOpenTracker::get(array_merge($paramArray, $timeRange, $constraint)); $this->minTs = getMinTs($this->data); $this->maxTs = getMaxTs($this->data); $this->median = getMedian($this->data); $this->total = getTotal($this->data); $this->average = getAverage($this->data); }
$top = true; $diagram = substr($diagram, 4); } else { $top = false; } if (substr($diagram, 0, 15) == "search_engines:") { $top = true; } if ($diagram != "") { if ($weekdays) { $paramArray = array('api_call' => 'nxweekdays', 'what' => $diagram, 'width' => $width, 'height' => $height); } else { if ($hours) { $paramArray = array('api_call' => 'nxhours', 'what' => $diagram, 'width' => $width, 'height' => $height); } else { if (!$top) { $paramArray = array('api_call' => 'nxaccess_statistics', 'width' => $width, 'height' => $height, 'what' => explode(",", $diagram), 'whatcolors' => array(__RED, __BLUE, __YELLOW, __GREEN, _PURPLE)); } else { if ($top) { $paramArray = array('api_call' => 'nxtop', 'width' => $width, 'height' => $height, 'what' => $diagram, 'limit' => 10); } } } } $constraint = array(); if (value("spid", "NUMERIC") != "0") { $constraint["constraints"] = array('document_string' => value("spid")); } $paramArray = array_merge($paramArray, $statsinfo->getRangeArray(), $constraint); phpOpenTracker::plot($paramArray); }
<?php // // +---------------------------------------------------------------------+ // | phpOpenTracker - The Website Traffic and Visitor Analysis Solution | // +---------------------------------------------------------------------+ // | Copyright (c) 2000-2003 Sebastian Bergmann. All rights reserved. | // +---------------------------------------------------------------------+ // | This source file is subject to the phpOpenTracker Software License, | // | Version 1.0, that is bundled with this package in the file LICENSE. | // | If you did not receive a copy of this file, you may either read the | // | license online at http://phpOpenTracker.de/license/1_0.txt, or send | // | a note to license@phpOpenTracker.de, so we can mail you a copy. | // +---------------------------------------------------------------------+ // // $Id: graph.php,v 1.1 2003/09/02 11:18:56 sven_weih Exp $ // require 'phpOpenTracker.php'; switch ($_GET['what']) { case 'access_statistics': $time = time(); phpOpenTracker::plot(array('api_call' => 'access_statistics', 'client_id' => isset($_GET['client_id']) ? $_GET['client_id'] : 1, 'start' => isset($_GET['start']) ? $_GET['start'] : mktime(0, 0, 0, date('m', $time), 1, date('Y', $time)), 'end' => isset($_GET['end']) ? $_GET['end'] : mktime(0, 0, 0, date('m', $time) + 1, 0, date('Y', $time)), 'interval' => isset($_GET['interval']) ? $_GET['interval'] : 'day', 'width' => isset($_GET['width']) ? $_GET['width'] : 640, 'height' => isset($_GET['height']) ? $_GET['height'] : 480)); break; }