The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Include Problem

Discussion in 'General Discussion' started by ManXP, Jul 15, 2008.

  1. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    I have some strange problems including files from other accounts on cPanel server. This server is NOT managed by me, so I need some suggestions what could be wrong. Here is my code:


    include_once(/home/aaa/public_html/file.php);


    And I get this error - Warning: include_once(/home/aaa/public_html/file.php) [function.include-once]: failed to open stream: Permission denied

    Warning: include_once() [function.include]: Failed opening '/home/aaa/public_html/file.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php'


    I checked /home/aaa/public_html/file.php and permissions/ownership is OK. open_basedir protection is disabled. What else could be wrong?

    Trying to delete and re-create account "aaa" (so it got new files) didn't solve problem
     
  2. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Is the server running SuPHP?

    Note, if you do not have root access to the server, you really should be contacting your hosting provider regarding these issues.
     
  3. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    I just got root access. Server was running SuPHP, and I disabled it now, but problem still exists
     
  4. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Who owns the PHP script that is doing the include?

    Who owns the file /home/aaa/public_html/file.php?

    What are the permissions on the /home/aaa/public_html/file.php file?
     
  5. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    /home/aaa/public_html/file.php is owned by aaa

    /home/aaa/public_html/file.php has permissions 644
     
  6. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    The file that contains the code:

    PHP:
    include_once("/home/aaa/public_html/file.php");
    Who owns that file?
     
  7. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    This file is owned by user where file is located, of course.

    I just checked all permissions once again and everything is perfect. I even created new accounts, uploaded new files, and issue still exists - files could not be included from other users. Like I said, open_basedir is disabled at all.
     
  8. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    So another words the PHP script is not owned by the user aaa?
     
  9. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    PHP scripts are owned by users where scripts are located.

    For example, /home/aaa/public_html/file.php is owned by "aaa".


    Let's say I include this file from /home/abc/public_html/test_include.php. In this case /home/abc/public_html/test_include.php is owned by user "abc".


    Same scripts work fine on 13+ servers
     
  10. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    This has to do with the permissions of the parent folder of the file you are trying to include.

    /home/aaa/public_html/file.php may have 0644 permissions, but I bet /home/aaa/public_html has permissions of 0750. Try changing the permissions on /home/aaa/public_html to 0755 and it should work.

    For whatever reason it seems that include() needs to be able to traverse into the parent directory to include the file. I am not sure if this is the intended behavior or if this is a bug in the way PHP handles includes.
     
  11. ManXP

    ManXP Well-Known Member

    Joined:
    Feb 3, 2005
    Messages:
    62
    Likes Received:
    0
    Trophy Points:
    6
    Permissions are OK. Like I said, I even created new accounts, used new includes (from new accounts), and nothing works on this server. It drives me crazy now
     
Loading...

Share This Page