Jump to content
xisto Community
turbopowerdmaxsteel

Url File-access Is Disabled In The Server Configuration

Recommended Posts

As per the php documentation:-

// Won't work; looks for a file named 'file.php?foo=1&bar=2' on the// local filesystem.include 'file.php?foo=1&bar=2';// Works.include 'http://forums.xisto.com/no_longer_exists/;;

So, I used the following code to include the header.php file which I use to draw the top navigation menu on my site.

<? include "http://" . $_SERVER['HTTP_HOST'] . "/includes/header.php?d=../../" ?>

It worked before, but now I see the following errors on my page.

Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/ntek/public_html/products/pikabot/index.php on line 31
Warning: include(http://forums.xisto.com/no_longer_exists/) [function.include]: failed to open stream: no suitable wrapper could be found in /home/ntek/public_html/products/pikabot/index.php on line 31

Warning: include() [function.include]: Failed opening 'http://forums.xisto.com/no_longer_exists/' for inclusion (include_path='.:/usr/lib/http://forums.xisto.com/no_longer_exists/;) in /home/ntek/public_html/products/pikabot/index.php on line 31


I suppose disabling URL file access was meant for security purposes. Is there any workaround?

Share this post


Link to post
Share on other sites

Correct me if I am wrong, but you want to include a PHP file that will, depending on the d parameter, display some data. Instead of including a file along with the parameter (header.php?d=value), all you need to is execute include('header.php');, while having the value assigned to a certain variable.

 

A bit confusing? Maybe. Here's how the code would look:

 

<?php// Some PHP code$d = value;include('header.php');//More PHP code?>

Since include means copying one file's contents to the current page, you would be able to use $d in header.php instead of $_GET['d']. That's at least how I do it.

Share this post


Link to post
Share on other sites

I'm not entirely sure that I understand you issue since what you are talking about doesn't really make any sense to me. ;)

If you include a file, you include ALL of it's contents into the script requesting it!
So, $foo and $bar don't need to be passed in the url!, you can set them as normal!

header.php:

<?phpif(isset($foo) && isset($bar)){	$foobar = $foo + $bar;	echo $foobar;}else{	echo "You forgot to set Foo and Bar";}?>

index.php:
<?php$foo = 2;$bar = 3;include('header.php');?>

I think a better option for you would be to create a function for your header area! For best results, you should place all of your functions in a single include file and then call the functions as needed!

I will be happy to discuss this further in the PHP forums! As it is, I really don't see that the server should be reconfigured to allow your method of file inclusion.
There is a work around available for your issue at php.net if you wish to continue with this method of coding!

vujsa

Share this post


Link to post
Share on other sites

Correct me if I am wrong, but you want to include a PHP file that will, depending on the d parameter, display some data. Instead of including a file along with the parameter (header.php?d=value), all you need to is execute include('header.php');, while having the value assigned to a certain variable.

 

A bit confusing? Maybe. Here's how the code would look:

 

<?php// Some PHP code$d = value;include('header.php');//More PHP code?>

Since include means copying one file's contents to the current page, you would be able to use $d in header.php instead of $_GET['d']. That's at least how I do it.

Sorry for the unclear clarification. I thought the example ought to make it clear. Anyways, what you've said is exactly what I want to do. I had no idea that variables are passed across files in such a fashion. Kinda, overrides the variable scope thingy we learn in the other programming languages, doesn't it? I was aware that such a thing could be done in the same file but still couldn't guess this comming.

 

I'm not entirely sure that I understand you issue since what you are talking about doesn't really make any sense to me. ;)

 

If you include a file, you include ALL of it's contents into the script requesting it!

So, $foo and $bar don't need to be passed in the url!, you can set them as normal!

 

header.php:

<?phpif(isset($foo) && isset($bar)){	$foobar = $foo + $bar;	echo $foobar;}else{	echo "You forgot to set Foo and Bar";}?>

index.php:

<?php$foo = 2;$bar = 3;include('header.php');?>

I think a better option for you would be to create a function for your header area! For best results, you should place all of your functions in a single include file and then call the functions as needed!

 

I will be happy to discuss this further in the PHP forums! As it is, I really don't see that the server should be reconfigured to allow your method of file inclusion.

There is a work around available for your issue at php.net if you wish to continue with this method of coding!

 

vujsa


My appologies to you too. I prefer to have different header files, more so because they contain a lot of plain HTML codes and having to resort to echo is really trecherous.

 

I wouldn't ask for server re-configuration either, just something that does the job.

 

Thank You guys, you were of tremendous help. ;)

Share this post


Link to post
Share on other sites

You don't really need to resort your html code to echo or print if you program in a "good' way, here is an example how you can do it:

<?phpfunction print_header($array = NULL) {?><html>...This is my HEADER!<?php			} # parse my Headerprint_header();?>

Furthermore, about the remote including, as Xisto is running on PHP5 now, there is a new option in the settings which doesn't exist on PHP4, even though allow_url_fopen is On by default on Xisto, the new setting allow_url_include is Off, and this is logical, a lot of people needs to open remote files and they don't want to have the inclusion for remote files, also this setting adds more security, due to there are a lot of novice php programmers, which lets their site include remote files through the get method, with this setting this will be impossible to do, they will get an error and no php code could be executed! It is recommended only to read the remote files and not to include anything. ;)
Edited by Quatrux (see edit history)

Share this post


Link to post
Share on other sites

You don't really need to resort your html code to echo or print if you program in a "good' way, here is an example how you can do it:

You can do this in another way, which doesn't require opening PHP code (again) when you want to inserta variable:

<?php// PHP code$titleVariable = 'Untitled document';$html = <<<EOF<!-- Here you would put pure HTML code, but would also be able to add variable --><html><head><title> $titleVariable </title></head></html>EOF;echo $html;?>

Share this post


Link to post
Share on other sites

Well, from a hosting support point of view, this issue has been resolved.Closing topic. Please feel free to discuss it further in the PHP forum!vujsa

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | 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.