]>
src.bluestatic.org Git - bugdar.git/blob - includes/auth/auth_ipb2.php
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: IPB2
27 * Authentication system for Invision Power Board 2
30 * @copyright Copyright (c)2004 - 2009, Blue Static
34 class AuthenticationIPB2
extends Authentication
37 * Map Bugdar fields to IPB ones
40 var $fieldMap = array (
42 'displayname' => 'name' ,
58 // ###################################################################
59 function _setupDatabase ()
61 parent
:: _setupDatabase ();
63 include 'includes/auth/config.php' ;
64 $this- > tablePrefix
= $config [ 'auth' ][ 'IPB2' ][ 'tablePrefix' ];
65 $this- > cookiePrefix
= $config [ 'auth' ][ 'IPB2' ][ 'cookiePrefix' ];
68 // ###################################################################
69 function _fetchCookieUniqueId ()
71 return $this- > registry
-> input_clean ( $this- > cookiePrefix
. 'member_id' , TYPE_UINT
);
74 // ###################################################################
75 function _fetchCookiePassword ()
77 return $this- > registry
-> in
[ $this- > cookiePrefix
. 'pass_hash' ];
80 // ###################################################################
81 function _fetchUserUsingCookies ()
83 return $this- > authDb
-> query_first ( "SELECT * FROM {$this->tablePrefix} members WHERE id = " . $this- > _fetchCookieUniqueId ());
86 // ###################################################################
87 function _verifyCookieData ()
89 return ( $this- > _fetchCookiePassword () == $this- > authUser
[ 'member_login_key' ]);
92 // ###################################################################
93 function _fetchUserWithIdentifier ( $username )
95 return $this- > authDb
-> query_first ( "SELECT * FROM {$this->tablePrefix} members WHERE name = '" . $this- > authDb
-> escape_string ( $username ) . "'" );
98 // ###################################################################
99 function _verifyLoginUser ( $password )
101 $cvg = $this- > authDb
-> query_first ( "SELECT * FROM {$this->tablePrefix} members_converge WHERE converge_email = '" . $this- > authUser
[ 'email' ] . "'" );
102 return ( md5 ( md5 ( $cvg [ 'converge_pass_salt' ]) . md5 ( $password )) == $cvg [ 'converge_pass_hash' ]);
105 // ###################################################################
106 function clearCookies ()
108 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'member_id' );
109 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'pass_hash' );
110 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'ipb_stronghold' );
111 $this- > authDb
-> query ( "DELETE FROM {$this->tablePrefix} sessions WHERE id = '" . $this- > authDb
-> escape_string ( $this- > registry
-> in
[ $this- > cookiePrefix
. 'session_id' ]) . "'" );
112 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'session_id' );
115 // ###################################################################
116 function _setCookies ( $sticky = false )
118 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'member_id' , $this- > authUser
[ 'id' ]);
119 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'pass_hash' , $this- > authUser
[ 'member_login_key' ]);
121 include 'includes/auth/config.php' ;
122 $ip = explode ( '.' , $_SERVER [ 'REMOTE_ADDR' ]);
123 $stronghold = md5 ( md5 ( $this- > authUser
[ 'id' ] . '-' . $ip [ 0 ] . '-' . $ip [ 1 ] . '-' . $this- > authUser
[ 'member_login_key' ]) . md5 ( $config [ 'auth' ][ 'dbPassword' ] . $config [ 'auth' ][ 'dbUser' ]));
124 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'ipb_stronghold' , $stronghold );
126 $this- > registry
-> funct
-> cookie ( $this- > cookiePrefix
. 'session_id' );