Exemple #1
0
 /**
  * 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();
 }
 /**
  * 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;
 }
 /**
  * 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();
 }
Exemple #4
0
/**
 * 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)
 {
     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();
 }
 /**
  * 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;
 }
 /**
  * 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);
 }
 /**
  * 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;
     }
 }
 /**
  * Runs the phpOpenTracker API call.
  *
  * @param  array $parameters
  * @return mixed
  * @access public
  */
 function run($parameters)
 {
     $parameters['interval'] = isset($parameters['interval']) ? $parameters['interval'] : false;
     $intervalStrings = array();
     $timestamps = array();
     $values = array();
     switch ($parameters['result_format']) {
         case 'csv':
             if ($parameters['api_call'] == 'page_impressions') {
                 $csv = "Interval;Page Impressions\n";
             } else {
                 $csv = "Interval;Visitors\n";
             }
             break;
         case 'xml':
         case 'xml_object':
             $tree = new XML_Tree();
             if ($parameters['api_call'] == 'page_impressions') {
                 $root =& $tree->addRoot('pageimpressions');
             } else {
                 $root =& $tree->addRoot('visitors');
             }
             break;
         default:
             $result = array();
     }
     if ($parameters['interval'] != false) {
         $start = $parameters['start'] ? $parameters['start'] : 0;
         $end = $parameters['end'] ? $parameters['end'] : time();
         for ($i = $parameters['start']; $i < $parameters['end']; $i += $parameters['interval']) {
             $correct = (mktime(0, 0, 0, date('m', $i), date('d', $i) + 1, date('Y', $i)) - mktime(0, 0, 0, date('m', $i), date('d', $i), date('Y', $i))) * ($parameters['interval'] / 86400) - $parameters['interval'];
             // Correct weeks
             $j = $i;
             if ($parameters['interval'] == 604800) {
                 $j = $i + 86400;
             }
             $intervalStrings[] = sprintf('%s - %s', date('d-m-Y', $j), date('d-m-Y', $j + $parameters['interval'] + $correct));
             $values[] = phpOpenTracker::get(array('client_id' => $parameters['client_id'], 'api_call' => $parameters['api_call'], 'start' => $j, 'end' => $j + $parameters['interval'] + $correct, 'constraints' => $parameters['constraints']));
             $timestamps[] = $i;
             $i += $correct;
         }
     } else {
         $this->db->query(sprintf("SELECT %s AS result\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                  %s\r\n                  %s", $parameters['api_call'] == 'page_impressions' ? 'COUNT(*)' : 'COUNT(DISTINCT(visitors.accesslog_id))', $this->config['accesslog_table'], $this->config['visitors_table'], $parameters['client_id'], $this->_constraint($parameters['constraints']), $this->_whereTimerange($parameters['start'], $parameters['end'], 'accesslog')));
         if ($row = $this->db->fetchRow()) {
             $values = array(intval($row['result']));
         } else {
             $values = array(0);
         }
         if ($parameters['start'] != false && $parameters['end'] != false) {
             $intervalStrings = array(sprintf('%s - %s', date('d-m-Y', $parameters['start']), date('d-m-Y', $parameters['end'])));
         } else {
             $intervalStrings = array('');
         }
     }
     switch ($parameters['result_format']) {
         case 'csv':
             for ($i = 0; $i < sizeof($values); $i++) {
                 $csv .= sprintf("%s;%d\n", $intervalStrings[$i], $values[$i]);
             }
             return $csv;
             break;
         case 'xml':
         case 'xml_object':
             for ($i = 0; $i < sizeof($values); $i++) {
                 $intervalChild =& $root->addChild('interval');
                 $intervalChild->addChild('interval', $intervalStrings[$i]);
                 $intervalChild->addChild('value', $values[$i]);
             }
             if ($parameters['result_format'] == 'xml') {
                 return $root->get();
             } else {
                 return $root;
             }
             break;
         default:
             if (sizeof($values) == 1) {
                 return $values[0];
             } else {
                 $result = array();
                 for ($i = 0; $i < sizeof($values); $i++) {
                     $result[] = array('timestamp' => $timestamps[$i], 'value' => $values[$i]);
                 }
             }
             return $result;
     }
 }
