Updating the auth/ system to ISSO3
authorRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jun 2008 15:06:39 +0000 (11:06 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Wed, 25 Jun 2008 15:06:39 +0000 (11:06 -0400)
includes/auth/auth.php
includes/auth/auth_default.php
includes/auth/auth_drupal.php
includes/auth/auth_phpbb2.php
includes/auth/auth_vbulletin.php
includes/init.php

index 34f7cd053358c473be6cf223c13ddc8e650ea45a..b4d3fbc57291fc44429bc4599f1c838e75b07fa1 100644 (file)
@@ -47,12 +47,6 @@ class Authentication
        */
        var $db;
        
-       /**
-       * The Bugdar registry
-       * @var object
-       */
-       var $registry;
-       
        /**
        * Array of user data from the AUTHENTICATION database
        * @var array
@@ -82,12 +76,9 @@ class Authentication
        */
        function __construct()
        {
-               global $bugsys;
-               
-               $this->registry =& $bugsys;
-               $this->db =& $bugsys->db;
+               $this->db = BSApp::$db;
                
-               $this->registry->debug('authentication system: ' . get_class($this));
+               BSApp::debug('authentication system: ' . get_class($this));
                
                $this->_setupDatabase();
        }
@@ -243,7 +234,7 @@ class Authentication
        */
        function _fetchBugdarUserFromAuthUser()
        {
-               $user = $this->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE authid = '" . $this->authUser[ $this->fieldMap['authid'] ] . "'");
+               $user = $this->db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE authid = '" . $this->authUser[ $this->fieldMap['authid'] ] . "'");
                if (!$user)
                {
                        return $this->_createBugdarUser();
@@ -264,7 +255,7 @@ class Authentication
                $user = new UserAPI($this->registry);
                
                // if the email already exists in the DB, it must be the same person so just hook up the authid
-               if ($check = $this->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->db->escape_string($this->authUser[ $this->fieldMap['email'] ]) . "'"))
+               if ($check = $this->db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->db->escape_string($this->authUser[ $this->fieldMap['email'] ]) . "'"))
                {
                        $user->set('userid', $check['userid']);
                        $user->set_condition();
index 0fe42cae1e7b112ca0690ac56d7f0d0e29798cbe..fc06ab9af2f807390dbb24012f1636ce50c3a4e7 100644 (file)
@@ -37,25 +37,25 @@ class AuthenticationDefault extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
-               $this->authDb =& $this->db;
+               $this->authDb = $this->db;
        }
        
        // ###################################################################
        function _fetchCookieUniqueId()
        {
-               return $this->registry->input_clean(COOKIE_PREFIX . 'userid', TYPE_UINT);
+               return BSApp::$input->inputClean(COOKIE_PREFIX . 'userid', TYPE_UINT);
        }
        
        // ###################################################################
        function _fetchCookiePassword()
        {
-               return $this->registry->in[COOKIE_PREFIX . 'authkey'];
+               return BSApp::$input->in[COOKIE_PREFIX . 'authkey'];
        }
        
        // ###################################################################
        function _fetchUserUsingCookies()
        {
-               return $this->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . $this->_fetchCookieUniqueId());
+               return $this->db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE userid = " . $this->_fetchCookieUniqueId());
        }
        
        // ###################################################################
@@ -67,15 +67,15 @@ class AuthenticationDefault extends Authentication
        // ###################################################################
        function _setCookies($sticky = false)
        {
-               $this->registry->funct->cookie(COOKIE_PREFIX . 'userid', $this->authUser['userid'], $sticky);
-       $this->registry->funct->cookie(COOKIE_PREFIX . 'authkey', $this->authUser['authkey'], $sticky);
+               BSFunctions::cookie(COOKIE_PREFIX . 'userid', $this->authUser['userid'], $sticky);
+       BSFunctions::cookie(COOKIE_PREFIX . 'authkey', $this->authUser['authkey'], $sticky);
        }
        
        // ###################################################################
        function clearCookies()
        {
-               $this->registry->funct->cookie(COOKIE_PREFIX . 'userid');
-               $this->registry->funct->cookie(COOKIE_PREFIX . 'authkey');
+               BSFunctions::cookie(COOKIE_PREFIX . 'userid');
+               BSFunctions::cookie(COOKIE_PREFIX . 'authkey');
        }
        
        // ###################################################################
