$value){ header($value); } } function init_curl($link,$headers){ $curlobj = curl_init(); curl_setopt($curlobj,CURLOPT_URL,$link); curl_setopt($curlobj, CURLOPT_RETURNTRANSFER, 1);//raw output curl_setopt($curlobj, CURLOPT_HTTPHEADER, $headers); curl_setopt($curlobj, CURLOPT_HEADER, 1); return $curlobj; } foreach(getallheaders() as $key=>$value){ if ($key=='Content-Length' and isset($_POST)){ $post=http_build_query($_POST); $value=strlen($post); } $headers[]=$key.':'.$value; } if(isset($_REQUEST['url'])){ $link=$_REQUEST['url']; $url=explode('/',$link)[2]; /* curl setting */ $curlobj = init_curl($link,$headers); //GET if ($_SERVER['REQUEST_METHOD']=='GET'){ //READ FILE if(substr($link, 0,7)=='file://'){ echo substr($link,7); $result=""; //$result=file_get_contents(substr($link,7)); echo $result; curl_close($curlobj); }else{ curl_setopt($curlobj, CURLOPT_POST, 0); curl_setopt($curlobj, CURLOPT_HTTPHEADER, ["HOST",$url]); get_result($curlobj); } }else { //POST curl_setopt($curlobj, CURLOPT_POST, 1); curl_setopt($curlobj, CURLOPT_POSTFIELDS,$post); curl_setopt($curlobj, CURLOPT_HTTPHEADER, ["HOST",$url]); get_result($curlobj); } }else{ echo 'invalid request'; } ?>