From abc8b8887035d0801172cfff7f34485b6cb3521f Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 14 Feb 2009 17:05:51 -0500 Subject: [PATCH] Add IPB2 authentication module * includes/auth/auth_ipb2.php: New file * includes/auth/config.php.new: Add config directives --- includes/auth/auth_ipb2.php | 130 +++++++++++++++++++++++++++++++++++ includes/auth/config.php.new | 13 ++++ 2 files changed, 143 insertions(+) create mode 100644 includes/auth/auth_ipb2.php diff --git a/includes/auth/auth_ipb2.php b/includes/auth/auth_ipb2.php new file mode 100644 index 0000000..156b08a --- /dev/null +++ b/includes/auth/auth_ipb2.php @@ -0,0 +1,130 @@ + 'id', + 'displayname' => 'name', + 'email' => 'email' + ); + + /** + * IPB2 table prefix + * @var string + */ + var $tablePrefix; + + /** + * Cookie prefix + * @var string + */ + var $cookiePrefix; + + // ################################################################### + function _setupDatabase() + { + parent::_setupDatabase(); + + include 'includes/auth/config.php'; + $this->tablePrefix = $config['auth']['IPB2']['tablePrefix']; + $this->cookiePrefix = $config['auth']['IPB2']['cookiePrefix']; + } + + // ################################################################### + function _fetchCookieUniqueId() + { + return $this->registry->input_clean($this->cookiePrefix . 'member_id', TYPE_UINT); + } + + // ################################################################### + function _fetchCookiePassword() + { + return $this->registry->in[$this->cookiePrefix . 'pass_hash']; + } + + // ################################################################### + function _fetchUserUsingCookies() + { + return $this->authDb->query_first("SELECT * FROM {$this->tablePrefix}members WHERE id = " . $this->_fetchCookieUniqueId()); + } + + // ################################################################### + function _verifyCookieData() + { + return ($this->_fetchCookiePassword() == $this->authUser['member_login_key']); + } + + // ################################################################### + function _fetchUserWithIdentifier($username) + { + return $this->authDb->query_first("SELECT * FROM {$this->tablePrefix}members WHERE name = '" . $this->authDb->escape_string($username) . "'"); + } + + // ################################################################### + function _verifyLoginUser($password) + { + $cvg = $this->authDb->query_first("SELECT * FROM {$this->tablePrefix}members_converge WHERE converge_email = '" . $this->authUser['email'] . "'"); + return (md5(md5($cvg['converge_pass_salt']) . md5($password)) == $cvg['converge_pass_hash']); + } + + // ################################################################### + function clearCookies() + { + $this->registry->funct->cookie($this->cookiePrefix . 'member_id'); + $this->registry->funct->cookie($this->cookiePrefix . 'pass_hash'); + $this->registry->funct->cookie($this->cookiePrefix . 'ipb_stronghold'); + $this->authDb->query("DELETE FROM {$this->tablePrefix}sessions WHERE id = '" . $this->authDb->escape_string($this->registry->in[$this->cookiePrefix . 'session_id']) . "'"); + $this->registry->funct->cookie($this->cookiePrefix . 'session_id'); + } + + // ################################################################### + function _setCookies($sticky = false) + { + $this->registry->funct->cookie($this->cookiePrefix . 'member_id', $this->authUser['id']); + $this->registry->funct->cookie($this->cookiePrefix . 'pass_hash', $this->authUser['member_login_key']); + + include 'includes/auth/config.php'; + $ip = explode('.', $_SERVER['REMOTE_ADDR']); + $stronghold = md5(md5($this->authUser['id'] . '-' . $ip[0] . '-' . $ip[1] . '-' . $this->authUser['member_login_key']) . md5($config['auth']['dbPassword'] . $config['auth']['dbUser'])); + $this->registry->funct->cookie($this->cookiePrefix . 'ipb_stronghold', $stronghold); + + $this->registry->funct->cookie($this->cookiePrefix . 'session_id'); + } +} + +?> \ No newline at end of file diff --git a/includes/auth/config.php.new b/includes/auth/config.php.new index 5371043..d5bb4af 100644 --- a/includes/auth/config.php.new +++ b/includes/auth/config.php.new @@ -76,4 +76,17 @@ $config['auth']['vBulletin3']['tablePrefix'] = ''; */ $config['auth']['vBulletin3']['licenseKey'] = 'LXXXXXXX'; +// ################################################################### +// Invision Power Board 2 configuration + +/** + * Database table prefix + */ +$config['auth']['IPB2']['tablePrefix'] = 'ibf_'; + +/** + * Cookie prefix + */ +$config['auth']['IPB2']['cookiePrefix'] = ''; + ?> \ No newline at end of file -- 2.43.5