Jump to content

Unable to include/require files


Recommended Posts

Okay, I have a file on my webhost server (000webhost, if that is important) called HTML.class.php whose only purpose is to print HTML documents automatically, eventually reading out a meta.txt file to print out <meta> tags.

 

So far, so good, that isn't much of a problem, I fixed my syntax and proof-read it, but when I open the file in a browser, I get three warnings and a fatal because include/require (I tried both) failed.

 

Below the output I get (excuse the formating, my mobile won't let me copy things as I want to, so I extracted the source code).

 

<b>Warning</b>: include() [<a href='function.include'>function.include</a>]: open_basedir restriction in effect. File(/sys/important/HTML.class.php) is not within the allowed path(s): (/home/:/usr/lib/php:/tmp) in <b>/home/myusername/public_html/test.php</b> on line <b>3</b><br /><br /><b>Warning</b>: include(/sys/important/HTML.class.php) [<a href='function.include'>function.include</a>]: failed to open stream: Operation not permitted in <b>/home/a1632545/public_html/test.php</b> on line <b>3</b><br /><b>Warning</b>: include() [<a href='function.include'>function.include</a>]: Failed opening '/sys/important/HTML.class.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in <b>/home/myusername/public_html/test.php</b> on line <b>3</b><br /><b>Fatal error</b>: Class 'HTML_Create' not found in <b>/home/myusername/public_html/test.php</b> on line <b>5</b>
Thanks in advance for your support.
Link to comment
Share on other sites

Looks like your host does not let you include files that are in certain directories (probably those above /home/a1632545/public_html) as a security precaution. That way if I can get a webpage on your server I can't do things like

include '/etc/passwd' ; 

 If you move the files you want to include to a directory like /home/a1632545/public_html/includes it should fix the problem.

Edited by davidannis
Link to comment
Share on other sites

File(/sys/important/HTML.class.php) is not within the allowed path(s):

When you put a slash at the beginning of a filepath, it points to the root of the SYSTEM. You need to specify where that file is:

 

/home/myusername/public_html/test.php

So the include should be something like this: include('/home/myusername/public_html/sys/important/HTML.class.php if it is in the public path.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.