%
function trim_str(str,line_len)
dim result
str = trim(str)
dim l
if isNULL(str) then
trim_str=""
exit function
end if
l=len(str)
result=""
if l>line_len then
result=left(str,line_len)+"..."
else
result=str
end if
trim_str=result
end function
'********************************************
'函数名:checkpassword
'作 用:检查输入口令的合法性
'参 数:email ----要检查的Email地址
'返回值:True ----Email地址合法
' False ----Email地址不合法
'********************************************
function checkpassword(password,minlen,maxlen)
dim good_password_chars,i,c
good_password_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
checkpassword=true
if len(Password)maxlen then
checkpassword=false
exit function
end if
for i=1 to len(password)
c=mid(password,I,1)
if(InStr(good_password_chars,c)=0) then
checkpassword=false
exit function
end if
next
end function
'********************************************
'函数名:checkEmail
'作 用:检查Email地址合法性
'参 数:email ----要检查的Email地址
'返回值:True ----Email地址合法
' False ----Email地址不合法
'********************************************
function checkEmail(email)
dim names, name, i, c
checkEmail = true
names = Split(email, "@")
if UBound(names) <> 1 then
checkEmail = false
exit function
end if
for each name in names
if Len(name) <= 0 then
checkEmail = false
exit function
end if
for i = 1 to Len(name)
c = Lcase(Mid(name, i, 1))
if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
checkEmail = false
exit function
end if
next
if Left(name, 1) = "." or Right(name, 1) = "." then
checkEmail = false
exit function
end if
next
if InStr(names(1), ".") <= 0 then
checkEmail = false
exit function
end if
i = Len(names(1)) - InStrRev(names(1), ".")
if i <> 2 and i <> 3 then
checkEmail = false
exit function
end if
if InStr(email, "..") > 0 then
checkEmail = false
end if
end function
'**************************************************
'函数名:strLength
'作 用:求字符串长度。汉字算两个字符,英文算一个字符。
'参 数:str ----要求长度的字符串
'返回值:字符串长度
'**************************************************
function strLength(str)
ON ERROR RESUME NEXT
dim WINNT_CHINESE
WINNT_CHINESE = (len("中国")=2)
if WINNT_CHINESE then
dim l,t,c
dim i
l=len(str)
t=l
for i=1 to l
c=asc(mid(str,i,1))
if c<0 then c=c+65536
if c>255 then
t=t+1
end if
next
strLength=t
else
strLength=len(str)
end if
if err.number<>0 then err.clear
end function
'**************************************************
'函数名:Ifchinese
'作 用:判断字符串是否中文,长度在设定的字符数
'参 数:str ----要求判断的字符串
'返回值:字符串符合要求真假
'**************************************************
function Ifchinese(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|\\'\"":;~!$%()`"
L=len(str)
if L=0 or Lmaxlen then
Ifchinese=false
exit function
elseif L>30 then
Ifchinese=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )<>0 then
Ifchinese=false
exit function
end if
next
Ifchinese=true
end function
'**************************************************
'函数名:IfchineseA
'作 用:判断字符串是否中文,长度在设定的字符数
'参 数:str ----要求判断的字符串
'返回值:字符串符合要求真假
'**************************************************
function IfchineseA(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789><,[]{}?/+=|\\'\"":;~!$%()`》《,。?/:;“”‘’|、——-)(*—……%¥#·!`~"
L=len(str)
if L=0 or Lmaxlen then
IfchineseA=false
exit function
elseif L>30 then
IfchineseA=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )<>0 then
IfchineseA=false
exit function
end if
next
IfchineseA=true
end function
'**************************************************
'函数名:Ifchar
'作 用:判断字符串是否包含特殊字符
'参 数:str ----要求判断的字符串
'返回值:字符串符合要求真假
'**************************************************
function Ifchar(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "><,[]{}?/+=|\\'\"":;~!$%()`"
L=len(str)
if L=0 or LMaxlen then
Ifchar=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )<>0 then
Ifchar=false
exit function
end if
next
Ifchar=true
end function
'**************************************************
'函数名:IfcharA
'作 用:判断字符串是否包含特殊字符
'参 数:str ----要求判断的字符串
'返回值:字符串符合要求真假
'**************************************************
function IfcharA(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "><,[]{}?/+=|\\'\"":;~!$%()》《,。/?;:‘’“”、|——-)(*—……%¥#·!~`"
L=len(str)
if L=0 or LMaxlen then
IfcharA=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )<>0 then
IfcharA=false
exit function
end if
next
IfcharA=true
end function
'**************************************************
'函数名:testcharA
'作 用:判断字符串是否包含特殊字符
'参 数:str ----要求判断的字符串
'返回值:字符串符合要求真假
'**************************************************
function testcharA(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "><,[]{}?/+=|\\'\"":;~!$%》《,。/?;:‘’“”、|——*……%¥#·!~`"
L=len(str)
if L=0 or LMaxlen then
testcharA=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )<>0 then
testcharA=false
exit function
end if
next
testcharA=true
end function
'**************************************************
'函数名:IfEnglish
'作 用:判断字符串是否字符和数字、下划线组成,长度在设定的字符数量
'参 数:str ----要求长度的字符串
'返回值:字符串符合要求真假
'**************************************************
function IfEnglish(str,minlen,maxlen)
Dim Letters,i,c,L
Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890_"
L=len(str)
if L=0 or Lmaxlen then
IfEnglish=false
exit function
end if
for i=1 to L
c = mid( str,i,1 )
if inStr( Letters,c )=0 then
IfEnglish=false
exit function
end if
next
IfEnglish=true
end function
'**************************************************
'函数名:IsInteger
'作 用:判断字符串是否数字
'参 数:para ----要求长度的字符串
'返回值:是否为数字
'**************************************************
function isInteger(para,minlen,maxlen)
on error resume next
dim str
dim l,i
if isNUll(para) then
isInteger=false
exit function
end if
str=cstr(para)
l=len(str)
if trim(str)="" or Lmaxlen then
isInteger=false
exit function
end if
for i=1 to l
if mid(str,i,1)>"9" or mid(str,i,1)<"0" then
isInteger=false
exit function
end if
next
isInteger=true
if err.number<>0 then err.clear
end function
'**************************************************
'函数名:Testtelephone
'作 用:判断字符串是否字符和数字组成。
'参 数:str ----要求长度的字符串
'返回值:字符串符合要求真假
'**************************************************
Function Testtelephone(str)
Dim re,b1,b2
Set re = new RegExp
re.IgnoreCase = false
re.global = false
re.Pattern = "^\d{3,4}-\d{7,8}$"
b1 = re.Test(str)
re.Pattern = "^\d{11,12}$"
b2 = re.Test(str)
if b1=true or b2=true then
Testtelephone=true
else
Testtelephone=false
end if
End Function
'**************************************************
'函数名:Testdate
'作 用:判断字符串是否字符和数字组成。
'参 数:str ----要求长度的字符串
'返回值:字符串符合要求真假
'**************************************************
Function Testdate(str)
Dim re
Set re = new RegExp
re.IgnoreCase = false
re.global = false
re.Pattern = "^\d{4}-\d{1,2}-\d{1,2}$"
testdate = re.Test(str)
End Function
'**************************************************
'函数名:Testpost
'作 用:判断字符串是否字符和数字组成。
'参 数:str ----要求长度的字符串
'返回值:字符串符合要求真假
'**************************************************
Function Testpost(str)
Dim re
Set re = new RegExp
re.IgnoreCase = false
re.global = false
re.Pattern = "^\d{6}$"
testpost = re.Test(str)
End Function
'**************************************************
'函数名:HTMLEncode
'作 用:用于过滤替换输入内容中的特殊字符。
'参 数:strFilter ----需要替换的字符串
'返回值:替换后的内容
'**************************************************
Public Function HTMLEncode(strFilter)
If Not IsNull(strFilter) Then
strFilter = replace(strFilter, ">", ">")
strFilter = replace(strFilter, "<", "<")
strFilter = Replace(strFilter, CHR(32), " ") '
strFilter = Replace(strFilter, CHR(9), " ") '
strFilter = Replace(strFilter, CHR(34), """)
'strFilter = Replace(strFilter, CHR(39), "'") '单引号过滤
strFilter = Replace(strFilter, CHR(13), "")
strFilter = Replace(strFilter, CHR(10) & CHR(10), "
")
strFilter = Replace(strFilter, CHR(10), " ")
'strFilter=ChkBadWords(strFilter)
HTMLEncode = strFilter
End If
End Function
'**************************************************
'函数名:HTMLdecode
'作 用:用于过滤替换输入内容中的特殊字符。
'参 数:strFilter ----需要替换的字符串
'返回值:替换后的内容
'**************************************************
Public Function HTMLdecode(strFilter)
If Not IsNull(strFilter) Then
strFilter = replace(strFilter, ">", ">")
strFilter = replace(strFilter, "<", "<")
strFilter = Replace(strFilter, " ", CHR(32)) '
strFilter = Replace(strFilter, " ", CHR(9)) '
strFilter = Replace(strFilter, """, CHR(34))
'strFilter = Replace(strFilter, "'", CHR(39)) '单引号过滤
strFilter = Replace(strFilter, "", CHR(13))
strFilter = Replace(strFilter, "
", CHR(10) & CHR(10))
strFilter = Replace(strFilter, " ", CHR(10))
'strFilter=ChkBadWords(strFilter)
HTMLdecode = strFilter
End If
End Function
'**************************************************
'函数名:ChkBadWords
'作 用:用于过滤替换输入内容中的特殊字符。
'参 数:strFilter ----需要替换的字符串
'返回值:替换后的内容
'**************************************************
Public Function ChkBadWords(strBad)
If IsNull(strBad) Then Exit Function
Dim i
BadWords=split(BadWords,",")
For i = 0 To UBound(BadWords)
If InStr(strBad,BadWords(i))>0 Then
strBad = Replace(strBad,BadWords(i),"***")
End If
Next
ChkBadWords = strBad
End Function
'**************************************************
'函数名:RealIP()
'作 用:用于获取客户的ip地址。
'返回值:ip地址
'**************************************************
Public Function RealIP()
RealIP=Request.ServerVariables("http_x_forwarded_for")
if RealIP="" or Isnull(RealIP) then RealIP=Request.ServerVariables("remote_addr")
End Function
'**************************************************
'函数名:isSQLInject
'作 用:判断输入内容中是否有sql注入的非法字符。
'参 数:strPara ----检测的字符串
'返回值:字符串是否包含注入过滤字符
'**************************************************
'Sql注入判断
public Function isSQLInject(StrPara)
Const Web_SqlInject= """,',;,and,exec,insert,select,delete,update,count,*,%,chr,mid,asc,master,truncate,char,declare,net user,xp_cmdshell,/add,drop,from" 'SQL 注入字符集常量定义
dim StrSQlInject
StrSQlInject=""
dim SqlInject
isSQLInject=False
if isNull(StrPara) then Exit Function
SqlInject=split(Web_SqlInject,",")
For i=0 to ubound(SqlInject)
if Instr(lcase(StrPara),lcase(SqlInject(i)))<>0 then
StrSQlInject=StrSQlInject&SqlInject(i)
isSQLInject=True
Response.Write ""
response.end
Exit For
end if
next
End Function
'**************************************************
'函数名:SafeRequest
'作 用:替换request的安全检测表单内容获取函数。
'参 数:ParaName,ParaType ----获取的字符串和检测类型
'返回值:字符串是否包含注入过滤字符
'**************************************************
public Function SafeRequest(ParaName,ParaType)
'--- 传入参数 ---
'ParaName:参数名称-字符型
'ParaType:参数类型-数字型(1表示以上参数是数字,0表示以上参数为字符)
Dim ParaValue
ParaValue=trim(Request(ParaName))
If ParaType=1 then
If not isNumeric(ParaValue) or ParaValue="" then
Response.write "参数" & ParaName & "必须为数字型!"
Response.end
else
SafeRequest=ParaValue
End if
end if
if ParaType=2 then
ParaValue=replace(ParaValue,"'","''")
SafeRequest=ParaValue
End if
if ParaType=3 then
if issqlinject(ParaValue)=false then
ParaValue=replace(ParaValue,"'","''")
SafeRequest=ParaValue
end if
end if
End function
%>
<%
dim conn
dim connstr
dim db
db="product/jgchain7788.asp"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(""&db&"")
On Error Resume Next
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "数据库连接出错,请检查连接字串。"'注释,需要把这几个字翻译成英文。
Response.End
End If
%>
<%
dim strsql,rs,rs1
set rs=server.createobject("adodb.recordset")
set rs1=server.createobject("adodb.recordset")
%>
诸暨市巨光重板链条厂
<%
if request("pclass")<>"" then
pclass=saferequest("pclass",1)
strsql="select * from product where pclass2="&pclass&" order by porder asc,id asc"
else
strsql="select * from product order by porder asc,id asc"
end if
rs.open strsql,Conn,1,1
if not rs.eof then
PgSz=1
rs.PageSize = cint(pgsz)
total=int(rs.recordcount / PgSz * -1)*-1
page=Request("page")
if page="" Then
page = 1
else
page=page+1
page=page-1
end if
if page<1 Then
page=1
end if
rs.absolutePage = page
sub showpage()
response.write "首页 "
if page > 1 Then
response.write "上一页 "
else
response.write "上一页 "
end if
if page < Total then
response.write "下一页 "
else
response.write "下一页 "
end if
response.write "末页 "
content=""
response.write"转到: "&content&" 页"
response.write" 共"&total&"页,每页"&PgSz&"条"
end sub
RowCount = RS.PageSize
do while not rs.eof and rowcount>0
%>
<%
rowcount=rowcount-1
rs.movenext
loop
end if
rs.close
%>