rendered paste body<?php // Get a list of headers the client sent to our webserver, which we will then send to the target webserver // Saves us writing this stuff ourselves $headersToGet = array( 'HTTP_ACCEPT' => 'Accept', 'HTTP_ACCEPT_CHARSET' => 'Accept-Charset', 'HTTP_ACCEPT_ENCODING' => 'Accept-Encoding', 'HTTP_ACCEPT_LANGUAGE' => 'Accept-Language', 'HTTP_CONNECTION' => 'Connection', 'HTTP_REFERER' => 'Referrer', 'HTTP_USER_AGENT' => 'User-Agent', ); $headersFromClient = array(); foreach($headersToGet as $PHPName => $HTTPName) { if(isset($_SERVER[$PHPName]) && trim($_SERVER[$PHPName]) != "") $headersFromClient[$HTTPName] = $_SERVER[$PHPName]; } // If the request method is POST then we need to send headers to indicate this, and extra data after the headers if($method == "POST") { $first = true; $data = ""; foreach($_POST as $name => $value) { if(!$first) $data .= "&"; $data .= "$name=$value"; } $headersFromClient["Content-Type"] = "application/x-www-form-urlencoded"; $headersFromClient["Content-Length"] = strlen($data); } $opts = array( 'http' => array( 'method' => $method, 'header' => '', ), ); foreach($headersFromClient as $name => $value) { $opts['http']['header'] .= "$name: $value\r\n"; } if($method == "POST") { $opts['http']['data'] = $data; } $context = stream_context_create($opts); $handle = fopen($url, "rb", false, $context);