Exemple #10
0
function top($clientID, $limit, $start = false, $end = false)
{
    $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();
    // 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));
        for ($j = 0; $j < sizeof($result['top_items']); $j++) {
            // Get item template
            $item = new MyTemplate('templates/item.htm');
            // Fill in item template variables
            $item->setVar(array('rank', 'count', 'percent', 'string'), array($j + 1, $result['top_items'][$j]['count'], $result['top_items'][$j]['percent'], $result['top_items'][$j]['string']));
            if (!isset($batchResult[$batchKeys[$i]]['top_items'])) {
                $batchResult[$batchKeys[$i]]['top_items'] = '';
            }
            $batchResult[$batchKeys[$i]]['top_items'] .= $item->parse();
        }
        $batchResult[$batchKeys[$i]]['unique_items'] = $result['unique_items'];
    }
    return $batchResult;
}
	$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);
 /**
  * Runs the phpOpenTracker API call.
  *
  * @param  array $parameters
  * @return mixed
  * @access public
  */
 function run($parameters)
 {
     global $lang, $c;
     $parameters['api_call'] = 'top';
     $parameters['result_format'] = 'separate_result_arrays';
     $apicall = array('api_call' => 'top', 'result_format' => 'separate_result_arrays', 'what' => $parameters["what"], 'start' => $parameters["start"], 'end' => $parameters["end"], 'client_id' => 1, 'limit' => $parameters["limit"]);
     list($names, $values, $percent, $total) = phpOpenTracker::get($apicall);
     $percent_others = 100.0;
     $values_others = 0;
     for ($j = 0; $j < $parameters['limit']; $j++) {
         $percent_others = $percent_others - $percent[$j];
         $values_others = $values_others + $values[$j];
         if (is_numeric($names[$j])) {
             $names[$j] = resolvePage($names[$j]);
         }
     }
     array_push($percent, $percent_others);
     array_push($names, $lang->get("others", "Others"));
     array_push($values, $values_others * $percent_others / 100);
     $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 .= 'Browsers';
             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->title->Set($title);
     if ($c["usettf"]) {
         $graph->title->SetFont(FF_ARIAL, FS_NORMAL, 8);
     }
     $graph->title->SetColor('black');
     $graph->legend->Pos(0.5, 0.6, "center", "top");
     $graph->legend->SetFillColor("white");
     $graph->legend->SetShadow(0);
     //$graph->legend->SetFrame(0);
     if ($c["usettf"]) {
         $graph->legend->SetFont(FF_ARIAL, FS_NORMAL, 8);
     }
     $graph->SetFrame(0);
     $plot = new PiePlot3d($percent);
     $plot->SetTheme('nx');
     $plot->SetCenter(0.5, 0.3);
     $plot->SetAngle(45);
     if ($c["usettf"]) {
         $plot->value->SetFont(FF_ARIAL, FS_NORMAL, 8);
     }
     $plot->SetLegends($legend);
     $graph->Add($plot);
     $graph->img->SetAntiAliasing("white");
     $graph->Stroke();
 }
Exemple #13
0
 /**
  * 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);
 }
 /**
  * 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));
 }
 /**
  * Retrieve the data needed for computation of this form
  */
 function prepareStatsData()
 {
     global $statsinfo;
     $timeRange = $statsinfo->getRangeArray();
     $timeRange['interval'] = $statsinfo->getIntervalTicks($timeRange['interval']);
     $this->data = phpOpenTracker::get(array_merge(array('api_call' => 'top', 'what' => $this->summaryType, 'limit' => $statsinfo->limit), $timeRange));
 }
