odell
05-03-2001, 03:01 PM
It would be great if there were some hack to integrate vbulletin's user database with htaccess...
that would do the following things:
[list=1]
Vbulletin would seamlessly control htaccess as well as vbulletin user databases (for example.. u change password in vbulletin it also changes htaccess pass, or when u reg new user in vbulletin it would also create necessary htaccess user, etc..)
When users login with htaccess vbb automatically logs them in using the information that the user inputed for htaccess login
[/list=1]
I just came across this script written for phpNuke that checks to see if a user logs in with htaccess and if they login with htaccess it will automatically log them in to phpNuke. I thought that much of this could be reused to work with vbulletin. Its only a portion of what would be required for a full htaccess integration hack but its a start anyway.
Im am just starting to learn php and dont have the necessary time or knowledge to create this hack but Im sure alot of ppl would benefit from it, and would all be very appreciateive if someone would create one. :)
Here is the source:
<?PHP
/************************************************** **********************/
/* Automatic recognition and connection of a user who connects to a */
/* PHPNuke site with a htaccess file. */
/* ================================================== ================== */
/* */
/* Copyright (c) 2001 by Thomas Rudant (thomas.rudant@grunk.net) */
/* http://www.grunk.net */
/* http://www.securite-internet.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************** **********************/
if(!isset($mainfile)) { include("mainfile.php"); }
function docookie($setuid, $setuname, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) {
$info = base64_encode("$setuid:$setuname:$setpass:$setstorynum:$setumode: $setuorder:$setthold:$setnoscore:$setublockon:$set theme:$setcommentmax");
setcookie("user","$info",time()+15552000);
global $user;
$user=$info;
}
function login($uname, $pass) {
global $setinfo,$system;
dbconnect();
$result = mysql_query("select pass, uid, storynum, umode, uorder, thold, noscore, ublockon, theme, commentmax from users where uname='$uname'");
if(mysql_num_rows($result)==1) {
$setinfo = mysql_fetch_array($result);
$dbpass=$setinfo[pass];
if(!$system)
$pass=crypt($pass,substr($dbpass,0,2));
if (strcmp($dbpass,$pass)) {
Header("Location: user.php?stop=1");
return;
}
docookie($setinfo[uid], $uname, $pass, $setinfo[storynum], $setinfo[umode], $setinfo[uorder], $setinfo[thold], $setinfo[noscore], $setinfo[ublockon], $setinfo[theme], $setinfo[commentmax]);
}
}
if ($user)
{
global $cookie;
cookiedecode($user);
$username = $cookie[1];
if ($PHP_AUTH_USER!=$username)
{
setcookie("user");
login ($PHP_AUTH_USER,$PHP_AUTH_PW);
}
}
else
{
login ($PHP_AUTH_USER,$PHP_AUTH_PW);
}
?>
that would do the following things:
[list=1]
Vbulletin would seamlessly control htaccess as well as vbulletin user databases (for example.. u change password in vbulletin it also changes htaccess pass, or when u reg new user in vbulletin it would also create necessary htaccess user, etc..)
When users login with htaccess vbb automatically logs them in using the information that the user inputed for htaccess login
[/list=1]
I just came across this script written for phpNuke that checks to see if a user logs in with htaccess and if they login with htaccess it will automatically log them in to phpNuke. I thought that much of this could be reused to work with vbulletin. Its only a portion of what would be required for a full htaccess integration hack but its a start anyway.
Im am just starting to learn php and dont have the necessary time or knowledge to create this hack but Im sure alot of ppl would benefit from it, and would all be very appreciateive if someone would create one. :)
Here is the source:
<?PHP
/************************************************** **********************/
/* Automatic recognition and connection of a user who connects to a */
/* PHPNuke site with a htaccess file. */
/* ================================================== ================== */
/* */
/* Copyright (c) 2001 by Thomas Rudant (thomas.rudant@grunk.net) */
/* http://www.grunk.net */
/* http://www.securite-internet.org */
/* */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License. */
/************************************************** **********************/
if(!isset($mainfile)) { include("mainfile.php"); }
function docookie($setuid, $setuname, $setpass, $setstorynum, $setumode, $setuorder, $setthold, $setnoscore, $setublockon, $settheme, $setcommentmax) {
$info = base64_encode("$setuid:$setuname:$setpass:$setstorynum:$setumode: $setuorder:$setthold:$setnoscore:$setublockon:$set theme:$setcommentmax");
setcookie("user","$info",time()+15552000);
global $user;
$user=$info;
}
function login($uname, $pass) {
global $setinfo,$system;
dbconnect();
$result = mysql_query("select pass, uid, storynum, umode, uorder, thold, noscore, ublockon, theme, commentmax from users where uname='$uname'");
if(mysql_num_rows($result)==1) {
$setinfo = mysql_fetch_array($result);
$dbpass=$setinfo[pass];
if(!$system)
$pass=crypt($pass,substr($dbpass,0,2));
if (strcmp($dbpass,$pass)) {
Header("Location: user.php?stop=1");
return;
}
docookie($setinfo[uid], $uname, $pass, $setinfo[storynum], $setinfo[umode], $setinfo[uorder], $setinfo[thold], $setinfo[noscore], $setinfo[ublockon], $setinfo[theme], $setinfo[commentmax]);
}
}
if ($user)
{
global $cookie;
cookiedecode($user);
$username = $cookie[1];
if ($PHP_AUTH_USER!=$username)
{
setcookie("user");
login ($PHP_AUTH_USER,$PHP_AUTH_PW);
}
}
else
{
login ($PHP_AUTH_USER,$PHP_AUTH_PW);
}
?>