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
  #62  
Old 06-24-2004, 04:45 PM
WishER WishER is offline
 
Join Date: Jun 2002
Location: Antioch, CA
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi folks,

After a while of debugging my problems and so on, i managed to get all this worked out.

Let start with the problems I had. After I logged in, I would still get the login form instead of the welcome back message. I fixed that by first making sure that vb3 was setting the cookies for my whole server, by using .bayareamuscle.com as the domain. I also had to put the initiation code, that calls/requires globals.php, at the very top of the php page:

At the top of my non vb3 page:
PHP Code:
<? 
chdir("./forum/"); 
include('./global.php');   
chdir("../"); 
?>
The rest of the code was the same. I just used that where i needed the login box.

So that fixed my problem witht he login box always showing up.

Now on to the avatar on this page. This was actually very simple, all i had to do was add 3 lines to the current code.

Lets start with the including of the required files:
PHP Code:
<? 
chdir("./forum/"); 
include('./global.php');   

// added this line to include the user functions which 
// has the fetch_avatar_url() function
include('./includes/functions_user.php');

chdir("../"); 
?>
PHP Code:
<? 
if ($bbuserinfo['userid']!=0) { 
    $username=$bbuserinfo['username']; 
    

    // i assigned the avatar url to the variable $user_av and check to see if it's empty.
    $user_av = fetch_avatar_url($bbuserinfo['userid']);
    if($user_av!='')
       $user_av="/forum/" . $user_av;  //replace "/forum/" with your virtual path to your forum pages.

    print("<align='center'><span class='sectionheader'>Welcome back, $username!<br>");
    
    //if the avatar url is not empty, display it
    if($user_av!='')
        print("<img src="" . $user_av . "" vspace=4>"); 
} 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> 
                        <? 



?>
Hope this helps. Ofcourse, now you can also use all the other functions in the functions_user.php include, so check out what it offers.

Sorry for the ugly code, but I just came up with it no more than 3 mins ago and since this page was still open, i figured i'd contribute with what i found. now ya can take care of the clean up.

p.s. you can see this work at BayAreaMuscle.com, you are going to have to login as user: DemoUser and password: demo, i created an avatar for this demo user.

Pz!
Reply With Quote
  #63  
Old 06-28-2004, 01:49 AM
DuffMan DuffMan is offline
 
Join Date: Nov 2003
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Whenever I try this, all variables that existed before global.php was called dissapaear. Is there any way around this or is vB's security just too powerful?
Reply With Quote
  #64  
Old 07-07-2004, 08:44 PM
DF-inside DF-inside is offline
 
Join Date: Aug 2003
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Still no stable code for this?
Reply With Quote
  #65  
Old 07-07-2004, 09:01 PM
ravenswood1000 ravenswood1000 is offline
 
Join Date: Oct 2002
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just want a stable way of getting the vbulletin user id from whichever directory I call for it, but to no avail.

Vbullletin broke my site so I had to neuter it by adding globals variables that were important to me by including them in the "/includes/init.php" ignore array subroutine.

It is fun to sometimes subtract globals that are important to vbulletin just to see how it reacts.

ravenswood
Reply With Quote
  #66  
Old 07-08-2004, 04:02 AM
CNibbana CNibbana is offline
 
Join Date: Apr 2003
Posts: 16
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Mu5icMan
has anyone figured out how to use this with other Javascript applications
I don't understand why you guys are using this line in the first place?
<script type='text/javascript' src='/forum/clientscript/vbulletin_md5.js'></script>

I am running my script as below which I copied directly from the VB3 source code and it works great: (of course you have to include the chdir at the top of your non VB3 page first)

<form method="post" class="login" action="/forum/login.php" onsubmit="md5hash(vb_login_password,vb_login_md5pa ssword)">
<p>Username:<input type="text" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="1" onfocus="if (this.value == 'User Name') this.value = '';" /></p>
<p>Password:<input type="password" name="vb_login_password" size="10" accesskey="p" tabindex="2" /></p>
<input type="hidden" name="cookieuser" value="1" tabindex="3" id="cb_cookieuser_navbar" accesskey="c" checked="checked" />
<input type="hidden" name="s" value="" />
<input type="hidden" name="do" value="login" /><input type="hidden" name="forceredirect" value="1" />
<input type="hidden" name="vb_login_md5password" />
<input type="submit" value="Login" class="submit" />
Reply With Quote
  #67  
Old 07-08-2004, 08:35 AM
Mu5icMan Mu5icMan is offline
 
Join Date: Aug 2003
Posts: 55
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i asked that question because i have multiple 'OnSumbit = ???' commands. But i got mine to work, sort off. I still have a problem with cookies.

Sometimes it lets me in without entering username and password and sometimes i have to enter them.
Reply With Quote
  #68  
Old 07-13-2004, 04:47 PM
WishER WishER is offline
 
Join Date: Jun 2002
Location: Antioch, CA
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by ravenswood1000
I just want a stable way of getting the vbulletin user id from whichever directory I call for it, but to no avail.

Vbullletin broke my site so I had to neuter it by adding globals variables that were important to me by including them in the "/includes/init.php" ignore array subroutine.

It is fun to sometimes subtract globals that are important to vbulletin just to see how it reacts.

ravenswood
Dude, in all the includes and requires, change it to the local path. so that you don't have to do the linking relative to the file. an example of this is:

require("c:/www/username/public_html/forum/globals.php");

that will work from anywhere you do it. Just learn how you use: http://us2.php.net/manual/en/function.require.php

to get the stable one, all you have to do is cusomize it for your use. and it's just a matter of changing the path for the files and you are set. You are not always going to get the perfect match with these mods. Learn to use the PHP manual and your life will be a bit easier: http://us2.php.net/manual/en/

That's the problem with php, it acts differently on different machines depending on config, os, and so on, but hey it's free! LOL

Pz!
Reply With Quote
  #69  
Old 07-14-2004, 07:22 AM
d3nnis d3nnis is offline
 
Join Date: Jun 2003
Location: Singapore
Posts: 211
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Ghostspy
if you use post nuke how will this work??

yeah i am curious if this works for php nuke?
Reply With Quote
  #70  
Old 07-14-2004, 01:08 PM
lmongello lmongello is offline
 
Join Date: Jan 2004
Posts: 54
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I can't seem to get this working right...

I have a www.mysite.com/downloads/index.php page that I want to implment this on

My forums are in www.mysite.com/forums

The top of my index page is:

<?php
chdir("../forums/");
require('./global.php');
chdir("../");
?>

and I was sure to change "forum" to "forums" throughout the rest fo the script. I get errors like:

Warning: fopen(./file_info/descriptions/logo_sm.gif.0): failed to open stream: No such file or directory in /home/virtual/site1/fst/var/www/html/download/index.php on line 716 (also 718 and 718)

I have a feeling that the first few lines of the page are what's screwing it up.

The /download/index page reads the downloads directory and lists files in there. It also calls to a subdirectory at downloads/file_info for headers, etc. (it's using PHP Easy Download V0.995 By Paul Alger)

Anybody able to help???

Thanks!!
Reply With Quote
  #71  
Old 08-12-2004, 05:58 PM
klassicd klassicd is offline
 
Join Date: May 2002
Posts: 8
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

chdir("../); should be chdir("../");
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 01:49 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.04715 seconds
  • Memory Usage 2,338KB
  • 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
  • (5)bbcode_php
  • (3)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