Commit 5ed49865 authored by lechuckdapirate's avatar lechuckdapirate

phpOpenTracker update to v1.5

parent f048e5b8
This diff is collapsed.
<?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 [email protected], so we can mail you a copy. |
// +---------------------------------------------------------------------+
// | Author: Sebastian Bergmann <[email protected]> |
// +---------------------------------------------------------------------+
//
// $Id: Clickpath.php,v 1.1 2003-04-25 18:43:53 lrargerich Exp $
//
/**
* Clickpath
*
* @author Sebastian Bergmann <[email protected]>
* @version $Revision: 1.1 $
* @since phpOpenTracker 1.0.0
*/
class phpOpenTracker_Clickpath {
/**
* Count
*
* @var integer $count
*/
var $count;
/**
* Length
*
* @var integer $length
*/
var $length;
/**
* documents
*
* @var array $documents
*/
var $documents;
/**
* document_urls
*
* @var array $document_urls
*/
var $document_urls;
/**
* Statistics
*
* @var array $statistics
*/
var $statistics;
/**
* Constructor.
*
* @param array $documents
* @param optional array $document_urls
* @param optional array $statistics
* @param optional integer $count
* @access public
*/
function phpOpenTracker_Clickpath($documents, $document_urls = array(), $statistics = array(), $count = 1) {
$this->documents = $documents;
$this->document_urls = $document_urls;
$this->count = $count;
$this->length = sizeof($documents);
$this->statistics = $statistics;
print("hey");
}
/**
* Returns GraphViz/dot markup for the graph.
*
* @param optional boolean $returnObject
* @return mixed
* @access public
*/
function toGraph($returnObject = false) {
if ([email protected]include_once('Image/GraphViz.php')) {
phpOpenTracker::handleError(
'Could not find PEAR Image_GraphViz package, exiting.',
E_USER_ERROR
);
}
$graph = new Image_GraphViz();
for ($i = 0; $i < $this->length - 1; $i++) {
$graph->addNode(
$i,
array(
'url' => $this->document_urls[$i],
'label' => $this->documents[$i],
'shape' => 'box'
)
);
$graph->addNode(
$i+1,
array(
'url' => $this->document_urls[$i+1],
'label' => $this->documents[$i+1],
'shape' => 'box'
)
);
if (isset($this->statistics[$i]['count'])) {
$label = sprintf(
'count: %d\naverage time: %d seconds',
$this->statistics[$i]['count'],
$this->statistics[$i]['time_spent']
);
} else {
$label = sprintf(
'time spent: %d seconds',
$this->statistics[$i]
);
}
$graph->addEdge(
array(
$i => $i+1
),
array(
'label' => $label
)
);
}
if ($returnObject) {
return $graph;
} else {
return $graph->parse();
}
}
/**
* Returns XML markup for the graph.
*
* @param optional boolean $returnObject
* @return mixed
* @access public
*/
function toXML($returnObject = false) {
if ([email protected]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;
}
}
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
<?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 [email protected], so we can mail you a copy. |
// +---------------------------------------------------------------------+
// | Author: Sebastian Bergmann <[email protected]> |
// +---------------------------------------------------------------------+
//
// $Id: Clickpath.php,v 1.2 2003-05-12 16:34:49 lechuckdapirate Exp $
//
/**
* Clickpath
*
* @author Sebastian Bergmann <[email protected]>
* @version $Revision: 1.2 $
* @since phpOpenTracker 1.0.0
*/
class phpOpenTracker_Clickpath {
/**
* Count
*
* @var integer $count
*/
var $count;
/**
* Length
*
* @var integer $length
*/
var $length;
/**
* documents
*
* @var array $documents
*/
var $documents;
/**
* document_urls
*
* @var array $document_urls
*/
var $document_urls;
/**
* Statistics
*
* @var array $statistics
*/
var $statistics;
/**
* Constructor.
*
* @param array $documents
* @param optional array $document_urls
* @param optional array $statistics
* @param optional integer $count
* @access public
*/
function phpOpenTracker_Clickpath($documents, $document_urls = array(), $statistics = array(), $count = 1) {
$this->documents = $documents;
$this->document_urls = $document_urls;
$this->count = $count;
$this->length = sizeof($documents);
$this->statistics = $statistics;
}
/**
* Returns GraphViz/dot markup for the graph.
*
* @param optional boolean $returnObject
* @return mixed
* @access public
*/
function toGraph($returnObject = false) {
if ([email protected]include_once('Image/GraphViz.php')) {
phpOpenTracker::handleError(
'Could not find PEAR Image_GraphViz package, exiting.',
E_USER_ERROR
);
}
$graph = new Image_GraphViz();
for ($i = 0; $i < $this->length - 1; $i++) {
$graph->addNode(
$i,
array(
'url' => $this->document_urls[$i],
'label' => $this->documents[$i],
'shape' => 'box'
)
);
$graph->addNode(
$i+1,
array(
'url' => $this->document_urls[$i+1],
'label' => $this->documents[$i+1],
'shape' => 'box'
)
);
if (isset($this->statistics[$i]['count'])) {
$label = sprintf(
'count: %d\naverage time: %d seconds',
$this->statistics[$i]['count'],
$this->statistics[$i]['time_spent']
);
} else {
$label = sprintf(
'time spent: %d seconds',
$this->statistics[$i]
);
}
$graph->addEdge(
array(
$i => $i+1
),
array(
'label' => $label
)
);
}
if ($returnObject) {
return $graph;
} else {
return $graph->parse();
}
}
/**
* Returns XML markup for the graph.
*
* @param optional boolean $returnObject
* @return mixed
* @access public
*/
function toXML($returnObject = false) {
if ([email protected]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;
}
}
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
This diff is collapsed.
<?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 [email protected], so we can mail you a copy. |
// +---------------------------------------------------------------------+
// | Author: Sebastian Bergmann <[email protected]> |
// +---------------------------------------------------------------------+
//
// $Id: individual_clickpath.php,v 1.1 2003-04-25 18:43:54 lrargerich Exp $
//
require_once POT_INCLUDE_PATH . 'API/Clickpath.php';
require_once POT_INCLUDE_PATH . 'API/Plugin.php';
/**
* phpOpenTracker API - Individual Clickpath
*
* @author Sebastian Bergmann <[email protected]>
* @version $Revision: 1.1 $
* @since phpOpenTracker 1.0.0
*/
class phpOpenTracker_API_individual_clickpath extends phpOpenTracker_API_Plugin {
/**
* API Calls
*
* @var array $apiCalls
*/
var $apiCalls = array('individual_clickpath');
/**
* API Type
*
* @var string $apiType
*/
var $apiType = 'get';
/**
* 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,
data_values.document_url AS document_url,
accesslog.timestamp AS timestamp
FROM %s accesslog,
%s data_values
WHERE accesslog.accesslog_id = %d
AND accesslog.document_id = data_values.data_id
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,
accesslog.timestamp
FROM %s accesslog
WHERE accesslog.accesslog_id = %d
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;
}
}
}
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
<?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 [email protected], so we can mail you a copy. |
// +---------------------------------------------------------------------+
// | Author: Sebastian Bergmann <[email protected]> |
// +---------------------------------------------------------------------+
//
// $Id: individual_clickpath.php,v 1.2 2003-05-12 16:34:50 lechuckdapirate Exp $
//
require_once POT_INCLUDE_PATH . 'API/Clickpath.php';
require_once POT_INCLUDE_PATH . 'API/Plugin.php';
/**
* phpOpenTracker API - Individual Clickpath
*
* @author Sebastian Bergmann <[email protected]>
* @version $Revision: 1.2 $
* @since phpOpenTracker 1.0.0
*/
class phpOpenTracker_API_individual_clickpath extends phpOpenTracker_API_Plugin {
/**
* API Calls
*
* @var array $apiCalls
*/
var $apiCalls = array('individual_clickpath');
/**
* API Type
*
* @var string $apiType
*/
var $apiType = 'get';
/**
* 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,
data_values.document_url AS document_url,
accesslog.timestamp AS timestamp
FROM %s accesslog,
%s data_values
WHERE accesslog.accesslog_id = %d
AND accesslog.document_id = data_values.data_id
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,
accesslog.timestamp
FROM %s accesslog
WHERE accesslog.accesslog_id = %d
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