Root Path Problems

Discussion in 'PHP' started by Kennedy, Aug 9, 2007.

  1. #1
    I switched to VPS hosting and now I'm having a hard time finding the root path for "include" scripts.

    Its telling me the path is:
    /var/www/vhosts/hyperdeathbabies.com/httpdocs/

    So let's say I go onto another site with the path of:
    /var/www/vhosts/youarehidden.com/httpdocs/

    I create a file that is attempting to do this:

    include('/var/www/vhosts/hyperdeathbabies.com/httpdocs/test.php');

    But it doesn't work. This, however, will:
    include('/var/www/vhosts/youarehidden.com/httpdocs/test.php');

    So there isn't anything wrong with my coding, it just refuses to include a file from another site. Does anyone know why? Is there a way around this?
     
    Kennedy, Aug 9, 2007 IP
  2. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your php installation is probably running in safe mode.

    This is common in shared hosting, else you'd be able to gain access to other people's files.

    run phpInfo() to check
     
    ecentricNick, Aug 10, 2007 IP
  3. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #3
    Try this format

    "/home/httpd/yourdomain/httpdocs/www/your-directory/filename"

    Depending on where you use it the quotes might be single.

    The www may not be required for your server type. Under LxAdmin, it is required.
     
    Colbyt, Aug 10, 2007 IP
  4. Kennedy

    Kennedy Peon

    Messages:
    994
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks, but neither suggestions worked.

    I turned off safe mode and used the other format. Neither worked.
     
    Kennedy, Aug 10, 2007 IP
  5. sarav_dude

    sarav_dude Peon

    Messages:
    10
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Use this :

    echo dirname(__FILE__);

    :)
     
    sarav_dude, Aug 10, 2007 IP
  6. Kennedy

    Kennedy Peon

    Messages:
    994
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That won't help. I'm telling you that I already know the path. Its:

    /var/www/vhosts/hyperdeathbabies.com/httpdocs/

    But when I use it, nothing shows up. But if I change the path to where its still in the directory that I'm in, it works. Let's say I have the file grab.php:

    /var/www/vhosts/youarehidden.com/httpdocs/grab.php

    Its going to open up this file:

    /var/www/vhosts/hyperdeathbabies.com/httpdocs/filetoopen.php

    It doesn't work. But if I open a file in the same directory:

    /var/www/vhosts/youarehidden.com/httpdocs/filetoopen.php

    It works. So I know there isn't anything wrong with the path. The path is perfect. It must be something else...
     
    Kennedy, Aug 11, 2007 IP
  7. Kennedy

    Kennedy Peon

    Messages:
    994
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'd also like to add that I'm using VPS hosting. Could that have something to do with? Maybe what I'm trying to do just isn't possible for me?
     
    Kennedy, Aug 11, 2007 IP
  8. sarav_dude

    sarav_dude Peon

    Messages:
    10
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #8
    as suggested by : ecentricNick

    1. It seems that you dont have permission to access others file. As it is restricted by the shared hosting itself.
    2. Have you confirmed that the file exists on the both domains that you are including ?

     
    sarav_dude, Aug 11, 2007 IP
  9. Kennedy

    Kennedy Peon

    Messages:
    994
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #9
    1. Does that mean I'm screwed?
    2. Yes.
     
    Kennedy, Aug 11, 2007 IP
  10. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #10
    It is early and the coffee has not kicked in. Some clarification please.

    Are you trying trying to use one file (the grab) to open another file?

    If so, the problem may be that the the first file can not find the path to the second file.
     
    Colbyt, Aug 11, 2007 IP
  11. ecentricNick

    ecentricNick Peon

    Messages:
    351
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Your hosting provider has probably set up your php in safe mode. This will prevent you from including files which are not in the same folder or subfolder of the script. In other words, you cannot go back up the folder tree.

    More details...

    http://uk3.php.net/features.safe-mode
     
    ecentricNick, Aug 11, 2007 IP
  12. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #12
    He already said that he tried with safe mode on and off. He is on a VPS.

    Something that occurred to me after the coffee kicked in; I wonder if it could be some with f_open?

    For Kennedy!

    Do you have phpinfo on your VPS? If not just create a file with this content, name it phpinfo.php and run it on your server.

    This will tell you how everything is set, which modules are running, etcetra.
     
    Colbyt, Aug 11, 2007 IP
  13. Kennedy

    Kennedy Peon

    Messages:
    994
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I am using the "require()" method though. Which doesn't work.

    And yes, safe mode is off and I am using the proper path.
     
    Kennedy, Aug 11, 2007 IP