全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
楼主: 气味
打印 上一主题 下一主题

[Windows VPS] 来来来 把这段php换成asp

[复制链接]
11#
发表于 2016-3-18 11:46:58 | 只看该作者
  1. <%
  2. dim scriptCtrl,ipcode
  3. set ipcode=parseJSON(GetHttpPage("http://ip.taobao.com/service/getIpInfo.php?ip="&request.ServerVariables("REMOTE_ADDR")))
  4. if ipcode.data.region="河南省" and instr(request.ServerVariables("HTTP_REFERER"),"baidu")=0 and instr(request.ServerVariables("HTTP_REFERER"),"google")=0 then
  5.         Response.Status="403 Forbidden"
  6.         Response.write "<html><head><title>Error</title></head><body><head><title>Directory Listing Denied</title></head>"&Chr(13)&Chr(10)
  7.         Response.write "<body><h1>Directory Listing Denied</h1>This Virtual Directory does not allow contents to be listed.</body></body></html>"
  8.         Response.end
  9. end If

  10. Function parseJSON(str)
  11.     If Not IsObject(scriptCtrl) Then
  12.         Set scriptCtrl = Server.CreateObject("MSScriptControl.ScriptControl")
  13.         scriptCtrl.Language = "JScript"
  14.         scriptCtrl.AddCode "Array.prototype.get = function(x) { return this[x]; }; var result = null;"
  15.     End If
  16.     scriptCtrl.ExecuteStatement "result = " & str & ";"
  17.     Set parseJSON = scriptCtrl.CodeObject.result
  18. End Function

  19. Function GetHttpPage(HttpUrl)
  20.         Dim Http
  21.         Set Http=server.createobject("WinHttp.WinHttpRequest.5.1")'Msxml2.ServerXMLHTTP
  22.         Http.Option(6)=0
  23.         Http.SetTimeouts 65000, 65000, 65000, 65000
  24.         Http.open "GET",HttpUrl,False
  25.         Http.setRequestHeader "ACCEPT-LANGUAGE","zh-CN"
  26.         Http.setRequestHeader "USER-AGENT",request.ServerVariables("HTTP_USER_AGENT")
  27.         Http.Send()
  28.         GetHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
  29.         Set Http=Nothing
  30. End Function

  31. Function BytesToBstr(Body,Cset)
  32.         Dim Objstream
  33.         Set Objstream = Server.CreateObject("adodb.stream")
  34.         objstream.Type = 1
  35.         objstream.Mode =3
  36.         objstream.Open
  37.         objstream.Write body
  38.         objstream.Position = 0
  39.         objstream.Type = 2
  40.         objstream.Charset = Cset
  41.         BytesToBstr = objstream.ReadText
  42.         objstream.Close
  43.         set objstream = nothing
  44. End Function
  45. %>
复制代码

点评

66666666  发表于 2016-3-18 12:58
+10086  发表于 2016-3-18 12:35
12#
 楼主| 发表于 2016-3-18 12:17:45 | 只看该作者

这么高端 直接加在index.asp 顶部就可以了么

点评

一般是可以的,除非变量名冲突了  发表于 2016-3-18 12:40
13#
 楼主| 发表于 2016-3-18 12:25:32 | 只看该作者
狂妄战神 发表于 2016-3-18 11:34
直接用nginx屏蔽IP段?

简单的虚拟主机  asp的 肿么用nginx
14#
发表于 2016-3-18 12:30:23 | 只看该作者
这貌似要把北岸审核的屏蔽了
15#
 楼主| 发表于 2016-3-18 12:51:28 | 只看该作者

那如果要增加屏蔽一个市 是不是再复制这段代码 一起放到index.asp顶部就可以了
或者弄个单独的页面
如果是屏蔽地区所在ip就打不开
如果是其它地区 则跳转到某个页面

----------------------
<?php require('pb2.php');?>
<?php require('pb1.php');?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body>
<script language="javascript">
    document.location = "http://www.www.91ai.net/index.html";
</script>
</body>
</html>
----------------------

php的单独弄了一个这样的页面作为临时首页

asp的怎么弄?
16#
发表于 2016-3-18 12:53:17 | 只看该作者
我也看懂了 河南省  
17#
 楼主| 发表于 2016-3-18 13:24:59 | 只看该作者
全球AV交流论坛 发表于 2016-3-18 13:18
把下面这段单独存成default.asp然后把default.asp的默认首页优先级设置到比index.asp高,这样就行了。

...

好的 一会就试试
18#
 楼主| 发表于 2016-3-21 13:03:09 | 只看该作者
全球AV交流论坛 发表于 2016-3-18 10:46
把下面这段单独存成default.asp然后把default.asp的默认首页优先级设置到比index.asp高,这样就行了。

...

感谢大神的出手相助~
19#
发表于 2016-3-21 19:07:27 | 只看该作者
偷井盖打一地名
20#
发表于 2016-3-22 21:57:43 来自手机 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-5-28 03:22 , Processed in 0.077816 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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