<%
'================================
'函數列表:
'1: 建立數據庫的連接 ConnOpen(DataBaseConnectStr,DBType,Conn_object)
'2: 斷開數據庫的連接 ConnClose(Conn_object)
'3: 防止SQL注入 SafeRequest(paraName,paraType)
'4: 格式化日期 DateFormat(dateStr,dateType)
'5: 顯示錯誤提示 ShowErr(errStr)
'6: 查詢字符串中特定數據 SelectStr(contentStr,patternStr,patternNum)
'7: 過濾指定字符 Leach(contentStr,badWords)
'8: 遠程文件內容抓取 Seize(urlStr)
'9: 數據流編碼處理 BytesToBstr(body,cset)
'10: 編碼cookies codeCookie(contentStr)
'11: 解碼cookies DecodeCookie(contentStr)
'12: 檢驗數據提交來源是否合法 ChkPost()
'13: 個性化加密 MyEncrypt(StrPassword)
'14: 禁止浏覽器緩存本頁 NoBuffer()
'15: 網頁格式化輸入文本 HTMLEncode(fString)
'16: 從頭部截取字符串的指定長度(按字符數算) GotTopic(Str,StrLen)
'17: 檢測驗證碼 CheckRadomPass(RadomPass)
'18: 生成驗證碼 GetCode()
'19: 獲取客戶端操作系統版本 GetSystem()
'20: 數據庫事務處理 ConnManage(Conn_object)
'21: 快速排序(遞歸) QuickSort(arr,Low,High)
'22: 將數組的元素以特定字符串連起來 arr_join(arr,character)
'23: 返回字符串以某分割符分割的數目 count_character(str,character)
'24: 截取含有分割符的字符串中指定數目的字符串 inter_str_by_character_num(str,character,start,num)
'25: 利用Stream下載文件 downloadFile(strFile)
'26: 返回信息 send_back(ResultWords)
'27: 獲取錯誤信息 get_err()
'28: 與SafeRequest相反 SafeResponse(content)
'29: 保存遠程圖片 SaveRemoteFile(LocalFileName,RemoteFileUrl)
'30: ...
dim language_arr(10)
language_arr(0) = "數據庫連接的參數設置錯誤!"
language_arr(1) = "數據庫連接的類型參數設置錯誤!"
language_arr(2) = "數據庫連接失敗!"
language_arr(3) = "非法的參數值!"
language_arr(4) = "參數值不是有效的日期格式!"
language_arr(5) = "操作失敗!"
language_arr(6) = "欄目有重名!"
language_arr(7) = "欄目名稱為空!"
language_arr(8) = "欄目文件夾創建失敗!"
language_arr(9) = "您沒有此權限!"
'
'函數ID:1
'函數作用:建立數據庫的連接
'修改時間:
'傳人參數:
' connectStr:數據庫連接字符串
' connectType:數據庫類別-數字型,0為Access,1為MS SQL
'返回值:
'
sub ConnOpen(DataBaseConnectStr,DBType,Conn_object)
Set Conn_object = Server.Createobject("adodb.connection")
if DataBaseConnectStr = "" then call ShowErr(language_arr(0))
if DBType = 0 then
Conn_object.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DataBaseConnectStr
elseif DBType = 1 then
Conn_object.Open "Provider=SQLOLEDB.1;" & DataBaseConnectStr
else
call ShowErr(language_arr(1))
end if
err.clear
end sub
'
'函數ID:2
'函數作用:斷開數據庫的連接
'修改時間:
'傳人參數:
'返回值:
'
Sub ConnClose(Conn_object)
Conn_object.close
set Conn_object = nothing
End sub
'
'函數ID:3
'函數作用:防止SQL注入
'修改時間:
'傳人參數:
' paraName:參數名稱-字符型
' paraType:參數類型-數字型(1表示以上參數是數字,0表示以上參數為字符)
'返回值:
' 過濾後的字符串
'
Function SafeRequest(paraName,paraType)
dim paraValue
paraValue = Request(paraName)
select case paraType
case 0
paraValue = replace(paraValue,"'","[system:34]")
paraValue = replace(paraValue,"=","[system:61]")
case 1
if not IsNumeric(paraValue) then call ShowErr(language_arr(3))
case -1
if not IsNumeric(paraValue) then call ShowErr(language_arr(3))
if paraValue = "" then paraValue = 0
case else
if len(paraValue) > paraType then call ShowErr(language_arr(3))
paraValue = replace(paraValue,"'","[system:34]")
paraValue = replace(paraValue,"=","[system:61]")
end select
SafeRequest = paraValue
End function
'==============================='函數ID:4
'函數作用:格式化日期
'修改時間:
'傳人參數:
' dateStr:日期字符串
' paraType:日期類型-數字型
'返回值:
' 格式化後的日期
Function DateFormat(dateStr,dateType)
Dim dateString
if IsDate(dateStr) = False then
call ShowErr(language_arr(4))
end if
Select Case dateType
Case "1"
dateString = Year(dateStr)&"-"&Month(dateStr)&"-"&Day(dateStr)
Case "2"
dateString = Year(dateStr)&"."&Month(dateStr)&"."&Day(dateStr)
Case "3"
dateString = Year(dateStr)&"/"&Month(dateStr)&"/"&Day(dateStr)
Case "4"
dateString = Month(dateStr)&"/"&Day(dateStr)&"/"&Year(dateStr)
Case "5"
dateString = Day(dateStr)&"/"&Month(dateStr)&"/"&Year(dateStr)
Case "6"
dateString = Month(dateStr)&"-"&Day(dateStr)&"-"&Year(dateStr)
Case "7"
dateString = Month(dateStr)&"."&Day(dateStr)&"."&Year(dateStr)
Case "8"
dateString = Month(dateStr)&"-"&Day(dateStr)
Case "9"
dateString = Month(dateStr)&"/"&Day(dateStr)
Case "10"
dateString = Month(dateStr)&"."&Day(dateStr)
Case "11"
dateString = Month(dateStr)&language_arr(6)&Day(dateStr)&language_arr(7)
Case "12"
dateString = Day(dateStr)&language_arr(7)&Hour(dateStr)&language_arr(8)
case "13"
dateString = Day(dateStr)&language_arr(7)&Hour(dateStr)&language_arr(8)
Case "14"
dateString = Hour(dateStr)&language_arr(8)&Minute(dateStr)&language_arr(9)
Case "15"
dateString = Hour(dateStr)&":"&Minute(dateStr)
Case "16"
dateString = Year(dateStr)&language_arr(5)&Month(dateStr)&language_arr(6)&Day(dateStr)&language_arr(7)
Case Else
dateString = dateStr
End Select
DateFormat = dateString
End Function
'
'函數ID:5
'函數作用:顯示錯誤提示
'修改時間:
'傳人參數:
' errStr:錯誤提示-字符型
'返回值:返回提交頁面
'
sub ShowErr(errStr)
Response.Write("<script>alert("""&errStr&""");location.href=""javascript:history.back()"";</script>")
Response.End
End sub