jamichelli Posted February 10, 2010 Share Posted February 10, 2010 I have a test page that I'm working on to figure out how to (supposedly) make my life a little easier. I want to include or require a top row of menu buttons and another row of menu buttons on the bottom of my pages. These page files will be located in subfolders with the php files to be included/required located in the root file. In my research, I see that PHP5 has disabled absolute file access as a security measure. Is there a work-around or code that I would be able to use so that I can simply get these buttons onto my pages and only have to update the 1 file should when it is needed instead of having to update every page manually? Here is one version of the code that I've tried: <? include('http://www.mywebsite.com/top_menu.php'); ?> <? include('http://www.mywebsite.com/bottom_menu.php'); ?> These are the errors I'm getting: Warning: include() [function.include]: URL file-access is disabled in the server configuration in D:\Hosting\0123456\html\test\test.php on line 69 Warning: include(http://www.mywebsite.com/top_menu.php) [function.include]: failed to open stream: no suitable wrapper could be found in D:\Hosting\0123456\html\test\test.php on line 69 Warning: include() [function.include]: Failed opening 'http://www.mywebsite.com/top_menu.php' for inclusion (include_path='.;C:\php5\pear') in D:\Hosting\0123456\html\test\test.php on line 69 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/191568-php5-file-access-is-disabledwork-around/ Share on other sites More sharing options...
alexjb Posted February 10, 2010 Share Posted February 10, 2010 In php.ini, allow_url_fopen must be turned off. If you are able, turn it on, or contact your host. Alternatively, there are ways around this. If both scripts are on the same server, you could do something like: <?php $file = file_get_contents('bottom_menu.php'); eval($file); ?> Depending on how you've configured your script. Quote Link to comment https://forums.phpfreaks.com/topic/191568-php5-file-access-is-disabledwork-around/#findComment-1009845 Share on other sites More sharing options...
PFMaBiSmAd Posted February 10, 2010 Share Posted February 10, 2010 When you use a URL in an include statement, it causes php to make a HTTP request back to your web server, the same as if you browsed to the file. This takes 10-100 times longer than if you use a file system path. Include is intended to be used with file paths. Quote Link to comment https://forums.phpfreaks.com/topic/191568-php5-file-access-is-disabledwork-around/#findComment-1009854 Share on other sites More sharing options...
jamichelli Posted February 10, 2010 Author Share Posted February 10, 2010 After a bit more research, here is what I came up with...do you see any problems with this PFMaBiSmAd? <?php $root = $_SERVER['DOCUMENT_ROOT']; include($root."/top_menu.php"); ?> <?php $root = $_SERVER['DOCUMENT_ROOT']; include($root."/bottom_menu.php"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/191568-php5-file-access-is-disabledwork-around/#findComment-1009861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.