宇宙主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

欧基零壹微头条IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: yilin101

[Windows VPS] 有没有网页代理源码?

[复制链接]
发表于 2016-12-30 17:04:59 | 显示全部楼层
自己改个input框出来就行了,无需手动传参

  1. <?PHP

  2. // Change these configuration options if needed, see above descriptions for info.
  3. $enable_jsonp    = false;
  4. $enable_native   = false;
  5. $valid_url_regex = '/.*/';

  6. // ############################################################################

  7. $url = $_GET['url'];

  8. if ( !$url ) {
  9.   
  10.   // Passed url not specified.
  11.   $contents = 'ERROR: url not specified';
  12.   $status = array( 'http_code' => 'ERROR' );
  13.   
  14. } else if ( !preg_match( $valid_url_regex, $url ) ) {
  15.   
  16.   // Passed url doesn't match $valid_url_regex.
  17.   $contents = 'ERROR: invalid url';
  18.   $status = array( 'http_code' => 'ERROR' );
  19.   
  20. } else {
  21.   $ch = curl_init( $url );
  22.   
  23.   if ( strtolower($_SERVER['REQUEST_METHOD']) == 'post' ) {
  24.     curl_setopt( $ch, CURLOPT_POST, true );
  25.     curl_setopt( $ch, CURLOPT_POSTFIELDS, $_POST );
  26.   }
  27.   
  28.   if ( $_GET['send_cookies'] ) {
  29.     $cookie = array();
  30.     foreach ( $_COOKIE as $key => $value ) {
  31.       $cookie[] = $key . '=' . $value;
  32.     }
  33.     if ( $_GET['send_session'] ) {
  34.       $cookie[] = SID;
  35.     }
  36.     $cookie = implode( '; ', $cookie );
  37.    
  38.     curl_setopt( $ch, CURLOPT_COOKIE, $cookie );
  39.   }
  40.   
  41.   curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
  42.   curl_setopt( $ch, CURLOPT_HEADER, true );
  43.   curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
  44.   
  45.   curl_setopt( $ch, CURLOPT_USERAGENT, $_GET['user_agent'] ? $_GET['user_agent'] : $_SERVER['HTTP_USER_AGENT'] );
  46.   
  47.   list( $header, $contents ) = preg_split( '/([\r\n][\r\n])\\1/', curl_exec( $ch ), 2 );
  48.   
  49.   $status = curl_getinfo( $ch );
  50.   
  51.   curl_close( $ch );
  52. }

  53. // Split header text into an array.
  54. $header_text = preg_split( '/[\r\n]+/', $header );

  55. if ( $_GET['mode'] == 'native' ) {
  56.   if ( !$enable_native ) {
  57.     $contents = 'ERROR: invalid mode';
  58.     $status = array( 'http_code' => 'ERROR' );
  59.   }
  60.   
  61.   // Propagate headers to response.
  62.   foreach ( $header_text as $header ) {
  63.     if ( preg_match( '/^(?:Content-Type|Content-Language|Set-Cookie):/i', $header ) ) {
  64.       header( $header );
  65.     }
  66.   }
  67.   
  68.   print $contents;
  69.   
  70. } else {
  71.   
  72.   // $data will be serialized into JSON data.
  73.   $data = array();
  74.   
  75.   // Propagate all HTTP headers into the JSON data object.
  76.   if ( $_GET['full_headers'] ) {
  77.     $data['headers'] = array();
  78.    
  79.     foreach ( $header_text as $header ) {
  80.       preg_match( '/^(.+?):\s+(.*)$/', $header, $matches );
  81.       if ( $matches ) {
  82.         $data['headers'][ $matches[1] ] = $matches[2];
  83.       }
  84.     }
  85.   }
  86.   
  87.   // Propagate all cURL request / response info to the JSON data object.
  88.   if ( $_GET['full_status'] ) {
  89.     $data['status'] = $status;
  90.   } else {
  91.     $data['status'] = array();
  92.     $data['status']['http_code'] = $status['http_code'];
  93.   }
  94.   
  95.   // Set the JSON data object contents, decoding it from JSON if possible.
  96.   $decoded_json = json_decode( $contents );
  97.   $data['contents'] = $decoded_json ? $decoded_json : $contents;
  98.   
  99.   // Generate appropriate content-type header.
  100.   $is_xhr = strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
  101.   header( 'Content-type: application/' . ( $is_xhr ? 'json' : 'x-javascript' ) );
  102.   
  103.   // Get JSONP callback.
  104.   $jsonp_callback = $enable_jsonp && isset($_GET['callback']) ? $_GET['callback'] : null;
  105.   
  106.   // change to utf-8
  107.   $charset = mb_detect_encoding($data['contents'],array('UTF-8','GBK','GB2312'));
  108.   $charset = strtolower($charset);
  109.   if('cp936' == $charset){
  110.       $charset='GBK';
  111.   }
  112.   if("utf-8" != $charset){
  113.       $data['contents'] = iconv($charset,"UTF-8//IGNORE",$data['contents']);
  114.   }
  115.   
  116.   // Generate JSON/JSONP string
  117.   $json = json_encode( $data );
  118.   
  119.   print $jsonp_callback ? "$jsonp_callback($json)" : $json;
  120.   
  121. }

  122. ?>
复制代码
发表于 2017-1-24 13:44:32 | 显示全部楼层
爱国者捣蛋 发表于 2016-12-30 16:24
就是glype,很久前还有个phpproxy不过很少用了
你给老人搭个反代多省事

glype中文支持很差。

如果不加密,很快就被封了。
如果加密,中文大都是乱码。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|宇宙主机交流论坛

GMT+8, 2024-10-30 09:32 , Processed in 0.054665 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表