Jump to content

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/191568-php5-file-access-is-disabledwork-around/
Share on other sites

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.

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.

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"); 
?>

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.