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
  #72  
Old 08-14-2004, 08:27 PM
genmud genmud is offline
 
Join Date: Aug 2003
Location: PHOENIX
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

would there be any way to do it so instead of making sure that the user is logged in, it would make sure that (a) the user is logged in, and (b)the user is in a certain group...
Reply With Quote
  #73  
Old 08-19-2004, 05:58 PM
jfreyholtz jfreyholtz is offline
 
Join Date: Dec 2003
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Shouldn't requiring global.php on any page on your site include those users online?

I have it included on all my pages (ie, /blah.php and not just /forum/*.php), and have login enabled for all pages (which works great), but those users aren't showing up in the Whos Online piece on the forum.

Any ideas why it doesn't?
Reply With Quote
  #74  
Old 08-21-2004, 01:59 AM
Jargon Jargon is offline
 
Join Date: Apr 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Its still not showing Welcome Back, Username! any ideas?

http://www.liquid-core.net/user2.php

That is the page im testing the code on. You can login but when it redirects you you get the same Guest message.

Here is the code I am currently using.

PHP Code:
<?php 
error_reporting
(7); 
////////////////////////////////////// 
// You need to EDIT your PATHS or this will not WORK properly 
////////////////////////////////////// 
chdir('/home/*****/public_html/forums'); 
require_once(
'/home/*****/public_html/forums/global.php');  
?>
<?php
////////////////////////////////////// 
// No need to edit anything just yet please scroll down
////////////////////////////////////// 
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user ORDER BY joindate DESC LIMIT 1");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];
$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);
// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);
$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);
// Top poster
$topposters=$DB_site->query_first("SELECT username,posts,userid FROM user ORDER BY posts desc LIMIT 1");
// Top Threads starter
$toptstarter=$DB_site->query_first("SELECT COUNT(*) AS count,postuserid,postusername FROM thread GROUP BY postuserid ORDER BY count DESC LIMIT 1");
//Get Latest Posts
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
//check usergroup of user to see if they can use PMs
//$permissions=getpermissions($forumid);
if ($enablepms==and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
  
$ignoreusers="";
  if (
trim($bbuserinfo['ignorelist'])!="") {
    
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' 'trim($bbuserinfo['ignorelist'])));
  }
  
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
  
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");
  if (
$newpm['messages']==0) {
    echo 
"";
  } else {
    echo 
"";
  }
} else {
  
$pminfo='';
}

//////////////////////////////////////////////////////////////////
//     STEP #1
//////////////////////////////////////////////////////////////////
//Please Enter the Full Path to the functions_user.php file
//////////////////////////////////////////////////////////////////
//
require_once('/home/*****/public_html/forums/includes/functions_user.php');
//
//////////////////////////////////////////////////////////////////
$indexpage true;
$bbuserinfo['avatarurl'] =
fetch_avatar_url($bbuserinfo['userid']);
$newposts $DB_site->query_first("
    SELECT COUNT(*) AS count
    FROM "
.TABLE_PREFIX."post
    WHERE dateline > '"
.$bbuserinfo['lastvisit']."'
"
);
$activethreads $DB_site->query_first("
    SELECT COUNT(*) AS count
    FROM "
.TABLE_PREFIX."thread
    WHERE lastpost > '"
.$bbuserinfo['lastvisit']."'
"
);
// ########## \\__> Added from Hwulex's Welcome Hack THANKS!!!<__// ########## \\
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
if (
$bbuserinfo['userid']!=0) {
  
$username=$bbuserinfo['username'];
 
 
//////////////////////////////////////////////////////////////////
//     STEP #2                                                  // 
//////////////////////////////////////////////////////////////////
//BEGIN HTML OUTPUT                                                   
//BE SURE TO LEAVE THE ECHO Strings in place                          
//Any Quotation marks need to have a \ before them                    
//////////////////////////////////////////////////////////////////
///////
// THE FOLLOWING IS THE HTML.  YOU MAY CHANGE THE HTML IF YOU MUST    
// Keep the strings intact and dont use quotation marks               
// A \ in front of them other wise you will get PARSE ERRORS!!!!!!
// THIS SECTION IS THE NAV LINKS AND THE LEFT COLUMN FOR THE TABLE    
// Leave All the ECHO tags Alone as well
//////////////////////////////////////////////////////////////////
///////
//////////////////////////////////////////////////////////////////
echo "


<table width=720><tr><td width=100% colspan=3 align=center valign=top>
<font size=1 face=verdana><a href="http://www.liquid-core.net/forums/private.php?s=
$session[sessionhash]" target="_parent"><b>Goto Your Inbox</b></a> |
<font size=1 face=verdana><a href="http://www.liquid-core.net/usercp.php?s=" target="_parent"><b>Control Panel</b></a> |
<a href="http://www.liquid-core.net/forums/search.php?s=
$session[sessionhash]&do=getnew" target="_parent"><font size="1" face="verdana" target="_parent">View New Posts</font></a> |
<a href="http://www.liquid-core.net/forums/login.php?s=
$session[sessionhash]&do=logout" target="_parent"><font size="1" face="verdana">Proceed to Log Out</font></a>
</td></tr><tr><td width=10%><a href="http://www.liquid-core.net/forums/profile.php?
$session[sessionurl]&do=editavatar"><img src="$bbuserinfo[avatarurl]" border="0"></a></td><td width=50%>

<font size=1 face=verdana>Welcome Back, <b>
$username!</b><br> There have been $activethreads[count] threads and $newposts[count] posts since your last visit! <br>
<font size=1 face=verdana>There is currently: <b>
$numbermembers</b> members with a total of <b>$totalposts</b> posts and <b>$totalthreads</b> threads.<br>
<font size=1 face=verdana><b>
$bbuserinfo[username]</b> - You have $bbuserinfo[pmunread] new message(s) since your last visit.<br>
<font size=1 face=verdana>(You have 
$bbuserinfo[pmunread] unread messages and $bbuserinfo[pmtotal] total messages in all your folders.


)"
;
////////////////////
//Leave This Alone//
////////////////////
} else {
/////////////////////
// STEP #3         //
//Guest Column Edit//
// Dont Forget to  //
// Change the Urls //
// IN the FORM     //
/////////////////////
echo "


<table width=720><tr><td width=10%>
$avatarimage</td><td width=50%>
<font size=1 face=verdana>Welcome Guest!<br><table width=100% border=0 cellpadding=0 cellspacing=0>
<font size=1 face=verdana>

If this is your first visit, be sure to read the <a href="http://www.liquid-core.net/forums/faq.php?s=
$session[sessionhash]" target="_parent">
<b>FAQ</b></a>.  You have to <a href="http://www.liquid-core.net/forums/register.php?s=
$session[sessionhash]"
target="_parent"><b>register</b></a>  before you can post on our forums or interact with our growing community.


  <form action="http://www.liquid-core.net/forums/login.php" method="post" onsubmit="md5hash(vb_login_password,vb_login_md5password)">
        <script type="text/javascript" src="http://www.liquid-core.net/forums/clientscript/vbulletin_md5.js"></script>
        <table cellpadding="0" cellspacing="3" border="0">
        <tr>
            <td><font size=1 face=verdana>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 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" /><font size=1 face=verdana>Remember Me?</label></td>
        </tr>
        <tr>
            <td><font size=1 face=verdana>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" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" /></td>
        </tr>
        </table>
        <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" />
        </form>

"
;

/////////////////////
//Leave This Alone //
/////////////////////
}
///////////////////////////////
// STEP #4                   //
// BEGIN RIGHT COLUMN HTML OUTPUT//
// NO QUOTATION MARKS PLEASE //
// You Can Edit This now     //
///////////////////////////////
echo "


