'****************************************************************
' Script Compont Object Model
' Design for Active Server Pages
' Copyright 2004 Version 2.0
' Made by 尹曙光
' All Rights Reserved.
' ****************************************************************
'
' 系统常用的一些公用函数
'
'*****************************************************************
'系统公用信息显示
'strMsg:提示信息
'msgType:信息提示类型
'jumpUrl:页面眺转地址
'strCopyRight:版权信息
Function FShowMsg(strMsg,msgType,jumpUrl,strCopyRight)
Response.Write ""&chr(13)
Response.Write "
| ||||||
Response.End()
End Function
'检查系统错误
'errMsg:出错后的提示信息
Function FIfError(errMsg)
if Err.number>0 then
Response.Write "
"
Response.Write errMsg
Response.End
end if
End Function
'显示系统错误信息
Function FSystemError()
if Err.number>0 then
Response.Write "
"
Response.Write "错误来源:"&Err.Source&"
"
Response.Write "错误代码:"&Err.number&"
"
Response.Write "错误说明:"&Err.Description &"
"
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 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
function decrypt(byval dcode)
dim texts
dim i
for i=1 to len(dcode)
texts=texts & chr(asc(mid(dcode,i,1))-i)
next
decrypt=texts
end function
'----------------不可逆加密---------------------------------------------------
function mistake(byval preString)
Dim texts
Dim seed
Dim i,length
prestring = trim(preString)
length = len(preString)
seed = length
Randomize(length)
texts = ""
for i = 1 to length
seed = int(94*rnd(-asc(mid(preString,i,1))-seed*asc(right(prestring,1)))+32)
texts = texts & chr(seed) & chr(int(94*rnd(-seed)+32))
next
dim dist
dist=""
for i = 1 to len(texts)
if mid(texts,i,1)<>"'" then
dist=dist+mid(texts,i,1)
end if
next
mistake = dist
end function
// ************************************************************************
// Script Compont Object Model
// Design for Active Server Pages
//
// Copyright 2003 Version 1.0
// Made by 尹曙光
// ************************************************************************
function getArrayOrder(aMain,str){ //数组,给定其数值,求其在数组的下标
//aMain为数组,str为数组中的内容
var iMain=-1
if ((aMain.length==0)||(str.length==0)){
return iMain
}
for(var i=0;i if (aMain[i]==str) { iMain=i break; } } return iMain } function getArrayOrders(aMain,str){ //数组,给定其数值,求其在数组的下标 //该函数返回树组,依次列出,值在数组中的下标 //aMain为数组,str为数组中的内容 thisResult=new Array thisResult[0]=-1 if ((aMain.length==0)||(str.length==0)){ return thisResult } var j=0; for(var i=0;i if (aMain[i]==str) { thisResult[j++]=i } } return thisResult } // ************************************************************************ // Script Compont Object Model // Design for Active Server Pages // // Copyright 2003 Version 1.0 // Made by 尹曙光 // ************************************************************************ function saveRsToTxtFile(rs,filename) { //将RecordSet的内容保存进一个txt文件中,rs数据集,filename文件的绝对路径 var fs = Server.CreateObject("Scripting.FileSystemObject") if (fs.FileExists(filename)) fs.DeleteFile(filename) var txtFile = fs.CreateTextFile(filename) var strLine="" //写入字段名 var nFields = rs.Fields.Count; for (var i=0; i < nFields; i++) strLine+= rs(i).name+"\t" txtFile.WriteLine(strLine) //写入内容 while (! rs.EOF ){ strLine="" for (var i=0; i < nFields; i++) strLine+= rs(i).value+"\t" txtFile.WriteLine(strLine) rs.MoveNext() } txtFile= null fs=null }