@@ -87,7 +87,7 @@ class AuthenticationDefault extends Authentication
        // ###################################################################
        function _fetchUserWithIdentifier($email)
        {
-               return $this->authDb->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->authDb->escape_string($email) . "'");
+               return $this->authDb->queryFirst("SELECT * FROM " . TABLE_PREFIX . "user WHERE email = '" . $this->authDb->escapeString($email) . "'");
        }
        
        // ###################################################################
@@ -106,4 +106,4 @@ class AuthenticationDefault extends Authentication
 || # $Id$
 || ###################################################################
 \*=====================================================================*/
-?>
+?>
\ No newline at end of file
index abcf29682ee47bb3c56817c1d41244d1ceb91756..2594a2a676bd426176d089682a510fc2ff765d26 100644 (file)
@@ -53,14 +53,14 @@ class AuthenticationDrupal extends Authentication
                $this->cookieName = ($this->cookieName == null ? session_name() : $this->cookieName);
                
                // connect to the DB
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('DRUPAL_DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME', false);
+               $this->authDb = new BSDbMySQLI();
+               $this->authDb->connect('DRUPAL_DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME');
        }
        
        // ###################################################################
        function _fetchCookieUniqueId()
        {
-               return $this->registry->in[ $this->cookieName ];
+               return BSApp::$input->in[$this->cookieName];
        }
        
        // ###################################################################
@@ -72,12 +72,12 @@ class AuthenticationDrupal extends Authentication
        // ###################################################################
        function _fetchUserUsingCookies()
        {
-               $session = $this->authDb->query_first("SELECT * FROM sessions WHERE sid = '" . $this->authDb->escape_string($this->_fetchCookieUniqueId()) . "'");
+               $session = $this->authDb->queryFirst("SELECT * FROM sessions WHERE sid = '" . $this->authDb->escapeString($this->_fetchCookieUniqueId()) . "'");
                if (!$session OR $session['uid'] == 0)
                {
                        return false;
                }
-               return $this->authDb->query_first("SELECT * FROM users WHERE uid = " . $session['uid']);
+               return $this->authDb->queryFirst("SELECT * FROM users WHERE uid = " . $session['uid']);
        }
        
        // ###################################################################
@@ -89,7 +89,7 @@ class AuthenticationDrupal extends Authentication
        // ###################################################################
        function _fetchUserWithIdentifier($string)
        {
-               return $this->authDb->query_first("SELECT * FROM users WHERE name = '" . $this->authDb->escape_string($string) . "'");
+               return $this->authDb->queryFirst("SELECT * FROM users WHERE name = '" . $this->authDb->escapeString($string) . "'");
        }
        
        // ###################################################################
@@ -101,8 +101,8 @@ class AuthenticationDrupal extends Authentication
        // ###################################################################
        function clearCookies()
        {
-               $this->registry->funct->cookie($this->cookieName);
-               $this->authDb->query("DELETE FROM sessions WHERE sid = '" . $this->authDb->escape_string($this->_fetchCookieUniqueId()) . "'");
+               BSFunctions::cookie($this->cookieName);
+               $this->authDb->query("DELETE FROM sessions WHERE sid = '" . $this->authDb->escapeString($this->_fetchCookieUniqueId()) . "'");
        }
        
        // ###################################################################
@@ -110,8 +110,8 @@ class AuthenticationDrupal extends Authentication
        {
                $sid = $this->_fetchCookieUniqueId();
                $sid = ($sid ? $sid : md5(microtime() . rand()));
-               $this->registry->funct->cookie($this->cookieName, $sid, $permanent);
-               $this->authDb->query("REPLACE INTO sessions (sid, uid, hostname, timestamp) VALUES ('$sid', '" . $this->authUser['uid'] . "', '" . $this->authDb->escape_string($_SERVER['REMOTE_ADDR']) . "', " . time() . ")");
+               BSFunctions::cookie($this->cookieName, $sid, $permanent);
+               $this->authDb->query("REPLACE INTO sessions (sid, uid, hostname, timestamp) VALUES ('$sid', '" . $this->authUser['uid'] . "', '" . $this->authDb->escapeString($_SERVER['REMOTE_ADDR']) . "', " . time() . ")");
        }
 }
 
