Function.asp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <%
  2. Function ReplaceBadChar(strChar)
  3. If strChar = "" Or IsNull(strChar) Then
  4. ReplaceBadChar = ""
  5. Exit Function
  6. End If
  7. Dim strBadChar, arrBadChar, tempChar, i
  8. strBadChar = "+,',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & "," & Chr(0) & ",--"
  9. arrBadChar = Split(strBadChar, ",")
  10. tempChar = strChar
  11. For i = 0 To UBound(arrBadChar)
  12. tempChar = Replace(tempChar, arrBadChar(i), "")
  13. Next
  14. tempChar = Replace(tempChar, "@@", "@")
  15. ReplaceBadChar = tempChar
  16. End Function
  17. '**************************************************
  18. '过程名:WriteErrMsg
  19. '作 用:显示错误提示信息
  20. '参 数:无
  21. '**************************************************
  22. Sub WriteErrMsg(sErrMsg, sComeUrl)
  23. Response.Write "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
  24. Response.Write "<link href='bs2010.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbCrLf
  25. Response.Write "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbCrLf
  26. Response.Write " <tr align='center' class='title'><td height='22'><strong>错误信息</strong></td></tr>" & vbCrLf
  27. Response.Write " <tr class='tdbg'><td height='100' valign='top'><b>产生错误的可能原因:</b>" & sErrMsg & "</td></tr>" & vbCrLf
  28. Response.Write " <tr align='center' class='tdbg'><td>"
  29. If sComeUrl <> "" Then
  30. Response.Write "<a href='javascript:history.go(-1)'>&lt;&lt; 返回上一页</a>"
  31. Else
  32. Response.Write "<a href='javascript:window.close();'>【关闭】</a>"
  33. End If
  34. Response.Write "</td></tr>" & vbCrLf
  35. Response.Write "</table>" & vbCrLf
  36. Response.Write "</body></html>" & vbCrLf
  37. End Sub
  38. '**************************************************
  39. '过程名:WriteSuccessMsg
  40. '作 用:显示成功提示信息
  41. '参 数:无
  42. '**************************************************
  43. Sub WriteSuccessMsg(sSuccessMsg, sComeUrl)
  44. Response.Write "<html><head><title>成功信息</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>" & vbCrLf
  45. Response.Write "<link href='" & strInstallDir & "images/Style.css' rel='stylesheet' type='text/css'></head><body><br><br>" & vbCrLf
  46. Response.Write "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbCrLf
  47. Response.Write " <tr align='center' class='title'><td height='22'><strong>恭喜你!</strong></td></tr>" & vbCrLf
  48. Response.Write " <tr class='tdbg'><td height='100' valign='top'><br>" & sSuccessMsg & "</td></tr>" & vbCrLf
  49. Response.Write " <tr align='center' class='tdbg'><td>"
  50. If sComeUrl <> "" Then
  51. Response.Write "<a href='" & sComeUrl & "'>&lt;&lt; 返回上一页</a>"
  52. Else
  53. Response.Write "<a href='javascript:window.close();'>【关闭】</a>"
  54. End If
  55. Response.Write "</td></tr>" & vbCrLf
  56. Response.Write "</table>" & vbCrLf
  57. Response.Write "</body></html>" & vbCrLf
  58. End Sub
  59. '**************************************************
  60. '函数名:IsObjInstalled
  61. '作 用:检查组件是否已经安装
  62. '参 数:strClassString ----组件名
  63. '返回值:True ----已经安装
  64. ' False ----没有安装
  65. '**************************************************
  66. Function IsObjInstalled(strClassString)
  67. On Error Resume Next
  68. IsObjInstalled = False
  69. Err = 0
  70. Dim xTestObj
  71. Set xTestObj = CreateObject(strClassString)
  72. If Err.Number = 0 Then IsObjInstalled = True
  73. Set xTestObj = Nothing
  74. Err = 0
  75. End Function
  76. '检查ID值
  77. Function IsValidID(Check_ID)
  78. Dim FixID, i
  79. If IsNull(Check_ID) Or Check_ID = "" Then
  80. IsValidID = False
  81. Exit Function
  82. End If
  83. FixID = Replace(Check_ID, "|", "")
  84. FixID = Replace(FixID, ",", "")
  85. FixID = Replace(FixID, "-", "")
  86. FixID = Trim(Replace(FixID, " ", ""))
  87. If FixID = "" Or IsNull(FixID) Then
  88. IsValidID = False
  89. Else
  90. For i = 1 To Len(FixID) Step 100
  91. If Not IsNumeric(Mid(FixID, i, 100)) Then
  92. IsValidID = False
  93. Exit Function
  94. End If
  95. Next
  96. IsValidID = True
  97. End If
  98. End Function
  99. '**************************************************
  100. '函数名:CheckBadChar
  101. '作 用:检查是否包含非法的SQL字符
  102. '参 数:strChar-----要检查的字符
  103. '返回值:True ----字符合法
  104. ' False ----字符不合法
  105. '**************************************************
  106. Function CheckBadChar(strChar)
  107. Dim strBadChar, arrBadChar, i
  108. strBadChar = "@@,+,',%,^,&,?,(,),<,>,[,],{,},/,\,;,:," & Chr(34) & ",--"
  109. arrBadChar = Split(strBadChar, ",")
  110. If strChar = "" Then
  111. CheckBadChar = False
  112. Else
  113. For i = 0 To UBound(arrBadChar)
  114. If InStr(strChar, arrBadChar(i)) > 0 Then
  115. CheckBadChar = False
  116. Exit Function
  117. End If
  118. Next
  119. End If
  120. CheckBadChar = True
  121. End Function
  122. '脚本名称,用户IP
  123. ScriptName = Trim(Request.ServerVariables("SCRIPT_NAME"))
  124. UserTrueIP = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
  125. If UserTrueIP = "" Then UserTrueIP = Request.ServerVariables("REMOTE_ADDR")
  126. UserTrueIP = ReplaceBadChar(UserTrueIP)
  127. '选项框设定值
  128. Public Function RadioValue(compvalue, showvalue)
  129. If compvalue = showvalue Then
  130. RadioValue = "value='" & showvalue & "' checked"
  131. Else
  132. RadioValue = "value='" & showvalue & "'"
  133. End If
  134. End Function
  135. %>