I'm getting these 2 errors:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in
/home/content/.../wp-content/themes/mytheme/functions.php on line 4035
Warning: file_get_contents(http://www.mysite.net/...y-1.7.2.min.js)
[function.file-get-contents]: failed to open stream: no suitable
wrapper could be found in
/home/content/.../html/wp-content/themes/mytheme/functions.php on line
4035
Here's line 4035
$myFile=file_get_contents(get_bloginfo('template_directory')."/js/jquery-1.4.2.min.js");
Is this just a permissions issue on the server? How might I wrap this function to prevent the error and exit out to a useful message?
You need to enable allow_url_fopen and allow_url_include (if you want to load remote resources using include) in your php.ini config file. Also, you can try adding this to .htaccess but I don't think it will work if you're running php as an apache module - it's not suppose to override this setting...
php_value allow_url_fopen On
Related
I have an issue. I was testing how remote file inclusion injection and tried to include the file from URL query string using PHP. But here I am getting some warning messages. I am explaining my code below.
<?php
$file = $_GET['file'];
include($file);
?>
I am getting the following messages.
Warning: include(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in /opt/lampp/htdocs/test/remote.php on line 3
Warning: include(http://attacker.com/evil.php): failed to open stream: no suitable wrapper could be found in /opt/lampp/htdocs/test/remote.php on line 3
Warning: include(): Failed opening 'http://attacker.com/evil.php' for inclusion (include_path='.:/opt/lampp/lib/php') in /opt/lampp/htdocs/test/remote.php on line 3
Here I am calling remote file like this http://localhost/test/remote.php?file=http://kooleedback.com/about.php. Here I need to know how it can be successfully included and also how it can be prevented.
Your server has the allow_url_include option disabled. This means you can only access local files with include(), not external URLs.
In general it doesn't make sense to use include() with a remote .php URL. When you request a .php file from a server, it doesn't return the source code, it executes the script and returns the output. But include() needs to get PHP code, which it executes as if it were in the including script.
If you want to get that remote data you should use file_get_contents($file), not include($file).
I am developing opencart application , i installed in on localhost ,and customize it but now i am trying to upload it to server but it get error
Warning: require_once() [function.require-once]: http:// wrapper is
disabled in the server configuration by allow_url_include=0 in
/home/content/29/9716229/html/johndhan/telhemboradz/index.php on line
17
Warning:
require_once(http://249development.us/johndhan/telhemboradz/system/startup.php)
[function.require-once]: failed to open stream: no suitable wrapper
could be found in
/home/content/29/9716229/html/johndhan/telhemboradz/index.php on line
17
Fatal error: require_once() [function.require]: Failed opening
required
'http://249development.us/johndhan/telhemboradz/system/startup.php'
(include_path='.:/usr/local/php5_3/lib/php') in
/home/content/29/9716229/html/johndhan/telhemboradz/index.php on line
17
You need to use paths for your files not HTTP url's. Open your config.php file and admin/config.php file and change
http://249development.us/
to
/home/content/29/9716229/html/
for all of the paths except for those that start HTTP_ or HTTPS_ in the define's
It seems that you are trying to include a remote file via HTTP. If this is intentionally the case, then you need to enable the http:// wrapper - as suggested by the warning you are getting. If this is not the case, then consider removing the URL http://249development.us/ from the require_once statements.
I'm trying to post a blog to my website. I downloaded Simplepie and followed the directions on the website, but I keep getting these errors. Being new to PHP, I'm not exactly sure what they mean. Any help?
Warning: require_once() [function.require-once]: URL file-access is disabled in the server configuration in /hermes/bosweb/web177/b1775/ipg.waldropcom/php/test.php on line 7
Warning: require_once(http://www.waldrop.com/php/autoloader.php) [function.require-once]: failed to open stream: no suitable wrapper could be found in /hermes/bosweb/web177/b1775/ipg.waldropcom/php/test.php on line 7
Fatal error: require_once() [function.require]: Failed opening required 'http://www.waldrop.com/php/autoloader.php' (include_path='.:/usr/local/lib/php-5.2.17/lib/php') in /hermes/bosweb/web177/b1775/ipg.waldropcom/php/test.php on line 7
Probably your application trying to include a remote file but it's failing. You need to enable allow_url_fopen and allow_url_include settings in php.ini to require or include remote files.
I am using file_get_contents on my PHP and it throws some errors:
My code
#try to fetch from remote
$this->remotePath = "http://some-hostname.com/blah/blah.xml
$fileIn = #file_get_contents($this->remotePath);
The errors:
Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /virtual/path/to/file/outputFile.php on line 127
Warning: file_get_contents(https://some-host-name/data/inputFile.xml) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /virtual/path/to/file/outputFile.php on line 127
Any idea? It worked fine in my computer but stopped working when I ported it to the web server.
Your server must have the allow_url_fopen property set to true. Being on a free webhost explains it, as it's usually disabled to prevent abuse. If you paid for your hosting, get in contact with your host so they can enable it for you.
If changing that setting is not an option, then have a look at the cURL library.
It seems "allow_url_fopen" setting is false on your server and hence does not allow using URLs with file_get_contents().
Try using CURL instead that is a better and efficient way of communicating with other server.
i got an error message when i try to do file_get_contents() function
Warning: file_get_contents()
[function.file-get-contents]: URL
file-access is disabled in the server
configuration in
/data/20/1/112/111/1927437/user/2100551/htdocs/cti-dev/admin/my
path
My site is https ..
how this happend? Does any one help me ?
This error is occurs when allow_url_fopen is disabled. You'll need to use cURL to grab this file or change your PHP.ini config.
Someone has disabled URL access in fopen() et alia, probably with allow_url_fopen.