Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.0 > vBulletin 3.0 Full Releases
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
VB Login on a Non-VB Page vB3 RC3 Details »»
VB Login on a Non-VB Page vB3 RC3
Version: 1.00, by mcahill mcahill is offline
Developer Last Online: Dec 2012 Show Printable Version Email this Page

Version: 3.0.0 Rating:
Released: 02-02-2004 Last Update: Never Installs: 74
 
No support by the author.

This is a simple modification to do, and adds a lot of value to your homepage.

Notes:

1. This script can occassionally have conflicts with other javascripts. Test before you deploy.
2. If you use and include to put the file on your page, be sure that the chdir and the require for global.php is in the head of the main document.
3. It is assumed that you are using a php page, and that you have already got connectivity with your database.


The code:

At the top of the document, before the <html> or <head> tags (edit to provide the path for your particular installation):

PHP Code:
<?php
  chdir
("forum/");
require(
'./global.php');  
chdir("../); 
?>
Wherever you want your login:

PHP Code:
 <?
 

if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
  
print("<align='center'><span class='sectionheader'>Welcome back, $username!<br>");

} else {
   


?>
<form action='/forum/login.php' method='post' onsubmit='md5hash(vb_login_password,vb_login_md5password)'>
        <script type='text/javascript' src='/forum/clientscript/vbulletin_md5.js'></script>
        
         <span class="sectionheader">Username:</span>
            <input type='text' class='button' name='vb_login_username' id='navbar_username' size='15' accesskey='u' tabindex='1' value='' onfocus='if (this.value == 'username') this.value = '';' /><br>
            
            <span class="sectionheader">Password:&nbsp;</span>
            <input type='password' class='button' name='vb_login_password' size='15' accesskey='p' tabindex='2' /><br>
            <input type='checkbox' name='cookieuser' value='1' tabindex='3' id='cb_cookieuser_navbar' accesskey='c' checked='checked' /><span class='sectionheader'>Remember Me</span><br>
        
        
        
        <input name="submit" type='submit' class='button' accesskey='s' tabindex='4' title='Log In' value='Log In' />
        <input type='hidden' name='do' value='login' />
        <input type='hidden' name='forceredirect' value='1' />            
        <input type='hidden' name='vb_login_md5password' />
        </form>
                        <?

 } 

?>
Troubleshooting:

Before requesting support, please check the following:

1. Make sure you have the path to your forum in the chdir. If you haven't done this, you will get a "can't include" error.
2. Make sure you have the chdir in the main document. If it isn't you will get a "can't modify header" error.
3. If those don't resolve the issue, try putting the login in a separate file, with no other code. If it works there, then you will know that you have a conflict with one of the scripts on the page you are trying to add the login to. I can't help you if you've got a conflict with another script.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #82  
Old 10-14-2004, 11:52 PM
seth044_x seth044_x is offline
 
Join Date: Jul 2003
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

ok ok i have a beta version of my site and its working like a charm, with a lot of another functions running smooth (avatar, new pms, etc) but in my real site.. its not working!

i get this error.

Code:
Fatal error: Call to a member function on a non-object in /xxxx/foros/includes/functions.php on line 922
and sometimes these other one:

Code:
Fatal error: Call to a member function on a non-object in /xxxx/foros/includes/sessions.php on line 72
functions.php line is:

