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
https://forums.phpfreaks.com/topic/278960-unable-to-includerequire-files/
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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.