Ok, for educational purposes, I was trying to write a proxy using the curl command.
I picked up an open source script from a blog somewhere, and modified it a bit so that it would work with a form. Its still not complete, but for some reason, it will only load pages on my own server.
Heres the code I have for the proxy itself:
<?php
$url = $_REQUEST['url'] ;
$headers = ($_POST['headers']) ? $_POST['headers'] : $_GET['headers'];
$mimeType =($_POST['mimeType']) ? $_POST['mimeType'] : $_GET['mimeType'];
//start curl session
$session = curl_init($url);
// body
$postvars= '';
{
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}
// no HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
// curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// make the call
$response = curl_exec($session);
if ($mimeType != "")
{
// The web service returns XML. Set the Content-Type appropriately
header("Content-Type: ".$mimeType);
}
echo $response;
curl_close($session);
?>
Could someone please tell me what the problem is?
If you want to see what I mean for yourself, then try it at http://exy.ej.am/exyproxy