Welcome Guest ( Log In | Register )



 
Closed TopicStart new topic
> Url File-access Is Disabled In The Server Configuration
turbopowerdmaxst...
post Mar 13 2007, 07:29 PM
Post #1


Premium Member
Group Icon

Group: [HOSTED]
Posts: 347
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322



As per the php documentation:-

CODE
// 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://www.example.com/file.php?foo=1&bar=2';


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

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


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

QUOTE

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://ntek.astahost.com/includes/header.php?d=../../) [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://ntek.astahost.com/includes/header.php?d=../../' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') 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?
Go to the top of the page
 
+Quote Post
pyost
post Mar 13 2007, 11:03 PM
Post #2


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 993
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



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:

CODE
<?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.
Go to the top of the page
 
+Quote Post
vujsa
post Mar 14 2007, 12:24 AM
Post #3


Absolute Newbie
Group Icon

Group: Admin
Posts: 871
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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

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:
CODE
<?php
if(isset($foo) && isset($bar)){
    $foobar = $foo + $bar;
    echo $foobar;
}
else{
    echo "You forgot to set Foo and Bar";
}
?>


index.php:
CODE
<?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
Go to the top of the page
 
+Quote Post
turbopowerdmaxst...
post Mar 14 2007, 04:46 AM
Post #4


Premium Member
Group Icon

Group: [HOSTED]
Posts: 347
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322



QUOTE(pyost @ Mar 14 2007, 04:33 AM) *
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:

CODE
<?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.

QUOTE(vujsa @ Mar 14 2007, 05:54 AM) *
I'm not entirely sure that I understand you issue since what you are talking about doesn't really make any sense to me. sad.gif

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:
CODE
<?php
if(isset($foo) && isset($bar)){
    $foobar = $foo + $bar;
    echo $foobar;
}
else{
    echo "You forgot to set Foo and Bar";
}
?>


index.php:
CODE
<?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. smile.gif
Go to the top of the page
 
+Quote Post
Quatrux
post Mar 14 2007, 06:25 AM
Post #5


the Q
Group Icon

Group: [HOSTED]
Posts: 982
Joined: 13-July 05
From: Lithuania, Vilnius
Member No.: 7,059



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:

CODE
<?php

function print_header($array = NULL) {

?>

<html>
...
This is my HEADER!

<?php    
    
    }

# parse my Header
print_header();

?>


Furthermore, about the remote including, as Astahost 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 Astahost, 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. wink.gif

This post has been edited by Quatrux: Mar 14 2007, 06:42 AM
Go to the top of the page
 
+Quote Post
pyost
post Mar 14 2007, 09:38 AM
Post #6


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 993
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



QUOTE(Quatrux @ Mar 14 2007, 07:25 AM) *
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:

CODE
<?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;
?>
Go to the top of the page
 
+Quote Post
vujsa
post Mar 14 2007, 06:13 PM
Post #7


Absolute Newbie
Group Icon

Group: Admin
Posts: 871
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



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
Go to the top of the page
 
+Quote Post
Feedbacker
post Mar 24 2008, 10:45 PM
Post #8


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 0
Joined: 1-November 07
Member No.: 25,869



Replying to vujsaeasy add this line to "/php-bin/your php.Ini":
Allow_url_include = On

Best regardz
---

-reply by vodafogne
Go to the top of the page
 
+Quote Post

Closed TopicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Installing Programs On The Server Via Cpanel(2)
  2. Is There A Max File Size Limit When Uploading?(4)
  3. Get Server Timeout Error Msg(0)
  4. Need Help With Music File(11)
  5. Public Access To Subdirs In Public_html(7)
  6. Server Issues Again?(2)
  7. Are Server Changes Being Made?(2)
  8. Ssh Access - Could I Get It Back(0)
  9. Is There Anyway To Get Telnet Access?(3)
  10. Cant Access My Account(1)
  11. File Size Limits?(2)
  12. AW Stats: Love em! Can't access them :((4)
  13. 123flashchat Server(0)
  14. File Types(7)
  15. Server Status Page Gone(1)


 



- Lo-Fi Version Time is now: 7th July 2008 - 12:23 AM