phpOpenTracker/phpOpenTracker Configuration.php,NONE,1.1 Database.php,NONE,1.1 Exception.php,NONE,1.1 API.php,1.39,1.40 Container.php,1.33,1.34 LoggingEngine.php,1.33,1.34 Parser.php,1.17,1.18 Version.php,1.26,1.27 Config.php,1.19,NONE DB.php,1.25,NONE

Sebastian Bergmann <[email protected]>
Newsgroups gmane.comp.web.phpopentracker.cvs
Message-ID <[email protected]>
Update of /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker
In directory sc8-pr-cvs1:/tmp/cvs-serv16743/phpOpenTracker

Modified Files:
	API.php Container.php LoggingEngine.php Parser.php Version.php 
Added Files:
	Configuration.php Database.php Exception.php 
Removed Files:
	Config.php DB.php 
Log Message:
HEAD is 2.0.0-dev now.

--- Config.php DELETED ---

--- NEW FILE: Configuration.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 read it online  |
// | at http://www.phpopentracker.de/license.html.                       |
// +---------------------------------------------------------------------+
//
// $Id: Configuration.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//

class phpOpenTracker_Configuration {
    private static $instance = null;

    private function __construct() {
    }

    public static function getInstance() {
        if (self::$instance == null) {
            self::$instance = new phpOpenTracker_Configuration;
        }

        return self::$instance;
    }
}

//
// "phpOpenTracker essenya, gul meletya;
//  Sebastian carneron PHP."
//
?>

Index: Container.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/Container.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** Container.php	13 Oct 2003 03:11:11 -0000	1.33
--- Container.php	22 Nov 2003 08:47:43 -0000	1.34
***************
*** 15,232 ****
  //
  
