PDA

View Full Version : Vbulletin user info in my frontpage (non-vb page)


TheFrienzNet
06-07-2009, 08:37 AM
Hi there,

I've been googling this for a while now but I can't seem to find an explanation on any other site, neither on vbulletin.org. Vbulletin.com support redirected me here since they do not support 3rd party mods / addons.

I have coded a small .php file to provide user login on my website(http://www.tfn.gr (https://www.vbulletin.com/link.php?u=http%3A%2F%2Fwww.tfn.gr)) pointing towards the http://www.tfn.gr/forum (https://www.vbulletin.com/link.php?u=http%3A%2F%2Fwww.tfn.gr%2Fforum) forum.

The script all by itself works perfectly, however when I try to port it to my OOP-based framework (CodeIgniter) to include it there i suddently get a lot of errors.

Source for simple code:
<?php
chdir("./forum/");
include('./global.php');
include('./includes/functions_user.php');

chdir("../");
?>

<?php
if ($vbulletin->userinfo['userid'] != '0') {
$username=$vbulletin->userinfo['username'];

$avatar_url = fetch_avatar_url($vbulletin->userinfo['userid'],false);
// i assigned the avatar url to the variable $user_av and check to see if it's empty.

print("<align='center'><span class='sectionheader'>Welcome back,".$vbulletin->userinfo['username']."!<br>");
echo '<img src="forum/'.$avatar_url['0'].'" '.$avatar_url['1'].' />';
echo '<br /><br /><br />';
echo '<a href="forum/login.php?do=logout">[logoff]</a>';
} else {
?>
<form action='/forum/login.php' method='post' onsubmit='md5hash(vb_login_password,vb_login_md5pa ssword)'>
<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>

<?php

}

?>The result of this script is shown in the attachment that I uploaded with this thread.

The odd thing is that what I need is working perfectly in a simple .php script but I can't get it ported without showing errors, and i'm pretty sure that I'm porting properly - went over the code 3 times (and it's not like its thousands of lines).

On Vbulletin.org they say that this might be because the code is in a class (object?), however my whole cms is divided in classes.

The error that I get when ported to my cms is the following:

When user is logged in:
Fatal error: Call to a member function query_read_slave() on a non-object in /home2/tfn/public_html/forum/includes/functions.php on line 3189



Anyone has any idea what might be the problem?

Regards,

Erik

Dismounted
06-07-2009, 11:28 AM
global.php cannot be included in any scope other than global scope. Doing so causes the errors you are seeing.

TheFrienzNet
06-07-2009, 12:19 PM
Okay...so are you saying that i should include global.php in the initialisation of my whole CMS a.k.a. where all the base classes are constructed, or even before that? Won't that affect performance (as the only thing i'm trying to recreate is a simple login + welcome back $user - area) ?