From a013281f5644e8c78d9e12639c93f66a5d9f3caa Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 27 Feb 2007 03:22:26 +0000 Subject: [PATCH] r1424: Add the initial authentication system for vBulletin --- includes/auth/auth_vbulletin.php | 140 +++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 includes/auth/auth_vbulletin.php diff --git a/includes/auth/auth_vbulletin.php b/includes/auth/auth_vbulletin.php new file mode 100644 index 0000000..ca36d79 --- /dev/null +++ b/includes/auth/auth_vbulletin.php @@ -0,0 +1,140 @@ +authDb =& new DB_MySQL($this->registry); + $this->authDb->connect('VBULLETIN_DATABASE_SERVER', 'VB_DATABASE_USER', 'VB_DATABASE_PASSWORD', 'VBULLETIN_DATABASE_NAME', false); + } + + // ################################################################### + function _fetchCookieUniqueId() + { + return $this->registry->input_clean('bbuserid', TYPE_UINT); + } + + // ################################################################### + function _fetchCookiePassword() + { + return $this->registry->in['bbpassword']; + } + + // ################################################################### + function _fetchUserUsingCookies() + { + return $this->authDb->query_first("SELECT * FROM {$this->vBTablePrefix}user WHERE userid = " . $this->_fetchCookieUniqueId()); + } + + // ################################################################### + function _verifyCookieData() + { + return (md5($this->authUser['password'] . $this->licenseKey) == $this->_fetchCookiePassword()); + } + + // ################################################################### + 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); + } + + // ################################################################### + function _clearCookies() + { + $this->registry->funct->cookie('bbpassword'); + $this->registry->funct->cookie('bbuserid'); + } + + // ################################################################### + function _fetchBugdarUserFromAuthUser() + { + $user = $this->db->query_first("SELECT * FROM " . TABLE_PREFIX . "user WHERE authid = " . $this->authUser['userid']); + if (!$user) + { + return $this->_createBugdarUser(); + } + return $user; + } + + // ################################################################### + function _createBugdarUser() + { + $user = new UserAPI($this->registry); // do not change this + $user->set('email', $this->authUser['email']); + $user->set('displayname', $this->authUser['name']); + $user->set('password', $this->authUser['password']); // some random value that won't be used for authentication + $user->set('usergroupid', 2); // default "Registered Users" group + $user->set('authid', $this->authUser['userid']); // This must be a COMPLETELY STATIC key that is found in the auth db that will permanently link Bugdar to the auth user + $user->insert(); // saves the user + + return $user->values; // returns the newly created user array + } + + // ################################################################### + function _fetchUserWithIdentifier($username) + { + return $this->authDb->query_first("SELECT * FROM {$this->vBTablePrefix}user WHERE username = '" . $this->authDb->escape_string($username) . "'"); + } + + // ################################################################### + function _verifyLoginUser($password) + { + return ($this->authUser['password'] == md5(md5($password) . $this->authUser['salt'])); + } +} + +/*=====================================================================*\ +|| ################################################################### +|| # $HeadURL$ +|| # $Id$ +|| ################################################################### +\*=====================================================================*/ +?> \ No newline at end of file -- 2.22.5