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

Source for file libip.php

Documentation is available at libip.php

  1. <?php
  2. /**
  3.  * IP address (unique user) abstraction class
  4.  * @author Christopher Troup <mini@chatetheory.com>
  5.  * @package phpUserTrack
  6.  * @subpackage Libraries
  7.  */
  8.  
  9.  require_once 'libdb.php';
  10.  
  11. class phpusertrack_ip extends phpusertrack_db {
  12.     /**
  13.      * Profile index
  14.      * @var integer
  15.      */
  16.     var $_profileId = null;
  17.     
  18.     /**
  19.      * IP Address
  20.      * @var string
  21.      */
  22.     var $_ip = null;
  23.     
  24.     /**
  25.      * Session identification string
  26.      * @var string
  27.      */
  28.     var $_sessId = null;
  29.  
  30.     /**
  31.      * Class contructor
  32.      * @param string $ip The IP address of requesting user
  33.      * @return boolean Success of object creation
  34.      */
  35.     function phpusertrack_ip($ip null{
  36.         if ($ip != null{
  37.             $this->_ip = $ip
  38.             $this->_sessId = session_id();
  39.             $this->_profileId = $this->lookupIdFromSession();
  40.         else {
  41.             return false;
  42.         }
  43.         return true;
  44.     }
  45.  
  46.     /**
  47.      * Find that users profile index from their session identification string
  48.      * @return integer Profile index
  49.      */
  50.     function lookupIdFromSession({
  51.         global $conf;
  52.         $result $this->_query('select id from ' $conf['ipTable'' where session_id="' $this->_sessId . '"');
  53.         if (!empty($result)) {
  54.             return $result[0]['id'];
  55.         else {
  56.             return null;
  57.         }
  58.     }
  59.     
  60.     /**
  61.      * Return the profile index number
  62.      * @return integer Profile index number
  63.      */
  64.     function getProfileId({
  65.         return $this->_profileId;
  66.     }
  67.     
  68.     /**
  69.      * Return IP address
  70.      * @return string IP address
  71.      */
  72.     function getIp({
  73.         return $this->_ip;
  74.     }
  75.     
  76.     /** 
  77.      * Return session identification string
  78.      * @return string Session identification string
  79.      */
  80.     function getSessId({
  81.         return $this->_sessId;
  82.     }
  83.     
  84.     /**
  85.      * Set classes IP address
  86.      * @param string $ip IP Address to set the class to
  87.      */
  88.     function setIp($ip{
  89.         $this->_ip = $ip;
  90.         $this->_profileId = $this->lookupIdFromSession();
  91.     }
  92.     
  93.     /**
  94.      * Insert new profile into the database
  95.      * @param string $browser Browser name user is using
  96.      * @param string $browser_verion Browser verison user is using
  97.      * @param string $platform Operating System
  98.      */
  99.     function insertProfile($browser$browser_version$platform{
  100.         global $conf;
  101.         $this->_insert('insert into ' $conf['ipTable'
  102.             ' set session_id="' $this->_sessId . 
  103.             '", ip="' $this->_ip . '", ' 
  104.             'browser="' $browser 
  105.             '", browser_version="' $browser_version '", ' .
  106.             'platform="' $platform '"');
  107.         $this->_profileId = $this->lookupIdFromSession();
  108.     }
  109.  
  110. }
  111. ?>

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