File get content error - php

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.

Related

All php files showing as 500 Internal Server Error

Problem: Any php file we attempt to access on our website shows up as a 500 internal server error. I'm not sure if this is related but I have had a look in the error logs and the below error appears:
[08-Nov-2013 12:41:51 UTC] PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20090626/htscanner.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20090626/htscanner.so:
cannot open shared object file: No such file or directory in Unknown on line 0
Attempt: Some of the things I have tried to do is delete the over size error log and renamed the htaccess file to see if that was causing the problem.
Page: You can see the problem at this page: http://science.org.au/support-us/donate-now.html (Half way down in the iframe)
Question: Does anyone have any ideas on how to fix this? Things to try?
Did you try this?
edit the file /etc/php5/cli/php.ini:
and remove the lines:
[htscanner] Extension = “htscanner.so”
config_file = “.htaccess”
default_docroot = “/var/www”
You should pay more attention to what your error log says. According to it, you should either install htscanner.so PHP extension, or remove reference to it from your php.ini.

Error handling "URL file-access is disabled..."

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

Getting strange error in PHP script running on unix

I'm running a php in a unix shell and I'm getting the following error.
The script is a web scraper and it work fine on my host if I access it. But I want to run it as a cron job, What shoul I do?
Warning: file_get_contents(http://www.lomamatkat.fi/iframes/last-minute-offers/?lastminute_next=50): failed to open stream: no suitable wrapper could be found in /var/www/customers/lentovertailufi/public_html/matkat/script/lomamatkat.php on line 30
PHP Warning: file_get_contents(): URL file-access is disabled in the server configuration in /var/www/customers/lentovertailufi/public_html/matkat/script/lomamatkat.php on line 30
Update your php.ini file, and set the 'allow_url_fopen' option to 'On'.
If you are unable to change allow_url_fopen consider using use curl (if must be php) or Wget
go to the php.ini and enable that or use curl or one of the other http get functions. file_get_contents is considered a dangerous system call for urls because people can slip files into it as well.

file_get_contents() error

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.

Warning on PHP fopen

$file = #fopen("http://ajax.htm","rb");
I am getting this error while using fopen
Warning: fopen(xyz.htm): failed to open stream: HTTP request failed!
in /home/user/public_html/aaa/ttt.php on line 8
what could be the reason behind this?
I am going to go out on a huge limb here and suggest the problem is the url, 'http://ajax.htm'.
from docs:
If PHP has decided that filename specifies a registered protocol, and that protocol is registered as a network URL, PHP will check to make sure that allow_url_fopen is enabled. If it is switched off, PHP will emit a warning and the fopen call will fail.
edit: ajax.htm is not a valid url.
$file = #fopen("ajax.htm","rb");
there is your problem i think
http://nl3.php.net/function.fopen

Categories