vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   possible to include(global.php) in a class? (https://vborg.vbsupport.ru/showthread.php?t=148456)

SaltedSlug 05-30-2007 05:48 AM

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

Dismounted 05-30-2007 07:19 AM

Instead of include_once, try require_once.

byon 05-30-2007 10:45 AM

Quote:

Originally Posted by Dismounted (Post 1257419)
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! :D

Dismounted 05-31-2007 11:36 AM

Quote:

Originally Posted by byon (Post 1257493)
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.

SaltedSlug 05-31-2007 02:51 PM

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.

Dismounted 06-01-2007 10:32 AM

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 



All times are GMT. The time now is 04:58 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.01097 seconds
  • Memory Usage 1,730KB
  • 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
  • (2)bbcode_code_printable
  • (3)bbcode_php_printable
  • (2)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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