Code:
$user = $DB_site->query_first("
and sessions.php line is:

Code:
$DB_site->shutdown_query("
Yes, i have included global.php before functions_user.php.

The beta version of the site is vb3.0.0 (working) and real is vb3.0.3 (not working) very strange.

Its kinda urgent, please help!

thanks in advance.
Reply With Quote
  #83  
Old 10-23-2004, 06:26 PM
ZeldaUniverse ZeldaUniverse is offline
 
Join Date: Aug 2002
Posts: 5
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This works perfectly fine for me on http://www.taiteki.net - Check it out if ya don't believe me
Reply With Quote
  #84  
Old 10-30-2004, 11:33 AM
reach_srinivas reach_srinivas is offline
 
Join Date: Sep 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

HI, I got a problem like
"Unable to add cookies, header already sent.
File: /usr/local/apache/htdocs/dev/i2-042804/test.php
Line: 2"

Pls any one can help me..
Thanks in advance
Reply With Quote
  #85  
Old 10-30-2004, 03:49 PM
Blue Moose Aaron's Avatar
Blue Moose Aaron Blue Moose Aaron is offline
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Post your PHP code
Reply With Quote
  #86  
Old 10-31-2004, 07:28 AM
kelangtri kelangtri is offline
 
Join Date: Oct 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i dont test it with localhost, why??
Reply With Quote
  #87  
Old 11-02-2004, 02:43 AM
Neyland Neyland is offline
 
Join Date: Oct 2004
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by seth044_x
ok ok i have a beta version of my site and its working like a charm, with a lot of another functions running smooth (avatar, new pms, etc) but in my real site.. its not working!

i get this error.

Code:
Fatal error: Call to a member function on a non-object in /xxxx/foros/includes/functions.php on line 922
and sometimes these other one:

Code:
Fatal error: Call to a member function on a non-object in /xxxx/foros/includes/sessions.php on line 72
functions.php line is:

Code:
$user = $DB_site->query_first("
and sessions.php line is:

Code:
$DB_site->shutdown_query("
Yes, i have included global.php before functions_user.php.

The beta version of the site is vb3.0.0 (working) and real is vb3.0.3 (not working) very strange.

Its kinda urgent, please help!

thanks in advance.
I get the same exact problem!
Reply With Quote
  #88  
Old 12-12-2004, 10:18 AM
sketchy sketchy is offline
 
Join Date: Oct 2004
Location: North London, England
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The creator of this script has NEVER repliedto anyones posts, shouldnt this be removed or something as it is clearly not working or maybe a notice in his post saying that it has bugs.

Just a suggestion
Reply With Quote
  #89  
Old 12-19-2004, 05:25 PM
Splatt_XP's Avatar
Splatt_XP Splatt_XP is offline
 
Join Date: Nov 2001
Location: Michigan
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sketchy
The creator of this script has NEVER repliedto anyones posts, shouldnt this be removed or something as it is clearly not working or maybe a notice in his post saying that it has bugs.

Just a suggestion
Here's how I finally got it to work. I had conflicting database statements so I just read the database right from the index.php file.

I placed this near the top of my index.php file:
PHP Code:
<?
$userid   = $HTTP_COOKIE_VARS['bbuserid'];
$password = $HTTP_COOKIE_VARS['bbpassword'];
$vbhost   = "localhost";
$vbuser   = "your_db_username";
$vbpass   = "your_db_password";
$vbname   = "your_db_name";
$vb=mysql_connect("$vbhost","$vbuser","$vbpass");
mysql_select_db($vbname,$vb) or die ("Forum Database Connectivity Error");

$vbsql=mysql_query("select * from user where userid = '$userid'");
$vbinfo=@mysql_fetch_array($vbsql);

$username=$vbinfo[username];
?>
Then, where I wanted the logon box, I placed the following:
PHP Code:
<?
if ($username) {
    print "<font class=title><b>Welcome back $username!&nbsp;&nbsp;</b></font>";
} else { 
?>
<!-- login form -->
<script type="text/javascript" src="forum/clientscript/vbulletin_global.js"></script>
<script type="text/javascript" src="forum/clientscript/vbulletin_menu.js"></script>
<form action="http://www.yourdomain.com/forum/login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password)">
<script type="text/javascript" src="forum/clientscript/vbulletin_md5.js"></script>
<table cellpadding="0" cellspacing="3" border="0">
  <tr>
    <td class="title">User Name</td>
    <td><input type="text" class="button" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /></td>
    <td class="title" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />Remember Me?</label></td>
  </tr>
  <tr>
    <td class="title">Password</td>
    <td><input type="password" class="button" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></td>
    <td><input type="submit" class="button" value="Log in" tabindex="4" accesskey="s" /></td>
  </tr>
</table>
<input type="hidden" name="s" value="" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="forceredirect" value="0" />            
<input type="hidden" name="vb_login_md5password" />
</form>
<!-- / login form -->
Of course you'll have to change the database info, classes, form action and paths to reflect your set up, but at least this got me working.
Reply With Quote
  #90  
Old 12-22-2004, 09:30 AM
T3MEDIA T3MEDIA is offline
 
Join Date: Dec 2004
Posts: 944
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Splatt_XP
Here's how I finally got it to work. I had conflicting database statements so I just read the database right from the index.php file.

I placed this near the top of my index.php file:
PHP Code:
<?
$userid   = $HTTP_COOKIE_VARS['bbuserid'];
$password = $HTTP_COOKIE_VARS['bbpassword'];
$vbhost   = "localhost";
$vbuser   = "your_db_username";
$vbpass   = "your_db_password";
$vbname   = "your_db_name";
$vb=mysql_connect("$vbhost","$vbuser","$vbpass");
mysql_select_db($vbname,$vb) or die ("Forum Database Connectivity Error");

$vbsql=mysql_query("select * from user where userid = '$userid'");
$vbinfo=@mysql_fetch_array($vbsql);

$username=$vbinfo[username];
?>
Then, where I wanted the logon box, I placed the following:
PHP Code:
<?
if ($username) {
    print "<font class=title><b>Welcome back $username!&nbsp;&nbsp;</b></font>";
} else { 
?>
<!-- login form -->
<script type="text/javascript" src="forum/clientscript/vbulletin_global.js"></script>
<script type="text/javascript" src="forum/clientscript/vbulletin_menu.js"></script>
<form action="http://www.yourdomain.com/forum/login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password)">
<script type="text/javascript" src="forum/clientscript/vbulletin_md5.js"></script>
<table cellpadding="0" cellspacing="3" border="0">
  <tr>
    <td class="title">User Name</td>
    <td><input type="text" class="button" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /></td>
    <td class="title" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />Remember Me?</label></td>
  </tr>
  <tr>
    <td class="title">Password</td>
    <td><input type="password" class="button" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></td>
    <td><input type="submit" class="button" value="Log in" tabindex="4" accesskey="s" /></td>
  </tr>
</table>
<input type="hidden" name="s" value="" />
<input type="hidden" name="do" value="login" />
<input type="hidden" name="forceredirect" value="0" />            
<input type="hidden" name="vb_login_md5password" />
</form>
<!-- / login form -->
Of course you'll have to change the database info, classes, form action and paths to reflect your set up, but at least this got me working.
umm is that safe putting that info in your index.php?
Reply With Quote
  #91  
Old 12-22-2004, 10:22 PM
Splatt_XP's Avatar
Splatt_XP Splatt_XP is offline
 
Join Date: Nov 2001
Location: Michigan
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by T3MEDIA
umm is that safe putting that info in your index.php?
It's no different than putting it in a "config.php" file.

If you feel uncomfortable with it in there then put the database information in another file and then just put an include statement in the index.php file.

somefile.php:
PHP Code:
<? 
$vbhost   = "localhost"; 
$vbuser   = "your_db_username"; 
$vbpass   = "your_db_password"; 
$vbname   = "your_db_name"; 
?>
index.php:
PHP Code:
<? 
$userid   = $HTTP_COOKIE_VARS['bbuserid']; 
$password = $HTTP_COOKIE_VARS['bbpassword']; 
include('somefile.php');
$vb=mysql_connect("$vbhost","$vbuser","$vbpass"); 
mysql_select_db($vbname,$vb) or die ("Forum Database Connectivity Error"); 

$vbsql=mysql_query("select * from user where userid = '$userid'"); 
$vbinfo=@mysql_fetch_array($vbsql); 

$username=$vbinfo[username]; 
?>
Reply With Quote
Reply


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 12:10 AM.


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.05833 seconds
  • Memory Usage 2,346KB
  • Queries Executed 25 (?)
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
  • (8)bbcode_code
  • (8)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete