I am trying to modify the AuthPress code to work with invisionboard 2.0. The problem I am running into is the way the password is stored with invisionboard. Usernames are stored in a table named "members" with a corresponding table row id. The passwords are stored in a separate table named members_converge that references the users table row id. The password has a "hash" and a "salt".
Can someone help me modify the password section of the below script to pull from a separate table and use the hash/salt encryption? Hopefully this will be helpful to other users also.
<?php
require_once('AuthPlugin.php');
class AuthPress extends AuthPlugin { var $mAuthPressTablePrefix=""; var $mUseSeparateAuthPressDB=false; var $mAuthPressDBServer; var $mAuthPressDBName; var $mAuthPressUser; var $mAuthPressPassword; var $mAuthPressDBconn = -1; function AuthPress () { global $wgDBserver, $wgDBname, $wgDBuser, $wgDBpassword;
$this->mAuthPressDBServer=$wgDBserver; $this->mAuthPressDBName=$wgDBname; $this->mAuthPressUser=$wgDBuser; $this->mAuthPressPassword=$wgDBpassword; }
function setAuthPressTablePrefix ( $prefix ) { $this->mAuthPressTablePrefix=$prefix; }
function getAuthPressUserTableName () { return $this->mAuthPressTablePrefix."members"; }
function setAuthPressDBServer ($server) { $this->mUseSeparateAuthPressDB=true; $this->mAuthPressDBServer=$server; }
function setAuthPressDBName ($dbname) { $this->mUseSeparateAuthPressDB=true; $this->mAuthPressDBName=$dbname; }
function setAuthPressUser ($user) { $this->mUseSeparateAuthPressDB=true; $this->mAuthPressUser=$user; }
function setAuthPressPassword ($password) { $this->mUseSeparateAuthPressDB=true; $this->mAuthPressPassword=$password; }
function &getAuthPressDB () { if( $this->mUseSeparateAuthPressDB ) { //print $this->mAuthPressDBServer; //print $this->mAuthPressUser; //print $this->mAuthPressPassword; //print $this->mAuthPressDBName; if(! is_object($this->mDBconn) ) { $this->mAuthPressDBconn = new Database($this->mAuthPressDBServer, $this->mAuthPressUser, $this->mAuthPressPassword, $this->mAuthPressDBName ); } return $this->mAuthPressDBconn; } else { return wfGetDB( DB_SLAVE ); } }
/** * Check whether there exists a user account with the given name. */ function userExists( $username ) { $dbr =& $this->getAuthPressDB(); $res = $dbr->selectRow($this->getAuthPressUserTableName(), "name", "name=".$dbr->addQuotes($username), "AuthPress::authenticate" );
if($res) { return true; } else { return false; } } /** * Check if a username+password pair is a valid login. */ function authenticate( $username, $password ) { $dbr =& $this->getAuthPressDB();
$res = $dbr->selectRow($this->getAuthPressUserTableName(), "password", "name=".$dbr->addQuotes($username), "AuthPress::authenticate" );
if( $res && ( $res->passwd == MD5( $password ))) { return true; } else { return false; } }
} ?>