Jump to content

Help!! fopen and HTTP_REFERER


mulysa

Recommended Posts

I want to go hotlink to some URL which protected by checking HTTP_REFERER.
Then I begin to code like this.
But I got an error as shown at the bottom.
Don't know why this happen.

mydownload.php
[code]<?

if($_POST['url']=="")
{
?>
<html>
<form method="post" action="mydownload.php" target="download">
  <table bgcolor="#ffffff">
  <tr><td colspan="2" nowrap="nowrap" valign="top" align="left" height="32">
  <br/>
  <input name="url" type="text" size="64" value=""></input>
  </td></tr>

  <tr><td valign="top" align="left">
  <input type="submit" value="Download"></input>
  </td>
  </tr></table>
  </form>
</html>

<?
}else {

$hackurl= htmlentities($_POST['url']);

$opts = array(
  'http'=>array(
  'method'=>"POST",
  'header'=>"Accept-language: en\r\n" .
  "Host:http://somewhere.com\r\n".
  "Referer:http://somewhere.com\r\n ".
  "Content-type: application/x-www-form-urlencoded\r\n"
  )
);
$fullurl="http://somewhere.com/download.php?url=".$hackurl;
$context = stream_context_create($opts);
$fp = fopen($fullurl, 'r', false, $context);
fpassthru($fp);
fclose($fp);
}
?>
[/code]

Here the error I got
[code]

Warning: fopen() [function.fopen]: php_network_getaddresses: getaddrinfo failed: No such host is known. in D:\xampplite\htdocs\mydownload.php on line 45

Warning: fopen(http://somewhere.php/download.php) [function.fopen]: failed to open stream: No error in D:\xampplite\htdocs\mydownload.php on line 45

Warning: fpassthru(): supplied argument is not a valid stream resource in D:\xampplite\htdocs\mydownload.php on line 46

Warning: fclose(): supplied argument is not a valid stream resource in D:\xampplite\htdocs\mydownload on line 47[/code]
Link to comment
https://forums.phpfreaks.com/topic/29416-help-fopen-and-http_referer/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.