| xqd
@@ -0,0 +1,74 @@
|
|
|
+<?php
|
|
|
+$host = $_SERVER['SERVER_NAME'];
|
|
|
+$szUrl = $_GET['url'];
|
|
|
+$baseUrl = explode('/',$szUrl);
|
|
|
+if($baseUrl[0] == 'http:' || $baseUrl[0] == 'https:'){
|
|
|
+ $baseUrl = '//'.$host.'?url='.$baseUrl[2];
|
|
|
+}else{
|
|
|
+ $baseUrl = '//'.$host.'?url='.$baseUrl[0];
|
|
|
+}
|
|
|
+
|
|
|
+$UserAgent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 3.5.21022; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';
|
|
|
+$curl = curl_init();
|
|
|
+curl_setopt($curl, CURLOPT_URL, $szUrl);
|
|
|
+curl_setopt($curl, CURLOPT_HEADER, 1); //0表示不输出Header,1表示输出
|
|
|
+curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
|
+curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
|
|
+curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
|
|
+curl_setopt($curl, CURLOPT_ENCODING, '');
|
|
|
+curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent);
|
|
|
+curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
+$data = curl_exec($curl);
|
|
|
+
|
|
|
+
|
|
|
+$i_headerLen = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
|
|
+$s_header = substr($data,0, $i_headerLen);
|
|
|
+$s_body = substr($data, $i_headerLen);
|
|
|
+
|
|
|
+$pos = substr($s_header,strpos($s_header,'Content-Type'));
|
|
|
+$content_type = explode(" ",$pos );
|
|
|
+
|
|
|
+//正则替换
|
|
|
+
|
|
|
+$regex4 = "/src=\"https:\/\/(.*\/.*?)\"/";;
|
|
|
+$replace4 = "src=https://$host?url=$1";
|
|
|
+$html = preg_replace($regex4,$replace4,$s_body);
|
|
|
+
|
|
|
+$regex5 = "/href=\"https:\/\/(.*\/.*?)/";;
|
|
|
+$replace5 = "href=\"https://$host?url=$1";
|
|
|
+$html = preg_replace($regex5,$replace5,$html);
|
|
|
+
|
|
|
+$regex6 = "/data-original=\"https:\/\/(.*\/.*?)/";;
|
|
|
+$replace6 = "data-original=\"https://$host?url=$1";
|
|
|
+$html = preg_replace($regex6,$replace6,$html);
|
|
|
+
|
|
|
+$regex7 = "/src=\"http:\/\/(.*\/.*?)\"/";;
|
|
|
+$replace7 = "src=https://$host?url=$1";
|
|
|
+$html = preg_replace($regex7,$replace7,$html);
|
|
|
+
|
|
|
+$regex8 = "/href=\"http:\/\/(.*\/.*?)/";;
|
|
|
+$replace8 = "href=\"https://$host?url=$1";
|
|
|
+$html = preg_replace($regex8,$replace8,$html);
|
|
|
+
|
|
|
+$regex9 = "/data-original=\"http:\/\/(.*\/.*?)/";;
|
|
|
+$replace9 = "data-original=\"https://$host?url=$1";
|
|
|
+$html = preg_replace($regex9,$replace9,$html);
|
|
|
+
|
|
|
+
|
|
|
+$regex = "/src=\"\/(.*\/.*?)\"/";;
|
|
|
+$replace = "src=$baseUrl/$1";
|
|
|
+$html = preg_replace($regex,$replace,$html);
|
|
|
+
|
|
|
+$regex2 = "/href=\"\/(.*\/.*?)/";;
|
|
|
+$replace2 = "href=\"$baseUrl/$1";
|
|
|
+$html = preg_replace($regex2,$replace2,$html);
|
|
|
+
|
|
|
+$regex3 = "/data-original=\"\/(.*\/.*?)/";;
|
|
|
+$replace3 = "data-original=\"$baseUrl/$1";
|
|
|
+$html = preg_replace($regex3,$replace3,$html);
|
|
|
+
|
|
|
+
|
|
|
+//echo curl_errno($curl); //返回0时表示程序执行成功 如何从curl_errno返回值获取错误信息
|
|
|
+header($content_type[0]);
|
|
|
+
|
|
|
+echo $html;
|