+ Reply to Thread
Results 1 to 8 of 8

Thread: open_basedir restriction in effect. help?

  1. #1
    werezwolf's Avatar
    werezwolf is offline x10Hosting Member werezwolf is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    Australia - QLD
    Posts
    8

    Post open_basedir restriction in effect. help?

    hi all heres a problem i cant understand

    Site Structure: (only showing part of the structure)
    WWW/
    Config/ (755)
    config.php (644)
    functions.php (644)
    index.php (644)
    ------------------------------
    the file works fine on my home test server but here it through up this.

    Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(/../Config/functions.php) is not within the allowed path(s): (/home/:/tmp) in /home/werezwol/public_html/Config/Config.php on line 21

    Warning: require_once(/../Config/functions.php) [function.require-once]: failed to open stream: Operation not permitted in /home/werezwol/public_html/Config/Config.php on line 21

    Fatal error: require_once() [function.require]: Failed opening required '/../Config/functions.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/werezwol/public_html/Config/Config.php on line 21

    --------------------------------

    The nice line of code behind it. As you can guess yes this is the backbone file of my site nothing works without this.
    PHP Code:
    <?php
    //THIS IS CONFIG.PHP
        //Define Site Name
        
    $site 'The Site';
        
    $style 'DarkFantasy'// Warning: Changing the style set may alter site layout in unwanted ways.
        
        //------ Do Not Change Below ------//
        
        //Define DIR Listings - absolute path
        
    define('MAINDIR',"/.."); // this goes from /config/config.php to / or full path as /config/../
            
    define('Config_DIR',MAINDIR '/Config'); // full path as /config/../config/
                
    define('Config_img_Dir',Config_DIR '/images');
            
    define('BB_DIR',MAINDIR '/bb');
                
    define('BB_style',BB_DIR "/styles/$style");
                    
    define('BB_theme',BB_style '/theme/images');
                    
    define('BB_imgset',BB_style '/imageset/en');
        
        
    //Define Var
        
    define('SITE',$site);
        
        
    //Require Variables, Functions & Template
        
    require_once(Config_DIR '/functions.php');
        require_once(
    Config_DIR '/template.php');

    ?>
    Last edited by werezwolf; 03-20-2010 at 12:09 AM.

  2. #2
    misson is online now Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: open_basedir restriction in effect. help?

    The leading slash means the MAINDIR path is absolute. The root directory is its own parent, so '/..' is equivalent to '/', which means Config_DIR is '/Config', BB_DIR is '/BB' &c. All of these are outside the '/home' and '/tmp' branches (not to mention non-existent) and thus blocked by the open_basedir restriction. To resolve, remove the leading slash or (more correctly) set MAINDIR to $_SERVER['DOCUMENT_ROOT'].
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    werezwolf's Avatar
    werezwolf is offline x10Hosting Member werezwolf is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    Australia - QLD
    Posts
    8

    Re: open_basedir restriction in effect. help?

    /.. is the directory up yes?. the config.php file isen't on the root dir but in the folder /config/. so it should work.

    i did post my sites structure up using tab indenting to simulate tree structure with current file permissions ive also added more comments to code above to show this.

    Site Structure:
    (only showing part of the structure)
    WWW/ ( /home/werezwol/public_html/ aka root dir)
    Config/ (755)
    config.php (644)
    functions.php (644)
    index.php (644)
    im also receiving errors apart from index.php any other files on it don't exist at all. all files have the default permissions of 644 and reside on root dir like the index.php (the links work on my local server)

    also my links use this absolute path to all links correct go to its destination when i use $_SERVER['DOCUMENT_ROOT'] things get messed up example www.name.exofire.com/home/werezwol/public_html/index.php. using my path it goes to www.name.exofire.com/index.php

    www.name.exofire.com is an example site

    as i have said i have tested this tree structure and it correctly displays and imported it all via a zip file all structural integrity has not been changed.
    Last edited by werezwolf; 03-20-2010 at 12:10 AM.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,267

    Re: open_basedir restriction in effect. help?

    Funny. You asked a question.
    You were given an answer by one of the most knowledgeable posters on this forum.
    But since it wasn't the answer you wanted, you didn't even bother to try his solution?
    Why ask?

    If you don't believe that the leading slash is a problem on a Linux box, put this scriptlet in Config and run it from the server.

    PHP Code:
    <?php

    $path_slash 
    '/../Config/functions.php'  ;
    $path_slashless '../Config/functions.php'  ;

    echo 
    "With slash : " ;

    echo 
    realpath(  $path_slash  );

    echo 
    "  <-<br />\n" ;

    echo 
    "Without slash : " ;

    echo 
    realpath(  $path_slashless  );

    ?>
    Nothing is always absolutely so.

  5. #5
    werezwolf's Avatar
    werezwolf is offline x10Hosting Member werezwolf is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    Australia - QLD
    Posts
    8

    Re: open_basedir restriction in effect. help?

    if i do that i get the following:

    Warning
    : require_once(../Config/functions.php) [function.require-once]: failed to open stream: No such file or directory in /home/werezwol/public_html/Config/Config.php on line 22

    Fatal error: require_once() [function.require]: Failed opening required '../Config/functions.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/werezwol/public_html/Config/Config.php on line 22

    this error also occurs on my local server thats why i added the / in front. i would of posted the result of your test debug code but i cant access any files other then my index.php on the root (permissions still have not been changed.) since i receive:

    The page you requested is not available, please try again in a few minutes. Alternatively you can use the form below to find what you are looking for.
    Registering an account with us is easy and free, sign up today!

    i appreciate the help but im just clearing things up and kinda disappointed that i could not just export it on to the server with out problems. the error above may have something to do with it i'm not sure. could anyone direct me to a permissions explanation page i need to find out why some files apparently don't exist.
    Last edited by werezwolf; 03-20-2010 at 02:22 AM.

  6. #6
    misson is online now Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: open_basedir restriction in effect. help?

    Quote Originally Posted by werezwolf View Post
    /.. is the directory up yes?.
    No. Each directory has a ".." entry, which refers to the parent of that directory, except in the root directory where it refers to the root directory. If a path begins with "..", such as in "../Config", it's the parent of the current directory. In "/home/werezwol/public_html/bb/../Config", ".." refers to the parent of "bb", which is "public_html"; thus the path is equivalent to the canonical path "/home/werezwol/public_html/Config". In "/../Config", ".." is the parent of "/", which is the root directory; thus the path is equivalent to "/Config", which doesn't exist on the X10 servers.

    Setting MAINDIR to "/.." is definitely wrong. Setting it to ".." is mostly wrong, because it will only work in subdirectories of the doc root. It won't work in the doc root and it won't work in descendants of subdirectories of the doc root.

    Quote Originally Posted by werezwolf View Post
    the config.php file isen't on the root dir but in the folder /config/. so it should work.
    The file path "/config" doesn't exist, an neither does "/Config" (the various versions of extfs, the primary file systems used under Linux, are case sensitive).

    Quote Originally Posted by werezwolf View Post
    /home/werezwol/public_html/ aka root dir
    No. "/home/werezwol/public_html/" is the document root for your site. The root directory has the absolute path "/".

    Quote Originally Posted by werezwolf View Post
    also my links use this absolute path to all links correct go to its destination when i use $_SERVER['DOCUMENT_ROOT'] things get messed up example www.name.exofire.com/home/werezwol/public_html/index.php.
    Then you're mixing filesystem paths with URL paths. URLs and filesystems are different namespaces. MAINDIR can only refer to a path in one of these namespaces. include, require, include_once and require_once, as well as many other server side functions, use filesystem paths. virtual and anything client side, such as links, use URL paths.

    Since functions.php and template.php are in the same directory as Config.php, don't bother prefixing either with a path.
    PHP Code:
    // Config.php
    ...
    require_once(
    'functions.php');
    require_once(
    'template.php'); 
    Last edited by misson; 03-20-2010 at 04:22 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  7. #7
    werezwolf's Avatar
    werezwolf is offline x10Hosting Member werezwolf is an unknown quantity at this point
    Join Date
    Jun 2009
    Location
    Australia - QLD
    Posts
    8

    Re: open_basedir restriction in effect. help?

    Ah i see now.

    Thanks for that. still using the /.. for links only it works because its relative from config.php. Also thanks for saying that everything case sensitive fixed most of my problems. could there be anyway i can set my local server to use absolute file paths instead. using Wamp install has Apache 2.2.11 and PHP 3.5.

    now i just got to go through my CSS ><

    anyway this problems is
    RESOLVED

    Thank you all

  8. #8
    misson is online now Community Advocate misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,391

    Re: open_basedir restriction in effect. help?

    For links (URL paths), all you need as a base is "/". The URL "http://www.name.exofire.com/../bb/" is the same as "http://www.name.exofire.com/bb/", as per RFC 3986 § 6.2.2.3 Path Segment Normalization and 5.2.4 Remove Dot Segments.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. open_basedir restriction
    By kntriga in forum Free Hosting
    Replies: 2
    Last Post: 03-07-2010, 01:58 PM
  2. How to turn of php:open_basedir
    By nitin800 in forum Free Hosting
    Replies: 1
    Last Post: 01-31-2010, 11:34 AM
  3. open_basedir(php parameter)
    By perelkosher in forum Free Hosting
    Replies: 5
    Last Post: 11-14-2009, 04:36 PM
  4. open_basedir restriction in effect?
    By waveking in forum Free Hosting
    Replies: 5
    Last Post: 06-12-2006, 08:59 AM
  5. open_basedir restriction??
    By oab in forum Free Hosting
    Replies: 3
    Last Post: 06-19-2005, 08:38 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers