Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!isset($_SERVER['PROXY_PASS'])) die('Security error');
- $request = $_SERVER["REQUEST_METHOD"]." http://".$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]." HTTP/1.0\n";
- $request .= "Host: ".$_SERVER["HTTP_HOST"]."\n";
- if(isset($_SERVER['HTTP_ACCEPT'])) $request .= "Accept: ".$_SERVER["HTTP_ACCEPT"]."\n";
- if(count($_COOKIE)) {
- $cookies = array();
- foreach($_COOKIE as $k=>$v) $cookies[] = URLEncode($k).'='.URLEncode($v);
- $request .= "Cookie: ".implode('; ',$cookies)."\n";
- }
- if(isset($_SERVER['HTTP_USER_AGENT'])) $request .= "User-Agent: ".$_SERVER["HTTP_USER_AGENT"]."\n";
- if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) $request .= "Accept-Language: ".$_SERVER["HTTP_ACCEPT_LANGUAGE"]."\n";
- if(isset($_SERVER['HTTP_ACCEPT_ENCODING'])) $request .= "Accept-Encoding: ".$_SERVER["HTTP_ACCEPT_ENCODING"]."\n";
- if($_SERVER['REQUEST_METHOD']=='POST'){
- if(isset($_SERVER['HTTP_CONTENT_TYPE'])) $request .= "Content-Type: ".$_SERVER["HTTP_CONTENT_TYPE"]."\n";
- $post_data = file_get_contents("php://input");
- $request .= "Content-Length: ".strlen($post_data)."\n";
- $request .= "\n";
- $request .= $post_data;
- $request .= "\n";
- } else {
- $request .= "\n";
- }
- $proxy = explode(':',$_SERVER['PROXY_PASS']);
- $port = array_pop($proxy);
- $host = implode(':',$proxy);
- $sock = fsockopen($host,$port,$s,$s,3);
- fwrite($sock,$request);
- while($p = fread($sock,255)){
- $ret .= $p;
- }
- $ret = explode("\n",$ret);
- while(($h = trim(array_shift($ret))) != ""){
- if(substr($h,0,6)!="Proxy-")
- Header($h);
- }
- echo implode("\n",$ret);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement