phpUserTrack
[ class tree: phpUserTrack ] [ index: phpUserTrack ] [ all elements ]

Source for file core.php

Documentation is available at core.php

  1. <?php
  2. /**
  3.  * The core componant of phpUserTrack. This brings all the libraries together.
  4.  * @author Christopher Troup <mini@chatetheory.com>
  5.  * @package phpUserTrack
  6.  */
  7.  
  8. require_once 'libExceptions.php';
  9.  
  10. /**
  11.  * Gets the system time in high resolution
  12.  *
  13.  * @return int System Time
  14.  */
  15. function getmicrotime({
  16.     list($usec$secexplode(" ",microtime());
  17.     return ((float)$usec + (float)$sec);
  18. }
  19. $time getmicrotime();
  20.  
  21. header('P3P: CP="CAO PSA OUR"');
  22. session_set_cookie_params (60 60 24 365'/');
  23. ob_start("ob_gzhandler");
  24.  
  25. /**
  26.  * Include login files
  27.  */
  28. require_once 'liblogin.php';
  29.  
  30. /**
  31.  * Include useragent detection library.
  32.  */
  33. require_once 'libdetectuseragent.php'// Browser detection alogorithm
  34.  
  35. /**
  36.  * Include database access functions.
  37.  */
  38. require_once 'libsite.php';
  39. require_once 'libdata.php';
  40. require_once 'libip.php';
  41.  
  42. /**
  43.  * Include the plugin architecture.
  44.  */
  45. require_once 'libplugins.php';
  46.  
  47.  
  48. /**
  49.  * Include the configuration file.
  50.  */
  51. if (!@include_once (dirname(__FILE__'/../conf/conf.php')) {
  52.     header'Location: install.php' ;
  53. }
  54. putenv("TZ=" $conf['timezone']);
  55.  
  56. /**
  57.  * Check to see if they have GeoIP installed. If they do record the fact for future use.
  58.  */
  59. if (@include_once 'Net/GeoIP.php'{
  60.     $geoIP file_exists(dirname(__FILE__'/../include/GeoLiteCity.dat');
  61. else {
  62.     $geoIP false;
  63. }
  64.  
  65. if (@include_once 'Cache/Lite.php'{
  66.     $cache true;
  67. else {
  68.     $cache false;
  69. }
  70.  
  71. $plugins new plugins()// create a new instance of the plugin class
  72.  
  73. /**
  74.  * Preform the tracking of the user who requested the page.
  75.  * @global array $conf
  76.  * @global plugins $plugins
  77.  */
  78. function phpUserTrack($site_id null$path null$refferrer null{
  79.     global $conf;
  80.     global $plugins;
  81.  
  82.     $ip $_SERVER['REMOTE_ADDR'];
  83.  
  84.     // ip.pre hook
  85.     $ipCon new phpusertrack_ip($ip);
  86.     foreach ($plugins->hooks['ip.pre'as $obj{
  87.         $ipCon $obj->invoke($ipCon);
  88.     }
  89.     if ($ipCon != null{
  90.         $path $_SERVER['REQUEST_URI'];
  91.         if ($ipCon->getProfileId(== null{
  92.             $agent =  new detectUserAgent();
  93.             $browserArray $agent->getBrowserArray();
  94.             $ipCon->insertProfile($browserArray['browser'],
  95.             $browserArray['version'],
  96.             $browserArray['platform']);
  97.         }
  98.  
  99.         // ip.post hook
  100.         foreach ($plugins->hooks['ip.post'as $obj{
  101.             $ipCon $obj->invoke($ip);
  102.         }
  103.         // data.pre hook
  104.         //$sql = 'select id from phpusertrack_sites where id like %' . $_GET['server'];
  105.         //$site_id = $db->_query($sql);
  106.         //$site_id = $site_id[0];
  107.         
  108.         $dataCon new phpusertrack_data($site_id$ipCon->getProfileId()$path$_SERVER['HTTP_REFERER']);
  109.         foreach ($plugins->hooks['data.pre'as $obj{
  110.             $dataCon $obj->invoke($dataCon);
  111.         }
  112.         $dataCon->insertNewPageHit();
  113.         // data.post hook
  114.         foreach ($plugins->hooks['data.post'as $obj{
  115.             $dataCon $obj->invoke($dataCon);
  116.         }
  117.     }
  118. }
  119.  
  120. ?>

Documentation generated on Tue, 06 Nov 2007 09:21:37 -0800 by phpDocumentor 1.4.0a2