Exemple #16
0
 /**
  * Returns the average clickpath length.
  *
  * @param  array $parameters
  * @return integer
  * @access private
  * @author Sven Weih <*****@*****.**>
  * @since  phpOpenTracker 1.3.0
  */
 function _averageClickpathLength($parameters)
 {
     $pageImpressionsParameters = $parameters;
     $pageImpressionsParameters['api_call'] = 'page_impressions';
     $visitsParameters = $parameters;
     $visitsParameters['api_call'] = 'visits';
     $pageImpressions = phpOpenTracker::get($pageImpressionsParameters);
     $visits = phpOpenTracker::get($visitsParameters);
     if (is_array($pageImpressions)) {
         for ($i = 0; $i < sizeof($pageImpressions); $i++) {
             $result[$i] = array('timestamp' => $pageImpressions[$i]['timestamp'], 'value' => $pageImpressions[$i]['value'] / ($visits[$i]['value'] == 0 ? 1 : $visits[$i]['value']));
         }
     } else {
         if ($visits != 0) {
             return $pageImpressions / $visits;
         } else {
             return 0;
         }
     }
     return $result;
 }
 /**
  * Retrieve the data needed for computation of this form
  */
 function prepareStatsData()
 {
     global $statsinfo;
     $timeRange = $statsinfo->getRangeArray();
     $timeRange['interval'] = $statsinfo->getIntervalTicks($timeRange['interval']);
     if (substr($this->summaryType, 0, 14) == "search_engines") {
         $this->data = phpOpenTracker::get(array_merge(array('api_call' => 'search_engines', 'what' => substr($this->summaryType, 15), 'limit' => $statsinfo->limit), $timeRange));
     } else {
         $this->data = phpOpenTracker::get(array_merge(array('api_call' => 'top', 'what' => $this->summaryType, 'limit' => $statsinfo->limit), $timeRange));
     }
 }
<?
	require_once "../../config.inc.php";
	require_once $c["path"]."modules/stats/phpOpenTracker.php";



// average clickstream


$documents = phpOpenTracker::get(
array(
'api_call' => 'page_impressions',
'range' => 'current_month',
'constraints' => array('document' => 100104)
)
);
var_dump($documents);



