首页  >  文章  >  后端开发  >  PHP Proxy

PHP Proxy

WBOY
WBOY原创
2016-07-25 09:09:393360浏览
PHP 实现的网页代理
  1. if ( !isset($_REQUEST["url"]) ) exit;
  2. $u = $_REQUEST["url"];
  3. if (substr($u, -0, 7) != "http://") exit;
  4. echo file_get_contents( $u );
  5. /*
  6. function getPage($url, $referer, $timeout, $header=true){
  7. if(!isset($timeout)) $timeout=30;
  8. $curl = curl_init();
  9. if(strstr($referer,"://")){
  10. curl_setopt ($curl, CURLOPT_REFERER, $referer);
  11. }
  12. curl_setopt ($curl, CURLOPT_URL, $url);
  13. curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
  14. curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
  15. curl_setopt ($curl, CURLOPT_HEADER, (int)$header);
  16. curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
  17. curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
  18. $html = curl_exec ($curl);
  19. curl_close ($curl);
  20. return $html;
  21. }
  22. echo getPage( $u, "http://www.websitename.com", "20", false );
  23. */
  24. ?>
复制代码


声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn