vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   How to include global.php from up two directories and down one directory (https://vborg.vbsupport.ru/showthread.php?t=220284)

RoxUrSox 08-06-2009 12:54 AM

How to include global.php from up two directories and down one directory
 
I got two files

/home/flowgrap/public_html/ig/cp/includes/cookie.php
PHP Code:

<?php // session is already started in file that includes this one
if ( !isset($_SESSION['user']) ){
    
// ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . '/home/flowgrap/public_html/ig/forums/');
    // echo "<!-- " . ini_get('include_path') . " -->";
    // $path = "/home/flowgrap/public_html/ig/forums/";
    // set_include_path(get_include_path() . PATH_SEPARATOR . $path);

    
include("global.php");

    
$userid $bbuserinfo['userid'];
    if ( 
$userid ) {
        
$_SESSION["user"] = $bbuserinfo['username'];
    }
}
?>

I tried setting the include path, and it showed up in the error saying the include path the forums correctly, but it still gave me:
Code:

Warning: require_once(/home/flowgrap/public_html/ig/cp/includes/init.php) [function.require-once]: failed to open stream: No such file or directory in /home/flowgrap/public_html/ig/forums/global.php on line 20

Fatal error: require_once() [function.require]: Failed opening required '/home/flowgrap/public_html/ig/cp/includes/init.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/flowgrap/public_html/ig/forums') in /home/flowgrap/public_html/ig/forums/global.php on line 20

/home/flowgrap/public_html/ig/forums/global.php
Code:

The Normal VBulletin 3.8.1 global.php Code here

So I understand that it's trying to require the files from inside my current directory, even though I changed the include path. How do I fix it so that the global.php loads the vbulletin files in the vbulletin directory, instead of the current one?

1Unreal 08-06-2009 06:02 AM

PHP Code:

include("./global.php"); 


Dismounted 08-06-2009 06:08 AM

PHP Code:

$curdir getcwd();
chdir('/home/flowgrap/public_html/ig/forums');
require_once(
'./global.php');
chdir($curdir); 


RoxUrSox 08-08-2009 06:42 PM

Quote:

Originally Posted by Dismounted (Post 1862370)
PHP Code:

$curdir getcwd();
chdir('/home/flowgrap/public_html/ig/forums');
require_once(
'./global.php');
chdir($curdir); 


Thanks, your code works. I did try chdir before, but apparently it requires the full path, didn't know that :P


All times are GMT. The time now is 08:23 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.00988 seconds
  • Memory Usage 1,736KB
  • 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
  • (4)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)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