#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    31
    Rep Power
    3

    Relative paths no longer working


    I am developing a site that is partly built on top of CodeIgniter and the other part is using a hacked version of wordpress. So, what I've done is "injected" CI functionality into the wordpress by including a global bootstrap via a plugin. The bootstrap defines some constants, loads some functions and does the following to create a $CI object:

    PHP Code:
    // Load it only for Wordpress and Elgg
    if ( PN_ENVIRONMENT !== 'codeigniter' ) {
        
    ob_start();
        require(
    PN_COMMONPATH '/ci-core/pn-ci-inject.php'); 
        
    ob_end_clean();
        
    $GLOBALS['CI'] = get_instance();

    the pn-ci-inject file loads codeigniter using a blank controller. I then flush the buffer, which wonderfully allows me to use

    global $CI

    to access libraries, helpers, etc.

    However, when I did this, something strange broke. Now, in wordpress, my relative paths are not working. So,

    require('./admin.php');

    or

    require('../../whatever.php');

    produces fatal errors. However, when I replace the paths with constants I've set with the absolute paths, everything works wonderfully. Again, these relative paths worked fine until I created the $CI object.

    I really, really, don't want to go through all of wordpress and replace all relative with absolute paths. What did I do? Does anyone have any idea what this is about?

    Thanks all.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    You can use the chdir function to change the active directory.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo