Home > Backend Development > PHP Tutorial > Web proxy implemented in PHP

Web proxy implemented in PHP

WBOY
Release: 2016-07-25 08:42:32
Original
2010 people have browsed it
  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. ?>
复制代码

PHP


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template