login.asp 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <!--#include file="inc/common.asp"-->
  2. <!--#include file="inc/md5.asp"-->
  3. <%
  4. Response.Expires = -1
  5. Response.ExpiresAbsolute = Now() - 1
  6. Response.Expires = 0
  7. Response.CacheControl = "no-cache"
  8. If Action = "Login" Then
  9. Call ChkLogin
  10. ElseIf Action = "Logout" Then
  11. Call Logout
  12. Else
  13. Call main
  14. End If
  15. If FoundErr = True Then
  16. Call WriteErrMsg
  17. End If
  18. Call CloseConn
  19. Sub main()
  20. %>
  21. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  22. <html xmlns="http://www.w3.org/1999/xhtml">
  23. <head>
  24. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  25. <title><%=systemPageTitle%></title>
  26. <script language=javascript>
  27. <!--
  28. function SetFocus() {
  29. if(document.Login.UserName.value == '')
  30. document.Login.UserName.focus();
  31. else
  32. document.Login.UserName.select();
  33. }
  34. function CheckForm() {
  35. if(document.Login.UserName.value == '') {
  36. alert('请输入用户名!');
  37. document.Login.UserName.focus();
  38. return false;
  39. }
  40. if(document.Login.Password.value == '') {
  41. alert('请输入密码!');
  42. document.Login.Password.focus();
  43. return false;
  44. }
  45. }
  46. function refreshimg(){document.all.CheckCode.src='inc/checkcode.asp?'+Math.random();}
  47. //-->
  48. </script><link href="style.css" rel="stylesheet" type="text/css" />
  49. <style type="text/css">
  50. <!--
  51. .STYLE1 {font-size: 12px}
  52. -->
  53. </style>
  54. </head>
  55. <body>
  56. <form name='Login' action='login.asp' method='post' target='_parent' onSubmit='return CheckForm();'>
  57. <table width="100%" border="0" cellspacing="0" cellpadding="0">
  58. <tr>
  59. <td align="center" bgcolor="#3E84C0"><img src="images/login_banner.jpg" width="960" height="350" /></td>
  60. </tr>
  61. <tr>
  62. <td align="center">&nbsp;</td>
  63. </tr>
  64. <tr>
  65. <td align="center"><table border="0" cellspacing="0" cellpadding="0">
  66. <tr>
  67. <td width="50"><img src="images/login_arr.jpg" width="31" height="20" /></td>
  68. <td width="50" align="right"><span class="STYLE1">用户名:</span></td>
  69. <td><input name="UserName" type="text" id="UserName" size="15" /></td>
  70. <td width="50" align="right"><span class="STYLE1">密 码:</span></td>
  71. <td><input name="Password" type="password" id="Password" /></td>
  72. <%if useSiteManageCode = true then%>
  73. <td width="80" align="right"><span class="STYLE1">系统验证码:</span></td>
  74. <td><input name="AdminLoginCode" type="password" id="AdminLoginCode" size="15" /></td>
  75. <%
  76. end if
  77. if useCheckCode = true then
  78. %>
  79. <td width="50" align="right"><span class="STYLE1">验证码:</span></td>
  80. <td><span class="STYLE1">
  81. <input name="CheckCode" type="text" id="CheckCode" size="6" />
  82. <img id='checkcode' src='inc/checkcode.asp' style='border: 1px solid #000' /></span></td>
  83. <%end if%>
  84. <td width="100"><input type='hidden' name='Action' value='Login' />
  85. <input type="submit" name="button" id="button" value="登陆系统" /></td>
  86. <td><label>
  87. <input name="voiceAlarm" type="checkbox" id="voiceAlarm" value="voiceAlarm" <%if openSound = true then response.write "checked"%> />
  88. 启用BS声音报警</label></td>
  89. </tr>
  90. </table></td>
  91. </tr>
  92. <tr>
  93. <td align="center">&nbsp;</td>
  94. </tr>
  95. <tr>
  96. <td align="center" background="images/login_bottom.jpg"><img src="images/login_bottom.jpg" width="10" height="56" /></td>
  97. </tr>
  98. </table>
  99. </form>
  100. <script language='JavaScript' type='text/JavaScript'>
  101. SetFocus();
  102. </script>
  103. </body>
  104. </html>
  105. <%
  106. end sub
  107. Sub ChkLogin()
  108. Dim sql, rs
  109. Dim UserName, Password, CheckCode, AdminLoginCode, RndPassword, voiceAlarm
  110. UserName = ReplaceBadChar(Trim(Request("UserName")))
  111. Password = ReplaceBadChar(Trim(Request("Password")))
  112. voiceAlarm = Trim(Request("voiceAlarm"))
  113. if useSiteManageCode = true then AdminLoginCode = Trim(Request("AdminLoginCode"))
  114. if useCheckCode = true then CheckCode = LCase(ReplaceBadChar(Trim(Request("CheckCode"))))
  115. If CSng(ScriptEngineMajorVersion & "." & ScriptEngineMinorVersion) < 5.6 Then
  116. FoundErr = True
  117. ErrMsg = ErrMsg & "<li>服务器脚本解释引擎(VBScript)版本过低,请联系您的空间商或服务器管理员更新。</li>"
  118. ErrMsg = ErrMsg & "<li><a href='http://www.microsoft.com/downloads/release.asp?ReleaseID=33136' target='_blank'><font color='green'>脚本解释引擎下载地址</font></a></li>"
  119. End If
  120. If UserName = "" Then
  121. FoundErr = True
  122. ErrMsg = ErrMsg & "<br><li>用户名不能为空!</li>"
  123. End If
  124. If Password = "" Then
  125. FoundErr = True
  126. ErrMsg = ErrMsg & "<br><li>密码不能为空!</li>"
  127. End If
  128. if useCheckCode = true then
  129. If CheckCode = "" Then
  130. FoundErr = True
  131. ErrMsg = ErrMsg & "<br><li>您输入的随机验证码和系统产生的不一致,请重新输入。</li>"
  132. End If
  133. If Trim(Session("CheckCode")) = "" Then
  134. FoundErr = True
  135. ErrMsg = ErrMsg & "<br><li>你在管理登陆停留的时间过长,导致验证码失效。请重新返回登陆页面进行登陆。</li>"
  136. End If
  137. If CheckCode <> Session("CheckCode") Then
  138. FoundErr = True
  139. ErrMsg = ErrMsg & "<br><li>您输入的验证码和系统产生的不一致,请重新输入。</li>"
  140. End If
  141. end if
  142. if useSiteManageCode = true then
  143. If AdminLoginCode <> SiteManageCode Then
  144. FoundErr = True
  145. ErrMsg = ErrMsg & "<br><li>您输入的系统验证码不对,请重新输入。</li>"
  146. End If
  147. end if
  148. If FoundErr = True Then
  149. Exit Sub
  150. End If
  151. ComeUrl = Trim(Request.ServerVariables("HTTP_REFERER"))
  152. Password = MD5(Password, 32)
  153. Set rs = Server.CreateObject("adodb.recordset")
  154. sql = "select * from t_user_info where pwd='" & Password & "' and uid='" & UserName & "'"
  155. rs.Open sql, Conn, 1, 3
  156. If rs.bof And rs.EOF Then
  157. FoundErr = True
  158. ErrMsg = ErrMsg & "<br><li>用户名或密码错误!!!</li>"
  159. Else
  160. If rs("status") = 1 then
  161. FoundErr = True
  162. ErrMsg = ErrMsg & "<br><li>用户已被禁用!!!</li>"
  163. if useUserLog = true then Call WriteLog(UserName,"禁止登录")
  164. Exit Sub
  165. End If
  166. If Password <> rs("pwd") Then
  167. FoundErr = True
  168. ErrMsg = ErrMsg & "<br><li>用户名或密码错误!!!</li>"
  169. End If
  170. End If
  171. If FoundErr = True Then
  172. Session("AdminName") = ""
  173. Session("AdminPassword") = ""
  174. Session("RndPassword") = ""
  175. rs.Close
  176. Set rs = Nothing
  177. Exit Sub
  178. End If
  179. RndPassword = GetRndPassword(16)
  180. rs("rndpassword") = RndPassword
  181. rs.Update
  182. Response.Cookies("AdminName") = rs("uid")
  183. Response.Cookies("AdminPassword") = rs("pwd")
  184. Response.Cookies("RndPassword") = RndPassword
  185. if useSiteManageCode = true then Response.Cookies("AdminLoginCode") = AdminLoginCode
  186. if voiceAlarm = "voiceAlarm" then Response.Cookies("voiceAlarm") = "on" else Response.Cookies("voiceAlarm") = "off"
  187. rs.Close
  188. Set rs = Nothing
  189. if useUserLog = true then Call WriteLog(UserName,"登录系统")
  190. Call CloseConn
  191. Response.Redirect "index.asp"
  192. End Sub
  193. Sub Logout()
  194. if useUserLog = true then Call WriteLog(trim(request.Cookies("AdminName")),"退出系统")
  195. Response.Cookies("AdminName") = ""
  196. Response.Cookies("AdminPassword") = ""
  197. Response.Cookies("RndPassword") = ""
  198. Response.Cookies("voiceAlarm") = "on"
  199. Call CloseConn
  200. Response.Redirect "login.asp"
  201. End Sub
  202. Sub WriteErrMsg()
  203. %>
  204. <html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
  205. </head><body>
  206. <strong>错误信息</strong><br/>
  207. 产生错误的可能原因:<br><%=ErrMsg%><br/><br/>
  208. <a href='login.asp'>&lt;&lt; 返回登录页面</a>
  209. </body></html>
  210. <%
  211. End Sub
  212. Sub WriteLog(uid,msg)
  213. conn.execute("insert into t_user_log (uid,happentime,contents) values ('"&uid&"','"&now()&"','"&msg&"')")
  214. End Sub
  215. %>