2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2009 Blue Static
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
22 require_once('./includes/auth/auth.php');
25 * Authentication: vBulletin
27 * This is used to authenticate against the vBulletin user database. It
28 * does NOT use the vBulletin permission system, however. Be sure you set
29 * all the database variables and your license key.
32 * @copyright Copyright (c)2002 - 2007, Blue Static
37 class AuthenticationVbulletin
extends Authentication
40 * This is the vBulletin license key that you can find in the Members' Area that is used in creating cookies
43 var $licenseKey = 'LXXXXXXX';
46 * The table prefix for all of vBulletin's tables
49 var $vBTablePrefix = '';
52 * Fields that map Bugdar fields to vBulletin fields
55 var $fieldMap = array(
58 'timezone' => 'timezoneoffset',
59 'displayname' => 'username'
62 // ###################################################################
63 function _setupDatabase()
65 require_once 'includes/auth/config.php';
66 $this->licenseKey
= $config['auth']['vBulletin3']['licenseKey'];
67 $this->vBTablePrefix
= $config['auth']['vBulletin3']['tablePrefix'];
70 // ###################################################################
71 function _fetchCookieUniqueId()
73 return BSApp
::$input->inputClean('bbuserid', TYPE_UINT
);
76 // ###################################################################
77 function _fetchCookiePassword()
79 return BSApp
::$input->in
['bbpassword'];
82 // ###################################################################
83 function _fetchUserUsingCookies()
85 return $this->authDb
->queryFirst("SELECT * FROM {$this->vBTablePrefix}user WHERE userid = " . $this->_fetchCookieUniqueId());
88 // ###################################################################
89 function _verifyCookieData()
91 return (md5($this->authUser
['password'] . $this->licenseKey
) == $this->_fetchCookiePassword());
94 // ###################################################################
95 function _setCookies($sticky = false
)
97 BSFunctions
::cookie('bbuserid', $this->authUser
['userid'], $sticky);
98 BSFunctions
::cookie('bbpassword', md5($this->authUser
['password'] . $this->licenseKey
), $sticky);
101 // ###################################################################
102 function clearCookies()
104 BSFunctions
::cookie('bbpassword', false
);
105 BSFunctions
::cookie('bbuserid', false
);
108 // ###################################################################
109 function _fetchUserWithIdentifier($username)
111 return $this->authDb
->queryFirst("SELECT * FROM {$this->vBTablePrefix}user WHERE username = '" . $this->authDb
->escapeString($username) . "'");
114 // ###################################################################
115 function _verifyLoginUser($password)
117 return ($this->authUser
['password'] == md5(md5($password) . $this->authUser
['salt']));