/*
$a =phpOpenTracker::get(
array(
'api_call' => 'visits',
'range' => 'current_month',
'interval' => '86400'

)
);
var_dump($a);*/
Exemple #19
0
 /**
  * Returns detailed information about the visitors who have made a conversion
  * (placed an order or inquiry or signed up for something).
  *
  * @param  array $parameters
  * @return mixed
  * @access private
  * @since  phpOpenTracker 1.3.0
  */
 function _conversions($parameters)
 {
     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();
     // get a list of all accesslogIDs where there was a conversion
     $this->db->query(sprintf("SELECT DISTINCT(accesslog.accesslog_id) AS accesslog_id\n           FROM %s accesslog,\n                %s conversions\n          WHERE conversions.client_id    = '%d'\n            AND conversions.accesslog_id = accesslog.accesslog_id\n            AND accesslog.timestamp  >= '%d'", $this->config['accesslog_table'], $this->config['plugins']['conversions']['table'], $parameters['client_id'], time() - $parameters['session_lifetime'] * 60));
     while ($row = $this->db->fetchRow()) {
         $accesslogIDs[] = $row['accesslog_id'];
     }
     // for each conversion, get details
     for ($i = 0, $max = sizeof($accesslogIDs); $i < $max; $i++) {
         // get the clickpaths for each conversion
         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]));
         }
         // get time of last access
         $this->db->query(sprintf("SELECT MAX(timestamp) as last_access\n             FROM %s\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. A');
         }
         // get host and user agent
         $this->db->query(sprintf("SELECT hosts.string       AS host,\n                  user_agents.string AS user_agent\n             FROM %s visitors,\n                  %s hosts,\n                  %s user_agents\n            WHERE visitors.accesslog_id  = '%d'\n              AND visitors.host_id       = hosts.data_id\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. B');
         }
         // to determine source, first look for a record of
         // the use of a search engine on the first visit,
         // then a referrer on the first visit, then
         // the use of a search engine on the most recent visit,
         // then a referrer on the most recent visit
         // get visitor_id and number of visits
         $this->db->query(sprintf("SELECT visitors.visitor_id AS visitor_id\n             FROM %s visitors\n            WHERE visitors.accesslog_id = '%d'", $this->config['visitors_table'], $accesslogIDs[$i]));
         if ($row = $this->db->fetchRow()) {
             $visitor_id = intval($row['visitor_id']);
         } else {
             $visitor_id = 0;
         }
         $this->db->query(sprintf("SELECT COUNT(visitors.visitor_id) AS num_visits\n             FROM %s visitors\n            WHERE visitors.visitor_id = '%d'", $this->config['visitors_table'], $visitor_id));
         if ($row = $this->db->fetchRow()) {
             $num_visits = intval($row['num_visits']);
         } else {
             $num_visits = 0;
         }
         switch ($parameters['result_format']) {
             case 'xml':
             case 'xml_object':
                 $visitorNode->addChild('num_visits', $num_visits);
                 break;
             default:
                 $result[$i]['num_visits'] = $num_visits;
         }
         // end query for visitor_id and number of visits
         // get accesslog_id of first visit
         $this->db->query(sprintf("SELECT visitors.accesslog_id AS first_access\n             FROM %s visitors\n            WHERE visitors.visitor_id = '%d'\n      ORDER BY visitors.timestamp", $this->config['visitors_table'], $visitor_id));
         if ($row = $this->db->fetchRow()) {
             $first_access = $row['first_access'];
         }
         // end query for accesslog_id of first visit
         // get first search engine and search engine keywords
         if ($num_visits > 1) {
             $this->db->query(sprintf("SELECT search_engines.search_engine AS search_engine,\n                 search_engines.keywords AS keywords\n                 FROM %s search_engines\n                WHERE search_engines.accesslog_id = '%d'", $this->config['plugins']['search_engines']['table'], $first_access));
             if ($row = $this->db->fetchRow()) {
                 $source = $row['search_engine'] . ': "' . $row['keywords'] . '"';
             }
         }
         // end query for first search engine and search engine keywords
         // get first referrer
         if (!isset($source)) {
             if ($num_visits > 1) {
                 $this->db->query(sprintf("SELECT referers.string AS first_referer\n                 FROM %s visitors,\n                      %s referers\n                WHERE visitors.accesslog_id = '%d'\n                  AND visitors.referer_id   = referers.data_id\n                  ORDER BY visitors.timestamp", $this->config['visitors_table'], $this->config['referers_table'], $first_access));
                 if ($row = $this->db->fetchRow()) {
                     $source = $row['first_referer'];
                 }
             }
         }
         // end query for first referrer
         // get most recent search engine and search engine keywords
         if (!isset($source)) {
             $this->db->query(sprintf("SELECT search_engines.search_engine AS search_engine,\n               search_engines.keywords AS keywords\n               FROM %s search_engines,\n                    %s visitors\n              WHERE visitors.visitor_id = '%d'\n                AND visitors.accesslog_id   = search_engines.accesslog_id\n                ORDER BY visitors.timestamp", $this->config['plugins']['search_engines']['table'], $this->config['visitors_table'], $visitor_id));
             if ($row = $this->db->fetchRow()) {
                 $source = $row['search_engine'] . ': "' . $row['keywords'] . '"';
             }
         }
         // end query for most recent search engines and search engine keywords
         // get most recent referrer
         if (!isset($source)) {
             $this->db->query(sprintf("SELECT referers.string AS referer\n               FROM %s visitors,\n                    %s referers\n              WHERE visitors.accesslog_id = '%d'\n                AND visitors.referer_id   = referers.data_id", $this->config['visitors_table'], $this->config['referers_table'], $accesslogIDs[$i]));
             if ($row = $this->db->fetchRow()) {
                 $source = $row['referer'];
             } else {
                 $source = '';
             }
         }
         // end query for most recent referrer
         // store source as a result
         switch ($parameters['result_format']) {
             case 'xml':
             case 'xml_object':
                 $visitorNode->addChild('source', $source);
                 break;
             default:
                 $result[$i]['source'] = $source;
         }
         // done storing source
         unset($source);
         // query for conversions type, amount, and details
         $this->db->query(sprintf("SELECT conversions.sale AS sale,\n             conversions.inquiry AS inquiry,\n             conversions.signup AS signup,\n             conversions.email AS email,\n             conversions.zip AS zip,\n             conversions.country AS country,\n             conversions.name AS name\n             FROM %s conversions,\n                  %s visitors\n            WHERE visitors.accesslog_id = '%d'\n              AND visitors.accesslog_id   = conversions.accesslog_id", $this->config['plugins']['conversions']['table'], $this->config['visitors_table'], $accesslogIDs[$i]));
         if ($row = $this->db->fetchRow()) {
             $sale = $row['sale'];
             $inquiry = $row['inquiry'];
             $signup = $row['signup'];
             $email = $row['email'];
             $zip = $row['zip'];
             $country = $row['country'];
             $name = $row['name'];
         } else {
             $sale = '';
             $inquiry = '';
             $signup = '';
             $email = '';
             $zip = '';
             $country = '';
             $name = '';
         }
         switch ($parameters['result_format']) {
             case 'xml':
             case 'xml_object':
                 $visitorNode->addChild('sale', $sale);
                 $visitorNode->addChild('inquiry', $inquiry);
                 $visitorNode->addChild('signup', $signup);
                 $visitorNode->addChild('email', $email);
                 $visitorNode->addChild('zip', $zip);
                 $visitorNode->addChild('country', $country);
                 $visitorNode->addChild('name', $name);
                 break;
             default:
                 $result[$i]['sale'] = $sale;
                 $result[$i]['inquiry'] = $inquiry;
                 $result[$i]['signup'] = $signup;
                 $result[$i]['email'] = $email;
                 $result[$i]['zip'] = $zip;
                 $result[$i]['country'] = $country;
                 $result[$i]['name'] = $name;
         }
         // end query for conversions type, amount, etc.
     }
     // end loop
     // return results
     switch ($parameters['result_format']) {
         case 'xml':
             return $root->get();
             break;
         case 'xml_object':
             return $root;
             break;
         default:
             return $result;
     }
 }
 /**
  * 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)
 {
     global $locale;
     $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, 'month' => 2592000, 'year' => 31536000);
     $starttitle = '';
     $endtitle = '';
     switch ($parameters['interval']) {
         case 'hour':
             $starthour = $hour = date('H', $parameters['start']);
             $endhour = date('H', $parameters['end']);
             $starttitle .= $starthour . ':00 ';
             $endtitle .= $endhour . ':00 ';
         case 'day':
             $startday = $day = date('d', $parameters['start']);
             $endday = date('d', $parameters['end']);
             $starttitle .= $startday . '. ';
             $endtitle .= $endday . '. ';
         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;
     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, 'end' => $end, 'constraints' => $parameters['constraints']);
             $y_pi[] = phpOpenTracker::get(array_merge(array('api_call' => 'page_impressions'), $apiCallParameters));
             $y_visits[] = phpOpenTracker::get(array_merge(array('api_call' => 'visits'), $apiCallParameters));
         } else {
             $y_pi[] = 0;
             $y_visits[] = 0;
         }
         switch ($parameters['interval']) {
             case 'hour':
                 $x_label[] = date('H', mktime($hour, 0, 0, $startmonth, $startday, $startyear)) . ':00';
                 $hour++;
                 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 ($parameters['interval'] == 'hour') {
         $angle = 50;
         $xasisFontSize = $parameters['font_size'] - 2;
     } else {
         $angle = 0;
         $xasisFontSize = $parameters['font_size'];
     }
     $graph = new Graph($parameters['width'], $parameters['height'], 'auto');
     $graph->img->SetMargin(40, 40, 20, 40);
     $graph->SetScale('textlin');
     $graph->SetY2Scale('lin');
     $graph->SetShadow();
     $pi_plot = new LinePlot($y_pi);
     $pi_plot->SetColor($parameters['color1']);
     $pi_plot->SetLegend($locale->get('admin_stat', 'field_monthlyvisitor'));
     $pi_plot->SetWeight(2);
     $visits_plot = new LinePlot($y_visits);
     $visits_plot->SetColor($parameters['color2']);
     $visits_plot->SetLegend($locale->get('admin_stat', 'field_monthlyimp'));
     $visits_plot->SetWeight(2);
     $graph->Add($pi_plot);
     $graph->AddY2($visits_plot);
     $graph->xaxis->SetTickLabels($x_label);
     $graph->xaxis->SetLabelAngle($angle);
     $graph->xaxis->SetFont($parameters['font'], $parameters['font_style'], $xasisFontSize);
     $graph->xaxis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->yaxis->SetColor('black');
     $graph->yaxis->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->yaxis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->y2axis->SetColor('black');
     $graph->y2axis->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->y2axis->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->title->Set($title);
     $graph->title->SetFont($parameters['font'], $parameters['font_style'], $parameters['font_size']);
     $graph->Stroke();
 }
Exemple #22
0
 }
 //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);
Exemple #23
0
<?php

// Közvetlenül ezt az állományt kérte
if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) {
    die("Közvetlenül nem lehet az állományhoz hozzáférni...");
}
if ($sub_act = "lst") {
    $visitors = array();
    foreach ($config['clients'] as $clientID => $client) {
        $resultSet = phpOpenTracker::get(array('client_id' => $clientID, 'api_call' => 'visitors_online'));
        if ($resultSet) {
            foreach ($resultSet as $resultItem) {
                $index = sizeof($visitors);
                $visitors[$index]['last_access'] = date($locale->get('date_format'), $resultItem['last_access']);
                $visitors[$index]['site'] = $client;
                $visitors[$index]['document'] = $resultItem['clickpath']->documents[sizeof($resultItem['clickpath']->documents) - 1];
                $visitors[$index]['document_url'] = $resultItem['clickpath']->document_urls[sizeof($resultItem['clickpath']->document_urls) - 1];
                $visitors[$index]['host'] = $resultItem['host'];
                $visitors[$index]['referer'] = $resultItem['referer'];
            }
        }
    }
    $tpl->assign('visitors', $visitors);
    $acttpl = "stat_current_list";
}
 /**
  * @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;
     }
 }
        $auth = new auth("TRAFFIC");
        require_once "statsinit.php";
        require_once "widgets/toppages.php";
	require_once "widgets/page_selector.php";
	
	$form->add(new AlignedLabel("lbl", $lang->get("pages_ind", "Individual Page Analysis"), "center","stats_title2", 3));
	$menu->topSelector = true;
	
	$wiselector = new WiPageSelector(3);
	$form->add($wiselector);
	$spid = $wiselector->value;
	
	$form->add(new StatsDiagram($lang->get("pi_overview", "Page Impressions overview"), "page_impressions", array($lang->get("pi", "Page Impressions")), "600",300,3,$spid));
	$piSummary = new StatsSummary($lang->get("pi_overview"), "page_impressions", 3, $spid);
	$piSummary->setStandardFields();
	$piSummary->addField($lang->get("avg_clickstream", "Average clickstream"), sprintf("%01.2f", phpOpenTracker::get(array_merge(array('api_call' =>'avg_clickstream'), $rangeArray ))));
	$piSummary->addSpacer();
	$piSummary->renderStatsData(array($lang->get("when", "When"), $lang->get("pi")));
	$form->add($piSummary);
	
	$form->add(new StatsDiagram($lang->get("top_pages", "Top pages"), "top:document", null, 600,400));
	$form->add(new TopPages($lang->get("top_pages", "Top pages"), "document", 3));
	
	$form->add(new StatsDiagram($lang->get("top_entrypages", "Top entry pages"), "top:entry_document", null, 300,300,1));
	$form->add(new Cell("clc", "bcopy", 1, 20, 20));
	$form->add(new StatsDiagram($lang->get("top_exitpages", "Top exit pages"), "top:exit_document", null, 300,300,1));
	
	
	$form->add(new TopPages($lang->get("top_entrypages" ), "entry_document", 1));
	$form->add(new Cell("clc", "bcopy", 1, 20, 20));
	$form->add(new TopPages($lang->get("top_exitpages"), "exit_document", 1));