- require POT_INCLUDE_PATH . 'Parser.php';
- 
- /**
- * phpOpenTracker Session Container
- *
- * @author   Sebastian Bergmann <[email protected]>
- * @version  $Revision$
- * @since    phpOpenTracker 1.0.0
- */
  class phpOpenTracker_Container {
!   /**
!   * Returns a reference to phpOpenTracker's session container.
!   *
!   * The first call to this method during a request triggers, if
!   * $parameters['init'] is not set to false, the generation of
!   * the session container array.
!   *
!   * @param  optional array $parameters
!   * @return array
!   * @access public
!   * @static
!   */
!   function &getInstance($parameters = array()) {
!     static $isInitialized;
! 
!     $init          = isset($parameters['init'])        ? $parameters['init']        : false;
!     $initAPI       = isset($parameters['initAPI'])     ? $parameters['initAPI']     : false;
!     $initNoSetup   = isset($parameters['initNoSetup']) ? $parameters['initNoSetup'] : false;
!     $isInitialized = isset($isInitialized)             ? $isInitialized             : false;
! 
!     if ($initAPI) {
!       $init          = true;
!       $isInitialized = false;
!     }
! 
!     else if ($initNoSetup) {
!       $init = true;
!     }
! 
!     if ($isInitialized && !$init) {
!       return $_SESSION['_phpOpenTracker_Container'];
!     }
  
!     if ($init && !$initAPI) {
!       session_register('_phpOpenTracker_Container');
!       $container = &$_SESSION['_phpOpenTracker_Container'];
      }
  
!     if ($init && !$isInitialized && !$initNoSetup) {
!       $config = &phpOpenTracker_Config::getConfig();
!       $db     = &phpOpenTracker_DB::getInstance();
! 
!       $parameters['client_id']    = isset($parameters['client_id'])    ? $parameters['client_id'] : 1;
!       $container['first_request'] = isset($container['first_request']) ? false                    : true;
! 
!       if ($container['first_request']) {
!         $client_id_switched = false;
!       }
! 
!       else if ($container['client_id'] != $parameters['client_id']) {
!         $container['first_request'] = true;
!         $client_id_switched         = true;
!       }
! 
!       $container['client_id'] = $parameters['client_id'];
! 
!       if ($container['first_request']) {
!         if (function_exists('posix_getpid')) {
!           $container['accesslog_id'] = crc32(microtime() . posix_getpid());
!         } else {
!           $container['accesslog_id'] = crc32(microtime() . session_id());
!         }
! 
!         if (!$client_id_switched) {
!           if (!isset($parameters['host']) &&
!               !isset($parameters['ip_address'])) {
!             if (isset($_SERVER['REMOTE_ADDR'])) {
!               $container['ip_address'] = $_SERVER['REMOTE_ADDR'];
! 
!               if (isset($_SERVER['REMOTE_HOST'])) {
!                 $container['host_orig'] = $_SERVER['REMOTE_HOST'];
!               } else {
!                 if ($config['resolve_hostname']) {
!                   $container['host_orig'] = gethostbyaddr($container['ip_address']);
!                 } else {
!                   $container['host_orig'] = $container['ip_address'];
!                 }
!               }
!             } else {
!               $container['host_orig']  = '';
!               $container['ip_address'] = '';
!             }
!           } else {
!             $container['host_orig']  = isset($parameters['host'])       ? $parameters['host']       : '';
!             $container['ip_address'] = isset($parameters['ip_address']) ? $parameters['ip_address'] : '';
!           }
! 
!           $container['host'] = $container['host_orig'];
! 
!           if ($config['group_hostnames']) {
!             $container['host'] = phpOpenTracker_Parser::hostname($container['host']);
!           }
! 
!           if (isset($parameters['user_agent'])) {
!             $container['user_agent_orig'] = $parameters['user_agent'];
!           } else {
!             $container['user_agent_orig'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
!           }
!           
!           if ($config['group_user_agents']) {
!             $container = array_merge(
!               $container,
!               phpOpenTracker_Parser::userAgent($container['user_agent_orig'])
!             );
!           } else {
!             $container['operating_system'] = 'Not identified';
!             $container['user_agent']       = $container['user_agent_orig'];
!           }
! 
!           $container['host_id'] = $db->storeIntoDataTable(
!             $config['hostnames_table'],
!             $container['host']
!           );
! 
!           $container['operating_system_id'] = $db->storeIntoDataTable(
!             $config['operating_systems_table'],
!             $container['operating_system']
!           );
! 
!           $container['user_agent_id'] = $db->storeIntoDataTable(
!             $config['user_agents_table'],
!             $container['user_agent']
!           );
!         }
! 
!         if (isset($parameters['referer'])) {
!           $container['referer_orig'] = $parameters['referer'];
!         } else {
!           $container['referer_orig'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
!         }
! 
!         $container['referer_orig'] = urldecode($container['referer_orig']);
! 
!         if ($config['clean_referer_string']) {
!           $container['referer'] = preg_replace('/(\?.*)/', '', $container['referer_orig']);
!         } else {
!           $container['referer'] = $container['referer_orig'];
!         }
! 
!         if (!empty($container['referer'])) {
!           $container['referer'] = str_replace('http://', '', $container['referer']);
!         }
! 
!         $container['referer_id'] = $db->storeIntoDataTable(
!           $config['referers_table'],
!           $container['referer']
!         );
!       } else {
!         $container['last_document'] = $container['document'];
!       }
! 
!       $container['document_url'] = isset($parameters['document_url']) ? $parameters['document_url'] : urldecode($_SERVER[$config['document_env_var']]);
! 
!       if ($config['clean_query_string']) {
!         $container['document_url'] = preg_replace(
!           '/(\?.*)/',
!           '',
!           $container['document_url']
!         );
!       } else {
!         if ($config['get_parameter_filter'] != '') {
!           $filters = explode(
!             ',',
!             str_replace(
!               ' ',
!               '',
!               $config['get_parameter_filter']
!             )
!           );
!         } else {
!           $filters = array();
!         }
! 
!         $filters[] = session_name();
! 
!         foreach ($filters as $filter) {
!           $container['document_url'] = preg_replace(
!             '#\?' .
!             $filter .
!             '=.*$|&' .
!             $filter .
!             '=.*$|' .
!             $filter .
!             '=.*&#msiU',
!             '',
!             $container['document_url']
!           );
          }
-       }
- 
-       $container['document']    = isset($parameters['document']) ? $parameters['document'] : $container['document_url'];
-       $container['document_id'] = $db->storeIntoDataTable(
-         $config['documents_table'],
-         $container['document'],
-         $container['document_url']
-       );
  
!       $container['timestamp'] = isset($parameters['timestamp']) ? $parameters['timestamp'] : time();
! 
!       $isInitialized = true;
      }
- 
-     return $container;
-   }
  }
  
--- 15,31 ----
  //
  
  class phpOpenTracker_Container {
!     private static $instance = null;
  
!     private function __construct() {
      }
  
!     public static function getInstance() {
!         if (self::$instance == null) {
!             self::$instance = new phpOpenTracker_Container;
          }
  
!         return self::$instance;
      }
  }
  

Index: LoggingEngine.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/LoggingEngine.php,v
retrieving revision 1.33
retrieving revision 1.34
diff -C2 -d -r1.33 -r1.34
*** LoggingEngine.php	13 Oct 2003 03:11:11 -0000	1.33
--- LoggingEngine.php	22 Nov 2003 08:47:43 -0000	1.34
***************
*** 15,286 ****
  //
  
- require POT_INCLUDE_PATH . 'LoggingEngine/Plugin.php';
- 
- /**
- * phpOpenTracker Logging Engine
- *
- * @author   Sebastian Bergmann <[email protected]>
- * @version  $Revision$
- * @since    phpOpenTracker 1.0.0
- */
  class phpOpenTracker_LoggingEngine {
-   /**
-   * Configuration
-   *
-   * @var array $config
-   */
-   var $config = array();
- 
-   /**
-   * Container
-   *
-   * @var array $container
-   */
-   var $container = array();
- 
-   /**
-   * DB
-   *
-   * @var object $db
-   */
-   var $db;
- 
-   /**
-   * Plugins
-   *
-   * @var array $plugins
-   */
-   var $plugins = array();
- 
-   /**
-   * Constructor.
-   *
-   * @param  optional array $parameters
-   * @access public
-   */
-   function phpOpenTracker_LoggingEngine($parameters = array()) {
-     $parameters['init'] = true;
- 
-     $this->config    = &phpOpenTracker_Config::getConfig();
-     $this->container = &phpOpenTracker_Container::getInstance($parameters);
-     $this->db        = &phpOpenTracker_DB::getInstance();
- 
-     $this->_loadPlugins($parameters);
-   }
- 
-   /**
-   * Logs an access.
-   *
-   * @param  array   $addData
-   * @return boolean
-   * @access public
-   */
-   function log($addData) {
-     if ($this->_isLocked()) {
-       return false;
-     }
- 
-     if ($this->config['track_returning_visitors'] &&
-         !empty($this->config['returning_visitors_cookie'])) {
-       $cookie = sprintf(
-         '%s_%d',
- 
-         $this->config['returning_visitors_cookie'],
-         $this->container['client_id']
-       );
-     } else {
-       $cookie = false;
-     }
- 
-     if ($this->container['first_request']) {
-       if ($cookie &&
-           isset($_COOKIE[$cookie])) {
-         $this->container['visitor_id']        = $_COOKIE[$cookie];
-         $this->container['returning_visitor'] = true;
-       } else {
-         $this->container['visitor_id']        = $this->container['accesslog_id'];
-         $this->container['returning_visitor'] = false;
- 
-         if ($cookie) {
-           @setcookie(
-             $cookie,
-             $this->container['visitor_id'],
-             $this->container['timestamp'] + ($this->config['returning_visitors_cookie_lifetime'] * 24 * 60 * 60)
-           );
-         }
-       }
- 
-       $this->_storeVisitData($addData);
-       $this->_storeRequestData();
-     } else {
-       if ($this->config['log_reload'] ||
-           $this->container['document'] != $this->container['last_document']) {
-         $this->_storeRequestData();
-       }
-     }
- 
-     return true;
-   }
- 
-   /**
-   * Checks if a locking rule applies to this visitor's data.
-   *
-   * @return boolean true, if a locking rule applies and the
-   *                 current request must not be counted.
-   * @access private
-   */
-   function _isLocked() {
-     if ($this->config['locking']) {
-       if ($rules = @file(POT_CONFIG_PATH . 'lock.ini', 1)) {
-         foreach ($rules as $rule) {
-           $field   = substr($rule, 0, strpos($rule, ' '));
-           $pattern = chop(substr($rule, strpos($rule, ' ') + 1));
- 
-           if (substr($field, 0, 1) != '#' &&
-               preg_match($pattern, $this->container[$field . '_orig'])) {
-             return true;
-           }
-         }
-       } else {
-         return phpOpenTracker::handleError(
-           sprintf(
-             'Could not open "%s", Locking disabled.',
- 
-             POT_CONFIG_PATH . 'lock.ini'
-           )
-         );
-       }
-     }
- 
-     $result = false;
- 
-     foreach ($this->plugins as $plugin) {
-       if (!$plugin->pre()) {
-         $result = true;
-       }
-     }
- 
-     return $result;
-   }
- 
-   /**
-   * Loads the phpOpenTracker Logging Engine plugins.
-   *
-   * @param  array $parameters
-   * @access private
-   */
-   function _loadPlugins($parameters) {
-     if ($this->config['logging_engine_plugins'] == '') {
-       return;
-     }
- 
-     $plugins = explode(
-       ',',
-       str_replace(
-         ' ',
-         '',
-         $this->config['logging_engine_plugins']
-       )
-     );
- 
-     foreach ($plugins as $pluginName) {
-       if (@include(POT_INCLUDE_PATH . 'LoggingEngine/plugins/' . $pluginName . '.php')) {
-         $pluginClass     = 'phpOpenTracker_LoggingEngine_Plugin_' . $pluginName;
-         $this->plugins[] = new $pluginClass($parameters);
-       } else {
-         phpOpenTracker::handleError(
-           sprintf(
-             'Could not load plugin "%s".',
- 
-             $pluginName
-           )
-         );
-       }
-     }
-   }
- 
-   /**
-   * Runs the phpOpenTracker Logging Engine 'post' plugins.
-   *
-   * @access private
-   */
-   function _runPostPlugins() {
-     $addData = array();
- 
-     foreach ($this->plugins as $plugin) {
-       $addData = array_merge($addData, $plugin->post());
-     }
- 
-     if ($this->container['first_request']) {
-       $this->db->storeAddData($this->container['accesslog_id'], $addData);
-     }
-   }
- 
-   /**
-   * Stores the request information.
-   *
-   * @access private
-   */
-   function _storeRequestData() {
-     if (!$this->container['first_request']) {
-       $this->_runPostPlugins();
-     }
- 
-     $this->db->query(
-       sprintf(
-         "INSERT
-            INTO %s
-                 (accesslog_id,
-                  timestamp, weekday, hour,
-                  document_id, entry_document)
-          VALUES ('%d', '%d', '%d', '%d', '%d', '%d')",
- 
-         $this->config['accesslog_table'],
-         $this->container['accesslog_id'],
-         $this->container['timestamp'],
-         date('w', $this->container['timestamp']),
-         date('H', $this->container['timestamp']),
-         $this->container['document_id'],
-         $this->container['first_request'] ? 1 : 0
-       )
-     );
-   }
- 
-   /**
-   * Stores the visit information.
-   *
-   * @param  array   $addData
-   * @access private
-   */
-   function _storeVisitData(&$addData) {
-     $this->_runPostPlugins();
- 
-     $this->db->query(
-       sprintf(
-         "INSERT
-            INTO %s
-                 (client_id, accesslog_id,  visitor_id,
-                  operating_system_id, user_agent_id, host_id, referer_id,
-                  timestamp, weekday, hour,
-                  returning_visitor)
-          VALUES ('%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d', '%d')",
- 
-         $this->config['visitors_table'],
-         $this->container['client_id'],
-         $this->container['accesslog_id'],
-         $this->container['visitor_id'],
-         $this->container['operating_system_id'],
-         $this->container['user_agent_id'],
-         $this->container['host_id'],
-         $this->container['referer_id'],
-         $this->container['timestamp'],
-         date('w', $this->container['timestamp']),
-         date('H', $this->container['timestamp']),
-         $this->container['returning_visitor'] ? 1 : 0
-       )
-     );
- 
-     $this->db->storeAddData($this->container['accesslog_id'], $addData);
-   }
  }
  
--- 15,19 ----

Index: API.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/API.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** API.php	13 Oct 2003 03:11:11 -0000	1.39
--- API.php	22 Nov 2003 08:47:43 -0000	1.40
***************
*** 15,526 ****
  //
  
- require POT_INCLUDE_PATH . 'API/Plugin.php';
- 
- /**
- * phpOpenTracker API
- *
- * This class provides an interface to the data gathered by
- * the phpOpenTracker Logging Engine.
- *
- * @author   Sebastian Bergmann <[email protected]>
- * @version  $Revision$
- * @since    phpOpenTracker 1.0.0
- */
  class phpOpenTracker_API {
!   /**
!   * API Calls
!   *
!   * @var array $apiCalls
!   */
!   var $apiCalls = array();
! 
!   /**
!   * Cache_Lite
!   *
!   * @var object $cache
!   */
!   var $cache = null;
! 
!   /**
!   * Configuration
!   *
!   * @var array $config
!   */
!   var $config = array();
! 
!   /**
!   * Container
!   *
!   * @var array $container
!   */
!   var $container = array();
! 
!   /**
!   * Plugins
!   *
!   * @var array $plugins
!   */
!   var $plugins = array();
! 
!   /**
!   * Weekdays
!   *
!   * @var array $weekdays
!   */
!   var $weekdays = array(
!     'sunday'    => 0,
!     'monday'    => 1,
!     'tuesday'   => 2,
!     'wednesday' => 3,
!     'thursday'  => 4,
!     'friday'    => 5,
!     'saturday'  => 6
!   );
! 
!   /**
!   * Constructor.
!   *
!   * @access public
!   */
!   function phpOpenTracker_API() {
!     $this->config = &phpOpenTracker_Config::getConfig();
! 
!     if ($this->config['query_cache']) {
!       @include_once 'Cache/Lite.php';
! 
!       if (class_exists('Cache_Lite')) {
!         $this->cache = new Cache_Lite(
!           array(
!             'cacheDir' => $this->config['query_cache_dir'],
!             'lifeTime' => $this->config['query_cache_lifetime']
!           )
!         );
!       } else {
!         phpOpenTracker::handleError(
!           'Could not find PEAR Cache_Lite package, Query Cache disabled.'
!         );
!       }
!     }
! 
!     $this->_loadPlugins();
!   }
! 
!   /**
!   * Returns an instance of phpOpenTracker_API.
!   *
!   * @return object  phpOpenTracker_API
!   * @access public
!   * @static
!   */
!   function &getInstance() {
!     static $instance;
! 
!     if (!isset($instance)) {
!       $instance = new phpOpenTracker_API;
!     }
! 
!     return $instance;
!   }
  
!   /**
!   * get() is the main method of the phpOpenTracker API. You pass it an
!   * array, which defines the type of information you want. Please refer to
!   * the chapter 'API Reference' of the phpOpenTracker Manual for detailed
!   * information and examples.
!   *
!   * @param  array   $parameters
!   * @return mixed
!   * @access public
!   */
!   function &get($parameters) {
!     if (!$this->_parseParameters($parameters)) {
!       return false;
      }
  
!     $doCache = false;
! 
!     if (is_object($this->cache)) {
!       ksort($parameters);
! 
!       $cacheID      = md5(serialize($parameters));
!       $cachedResult = $this->cache->get($cacheID, 'phpOpenTracker');
! 
!       if ($cachedResult != NULL) {
!         return unserialize($cachedResult);
!       }
  
!       if ($parameters['start'] != false && $parameters['start'] < time() &&
!           $parameters['end']   != false && $parameters['end']   < time()) {
!         $doCache = true;
!       }
      }
  
!     if (isset($this->apiCalls['get'][$parameters['api_call']])) {
!       $result = $this->apiCalls['get'][$parameters['api_call']]->run($parameters);
!     } else {
!       return phpOpenTracker::handleError(
!         sprintf(
!           'Unknown API Call %s.',
! 
!           $parameters['api_call']
!         )
!       );
      }
  
!     if ($doCache && $result !== false) {
!       $this->cache->save(serialize($result), $cacheID, 'phpOpenTracker');
      }
  
!     return $result;
!   }
! 
!   /**
!   * Plot a chart.
!   *
!   * @param  array   $parameters
!   * @access public
!   */
!   function plot($parameters) {
!     if (!$this->_parseParameters($parameters)) {
!       return false;
      }
  
!     if (empty($this->config['jpgraph_path'])) {
!       return phpOpenTracker::handleError(
!         'The JPGraph package is not installed, exiting.',
!         E_USER_ERROR
!       );
      }
  
!     include_once $this->config['jpgraph_path'] . 'jpgraph.php';
!     include_once $this->config['jpgraph_path'] . 'jpgraph_line.php';
!     include_once $this->config['jpgraph_path'] . 'jpgraph_pie.php';
!     include_once $this->config['jpgraph_path'] . 'jpgraph_pie3d.php';
! 
!     $parameters['color1']     = isset($parameters['color1'])     ? $parameters['color1']     : 'red';
!     $parameters['color2']     = isset($parameters['color2'])     ? $parameters['color2']     : 'blue';
!     $parameters['font']       = isset($parameters['font'])       ? $parameters['font']       : FF_VERDANA;
!     $parameters['font_style'] = isset($parameters['font_style']) ? $parameters['font_style'] : FS_NORMAL;
!     $parameters['font_size']  = isset($parameters['font_size'])  ? $parameters['font_size']  : 10;
!     $parameters['width']      = isset($parameters['width'])      ? $parameters['width']      : 640;
!     $parameters['height']     = isset($parameters['height'])     ? $parameters['height']     : 480;
! 
!     if (isset($this->apiCalls['plot'][$parameters['api_call']])) {
!       // Prevent caching
!       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');
! 
!       $this->apiCalls['plot'][$parameters['api_call']]->run($parameters);
!     } else {
!       return phpOpenTracker::handleError(
!         sprintf(
!           'Unknown API Call %s.',
! 
!           $parameters['api_call']
!         )
!       );
      }
-   }
  
!   /**
!   * Checks if a given phpOpenTracker API plugin is loaded.
!   *
!   * @param  string  $plugin
!   * @return boolean
!   * @access public
!   * @static
!   */
!   function pluginLoaded($plugin) {
!     $api = &phpOpenTracker_API::getInstance();
! 
!     return in_array(
!       $plugin,
!       $api->plugins
!     );
!   }
! 
!   /**
!   * Loads the phpOpenTracker API plugins.
!   *
!   * @access private
!   */
!   function _loadPlugins() {
!     if ($dir = @opendir(POT_INCLUDE_PATH . 'API/plugins')) {
!       while (($file = @readdir($dir)) !== false) {
!         if (strstr($file, '.php') &&
!             substr($file, -1, 1) != "~" &&
!             substr($file,  0, 1) != "#") {
!           if (@include(POT_INCLUDE_PATH . 'API/plugins/' . $file)) {
!             $this->plugins[] = substr($file, 0, -4);
! 
!             $class  = 'phpOpenTracker_API_' . substr($file, 0, -4);
!             $plugin = new $class;
! 
!             foreach ($plugin->apiCalls as $apiCall) {
!               if (!isset($this->apiCalls[$apiCall])) {
!                 $this->apiCalls[$plugin->apiType][$apiCall] = $plugin;
!               } else {
!                 phpOpenTracker::handleError(
!                   sprintf(
!                     'API Call "%s" already registered.',
! 
!                     $apiCall
!                   )
                  );
-               }
              }
-           } else {
-             phpOpenTracker::handleError(
-               sprintf(
-                 'Cannot load plugin "%s".',
- 
-                 substr($file, 0, -4)
-               )
-             );
-           }
          }
!       }
! 
!       @closedir($dir);
!     }
!   }
! 
!   /**
!   * Parses the parameters of an phpOpenTracker API call.
!   *
!   * @param  array   $parameters
!   * @return boolean
!   * @access private
!   */
!   function _parseParameters(&$parameters) {
!     if (!is_array($parameters) || !isset($parameters['api_call'])) {
!       return phpOpenTracker::handleError(
!         'No array was passed to API Call, or "api_call" field missing.'
!       );
!     }
! 
!     if (array_search('this', $parameters, true) !== false) {
!       $this->container = &phpOpenTracker_Container::getInstance(
!         array(
!           'initAPI' => true
!         )
!       );
!     }
! 
!     if (!isset($parameters['client_id'])) {
!       $parameters['client_id'] = isset($this->container['client_id']) ? $this->container['client_id'] : 1;
!     }
! 
!     $parameters['start']         = isset($parameters['start'])         ? $parameters['start']         : false;
!     $parameters['end']           = isset($parameters['end'])           ? $parameters['end']           : false;
!     $parameters['constraints']   = isset($parameters['constraints'])   ? $parameters['constraints']   : array();
!     $parameters['limit']         = isset($parameters['limit'])         ? $parameters['limit']         : false;
!     $parameters['order']         = isset($parameters['order'])         ? $parameters['order']         : 'DESC';
!     $parameters['range']         = isset($parameters['range'])         ? $parameters['range']         : 'total';
!     $parameters['range_start']   = isset($parameters['range_start'])   ? $parameters['range_start']   : 0;
!     $parameters['range_length']  = isset($parameters['range_length'])  ? $parameters['range_length']  : 0;
!     $parameters['result_format'] = isset($parameters['result_format']) ? $parameters['result_format'] : false;
! 
!     if (!$parameters['start'] && !$parameters['end']) {
!       if ($parameters['range'] != 'total') {
!         $timerange = $this->_timerange(
!           $parameters['range'],
!           $parameters['range_start'],
!           $parameters['range_length']
          );
- 
-         if ($timerange) {
-           $parameters['start'] = $timerange[0];
-           $parameters['end']   = $timerange[1];
-         } else {
-           return false;
-         }
-       }
-     }
- 
-     foreach ($parameters['constraints'] as $field => $value) {
-       if (is_string($value)) {
-         if ($value == 'this') {
-           $parameters['constraints'][$field] = $this->container[$field . '_id'];
-         }
- 
-         else if ($field == 'weekday') {
-           $parameters['constraints'][$field] = $this->weekdays[strtolower($value)];
-         }
- 
-         else {
-           $parameters['constraints'][$field] = crc32(strtolower($value));
-         }
-       }
      }
  
!     if (stristr($parameters['result_format'], 'xml')) {
!       if (!@include_once('XML/Tree.php')) {
!         phpOpenTracker::handleError(
!           'Could not find PEAR XML_Tree package, exiting.',
!           E_USER_ERROR
          );
-       }
      }
  
!     return true;
!   }
! 
!   /**
!   * Parses plain-text timeranges into timestamp intervals.
!   *
!   * @param  string            $range
!   * @param  optional  integer $start
!   * @param  optional  integer $length
!   * @return array
!   * @access private
!   */
!   function _timerange($range, $start = 0, $length = 0) {
!     switch ($range) {
!       case 'current_minute': {
!         return $this->_timerange('minute');
!       }
!       break;
! 
!       case 'previous_minute': {
!         return $this->_timerange('minute', 1, 1);
!       }
!       break;
! 
!       case 'current_hour': {
!         return $this->_timerange('hour');
!       }
!       break;
! 
!       case 'previous_hour': {
!         return $this->_timerange('hour', 1, 1);
!       }
!       break;
! 
!       case 'today': {
!         return $this->_timerange('day');
!       }
!       break;
! 
!       case 'yesterday': {
!         return $this->_timerange('day', 1, 1);
!       }
!       break;
! 
!       case 'current_month': {
!         return $this->_timerange('month');
!       }
!       break;
! 
!       case 'previous_month': {
!         return $this->_timerange('month', 1, 1);
!       }
!       break;
! 
!       case 'current_week': {
!         return $this->_timerange('week');
!       }
!       break;
! 
!       case 'previous_week': {
!         return $this->_timerange('week', 1, 1);
!       }
!       break;
! 
!       case 'current_year': {
!         return $this->_timerange('year');
!       }
!       break;
! 
!       case 'previous_year': {
!         return $this->_timerange('year', 1, 1);
!       }
!       break;
! 
!       case 'minute': {
!         $start = mktime(date('H'), date('i') - $start,   0);
!         $end   = mktime(date('H'), date('i') - $length, 59);
!       }
!       break;
! 
!       case 'hour': {
!         $start = mktime(date('H') - $start,  0,   0);
!         $end   = mktime(date('H') - $length, 59, 59);
!       }
!       break;
! 
!       case 'day': {
!         $start = mktime( 0,  0,  0, date('m'), date('d') - $start);
!         $end   = mktime(23, 59, 59, date('m'), date('d') - $length);
!       }
!       break;
! 
!       case 'month': {
!         $start = mktime( 0,  0,  0, date('m') - $start, 1);
!         $end   = mktime(23, 59, 59, date('m') - $length, date('t', mktime(0, 0, 0, date('m') - $length)));
!       }
!       break;
! 
!       case 'week': {
!         $start = $this->_mondayOfWeek(date('W') - $start,  date('Y'));
!         $end   = $this->_sundayOfWeek(date('W') - $length, date('Y'));
!       }
!       break;
! 
!       case 'year': {
!         $start = mktime( 0,  0,  0,  1,  1, date('Y') - $start);
!         $end   = mktime(23, 59, 59, 12, 31, date('Y') - $length);
!       }
!       break;
! 
!       default: {
!         return phpOpenTracker::handleError(
!           'Syntax error in timerange specification.'
!         );
!       }
      }
- 
-     return array(
-       $start,
-       $end
-     );
-   }
- 
-   /**
-   * Returns the timestamp for 00:00:00 of a given week's monday.
-   *
-   * @param  integer $week
-   * @param  integer $year
-   * @return integer
-   * @access private
-   * @author Sven Weih <[email protected]>
-   * @since  phpOpenTracker 1.3.0
-   */
-   function _mondayOfWeek($week, $year) {
-   	return mktime(
-   	  0, 0, 0, 1,
-   	  ($week + ((((date('w', mktime(0, 0, 0, 1, 0, $year)) + .01 - 4) /
-   	               abs(date('w', mktime(0, 0, 0, 1, 0, $year)) + .01 - 4)) / 2) + .5)) * 7
-   	         - date('w', mktime(0, 0, 0, 1, $week * 7, $year)) - 6,
-       $year
-     );
-   }
- 
-   /**
-   * Returns the timestamp for 23:59:59 of a given week's sunday.
-   *
-   * @param  integer $week
-   * @param  integer $year
-   * @return integer
-   * @access private
-   * @author Sven Weih <[email protected]>
-   * @since  phpOpenTracker 1.3.0
-   */
-   function _sundayOfWeek($week, $year) {
-     return $this->_mondayOfWeek($week, $year) + (((60 * 60) * 24) * 7) - 1;
-   }
  }
  
--- 15,176 ----
  //
  
  class phpOpenTracker_API {
!     private $apiCalls = array();
!     private $cache = null;
!     private $configuration;
!     private $container;
!     private $instance = null;
!     private $plugins = array();
  
!     private function __construct() {
      }
  
!     public static function getInstance() {
!         if (self::$instance == null) {
!             self::$instance = new phpOpenTracker_API;
!         }
  
!         return self::$instance;
      }
  
!     public static function get($parameters) {
      }
  
!     public static function plot($parameters) {
      }
  
!     public static function pluginLoaded($pluginName) {
      }
  
!     private function loadPlugins() {
      }
  
!     private function parseParameters(&$parameters) {
      }
  
!     private function parseTimerange($range, $start = 0, $length = 0) {
!         switch ($range) {
!             case 'current_minute': {
!                 return $this->parseTimerange('minute');
!             }
!             break;
!       
!             case 'previous_minute': {
!                 return $this->parseTimerange('minute', 1, 1);
!             }
!             break;
!       
!             case 'current_hour': {
!                 return $this->parseTimerange('hour');
!             }
!             break;
!       
!             case 'previous_hour': {
!                 return $this->parseTimerange('hour', 1, 1);
!             }
!             break;
!       
!             case 'today': {
!                 return $this->parseTimerange('day');
!             }
!             break;
!       
!             case 'yesterday': {
!                 return $this->parseTimerange('day', 1, 1);
!             }
!             break;
!       
!             case 'current_month': {
!                 return $this->parseTimerange('month');
!             }
!             break;
!       
!             case 'previous_month': {
!                 return $this->parseTimerange('month', 1, 1);
!             }
!             break;
!       
!             case 'current_week': {
!                 return $this->parseTimerange('week');
!             }
!             break;
!       
!             case 'previous_week': {
!                 return $this->parseTimerange('week', 1, 1);
!             }
!             break;
!       
!             case 'current_year': {
!                 return $this->parseTimerange('year');
!             }
!             break;
!       
!             case 'previous_year': {
!                 return $this->parseTimerange('year', 1, 1);
!             }
!             break;
!       
!             case 'minute': {
!                 $start = mktime(date('H'), date('i') - $start,   0);
!                 $end   = mktime(date('H'), date('i') - $length, 59);
!             }
!             break;
!       
!             case 'hour': {
!                 $start = mktime(date('H') - $start,  0,   0);
!                 $end   = mktime(date('H') - $length, 59, 59);
!             }
!             break;
!       
!             case 'day': {
!                 $start = mktime( 0,  0,  0, date('m'), date('d') - $start);
!                 $end   = mktime(23, 59, 59, date('m'), date('d') - $length);
!             }
!             break;
!       
!             case 'month': {
!                 $start = mktime( 0,  0,  0, date('m') - $start, 1);
!                 $end   = mktime(23, 59, 59, date('m') - $length, date('t', mktime(0, 0, 0, date('m') - $length)));
!             }
!             break;
!       
!             case 'week': {
!                 $start = $this->_mondayOfWeek(date('W') - $start,  date('Y'));
!                 $end   = $this->_sundayOfWeek(date('W') - $length, date('Y'));
!             }
!             break;
!       
!             case 'year': {
!                 $start = mktime( 0,  0,  0,  1,  1, date('Y') - $start);
!                 $end   = mktime(23, 59, 59, 12, 31, date('Y') - $length);
!             }
!             break;
!       
!             default: {
!                 throw new phpOpenTracker_API_Exception(
!                   'Syntax error in timerange specification.'
                  );
              }
          }
!     
!         return array(
!           $start,
!           $end
          );
      }
  
!     private function getMondayOfWeek($week, $year) {
!       	return mktime(
!       	  0, 0, 0, 1,
!       	  ($week + ((((date('w', mktime(0, 0, 0, 1, 0, $year)) + .01 - 4) /
!       	               abs(date('w', mktime(0, 0, 0, 1, 0, $year)) + .01 - 4)) / 2) + .5)) * 7
!       	         - date('w', mktime(0, 0, 0, 1, $week * 7, $year)) - 6,
!           $year
          );
      }
  
!     private function getSundayOfWeek($week, $year) {
!         return $this->getMondayOfWeek($week, $year) + (((60 * 60) * 24) * 7) - 1;
      }
  }
  

Index: Version.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/Version.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Version.php	17 Nov 2003 11:24:07 -0000	1.26
--- Version.php	22 Nov 2003 08:47:43 -0000	1.27
***************
*** 1,3 ****
  <?php
! define('PHPOPENTRACKER_VERSION', '1.4.0-dev ($Date$)');
  ?>
--- 1,29 ----
  <?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 read it online  |
! // | at http://www.phpopentracker.de/license.html.                       |
! // +---------------------------------------------------------------------+
! //
! // $Id$
! //
! 
! class phpOpenTracker_Version {
!     const version = '2.0.0-dev ($Date$)';
! 
!     public static function get() {
!         return self::version;
!     }
! }
! 
! //
! // "phpOpenTracker essenya, gul meletya;
! //  Sebastian carneron PHP."
! //
  ?>

--- NEW FILE: Database.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 read it online  |
// | at http://www.phpopentracker.de/license.html.                       |
// +---------------------------------------------------------------------+
//
// $Id: Database.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//

abstract class phpOpenTracker_Database {
    private $configuration;
    private static $instance = null;

    private function __construct(phpOpenTracker_Configuration $configuration) {
        $this->configuration = $configuration;
    }

    public static function getInstance() {
        if (self::$instance == null) {
            $configuration = phpOpenTracker_Configuration::getInstance();

            $class = 'phpOpenTracker_Database_' . $configuration->databaseType;

            self::$instance = new $class($configuration);
        }

        return self::$instance;
    }
}

//
// "phpOpenTracker essenya, gul meletya;
//  Sebastian carneron PHP."
//
?>

--- DB.php DELETED ---

Index: Parser.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/Parser.php,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** Parser.php	19 Sep 2003 07:17:26 -0000	1.17
--- Parser.php	22 Nov 2003 08:47:43 -0000	1.18
***************
*** 28,161 ****
  */
  class phpOpenTracker_Parser {
!   /**
!   * Parses a given string for Hostname information.
!   *
!   * @param  string $string
!   * @return string
!   * @access public
!   * @static
!   */
!   function hostname($string) {
!     return phpOpenTracker_Parser::match(
!       $string,
!       phpOpenTracker_Parser::readRules(POT_CONFIG_PATH . 'hosts.ini')
!     );
!   }
! 
!   /**
!   * Parses a given string for Operating System and
!   * User Agent information.
!   *
!   * @param  string $string
!   * @return array
!   * @access public
!   * @static
!   */
!   function userAgent($string) {
!     if (preg_match('#\((.*?)\)#', $string, $tmp)) {
!       $elements   = explode(';', $tmp[1]);
!       $elements[] = $string;
!     } else {
!       $elements = array($string);
      }
  
!     if ($elements[0] != 'compatible') {
!       $elements[] = substr($string, 0, strpos($string, '('));
      }
  
!     $result['operating_system'] = phpOpenTracker_Parser::match(
!       $elements,
!       phpOpenTracker_Parser::readRules(
!         POT_CONFIG_PATH . 'operating_systems.ini'
!       )
!     );
  
!     $result['user_agent'] = phpOpenTracker_Parser::match(
!       $elements,
!       phpOpenTracker_Parser::readRules(
!         POT_CONFIG_PATH . 'user_agents.ini'
!       )
!     );
  
!     return $result;
!   }
  
!   /**
!   * Matches a string against a set of regular expressions.
!   *
!   * @param  mixed   $elements
!   * @param  array   $rules
!   * @return string
!   * @access public
!   * @static
!   */
!   function match($elements, $rules) {
!     if (!is_array($elements)) {
!       $noMatch  = $elements;
!       $elements = array($elements);
!     } else {
!       $noMatch = 'Not identified';
      }
  
!     foreach ($rules as $rule) {
!       if (!isset($result)) {
!         foreach ($elements as $element) {
!           $element = trim($element);
!           $pattern = trim($rule['pattern']);
  
!           if (preg_match($pattern, $element, $tmp)) {
!             $result = str_replace(
!               array('$1', '$2', '$3'),
!               array(
!                 isset($tmp[1]) ? $tmp[1] : '',
!                 isset($tmp[2]) ? $tmp[2] : '',
!                 isset($tmp[3]) ? $tmp[3] : ''
!               ),
!               trim($rule['string'])
!             );
  
!             break;
!           }
          }
!       } else {
!         break;
!       }
      }
  
!     return isset($result) ? $result : $noMatch;
!   }
  
!   /**
!   * Reads a set of regular expressions from a given file.
!   *
!   * @param  string $rulesFile
!   * @return array
!   * @access public
!   * @static
!   */
!   function readRules($rulesFile) {
!     $rules = array();
  
!     if ($file = @file($rulesFile)) {
!       $index    = 0;
!       $numLines = sizeof($file);
  
!       for ($i = 0; $i < $numLines; $i += 3) {
!         $rules[$index]['pattern'] = $file[$i];
!         $rules[$index]['string']  = $file[$i+1];
!         $index++;
!       }
!     } else {
!       return phpOpenTracker::handleError(
!         sprintf(
!           'Cannot open "%s".',
!           $rulesFile
!         ),
!         E_USER_ERROR
!       );
      }
- 
-     return $rules;
-   }
  }
  
--- 28,163 ----
  */
  class phpOpenTracker_Parser {
!     private function __construct() {
      }
  
!     /**
!     * Parses a given string for Hostname information.
!     *
!     * @param  string $string
!     * @return string
!     * @access public
!     * @static
!     */
!     public static function parseHostname($string) {
!         return self::match(
!           $string,
!           self::readRules(POT_CONFIG_PATH . 'hosts.ini')
!         );
      }
  
!     /**
!     * Parses a given string for Operating System and
!     * User Agent information.
!     *
!     * @param  string $string
!     * @return array
!     * @access public
!     * @static
!     */
!     public static function parseUserAgent($string) {
!         if (preg_match('#\((.*?)\)#', $string, $tmp)) {
!             $elements   = explode(';', $tmp[1]);
!             $elements[] = $string;
!         } else {
!             $elements = array($string);
!         }
  
!         if ($elements[0] != 'compatible') {
!             $elements[] = substr($string, 0, strpos($string, '('));
!         }
  
!         $result['operating_system'] = self::match(
!           $elements,
!           self::readRules(
!             POT_CONFIG_PATH . 'operating_systems.ini'
!           )
!         );
  
!         $result['user_agent'] = self::match(
!           $elements,
!           self::readRules(
!             POT_CONFIG_PATH . 'user_agents.ini'
!           )
!         );
! 
!         return $result;
      }
  
!     /**
!     * Matches a string against a set of regular expressions.
!     *
!     * @param  mixed   $elements
!     * @param  array   $rules
!     * @return string
!     * @access public
!     * @static
!     */
!     public static function match($elements, $rules) {
!         if (!is_array($elements)) {
!             $noMatch  = $elements;
!             $elements = array($elements);
!         } else {
!             $noMatch = 'Not identified';
!         }
  
!         foreach ($rules as $rule) {
!             if (!isset($result)) {
!                 foreach ($elements as $element) {
!                     $element = trim($element);
!                     $pattern = trim($rule['pattern']);
  
!                     if (preg_match($pattern, $element, $tmp)) {
!                         $result = str_replace(
!                           array('$1', '$2', '$3'),
!                           array(
!                             isset($tmp[1]) ? $tmp[1] : '',
!                             isset($tmp[2]) ? $tmp[2] : '',
!                             isset($tmp[3]) ? $tmp[3] : ''
!                           ),
!                           trim($rule['string'])
!                         );
! 
!                         break;
!                     }
!                 }
!             } else {
!                 break;
!             }
          }
! 
!         return isset($result) ? $result : $noMatch;
      }
  
!     /**
!     * Reads a set of regular expressions from a given file.
!     *
!     * @param  string $rulesFile
!     * @return array
!     * @access protected
!     * @static
!     */
!     protected static function readRules($rulesFile) {
!         $rules = array();
  
!         if ($file = @file($rulesFile)) {
!             $index    = 0;
!             $numLines = sizeof($file);
  
!             for ($i = 0; $i < $numLines; $i += 3) {
!                 $rules[$index]['pattern'] = $file[$i];
!                 $rules[$index]['string']  = $file[$i+1];
!                 $index++;
!             }
!         } else {
!             throw new phpOpenTracker_Exception(
!               sprintf(
!                 'Cannot open "%s".',
!                 $rulesFile
!               )
!             );
!         }
  
!         return $rules;
      }
  }
  

--- NEW FILE: Exception.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 read it online  |
// | at http://www.phpopentracker.de/license.html.                       |
// +---------------------------------------------------------------------+
//
// $Id: Exception.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//

class phpOpenTracker_Exception extends Exception {
}

//
// "phpOpenTracker essenya, gul meletya;
//  Sebastian carneron PHP."
//
?>




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.