Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/DBSessionHandler.inc.php

    r41 r42  
    99
    1010class DBSessionHandler {
    11    
     11
    1212    var $db; // DB object.
    1313
     
    2020        'create_table' => true, // Automatically create table and verify columns. Better set to false after site launch.
    2121    );
    22    
     22
    2323    /**
    2424     * Constructor
    2525     *
    2626     * @access  public
    27      * @param   
    28      * @return 
     27     * @param
     28     * @return
    2929     * @author  Quinn Comendant <quinn@strangecode.com>
    3030     * @since   18 Jul 2005 11:02:50
     
    3333    {
    3434        $this->_params = array_merge($this->_params, $params);
    35        
     35
    3636        if (isset($db)) {
    3737            if (is_a($db, 'DB')) {
    38                 if ($db->isConnected()) {
     38                if ($db->isConnected()) {
    3939                    // Use existing db connection.
    4040                    $this->db =& $db;
    41                 } else {
     41                } else {
    4242                    App::logMsg(sprintf('Provided DB object is not connected. %s', mysql_error($db->dbh)), LOG_ERR, __FILE__, __LINE__);
    43                 }
     43                }
    4444            } else {
    4545                App::logMsg(sprintf('Provided DB object is not valid. %s', gettype($db)), LOG_ERR, __FILE__, __LINE__);
     
    4848            // Create our own new db connection.
    4949            require_once dirname(__FILE__) . '/DB.inc.php';
    50            
     50
    5151            $this->db =& new DB();
    5252            $this->db->setParam(array(
     
    5959                'db_die_on_failure' => $this->_params['db_die_on_failure'],
    6060            ));
    61            
     61
    6262            // Connect to database.
    6363            $this->db->connect();
     
    6767            trigger_error('Invalid DB object or unable to connect to database.', E_USER_ERROR);
    6868        }
    69        
     69
    7070        // Get create tables config from global context.
    7171        if (!is_null(App::getParam('db_create_tables'))) {
    7272            $this->_params['create_table'] = App::getParam('db_create_tables');
    7373        }
    74        
     74
    7575        // Ensure db table is fit.
    7676        $this->initDB();
    77        
     77
    7878        ini_set('session.save_handler', 'user');
    7979        session_set_save_handler(
     
    9797    {
    9898        static $_db_tested = false;
    99    
     99
    100100        if ($recreate_db || !$_db_tested && $this->_params['create_table']) {
    101101            if ($recreate_db) {
     
    110110                KEY last_access (last_access)
    111111            )");
    112            
     112
    113113            if (!$this->db->columnExists($this->_params['db_table'], array('session_id', 'session_data', 'last_access'))) {
    114114                App::logMsg(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), LOG_ALERT, __FILE__, __LINE__);
    115115                trigger_error(sprintf('Database table %s has invalid columns. Please update this table manually.', $this->_params['db_table']), E_USER_ERROR);
    116116            }
    117         }   
     117        }
    118118        $_db_tested = true;
    119119    }
     
    121121    function dbSessionOpen($save_path, $sess_name)
    122122    {
    123         return true; 
     123        return true;
    124124    }
    125    
     125
    126126    function dbSessionClose()
    127127    {
    128128        return true;
    129129    }
    130    
     130
    131131    function dbSessionRead($session_id)
    132132    {
    133         // Select the data belonging to session $session_id from the session table   
     133        // Select the data belonging to session $session_id from the session table
    134134        $qid = $this->db->query("SELECT session_data FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'");
    135        
     135
    136136        // Return the session data that was found
    137137        if (mysql_num_rows($qid) == 1) {
     
    139139            return $row[0];
    140140        }
    141        
     141
    142142        // NOTICE: Output is expected to be an empty string always rather than 'false'.
    143143        return '';
    144144    }
    145    
     145
    146146    function dbSessionWrite($session_id, $session_data)
    147     {   
     147    {
    148148        // Write the serialized session data ($session_data) to the session table
    149149        $this->db->query("REPLACE INTO " . $this->_params['db_table'] . "(session_id, session_data, last_access) VALUES ('" . addslashes($session_id) . "', '" . addslashes($session_data) . "', null)");
    150            
    151         return true;     
     150
     151        return true;
    152152    }
    153    
     153
    154154    function dbSessionDestroy($session_id)
    155155    {
    156156        // Delete from the table all data for the session $session_id
    157157        $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE session_id = '" . addslashes($session_id) . "'");
    158    
    159         return true;     
     158
     159        return true;
    160160    }
    161    
     161
    162162    function dbSessionGarbage($max_lifetime=4000)
    163163    {
    164164        // Delete old values from the session table
    165165        $qid = $this->db->query("DELETE FROM " . $this->_params['db_table'] . " WHERE UNIX_TIMESTAMP(last_access) < " . (time() - $max_lifetime));
    166            
    167         return true;     
     166
     167        return true;
    168168    }
    169169}
Note: See TracChangeset for help on using the changeset viewer.