当前位置 : 主页 > 网络编程 > PHP >

PHP 实现的网页代理

来源:互联网 收集:自由互联 发布时间:2021-06-30
?php if ( !isset($_REQUEST["url"]) ) exit; $u = $_REQUEST["url"]; if (substr($u, -0, 7) != "http://") exit; echo file_get_contents( $u );/* function getPage($url, $referer, $timeout, $header=true){ if(!isset($timeout)) $timeout=30; $curl =
<?php
   if ( !isset($_REQUEST["url"]) ) exit;

   $u = $_REQUEST["url"];
   if (substr($u, -0, 7) != "http://") exit;

    echo file_get_contents( $u );

/*
    function getPage($url, $referer, $timeout, $header=true){
        if(!isset($timeout)) $timeout=30;
        $curl = curl_init();
        if(strstr($referer,"://")){
            curl_setopt ($curl, CURLOPT_REFERER, $referer);
        }
        curl_setopt ($curl, CURLOPT_URL, $url);
        curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
        curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
        curl_setopt ($curl, CURLOPT_HEADER, (int)$header);
        curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);
        $html = curl_exec ($curl);
        curl_close ($curl);
        return $html;
    }

    echo getPage( $u, "http://www.websitename.com", "20", false );
*/
?>
网友评论