[b]ASP17种正则表达式[/b]
"^\\d+$" //非负整数(正整数 + 0)
"^[0-9]*[1-9][0-9]*$" //正整数
"^((-\\d+)|(0+))$" //非正整数(负整数 + 0)
"^-[0-9]*[1-9][0-9]*$" //负整数
"^-?\\d+$" //整数
"^\\d+(\\.\\d+)?$" //非负浮点数(正浮点数 + 0)
"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮点数
"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$" //非正浮点数(负浮点数 + 0)
"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //负浮点数
"^(-?\\d+)(\\.\\d+)?$" //浮点数
"^[A-Za-z]+$" //由26个英文字母组成的字符串
"^[A-Z]+$" //由26个英文字母的大写组成的字符串
"^[a-z]+$" //由26个英文字母的小写组成的字符串
"^[A-Za-z0-9]+$" //由数字和26个英文字母组成的字符串
"^\\w+$" //由数字、26个英文字母或者下划线组成的字符串
"^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$" //email地址
"^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$" //url
[b]asp 的网页代理[/b]
使用方法:webproxy.asp?url=http://网址
<%
Response.Buffer = True
Dim sUrlB
PageWebProxy()
Sub PageWebProxy()
Dim i, re, Url, Html
Url = Request.QueryString("url")
If Url = "" Then Response.Redirect("?url=http://www.gdqy.edu.cn/")
[b]把 ip 转换为整数[/b]
原理:先把 192.168.1.13 变成16进制的 c0.a8.01.0d ,再去了“.”后转成10进制的 3232235789 即可。
<%
function ip2int(ipstr)
dim iptemp,max
iptemp = split(ipstr&".",".")
max = ubound(iptemp)
if max <> 4 then
exit function
end if
dim a,b,i
a = "&H"
for i = 0 to 3
b = Hex(iptemp(i))
if len(b) = 1 then
b = "0"&b
end if
a = a&b
next
ip2int = CLng(a)
end function
function int2ip(ip)
dim iptemp,a,ipstr,i,length
iptemp = Hex(ip)
length = 8 - len(iptemp)
for i = 1 to length
iptemp = "0" & iptemp
next
a = left(iptemp,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = a & "."
a = mid(iptemp,3,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a & "."
a = mid(iptemp,5,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a & "."
a = right(iptemp,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a
int2ip = ipstr
end function
[b] 防止数据库下载代码[/b]
<!--#include file="Conn.asp" -->
<%
If DBType = 0 Then 'access=0,其他为sql server
SqlCmd = "Create Table NotDownload(NotDown OLEObject)"
Conn.Execute(SqlCmd)
SqlCmd = "Insert into NotDownload(NotDown) values('" &chrB(Asc("<")) & chrB(Asc("%")) & "')"
Conn.Execute(SqlCmd)
Conn.Close
Set Conn = Nothing
Response.Write "数据库防下载处理完成,请确认您的Access数据库已经改为ASP后缀!"
Else
SqlCmd = "Create Table NotDownLoad(NotDown image)"
Conn.Execute(SqlCmd)
SqlCmd = "Insert NotDownload(NotDown) values(0x3c25)"
Conn.Execute(SqlCmd)
Conn.Close
Set Conn = Nothing
Response.Write "数据库防下载处理完成,即使您的SQL Server数据库备份为ASP后缀也不会正常执行。"
End If
"^\\d+$" //非负整数(正整数 + 0)
"^[0-9]*[1-9][0-9]*$" //正整数
"^((-\\d+)|(0+))$" //非正整数(负整数 + 0)
"^-[0-9]*[1-9][0-9]*$" //负整数
"^-?\\d+$" //整数
"^\\d+(\\.\\d+)?$" //非负浮点数(正浮点数 + 0)
"^(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*))$" //正浮点数
"^((-\\d+(\\.\\d+)?)|(0+(\\.0+)?))$" //非正浮点数(负浮点数 + 0)
"^(-(([0-9]+\\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\\.[0-9]+)|([0-9]*[1-9][0-9]*)))$" //负浮点数
"^(-?\\d+)(\\.\\d+)?$" //浮点数
"^[A-Za-z]+$" //由26个英文字母组成的字符串
"^[A-Z]+$" //由26个英文字母的大写组成的字符串
"^[a-z]+$" //由26个英文字母的小写组成的字符串
"^[A-Za-z0-9]+$" //由数字和26个英文字母组成的字符串
"^\\w+$" //由数字、26个英文字母或者下划线组成的字符串
"^[\\w-]+(\\.[\\w-]+)*@[\\w-]+(\\.[\\w-]+)+$" //email地址
"^[a-zA-z]+://(\\w+(-\\w+)*)(\\.(\\w+(-\\w+)*))*(\\?\\S*)?$" //url
[b]asp 的网页代理[/b]
使用方法:webproxy.asp?url=http://网址
<%
Response.Buffer = True
Dim sUrlB
PageWebProxy()
Sub PageWebProxy()
Dim i, re, Url, Html
Url = Request.QueryString("url")
If Url = "" Then Response.Redirect("?url=http://www.gdqy.edu.cn/")
[b]把 ip 转换为整数[/b]
原理:先把 192.168.1.13 变成16进制的 c0.a8.01.0d ,再去了“.”后转成10进制的 3232235789 即可。
<%
function ip2int(ipstr)
dim iptemp,max
iptemp = split(ipstr&".",".")
max = ubound(iptemp)
if max <> 4 then
exit function
end if
dim a,b,i
a = "&H"
for i = 0 to 3
b = Hex(iptemp(i))
if len(b) = 1 then
b = "0"&b
end if
a = a&b
next
ip2int = CLng(a)
end function
function int2ip(ip)
dim iptemp,a,ipstr,i,length
iptemp = Hex(ip)
length = 8 - len(iptemp)
for i = 1 to length
iptemp = "0" & iptemp
next
a = left(iptemp,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = a & "."
a = mid(iptemp,3,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a & "."
a = mid(iptemp,5,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a & "."
a = right(iptemp,2)
a = "&H" & a
i = CInt(a)
a = CStr(i)
ipstr = ipstr & a
int2ip = ipstr
end function
[b] 防止数据库下载代码[/b]
<!--#include file="Conn.asp" -->
<%
If DBType = 0 Then 'access=0,其他为sql server
SqlCmd = "Create Table NotDownload(NotDown OLEObject)"
Conn.Execute(SqlCmd)
SqlCmd = "Insert into NotDownload(NotDown) values('" &chrB(Asc("<")) & chrB(Asc("%")) & "')"
Conn.Execute(SqlCmd)
Conn.Close
Set Conn = Nothing
Response.Write "数据库防下载处理完成,请确认您的Access数据库已经改为ASP后缀!"
Else
SqlCmd = "Create Table NotDownLoad(NotDown image)"
Conn.Execute(SqlCmd)
SqlCmd = "Insert NotDownload(NotDown) values(0x3c25)"
Conn.Execute(SqlCmd)
Conn.Close
Set Conn = Nothing
Response.Write "数据库防下载处理完成,即使您的SQL Server数据库备份为ASP后缀也不会正常执行。"
End If