Back to Programming Articles

FIX: How to connect your website with vBulletin
by Ahmed_Eissa 11 Jul 2007

Hi All,

Thank you for helping me , now I find the way to how to connect your website (What ever language you use to build your website) with vBulletin by forwarding the username and password for your users to vBulletin through a bridge.

The language I use it to build this bridge is ASP 6.0, but no problem as soon I will describe each step how it work. The idea behind that is:
1. Let your existing website create those two cookies:
a. $_COOKIE["username"];
b. $_COOKIE["password"];
2. Create a bridge that connects the username and password fields in vBulletin with those cookies.
3. Ones the bridge fired it must call the “login.php” in vBulletin after forwarding the username and password as the normal situation, and let the user be logged in both: vBulletin and your website.

Please note that vBulletin will run in a deferent environment than your website runs, also it uses a deferent cookies and it encrypted to prevent anybody from reading it: so that why many people fail to do that. I didn’t say that forwarding the user information through a cookies is wrong, but because vBulletin encrypt every transaction between the files.

Now, let we start!

In this article, we will use a splash screen as a bridge, and let the user login to vBulletin after clicking a button.

The code of the (splash.asp) is:
===========================================
Code:
<%
	Dim F
	F = False
	Sub btn_click()
		if F = True Then
			Response.Redirect "/vbulletin/index.php"
		End If
	End Sub
	Sub btn_bf()
		F = True
	End Sub
%>
<html>
<head>
<title>vBulletin Splash Screen</title>
</head>
<body onload="btn_click()" onbeforeunload="btn_bf()">
<div style="border-style: solid; border-width: 1px; padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px">
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center"><b><font face="Arial" color="#0000FF">Welcome to My forum</font></b></p>
	<p align="center">&nbsp;</p>
	<form action="/vbulletin/login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
		<script type="text/javascript" src="clientscript/vbulletin_md5.js?v=365"></script>
		<p align="center">		 
		<input type="hidden" name="vb_login_username" id="navbar_username" onfocus="if (this.value == 'User Name') this.value = '';" size="10" value = <%= Request.Cookies("pad_name")%>>
		<input type="hidden" name="vb_login_password" id="navbar_password" size="10" value = <%= Request.Cookies("pad_word")%>></p>
		<p align="center">
		<input type="submit" value="Click to comtinue" name="Button"></p>
		<input type="hidden" name="s" value="" />
		<input type="hidden" name="do" value="login" />		
		<input type="hidden" name="vb_login_md5password" />
		<input type="hidden" name="vb_login_md5password_utf" />
	</form>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</p>
	<p align="center">&nbsp;</div>
</body>
</html>
============================================

And edit the (includes/functions_login.php) around line number 228 to let it redirect the user only to the main page in vBulletin, your code should be like this:

============================================
Code:
// ###################### Start do login redirect #######################
function do_login_redirect()
{
	global $vbulletin;
	if (
		$vbulletin->url == 'login.php'
		OR $vbulletin->url == $vbulletin->options['forumhome'] . '.php'
		OR strpos($vbulletin->url, 'do=logout') !== false
	)
	{
		$vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'];
	}
	else
	{
		$vbulletin->url = fetch_replaced_session_url($vbulletin->url);
		$vbulletin->url = preg_replace('#^/+#', '/', $vbulletin->url); // bug 3654 don't ask why
	}
…
============================================

Change it to be like this: (Change only the red)

============================================
Code:
// ###################### Start do login redirect #######################
function do_login_redirect()
{
	global $vbulletin;
	if (
		$vbulletin->url == 'login.php'
		OR $vbulletin->url == $vbulletin->options['forumhome'] . '.php'
		OR strpos($vbulletin->url, 'do=logout') !== false
	)
	{
		$vbulletin->url = $vbulletin->options['forumhome'] . '.php' . $vbulletin->session->vars['sessionurl_q'];
	}
	else
	{
		$vbulletin->url ="index.php";
        		//$vbulletin->url = fetch_replaced_session_url($vbulletin->url);
		//$vbulletin->url = preg_replace('#^/+#', '/', $vbulletin->url); // bug 3654 don't ask why	}
…
============================================

And then put a link in your page to the (splash.asp) and name it: “Forums” to guide the user to go to the forum. And your done!

What I do is just forward the values what vBulletin need it to loge the user in the forums mixed with the username and password which is taken from the cookies.

Many thanks for those people, who give me some hints, but I create the whole code alone.

Take care,

Ahmed Eissa.

vblts.ru supports vBulletin®, 2022-2024