Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 08-19-2011, 04:56 PM
punterzone punterzone is offline
 
Join Date: Mar 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default External Page Login and Variables

Hey,

I'm looking to make a login form whereby I can login using a page on the root (as opposed to the forums which are located at /forum).

I've managed to make a login form that logs the user in, and redirects them back to the root, and they are logged in. What I can't get to work though, is getting access to the vB variables (to show username, avatar etc).

If I include global.php then the login form doesn't work. I've been at this for ages and just can't seem to get it to work. Was wondering if anyone has got this to work?

Just to clarity, I have other pages outside the forum which I would like people to be able to navigate around whilst logged in, and be shown as logged in, and have access to their user variables.

Here's the code I have:

PHP Code:
        <form action="forum/login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
        <
script type="text/javascript" src="forum/clientscript/vbulletin_md5.js?v=367"></script>
        <
table cellpadding="0" cellspacing="0" border="1">
        <
tr>
            <
td>User Name</td>
            <
td><input type="text" name="vb_login_username" id="navbar_username" /></td>
            <
td colspan="2"><input type="checkbox" name="cookieuser" value="1" id="cb_cookieuser_navbar" />Remember Me?</td>
        </
tr>
        <
tr>
            <
td>Password</td>
            <
td><input type="password" name="vb_login_password" id="navbar_password" /></td>
            <
td><input type="submit" value="Log in" /></td>
        </
tr>
        </
table>
        <
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
That works fine to login, and redirects back to my test.php file. BUT if I add the following to the file it fails:
PHP Code:
chdir('/home/pzone/public_html/forum/'); 
require_once(
'/home/pzone/public_html/forum/global.php'); 
Thanks
Reply With Quote
  #2  
Old 08-19-2011, 05:09 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

try with the require once the location the file is from your calling file.
like
PHP Code:
require_once('global.php'); 
or
PHP Code:
require_once('./global.php'); 
in your case you called
PHP Code:
forum/login.php
so..
PHP Code:
require_once('forum/global.php'); 
would be my best bet
Reply With Quote
  #3  
Old 08-19-2011, 05:16 PM
punterzone punterzone is offline
 
Join Date: Mar 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The strange thing is, as soon as I do that, the login won't work

Here's my fill code now:

PHP Code:
<?php 
chdir
('/home/pzone/public_html/forum/'); 
require_once(
'global.php');  
?>
<script type="text/javascript" src="forum/clientscript/vbulletin_md5.js?v=367"></script>
<form action="forum/login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)">
<table cellpadding="0" cellspacing="0" border="1">
<tr>
    <td>User Name</td>
    <td><input type="text" name="vb_login_username" /></td>
    <td><input type="checkbox" name="cookieuser" />Remember?</td>
</tr>
<tr>
    <td>Password</td>
    <td><input type="password" name="vb_login_password" /></td>
    <td><input type="submit" value="Log in" /></td>
</tr>
</table>
<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>
<?
if($vbulletin->userinfo['userid']!=0){echo "yes";}else{echo "no";}
?>
Now, if I remove the PHP at the top, the login works (I only know by viewing the actual forum, the $vbulletin->userinfo thing always shows no).

As I say though, when I add that PHP at the top, it doesn't even login. Any help would be greatly appreciated.

I'm actually beginning to wonder if this is possible? It must be though.
Reply With Quote
  #4  
Old 08-19-2011, 05:31 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #5  
Old 08-19-2011, 05:32 PM
punterzone punterzone is offline
 
Join Date: Mar 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #6  
Old 08-19-2011, 05:40 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #7  
Old 08-19-2011, 05:47 PM
punterzone punterzone is offline
 
Join Date: Mar 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Not 100% with you here.

My forum is at /forum
My test.php script to login is at /test.php

What should I put at the top to allow me to access the variables?
Reply With Quote
  #8  
Old 08-19-2011, 05:53 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #9  
Old 08-19-2011, 05:55 PM
punterzone punterzone is offline
 
Join Date: Mar 2010
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Reply With Quote
  #10  
Old 08-19-2011, 05:57 PM
Vincinzerei Vincinzerei is offline
 
Join Date: Jun 2010
Posts: 30
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

you are using vbulletin 4 and create the template with the template system or using an extern php/html file?
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 02:22 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05930 seconds
  • Memory Usage 2,273KB
  • Queries Executed 11 (?)
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
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)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