vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Vbulletin user info in my frontpage (non-vb page) (https://vborg.vbsupport.ru/showthread.php?t=215546)

TheFrienzNet 06-07-2009 07:37 AM

Vbulletin user info in my frontpage (non-vb page)
 
1 Attachment(s)
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) pointing towards the http://www.tfn.gr/forum 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 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_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>  
                        
        <?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 10: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 11:19 AM

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) ?


All times are GMT. The time now is 09:47 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.02795 seconds
  • Memory Usage 1,731KB
  • 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
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete