]>
src.bluestatic.org Git - bugdar.git/blob - includes/auth/auth_vbulletin.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 - [#]year[#], 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 = 'LXXXXXX' ;
46 * The table prefix for all of vBulletin's tables
49 var $vBTablePrefix = '' ;
51 // ###################################################################
52 function _setupDatabase ()
54 $this- > authDb
=& new DB_MySQL ( $this- > registry
);
55 $this- > authDb
-> connect ( 'VBULLETIN_DATABASE_SERVER' , 'VB_DATABASE_USER' , 'VB_DATABASE_PASSWORD' , 'VBULLETIN_DATABASE_NAME' , false );
58 // ###################################################################
59 function _fetchCookieUniqueId ()
61 return $this- > registry
-> input_clean ( 'bbuserid' , TYPE_UINT
);
64 // ###################################################################
65 function _fetchCookiePassword ()
67 return $this- > registry
-> in
[ 'bbpassword' ];
70 // ###################################################################
71 function _fetchUserUsingCookies ()
73 return $this- > authDb
-> query_first ( "SELECT * FROM {$this->vBTablePrefix} user WHERE userid = " . $this- > _fetchCookieUniqueId ());
76 // ###################################################################
77 function _verifyCookieData ()
79 return ( md5 ( $this- > authUser
[ 'password' ] . $this- > licenseKey
) == $this- > _fetchCookiePassword ());
82 // ###################################################################
83 function _setCookies ( $sticky = false )
85 $this- > registry
-> funct
-> cookie ( 'bbuserid' , $this- > authUser
[ 'userid' ], $sticky );
86 $this- > registry
-> funct
-> cookie ( 'bbpassword' , md5 ( $this- > authUser
[ 'password' ] . $this- > licenseKey
), $sticky );
89 // ###################################################################
90 function _clearCookies ()
92 $this- > registry
-> funct
-> cookie ( 'bbpassword' );
93 $this- > registry
-> funct
-> cookie ( 'bbuserid' );
96 // ###################################################################
97 function _fetchBugdarUserFromAuthUser ()
99 $user = $this- > db
-> query_first ( "SELECT * FROM " . TABLE_PREFIX
. "user WHERE authid = " . $this- > authUser
[ 'userid' ]);
102 return $this- > _createBugdarUser ();
107 // ###################################################################
108 function _createBugdarUser ()
110 $user = new UserAPI ( $this- > registry
); // do not change this
111 $user- > set ( 'email' , $this- > authUser
[ 'email' ]);
112 $user- > set ( 'displayname' , $this- > authUser
[ 'name' ]);
113 $user- > set ( 'password' , $this- > authUser
[ 'password' ]); // some random value that won't be used for authentication
114 $user- > set ( 'usergroupid' , 2 ); // default "Registered Users" group
115 $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
116 $user- > insert (); // saves the user
118 return $user- > values
; // returns the newly created user array
121 // ###################################################################
122 function _fetchUserWithIdentifier ( $username )
124 return $this- > authDb
-> query_first ( "SELECT * FROM {$this->vBTablePrefix} user WHERE username = '" . $this- > authDb
-> escape_string ( $username ) . "'" );
127 // ###################################################################
128 function _verifyLoginUser ( $password )
130 return ( $this- > authUser
[ 'password' ] == md5 ( md5 ( $password ) . $this- > authUser
[ 'salt' ]));
134 /*=====================================================================*\
135 || ###################################################################
138 || ###################################################################
139 \*=====================================================================*/