index acabf9a81a703abb3584359a769a84dee74e392f..a4391fada8439fa0c8f5e56eb64249efc66bf7f3 100644 (file)
@@ -60,14 +60,14 @@ class AuthenticationPhpbb2 extends Authentication
        function _setupDatabase()
        {
                // connect to the DB
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME', false);
+               $this->authDb = new BSDbMySQLI($this->registry);
+               $this->authDb->connect('DATABASE_SERVER', 'DATABASE_USER', 'DATABASE_PASSWORD', 'DATABASE_NAME');
        }
        
        // ###################################################################
        function _fetchCookieUniqueId()
        {
-               $val = $this->registry->in[$this->cookieName . '_sid'];
+               $val = BSApp::$input->in[$this->cookieName . '_sid'];
                return (!$val ? -1 : $val); // hack so we don't do stupid things but can still create a session
        }
        
@@ -80,7 +80,7 @@ class AuthenticationPhpbb2 extends Authentication
        // ###################################################################
        function _fetchUserUsingCookies()
        {
-               $session = $this->authDb->query_first("SELECT * FROM {$this->phpBBTablePrefix}sessions WHERE session_id = '" . $this->authDb->escape_string($this->_fetchCookieUniqueId()) . "'");
+               $session = $this->authDb->queryFirst("SELECT * FROM {$this->phpBBTablePrefix}sessions WHERE session_id = '" . $this->authDb->escapeString($this->_fetchCookieUniqueId()) . "'");
                if (!$session)
                {
                        // phpBB's wacky auto-login system
@@ -89,7 +89,7 @@ class AuthenticationPhpbb2 extends Authentication
                        {
                                return false;
                        }
-                       return $this->authDb->query_first("SELECT * FROM {$this->phpBBTablePrefix}users WHERE user_id = " . $this->registry->clean($data['userid'], TYPE_UINT) . " AND user_password = '" . $this->authDb->escape_string($data['autologinid']) . "'");
+                       return $this->authDb->queryFirst("SELECT * FROM {$this->phpBBTablePrefix}users WHERE user_id = " . BSApp::$input->clean($data['userid'], TYPE_UINT) . " AND user_password = '" . $this->authDb->escapeString($data['autologinid']) . "'");
                }
                else
                {
@@ -97,7 +97,7 @@ class AuthenticationPhpbb2 extends Authentication
                        {
                                return false;
                        }
-                       return $this->authDb->query_first("SELECT * FROM {$this->phpBBTablePrefix}users WHERE user_id = " . $session['session_user_id']);
+                       return $this->authDb->queryFirst("SELECT * FROM {$this->phpBBTablePrefix}users WHERE user_id = " . $session['session_user_id']);
                }
        }
        
@@ -110,7 +110,7 @@ class AuthenticationPhpbb2 extends Authentication
        // ###################################################################
        function _fetchUserWithIdentifier($string)
        {
-               return $this->authDb->query_first("SELECT * FROM {$this->phpBBTablePrefix}users WHERE username = '" . $this->authDb->escape_string($string) . "'");
+               return $this->authDb->queryFirst("SELECT * FROM {$this->phpBBTablePrefix}users WHERE username = '" . $this->authDb->escapeString($string) . "'");
        }
        
        // ###################################################################
@@ -122,9 +122,9 @@ class AuthenticationPhpbb2 extends Authentication
        // ###################################################################
        function clearCookies()
        {
-               $this->registry->funct->cookie($this->cookieName . '_data');
-               $this->registry->funct->cookie($this->cookieName . '_sid');
-               $this->authDb->query("DELETE FROM {$this->phpBBTablePrefix}sessions WHERE session_id = '" . $this->authDb->escape_string($this->_fetchCookieUniqueId()) . "'");
+               BSFunctions::cookie($this->cookieName . '_data');
+               BSFunctions::cookie($this->cookieName . '_sid');
+               $this->authDb->query("DELETE FROM {$this->phpBBTablePrefix}sessions WHERE session_id = '" . $this->authDb->escapeString($this->_fetchCookieUniqueId()) . "'");
        }
        
        // ###################################################################
