As so many people are asking about integration with a product heres a quick class i whipped up to check the password.
PHP Code:
class forum {
var $database = '';
function check_password ($username='', $userid=0, $password, $md5=0) {
if ($userid == 0) {
$query = mysql_query("SELECT * FROM " . $this->database . ".user WHERE username='".addslashes($username)."'");
} else {
$query = mysql_query("SELECT * FROM " . $this->database . ".user WHERE userid='".intval($userid)."'");
}
$user = mysql_fetch_array($query);
if ($md5) {
if ($password == $user['password']) {
return true;
} else {
return false;
}
} else {
if (md5($password) == $user['password']) {
return true;
} else {
return false;
}
}
}
}
usage
PHP Code:
/*usage
$object->check_password(USERNAME, USERID, PASSWORD, MD5)
username is the username of password to check
userid is the userid of the user you can use either of these
password is the password either in md5 or unhashed
md5 set this to 1 if the password you are putting into the function has already been hashed
*/
require_once('./forum_class.php');
$forum = new forum;
$forum->database = 'vbulletin_development';
//username method
if ($forum->check_password($_POST['username'], '', $_POST['password'])) {
echo 'password matches';
} else {
echo 'no access';
}
//userid method
if ($forum->check_password('', $_COOKIE['bbuserid'], $_COOKIE['bbpassword'], 1)) {
echo 'password matches';
} else {
echo 'no access';
}
though it does presume an active connection to the database has already been made by some aspect of the script.
Hopefully this will help someone.