Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FIX: How to connect your website with vBulletin
Ahmed_Eissa
Join Date: Jul 2007
Posts: 11

 

UK
Show Printable Version Email this Page Subscription
Ahmed_Eissa Ahmed_Eissa is offline 07-10-2007, 10:00 PM

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.:up:
Reply With Quote
  #2  
Old 09-15-2007, 04:23 AM
tam2000k2 tam2000k2 is offline
 
Join Date: Sep 2007
Posts: 4
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi Ahmed,

I'm trying to do something similar with AJAX and logging directly in by using the tables within the vbulletin's forum section of our web site. Can you take a look at my post to see if you could help?

https://vborg.vbsupport.ru/showthrea...hlight=md5hash

Thanks in advance,
Tarik
Reply With Quote
  #3  
Old 10-12-2007, 04:24 PM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

In vB 3.6.7 the includes code is changed..

Code:
// ###################### Start process new login #######################
// creates new session once $vbulletin->userinfo has been set to the newly logged in user
// processes logins into CP
function process_new_login($logintype, $cookieuser, $cssprefs)
{
    global $vbulletin;

    $vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "session WHERE sessionhash = '" . $vbulletin->db->escape_string($vbulletin->session->vars['dbsessionhash']) . "'");

    if ($vbulletin->session->created == true AND $vbulletin->session->vars['userid'] == 0)
    {
        // if we just created a session on this page, there's no reason not to use it
        $newsession =& $vbulletin->session;
    }
    else
    {
        $newsession =& new vB_Session($vbulletin, '', $vbulletin->userinfo['userid'], '', $vbulletin->session->vars['styleid']);
    }
    $newsession->set('userid', $vbulletin->userinfo['userid']);
    $newsession->set('loggedin', 1);
    if ($logintype == 'cplogin')
    {
        $newsession->set('bypass', 1);
    }
    else
    {
        $newsession->set('bypass', 0);
    }
    $newsession->set_session_visibility(($vbulletin->superglobal_size['_COOKIE'] > 0));
    $vbulletin->session =& $newsession;
How do I edit it?
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 02:57 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03523 seconds
  • Memory Usage 2,219KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (1)post_thanks_box_bit
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (3)post_thanks_postbit_info
  • (2)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete