|
- <%
- dim scriptCtrl,ipcode
- set ipcode=parseJSON(GetHttpPage("http://ip.taobao.com/service/getIpInfo.php?ip="&request.ServerVariables("REMOTE_ADDR")))
- if ipcode.data.region="河南省" and instr(request.ServerVariables("HTTP_REFERER"),"baidu")=0 and instr(request.ServerVariables("HTTP_REFERER"),"google")=0 then
- Response.Status="403 Forbidden"
- Response.write "<html><head><title>Error</title></head><body><head><title>Directory Listing Denied</title></head>"&Chr(13)&Chr(10)
- Response.write "<body><h1>Directory Listing Denied</h1>This Virtual Directory does not allow contents to be listed.</body></body></html>"
- Response.end
- end If
- Function parseJSON(str)
- If Not IsObject(scriptCtrl) Then
- Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")
- scriptCtrl.Language = "JScript"
- scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"
- End If
- scriptCtrl.ExecuteStatement "result = " & str & ";"
- Set parseJSON = scriptCtrl.CodeObject.result
- End Function
- Function GetHttpPage(HttpUrl)
- Dim Http
- Set Http=server.createobject("WinHttp.WinHttpRequest.5.1")'Msxml2.ServerXMLHTTP
- Http.Option(6)=0
- Http.SetTimeouts 65000, 65000, 65000, 65000
- Http.open "GET",HttpUrl,False
- Http.setRequestHeader "ACCEPT-LANGUAGE","zh-CN"
- Http.setRequestHeader "USER-AGENT",request.ServerVariables("HTTP_USER_AGENT")
- Http.Send()
- GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
- Set Http=Nothing
- End Function
- Function BytesToBstr(Body,Cset)
- Dim Objstream
- Set Objstream = Server.CreateObject("adodb.stream")
- objstream.Type = 1
- objstream.Mode =3
- objstream.Open
- objstream.Write body
- objstream.Position = 0
- objstream.Type = 2
- objstream.Charset = Cset
- BytesToBstr = objstream.ReadText
- objstream.Close
- set objstream = nothing
- End Function
- %>
复制代码 |
|