</td>
<td width=40% align=right>
<font size=1 face=verdana>Newest member <a
href="http://www.liquid-core.net/forums/member.php?s=&action=getinfo&userid=
$newuserid">$newusername</a><br>
<font size=1 face=verdana>The Current Top Poster is: <a href=http://www.liquid-core.net/forums/member.php?&action=getinfo&userid=
$topposters[userid]>
<b>
$topposters[username]</b></a></font>($topposters[posts])<br>
<font size=1 face=verdana>The Current Top Thread Starter is: <font color=red>
<a href=http://www.liquid-core.net/forums/member.php?&action=getinfo&userid=
$toptstarter[postuserid]><b>$toptstarter[postusername]</b></font>
</a>(
$toptstarter[count])</td></tr></table>


"
;
?>
Reply With Quote
  #75  
Old 08-25-2004, 11:25 PM
AlexSFBay AlexSFBay is offline
 
Join Date: Jan 2004
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This hack is GREAT, but I was wondering if anyone figured out a way to not have users on non-vB pages showing up on the forum's "Who's Online" page, which results in:

Guest | Unknown Location (followed by the non-vB page URL)

* I tried closing the script hack by adding mysql_close (); to the end of the script, but it didn't change anything. Any suggestions?
Reply With Quote
  #76  
Old 08-27-2004, 02:00 PM
Tayeb Tayeb is offline
 
Join Date: Sep 2002
Posts: 25
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello all:

I have a login system working outside vb actually under phpnuke and am at at the moment refining it, to release the hack next week as my new contribution to vbulletin.org.

The ideas can be used in other portal system. If you want to have a look at the login check at:

http://www.myiwc.com

Reply With Quote
  #77  
Old 08-29-2004, 07:49 PM
Jargon Jargon is offline
 
Join Date: Apr 2004
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah its still not working. Anyone have a better version?
Reply With Quote
  #78  
Old 08-31-2004, 02:50 PM
stan68 stan68 is offline
 
Join Date: Sep 2003
Posts: 22
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by WishER
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!
This worked Great ty for the info
the machine

heres a screenshot since most of you won't see anything

Reply With Quote
  #79  
Old 09-12-2004, 06:26 AM
kelangtri kelangtri is offline
 
Join Date: Oct 2002
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

stan68, do u can share ur homepage, i can creat a info.php page, but i dont include it to my homepage, .html page , so sad
Reply With Quote
  #80  
Old 09-26-2004, 05:17 AM
nhatrang nhatrang is offline
 
Join Date: Jun 2004
Posts: 68
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is an easy script but why is it soo hard? hehehe
Reply With Quote
  #81  
Old 10-12-2004, 01:06 AM
csimo csimo is offline
 
Join Date: Jul 2003
Posts: 7
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No longer needed.
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:43 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.05145 seconds
  • Memory Usage 2,394KB
  • 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
  • (6)bbcode_php
  • (1)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