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

Reply
 
Thread Tools Display Modes
  #1  
Old 05-30-2007, 05:48 AM
SaltedSlug's Avatar
SaltedSlug SaltedSlug is offline
 
Join Date: Mar 2004
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default possible to include(global.php) in a class?

Hello, here's my test case (php4):

Test.php
PHP Code:
<?
class Test {
    function Test() {
       $cwd = getcwd(); 
       chdir($_SERVER['DOCUMENT_ROOT'].'/talk');  
         include_once('global.php');
         chdir($cwd);
    }
    function Whoami() {
        global $vbulletin;
        return $vbulletin->userinfo["username"];
    }
}
?>

dotest.php
PHP Code:
<?
include("Test.php");
$dotest = new Test;
echo($dotest->Whoami());
?>
always dies with:
Code:
Fatal error: Call to a member function on a non-object in 
(snip)talk/includes/functions.php on line 1154
The constructor in the class always dies at the include statement, Whoami is never called.
Is it possible to create a $vbulletin registry object inside of a class?

I did a search and attempted using the solution proposed Here by kolita, and that gives me a vbulletin object that has all the standard properties and that I can enumerate, but only if I skip creating a session (meaning my userinfo array is empty), and this is useless for me.

i.e. if I comment out
Code:
define('SKIP_SESSIONCREATE', 1);
I get the same error as above.

Anyone have some insight? I'm trying to build a amfphp connector to vbulletin and i'm truly stumped. thanks
Reply With Quote
  #2  
Old 05-30-2007, 07:19 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Instead of include_once, try require_once.
Reply With Quote
  #3  
Old 05-30-2007, 10:45 AM
byon byon is offline
 
Join Date: Apr 2007
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dismounted View Post
Instead of include_once, try require_once.
How would include_once be different from require_once? i guess your statement was, Instead of include, try require_once. yeah?

Sorry to hijack this thread, but it would be more logical to type here then creating another unnecessary thread.


thanks!
Reply With Quote
  #4  
Old 05-31-2007, 11:36 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by byon View Post
How would include_once be different from require_once?
Include continues regardless if the file was found or not. Require spits out an error and stops execution if it doesn't find the file.
Reply With Quote
  #5  
Old 05-31-2007, 02:51 PM
SaltedSlug's Avatar
SaltedSlug SaltedSlug is offline
 
Join Date: Mar 2004
Posts: 26
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For the purposes of this thread there's no difference between include, require, include_once and require_once.

Note that the error is not occuring in either of the files defined above - but instead in functions.php which is part of the vbulletin inner-workings. This means that the include/require is working up until the point where something about it being inside of a class construct makes Vbulletin go haywire.
Reply With Quote
  #6  
Old 06-01-2007, 10:32 AM
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Location: Melbourne, Australia
Posts: 15,047
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What version of vBulletin are you using? Line 1154 in 3.6.7 PL1 is part of a comment:
PHP Code:
* @return    array    The information for the requested user 
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 07:32 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.04804 seconds
  • Memory Usage 2,218KB
  • Queries Executed 13 (?)
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
  • (2)bbcode_code
  • (3)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (6)post_thanks_box
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (6)post_thanks_postbit_info
  • (6)postbit
  • (6)postbit_onlinestatus
  • (6)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_postinfo_query
  • fetch_postinfo
  • 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
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete