apache - PHP Message: failed to open stream: HTTP request failed -
i using php script proxy. same script on serer works no problem, on server b not work , receive these errors:
failed open stream: http request failed! http/1.1 401 unauthorized
and
cannot modify header information - headers sent
on server b allow_url_fopen = on
is setup
any idea wrong?
thanks
<?php /* * in javascript call `encodeuricomponent` * $.get('proxy.php?proxy_url='+encodeuricomponent('http://google.com?param=1¶m2=2')) */ $url = rawurldecode($_get['proxy_url']); $cb = ! empty($_get['callback']) ? $_get['callback'] : null; if(preg_match('#ccc\.aaa\.com/bbb/#', $url)){ $url = preg_replace('#http\://xxx\.xxx\.com/xxx/#', '', $url); } if(! preg_match('#^https?:#', $url)){ $url = preg_replace('#^[\.\/]+#', '', $url); if(!file_exists($url)){ echo 'file not found'; die(0); } } if(preg_match('#\.xml$#', $url)){ header('content-type: text/xml'); } $file = file_get_contents($url); if($cb){ header('content-type: application/javascript'); echo $cb.'('.$file.');'; }else{ echo $file; }
Comments
Post a Comment