<Script language="vbscript" runat="server">
'****************************************************************
' 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 "<Style>"&chr(13)
Response.Write "BODY { margin: 0px 0px 0px 0px;FONT-FAMILY: '宋體','Tahoma', 'MS Shell Dlg';color: #000000;font: 9pt;background-color:#f0f1eb;}"&chr(13)
Response.Write "A{font:normal 12px 宋體;COLOR: #336699; TEXT-DECORATION: none}"&chr(13)
Response.Write "TD{font-family:宋體; font-size: 12px; line-height: 15px;background-color:#f0f1eb;}"&chr(13)
Response.Write ".THead{ background-color: #336699;color:#ffffff;font-weight:bold;}"&chr(13)
Response.Write ".TFoot{ background-color: #336699;COLOR: #ffffff;}"&chr(13)
Response.Write "</style>"&chr(13)
Response.Write "<table height='90%' width='100%'> <tr>"&chr(13)
Response.Write "<td align=center> <table align=center cellpadding=0 cellspacing=0 bordercolor='#336699' bgcolor='#336699' style='width:90%'>"
Response.Write "<tr align=center>"&chr(13)
Response.Write "<td width='100%' height=20 colspan=2 bgcolor='#336699' class='THead' >系統提示資訊</t> "&chr(13)
Response.Write "<tr><td width='100%' colspan=2 align='center' bgcolor='#FFFFFF'><br> "&chr(13)
Response.Write strMsg
Select Case cint(msgType)
case 1
Response.Write "[<a href='javascript:window.close();'>關閉視窗</a>]"
Case 2
Response.Write "[<a href='javascript:history.back(-1);'>返回</a>]"
case 3
Response.Write "[<a href='javascript:history.back("&jumpUrl&");'>返回</a>]"
case 4
Response.Write "<meta HTTP-EQUIV=REFRESH CONTENT='3; URL="&jumpUrl&"'>,正在跳轉..."
case 5
Response.Write "[<a href='"&jumpUrl&"'>返回</a>]"
End Select
Response.Write "<br><br></td></tr><tr align=center><td width='100%' height=20 colspan=2 class='TFoot'>"&chr(13)
Response.Write strCopyRight
Response.Write "</td> </tr></table></td> </tr> </table>"&chr(13)
Response.End()
End Function
'檢查系統錯誤
'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
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>
<SCRIPT LANGUAGE=javascript RUNAT=Server>
// ************************************************************************
// 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<aMain.length;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<aMain.length;i++){
if (aMain[i]==str) {
thisResult[j++]=i
}
}
return thisResult
}
</SCRIPT>
<script language=jscript runat=server>
// ************************************************************************
// 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
}
</script>