Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 01-15-2004, 12:34 PM
Swedie's Avatar
Swedie Swedie is offline
 
Join Date: Feb 2002
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default PHP: includig global.php outside of forum

Okay, including the global.php file isn't all that hard, but what I've noticed is a problem is that ANYTHING put in a $string before I include the global.php is removed / dumped and ... NULL... this messes up my scripts. I need to figure out a way of keeping the value of a $string I set before the inclusion..

please help me with this.

Okay, to detail the issue a little, here is my header.php file:

$currentdir = $_SERVER['DOCUMENT_ROOT'];

chdir("/home/sporthoj.com/www/www.sporthoj.com/forum");
require("./global.php");
if($currentdir) {
chdir("$currentdir");
}
else
{
chdir("/home/sporthoj.com/www/www.sporthoj.com");
}

You might see what I am trying to do. I am including the global.php file from other directories and need to return back to the original directory. but it just don't work because the value of $currentdir is set to NULL after the global.php file has been loaded.

How I know:
Because if I echo $currentdir before requre() there is a value inside it. But when I echo AFTER require, the value of $currentdir is no longer present.
Reply With Quote
  #2  
Old 01-15-2004, 12:38 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
define('CURRENT_DIR'$_SERVER['DOCUMENT_ROOT']);

chdir('/home/sporthoj.com/www/www.sporthoj.com/forum');

require(
'./global.php');

if(
CURRENT_DIR) {
    
chdir(CURRENT_DIR);
} else {
    
chdir('/home/sporthoj.com/www/www.sporthoj.com');

Not sure why you have the if statement as its not really needed. Anyway the above example will work as vB unsets the majority of variables at the start of the script for safety reasons.
Reply With Quote
  #3  
Old 01-15-2004, 02:26 PM
Swedie's Avatar
Swedie Swedie is offline
 
Join Date: Feb 2002
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks, but CURRENT_DIR is empty when I try to echo it with: echo CURRENT_DIR();
It gives me: Fatal error: Call to undefined function: current_dir() in /home/sporthoj.com/www/www.sporthoj.com/top.php on line 16

and I am not returned to the original dir.

so apparently vB also unsets any define values as well?

I am using vBulletin v3.0 RC2.

There has to be a way?
Reply With Quote
  #4  
Old 01-15-2004, 02:27 PM
NTLDR's Avatar
NTLDR NTLDR is offline
Coder
 
Join Date: Apr 2002
Location: Bristol, UK
Posts: 3,644
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

CURRENT_DIR isn't a fucntion, its a constant, echo CURRENT_DIR; will work
Reply With Quote
  #5  
Old 01-15-2004, 02:36 PM
KuraFire's Avatar
KuraFire KuraFire is offline
 
Join Date: Oct 2001
Location: inside vB3's .php
Posts: 1,245
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Swedie
thanks, but CURRENT_DIR is empty when I try to echo it with: echo CURRENT_DIR();
It gives me: Fatal error: Call to undefined function: current_dir() in /home/sporthoj.com/www/www.sporthoj.com/top.php on line 16

and I am not returned to the original dir.

so apparently vB also unsets any define values as well?

I am using vBulletin v3.0 RC2.

There has to be a way?
constants are CaSe SenSiTive. A define() is a creation of a CONSTANT, and thus don't treat it as a function (never add () after it), as well making sure you're using the exact same, case-sensitive name.
Reply With Quote
  #6  
Old 01-16-2004, 01:15 PM
Swedie's Avatar
Swedie Swedie is offline
 
Join Date: Feb 2002
Posts: 292
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KuraFire
constants are CaSe SenSiTive. A define() is a creation of a CONSTANT, and thus don't treat it as a function (never add () after it), as well making sure you're using the exact same, case-sensitive name.
Thank you for clearing that up.

I have now noticed that since I do:
define('CURRENT_DIR', $_SERVER['DOCUMENT_ROOT']);
inside the include file that is outside of the directory that I am actually in, the value of CURRENT_DIR is the one that my header.php file is in... always.

Is there a way to go around this or would I have to specify the value of CURRENT_DIR inside the file that calls the header file? That would be a pain in the butt and would make the function kind of worthless for me.
Reply With Quote
Reply

Thread Tools
Display Modes

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 05:56 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08442 seconds
  • Memory Usage 2,207KB
  • Queries Executed 11 (?)
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
  • (1)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_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