<Script language="vbscript" runat="server">
'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004 Version 2.0
' Made by 尹曙光
' All Rights Reserved.
' ****************************************************************
'
' 系统常用的一些公用函数
'
'*****************************************************************
'检查系统错误
'errMsg:出错后的提示信息
Function FIfError(errMsg)
if Err.number>0 then
Response.Write "<br>"
Response.Write errMsg
Response.End
end if
End Function
'显示系统错误信息
Function FSystemError()
if Err.number>0 then
Response.Write "<br>"
Response.Write "错误来源:"&Err.Source&"<br>"
Response.Write "错误代码:"&Err.number&"<br>"
Response.Write "错误说明:"&Err.Description &"<br>"
Response.End
end if
End Function
'判断是不是从form提交过来的
Function FIsPostBack()
if ( UCase(trim(Request.ServerVariables("REQUEST_METHOD")))="POST") then
FIsPostBack=true
else
FIsPostBack=false
end if
End Function
function FGetUserIp()
FGetUserIp=Request.ServerVariables("remote_addr")
End Function
</Script>
<Script language="vbscript" runat="server">
'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004 Version 2.0
' Made by 尹曙光
' All Rights Reserved.
' ****************************************************************
'
' 字符串处理函数
'
'*****************************************************************
'取得一个长度为ilen的字符串,含字母和数字
Function FRandomStr(ilen)
dim c,strResult
ilen=cint(ilen)
for i=1 to ilen
Randomize
c=Int((74 * Rnd) + 48) 'c>48 and c<122
while (c>57 and c<65) or (c>90 and c<97)
Randomize
c=Int((74 * Rnd) + 48)
wend
strResult=strResult&cstr(chr(c))
next
FRandomStr=strResult
End Function
'以下两个函数是用于检查身份证件号的
Function FCheckIdCard2(strIdCard)
dim iIdCard,strTmp
iIdCard=Len(strIdCard)
if (iIdCard=null or (not(iIdCard=15 or iIdCard=18))) then
FCheckIdCard2=false
exit function
end if
if iIdCard=15 then
strTmp=strIdCard
else
strTmp=mid(strIdCard,1,17)
end if
if IsNumeric(strTmp) then
FCheckIdCard2=true
else
FCheckIdCard2=false
exit function
end if
if iIdCard=18 then
strTmp=mid(strIdCard,18,1)
strTmp=ucase(strTmp)
if not (IsNumeric(strTmp) or strTmp="X") then
FCheckIdCard2=false
exit function
end if
end if
End Function
'检查身份证号
'参数:str:待检查的字符串
'参数2:出生日期的年(4位)
'参数3:出生日期的月
'参数4:出生日期的日
Function FCheckIdCard(byval strIdCard,byval iYear,byval iMonth,byval iDay)
dim strBirthDay,strTmp1
if not FCheckIdCard2(strIdCard) then
FCheckIdCard=false
exit function
end if
if len(iYear)<>4 then
FCheckIdCard=false
exit function
end if
strBirthDay=cstr(iYear)+String(2-len(cstr(iMonth)),"0")+cstr(iMonth)+String(2-len(cstr(iDay)),"0")+cstr(iDay)
if len(strIdCard)=15 then
strTmp1=mid(strIdCard,7,6)
strBirthDay=mid(strBirthDay,3,6)
if strTmp1<>strBirthDay then
FCheckIdCard=false
exit function
end if
else
strTmp1=mid(strIdCard,7,8)
if strTmp1<>strBirthDay then
FCheckIdCard=false
exit function
end if
end if
FCheckIdCard=true
End Function
'检查邮编
function FCheckPostCode(byval strCode)
if (len(trim(strCode))<>6) then
FCheckPostCode=false
exit function
else
FCheckPostCode=IsNumeric(strCode)
Exit Function
end if
End function
'-----------------可逆加密----------------------------------------------
function encrypt(byval ecode)
Dim texts
dim i
for i=1 to len(ecode)
texts=texts & chr(asc(mid(ecode,i,1))+i)
next
encrypt = texts
end function