@@ -132,10 +132,10 @@ class AuthenticationPhpbb2 extends Authentication
        {
                $sid = $this->_fetchCookieUniqueId();
                $sid = ($sid != '-1' ? $sid : md5(microtime() . rand()));
-               $this->registry->funct->cookie($this->cookieName . '_sid', $sid, false);
+               BSFunctions::cookie($this->cookieName . '_sid', $sid, false);
                if ($permanent)
                {
-                       $this->registry->funct->cookie($this->cookieName . '_data', serialize(array('autologinid' => $this->authUser['user_password'], 'userid' => $this->authUser['user_id'])), true);
+                       BSFunctions::cookie($this->cookieName . '_data', serialize(array('autologinid' => $this->authUser['user_password'], 'userid' => $this->authUser['user_id'])), true);
                }
                $this->authDb->query("
                        REPLACE INTO {$this->phpBBTablePrefix}sessions
index 2d6da6be9be3eaf6329645d7b801009ffbc94c9a..b6e6f029633d2a495a6bad1eb87916bea151f0d6 100644 (file)
@@ -62,26 +62,26 @@ class AuthenticationVbulletin extends Authentication
        // ###################################################################
        function _setupDatabase()
        {
-               $this->authDb = new DB_MySQL($this->registry);
-               $this->authDb->connect('VBULLETIN_DATABASE_SERVER', 'VB_DATABASE_USER', 'VB_DATABASE_PASSWORD', 'VBULLETIN_DATABASE_NAME', false);
+               $this->authDb = new BSDbMySqlI($this->registry);
+               $this->authDb->connect('VBULLETIN_DATABASE_SERVER', 'VB_DATABASE_USER', 'VB_DATABASE_PASSWORD', 'VBULLETIN_DATABASE_NAME');
        }
        
        // ###################################################################
        function _fetchCookieUniqueId()
        {
-               return $this->registry->input_clean('bbuserid', TYPE_UINT);
+               return BSApp::$input->inputClean('bbuserid', TYPE_UINT);
        }
        
        // ###################################################################
        function _fetchCookiePassword()
        {
-               return $this->registry->in['bbpassword'];
+               return BSApp::$input->in['bbpassword'];
        }
        
        // ###################################################################
        function _fetchUserUsingCookies()
        {
-               return $this->authDb->query_first("SELECT * FROM {$this->vBTablePrefix}user WHERE userid = " . $this->_fetchCookieUniqueId());
+               return $this->authDb->queryFirst("SELECT * FROM {$this->vBTablePrefix}user WHERE userid = " . $this->_fetchCookieUniqueId());
        }
        
        // ###################################################################
@@ -93,21 +93,21 @@ class AuthenticationVbulletin extends Authentication
        // ###################################################################
        function _setCookies($sticky = false)
        {
-               $this->registry->funct->cookie('bbuserid', $this->authUser['userid'], $sticky);
-       $this->registry->funct->cookie('bbpassword', md5($this->authUser['password'] . $this->licenseKey), $sticky);
+               BSFunctions::cookie('bbuserid', $this->authUser['userid'], $sticky);
+       BSFunctions::cookie('bbpassword', md5($this->authUser['password'] . $this->licenseKey), $sticky);
        }
        
        // ###################################################################
        function clearCookies()
        {
-               $this->registry->funct->cookie('bbpassword');
-               $this->registry->funct->cookie('bbuserid');
+               BSFunctions::cookie('bbpassword');
+               BSFunctions::cookie('bbuserid');
        }
 
        // ###################################################################
        function _fetchUserWithIdentifier($username)
        {
-               return $this->authDb->query_first("SELECT * FROM {$this->vBTablePrefix}user WHERE username = '" . $this->authDb->escape_string($username) . "'");
+               return $this->authDb->queryFirst("SELECT * FROM {$this->vBTablePrefix}user WHERE username = '" . $this->authDb->escapeString($username) . "'");
        }
        
        // ###################################################################
index cf2d30ab85137922ec80df9987b8fda93aa96575..3862ebcd849f4a7122e4b5676e18e6d260cea153 100755 (executable)
@@ -41,6 +41,12 @@ define('ISSO', getcwd() . '/includes/framework/');
 require_once ISSO . '/App.php';
 BSApp::set_debug($debug);
 
+require_once ISSO . '/Functions.php';
+BSFunctions::set_cookie_timeout(3600);
+
+require_once ISSO . '/Input.php';
+$input = BSApp::$input = new BSInput();
+
 // ###################################################################
 // initialize the database
 
@@ -53,11 +59,6 @@ if ($utf8)
        $db->query("SET NAMES utf8");
 }
 
-require_once ISSO . '/Functions.php';
-
-// change cookie expiration to one hour
-BSFunctions::set_cookie_timeout(3600);
-
 define('DEVDEBUG', $debug);
 define('TABLE_PREFIX', $tableprefix);
 define('COOKIE_PREFIX', $cookieprefix);