- UID
- 3738
- 阅读权限
- 20
- 注册时间
- 2020-1-3
- 最后登录
- 1970-1-1
- 在线时间
- 小时
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
// 要访问的目标页面
* s- C3 b1 M& \- ^7 K2 r3 \ $url = "http://baidu.org/ip";0 M: W' n. e2 Q" F' P* A7 o3 E+ V1 j
$urls = "https://baidu.org/ip";" i: N3 Z6 C6 T9 P# x- F
r1 t% ^6 _, T2 I // 代理服务器
. _7 |6 Z9 n6 v- G# l+ I define("PROXY_SERVER", "tcp://t.xxxx.cn:31111");
) y ~9 f" G" L! H) |7 H
4 q, w/ f* K5 t8 `* J: j+ c // 隧道身份信息
6 |* Y, a' Y% b; O define("PROXY_USER", "xxxxx");
( g0 n% D6 e7 o+ R3 r e7 U2 R define("PROXY_PASS", "123456");! p6 H" G) G8 ^" `- w% W+ {
3 |2 }- }# Z% e2 x& f6 | $proxyAuth = base64_encode(PROXY_USER . ":" . PROXY_PASS);+ T% v2 A4 w2 N9 N! T
2 t4 h# m" l" j
// 设置 Proxy tunnel
% h7 v4 v8 P4 W4 T& z) R. v2 s, x $tunnel = rand(1,10000);
$ Y F! {1 [5 o+ @5 L6 P
$ h: ?! w& d6 R. l* y4 r# ]9 \( g $headers = implode("\r\n", [
9 P5 _. \1 q- Q "Proxy-Authorization: Basic {$proxyAuth}",
; ^: t$ y+ I) T "Proxy-Tunnel: ${tunnel}",( S/ n6 }# b/ K& s+ A! e ^$ Q
]);
: ~# Y, s( I& R9 {- Z: V4 e0 P8 j $sniServer = parse_url($urls, PHP_URL_HOST);$ y7 j; c8 a p6 o) b5 f
$options = [/ p" h& b) @9 @3 m e
"http" => [2 a% s8 |- ^1 | E% T4 N9 U8 {
"proxy" => PROXY_SERVER," j/ p* }1 i4 x
"header" => $headers,- d7 H3 D+ i5 f
"method" => "GET",
: o* y6 l/ \) F' b; t4 `( y x 'request_fulluri' => true,* m! ?( i9 B' W( X
],
. m, h/ s8 g* L8 o! t, d; n! x 'ssl' => array() z9 v7 ?9 {9 x' ]' ]- o3 n* j
'SNI_enabled' => true, // Disable SNI for https over http proxies/ a( @8 V# B0 s+ H8 s2 [" ]( L
'SNI_server_name' => $sniServer
+ H6 e* }8 H8 t1 R: Q) P9 F9 G )0 s. z/ S, X5 j( h& a" O- a$ O
];" T' H8 Z; G1 o$ D3 H: e
print($url);
$ n- O7 E7 U, S- x! d6 d1 N $context = stream_context_create($options);4 ^3 r o) ^5 G P4 _2 V k7 J( t
$result = file_get_contents($url, false, $context);1 B/ y$ w) g, E/ C( Z1 H
var_dump($result);
8 t& e! X$ H, [; x" @" C g1 L' i4 S: r* \
// 访问 HTTPS 页面
1 U* S# o( b4 K; A; @( \ print($urls);
* i; }1 a4 |1 ? $context = stream_context_create($options);
# m5 O0 ]. W) \( M9 B1 u3 t $result = file_get_contents($urls, false, $context);4 G3 b- B( o* D! m
var_dump($result); |
|