vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   External Page Login and Variables (https://vborg.vbsupport.ru/showthread.php?t=268781)

punterzone 08-19-2011 04:56 PM

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

Vincinzerei 08-19-2011 05:09 PM

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

punterzone 08-19-2011 05:16 PM

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. :confused:

I'm actually beginning to wonder if this is possible? It must be though.

Vincinzerei 08-19-2011 05:31 PM


punterzone 08-19-2011 05:32 PM


Vincinzerei 08-19-2011 05:40 PM


punterzone 08-19-2011 05:47 PM

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?

Vincinzerei 08-19-2011 05:53 PM


punterzone 08-19-2011 05:55 PM


Vincinzerei 08-19-2011 05:57 PM

you are using vbulletin 4 and create the template with the template system or using an extern php/html file?


All times are GMT. The time now is 03:16 AM.

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.01037 seconds
  • Memory Usage 1,753KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (7)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete