{"id":323,"date":"2008-06-10T13:58:47","date_gmt":"2008-06-10T13:58:47","guid":{"rendered":""},"modified":"2013-02-27T12:23:08","modified_gmt":"2013-02-27T04:23:08","slug":"323","status":"publish","type":"post","link":"https:\/\/1vr.cn\/?p=323","title":{"rendered":"\u8fdc\u7a0b\u5f15\u7528\u7f51\u6613\u76f8\u518c\u56fe\u7247(xmlhttp+\u7f13\u5b58)"},"content":{"rendered":"<p>163\u7684\u76f8\u518c\u6709\u9632\u76d7\u94fe\u7684\u529f\u80fd,\u5728\u5176\u4ed6\u57df\u540d\u4e0b\u5f15\u7528\u56fe\u7247\u65f6\u5019\u4f1a\u5f97\u4e0d\u5230\u6570\u636e.<br \/>\u4f53\u73b0\u5728\u6d4f\u89c8\u5668\u4e0a,\u5c31\u662f\u4e00\u4e2a\u7ea2X.<br \/>\u6211\u4eec\u5229\u7528httprequest\u548capplication\u7f13\u5b58\u6280\u672f,\u53ef\u4ee5\u7834\u89e3\u8fd9\u79cd\u9632\u76d7\u94fe.<\/p>\n<p>\u4fdd\u5b58\u6210\u4e00\u4e2aasp\u6587\u4ef6\u5728\u4f60\u7f51\u7ad9\u76ee\u5f55,\u5c31\u53ef\u4ee5\u7528\u5982\u4e0b\u7684\u65b9\u5f0f\u8c03\u7528\u7f51\u6613\u7684\u56fe\u7247\u4e86.\u9664\u4e86\u7f51\u6613,\u6211\u60f3\u5176\u4ed6\u52a0\u4e86\u9632\u76d7\u94fe\u7684\u56fe\u7247\u90fd\u53ef\u4ee5\u7528\u8fd9\u4e2a\u65b9\u6cd5,\u6bd4\u5982\u767e\u5ea6,\u6bd4\u5982QQ\u76f8\u518c.\u7b49\u7b49<\/p>\n<p><font color=\"Red\">http:\/\/\u4f60\u7684\u7f51\u7ad9\/aspname.asp?url=\u56fe\u7247\u5730\u5740<\/font><\/p>\n<p><code>&lt;%<br \/>'\u4ee3\u7801\u4f5c\u8005:siyizhu \u65e5\u671f:2006-05-22<br \/>Dim url, body, myCache<\/p>\n<p>url = Request.QueryString(\"url\")<\/p>\n<p>Set myCache = new cache<br \/>myCache.name = \"picindex\"&url<br \/>If myCache.valid Then<br \/>body = myCache.value<br \/>Else<br \/>body = GetWebData(url)<br \/>myCache.add body,dateadd(\"d\",1,now)<br \/>End If<\/p>\n<p>If Err.Number = 0 Then<br \/>Response.CharSet = \"UTF-8\"<br \/>Response.ContentType = \"application\/octet-stream\"<br \/>Response.BinaryWrite body<br \/>Response.Flush<br \/>Else<br \/>Wscript.Echo Err.Description<br \/>End if<\/p>\n<p>'\u53d6\u5f97\u6570\u636e<br \/>Public Function GetWebData(ByVal strUrl)<br \/>Dim curlpath<br \/>curlpath = Mid(strUrl,1,Instr(8,strUrl,\"\/\"))<br \/>Dim Retrieval<br \/>Set Retrieval = Server.CreateObject(\"Microsoft.XMLHTTP\")<br \/>With Retrieval<br \/>.Open \"Get\", strUrl, False,\"\",\"\"<br \/>.setRequestHeader \"Referer\", curlpath<br \/>.Send<br \/>GetWebData =.ResponseBody<br \/>End With<br \/>Set Retrieval = Nothing<br \/>End Function<\/p>\n<p>'cache\u7c7b<\/p>\n<p>class Cache<br \/>private obj 'cache\u5185\u5bb9<br \/>private expireTime '\u8fc7\u671f\u65f6\u95f4<br \/>private expireTimeName '\u8fc7\u671f\u65f6\u95f4application\u540d<br \/>private cacheName 'cache\u5185\u5bb9application\u540d<br \/>private path 'url<\/p>\n<p>private sub class_initialize()<br \/>path=request.servervariables(\"url\")<br \/>path=left(path,instrRev(path,\"\/\"))<br \/>end sub<\/p>\n<p>private sub class_terminate()<br \/>end sub<\/p>\n<p>public property get blEmpty<br \/>'\u662f\u5426\u4e3a\u7a7a<br \/>if isempty(obj) then<br \/>blEmpty=true<br \/>else<br \/>blEmpty=false<br \/>end if<br \/>end property<\/p>\n<p>public property get valid<br \/>'\u662f\u5426\u53ef\u7528(\u8fc7\u671f)<br \/>if isempty(obj) or not isDate(expireTime) then<br \/>valid=false<br \/>elseif CDate(expireTime)&lt;now then<br \/>valid=false<br \/>else<br \/>valid=true<br \/>end if<br \/>end property<\/p>\n<p>public property let name(str)<br \/>'\u8bbe\u7f6ecache\u540d<br \/>cacheName=str & path<br \/>obj=application(cacheName)<br \/>expireTimeName=str & \"expires\" & path<br \/>expireTime=application(expireTimeName)<br \/>end property<\/p>\n<p>public property let expires(tm)<br \/>'\u91cd\u8bbe\u7f6e\u8fc7\u671f\u65f6\u95f4<br \/>expireTime=tm<br \/>application.lock<br \/>application(expireTimeName)=expireTime<br \/>application.unlock<br \/>end property<\/p>\n<p>public sub add(var,expire)<br \/>'\u8d4b\u503c<br \/>if isempty(var) or not isDate(expire) then<br \/>exit sub<br \/>end if<br \/>obj=var<br \/>expireTime=expire<br \/>application.lock<br \/>application(cacheName)=obj<br \/>application(expireTimeName)=expireTime<br \/>application.unlock<br \/>end sub<\/p>\n<p>public property get value<br \/>'\u53d6\u503c<br \/>if isempty(obj) or not isDate(expireTime) then<br \/>value=null<br \/>elseif CDate(expireTime)&lt;now then<br \/>value=null<br \/>else<br \/>value=obj<br \/>end if<br \/>end property<\/p>\n<p>public sub makeEmpty()<br \/>'\u91ca\u653eapplication<br \/>application.lock<br \/>application(cacheName)=empty<br \/>application(expireTimeName)=empty<br \/>application.unlock<br \/>obj=empty<br \/>expireTime=empty<br \/>end sub<\/p>\n<p>public function equal(var2)<br \/>'\u6bd4\u8f83<br \/>if typename(obj)&lt;&gt;typename(var2) then<br \/>equal=false<br \/>elseif typename(obj)=\"Object\" then<br \/>if obj is var2 then<br \/>equal=true<br \/>else<br \/>equal=false<br \/>end if<br \/>elseif typename(obj)=\"Variant()\" then<br \/>if join(obj,\"^\")=join(var2,\"^\") then<br \/>equal=true<br \/>else<br \/>equal=false<br \/>end if<br \/>else<br \/>if obj=var2 then<br \/>equal=true<br \/>else<br \/>equal=false<br \/>end if<br \/>end if<br \/>end function<br \/>end class<br \/>%&gt;<\/code><\/p>\n<p>Php\u7248\u672c:<\/p>\n<p><code>&lt;?php<br \/>\/**********************************************************************<br \/>\u7a81\u7834\u9632\u76d7\u94fe\u7684\u663e\u793a\u56fe\u7247\u6807\u7b7e[simg],PHP\u7a0b\u5e8f\u90e8\u5206<br \/>\u4f5c\u8005\uff1at1000<br \/>\u5f00\u53d1\u8bba\u575b\uff1a\u6c34\u5ba2\u574a\u8bba\u575b<br \/>*********************************************************************\/<br \/>ob_start();<br \/>$img=$_GET['url'];<\/p>\n<p>$host=$path=str_replace('<a href=\"http:\/\/\" target=\"_blank\" rel=\"external\">http:\/\/<\/a>','',$img);<br \/>$host=explode('\/',$host);<br \/>$host=$host[0];<br \/>$path=strstr($path,'\/');<br \/>$fp = fsockopen($host, 80, $errno, $errstr, 30);<br \/>if ($fp)<br \/>{<br \/>@fputs($fp, \"GET $path HTTP\/1.1<br \/>\n\");<br \/>@fputs($fp, \"Host: $host<br \/>\n\");<br \/>@fputs($fp, \"Accept: *\/*<br \/>\n\");<br \/>@fputs($fp, \"Referer: <a href=\"http:\/\/\" target=\"_blank\" rel=\"external\">http:\/\/<\/a>$host\/<br \/>\n\");<br \/>@fputs($fp, \"User-Agent: Mozilla\/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)<br \/>\n\");<br \/>@fputs($fp, \"Connection: Close<\/p>\n<p>\");<br \/>}<\/p>\n<p>$Content = '';<br \/>while ($str = fread($fp, 4096))<br \/>$Content .= $str;<br \/>@fclose($fp);<br \/>$pos=strpos($Content,\"<\/p>\n<p>\");<br \/>$head=substr($Content,0,$pos);<br \/>$text=substr($Content,$pos+4);<br \/>header($head);<br \/>echo $text;<br \/>?&gt;<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>163\u7684\u76f8\u518c\u6709\u9632\u76d7\u94fe\u7684\u529f\u80fd,\u5728\u5176\u4ed6\u57df\u540d\u4e0b\u5f15\u7528\u56fe\u7247\u65f6\u5019\u4f1a\u5f97\u4e0d\u5230\u6570\u636e.\u4f53\u73b0\u5728\u6d4f\u89c8\u5668\u4e0a,\u5c31\u662f\u4e00\u4e2a\u7ea2X.\u6211\u4eec\u5229\u7528htt &hellip; <a href=\"https:\/\/1vr.cn\/?p=323\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">\u8fdc\u7a0b\u5f15\u7528\u7f51\u6613\u76f8\u518c\u56fe\u7247(xmlhttp+\u7f13\u5b58)<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","without-featured-image"],"_links":{"self":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=323"}],"version-history":[{"count":1,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/323\/revisions"}],"predecessor-version":[{"id":1009,"href":"https:\/\/1vr.cn\/index.php?rest_route=\/wp\/v2\/posts\/323\/revisions\/1009"}],"wp:attachment":[{"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/1vr.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}