PageRenderTime 50ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/webadmin/guanli.asp

http://asp-wap-cms.googlecode.com/
ASP | 312 lines | 299 code | 7 blank | 6 comment | 40 complexity | d102105fd39e77a62562a84e00e51e7d MD5 | raw file
  1. <!-- #include file="ding.asp" -->
  2. <!-- #include file="mymin.asp" -->
  3. <!-- #include file="md5.asp" -->
  4. <%Call Head2()
  5. Dim act,idd
  6. act = Request("action")
  7. idd = Request("id")
  8. if idd<>"" and IsNumeric(idd) Then
  9. idd=int(idd)
  10. Else
  11. idd=1
  12. end if
  13. '?????ID???1??????????????
  14. Function ifEditable()
  15. If idd<>1 and keyid=1 Then ifEditable=True:Exit Function
  16. ifEditable=False
  17. End Function
  18. '???? keyid??????ID?idd??????ID????1
  19. ' 0???????
  20. ' 1????????
  21. ' 2?????????????
  22. ' 3???????????????
  23. Dim user_level
  24. if KEYid<>1 then
  25. user_level=1'???
  26. else
  27. user_level=0
  28. end if
  29. if KEYid<>idd then user_level=user_level+2'?????
  30. IF act="view" Then
  31. if user_level=3 then
  32. Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  33. end if
  34. call view
  35. elseiF act="del" Then
  36. if user_level<>2 then'????????????
  37. Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  38. end if
  39. call del
  40. elseiF act="edit" Then
  41. if user_level=3 then
  42. Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  43. end if
  44. call edit
  45. elseiF act="add" Then
  46. if user_level<>0 then'?????????ID
  47. Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  48. end if
  49. call add
  50. elseiF act="save" Then
  51. if user_level=3 then
  52. Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  53. end if
  54. call save
  55. else
  56. call index
  57. end if
  58. Function index()
  59. if keyid<>1 Then response.redirect "guanli.asp?sid="&sid&"&action=view&id="&keyid%>
  60. <title>?????</title></head><body><div class='main400'>
  61. ?????:<br/>
  62. <%
  63. Dim rs,sql,pagesize,count,page,i,keyname
  64. Set Rs = Server.CreateObject("Adodb.Recordset")
  65. Sql = "SELECT * FROM 74hu_admin order by id asc"
  66. Rs.Open Sql,conn,1,1
  67. If Not rs.eof Then
  68. PageSize=10
  69. Count=rs.recordcount
  70. page=getN("page",1)
  71. if page<1 then page=1
  72. pagecount=(count+pagesize-1)\pagesize
  73. if page>pagecount then page=pagecount
  74. rs.move(pagesize*(page-1))
  75. For i=1 To PageSize
  76. If rs.eof Then Exit For
  77. keyname=" <br/>????:??"
  78. if rs("classids")<>"" then keyname=" <br/>????:"&rs("classids")
  79. if rs("key")=2 then keyname="?????"&keyname
  80. if rs("key")=0 then keyname="?????"
  81. if rs("id")=1 then keyname="??"
  82. %><%=i+(page-1)*PageSize%>.<a href='guanli.asp?sid=<%=sid%>&amp;action=view&amp;id=<%=rs("id")%>'><%=nowml(rs("username"))%></a><br/>????:<%=keyname%><br/>
  83. ????:<%=nowml(fordate(rs("dltime")))%><br/>--------<br/>
  84. <%
  85. rs.moveNext
  86. Next
  87. w showsPage("guanli.asp", "", page, pageCount)&"<br/>"
  88. Else
  89. %>
  90. (????)
  91. <%end if
  92. Rs.close
  93. set rs=nothing
  94. %><br/>??????<br/>
  95. 1??????????????????????????????<br/>
  96. 2?????????????????????????????<br/>
  97. 3????????????????????????????ID?<br/>
  98. 4??????????????????????????????<br/>
  99. 5????????????????????<a href="http://74hu.cn">??? 74hu.cn</a>???<br/><%
  100. Response.Write("<br/><a href='guanli.asp?sid="&sid&"&amp;action=add'>[????]</a><br/>")
  101. end Function
  102. Function add()%>
  103. <title>????</title></head><body><div class='main400'>
  104. <form method="post" action="guanli.asp?sid=<%=sid%>&amp;action=save&amp;edit=add">
  105. ??:<br/><input name="username" maxlength="16" /><br/>
  106. ??:<br/><input name="password" /><br/>
  107. ??:<br/><input name="password2" /><br/>
  108. ??:<br/><select name="keyvar">
  109. <option value="0">?????</option>
  110. <option value="2">?????</option>
  111. </select><br/>
  112. ????:<br/><input name="classids" /><br/>
  113. <input type="submit" value="??"/>
  114. </form>
  115. ??????<br/>
  116. 1?????????????????????????????????????????????<br/>
  117. 2???????????????????1,2,4??1?2?4???????ID???????????????????<br/><br/>
  118. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  119. <%
  120. end Function
  121. Function edit()
  122. id=idd
  123. Set Rs = Server.CreateObject("Adodb.Recordset")
  124. Sql = "SELECT * FROM 74hu_admin where id="&id
  125. Rs.Open Sql,conn,1,1
  126. if not (rs.bof and rs.eof) then %>
  127. <title>????</title></head><body><div class='main400'>
  128. <form method="post" action="guanli.asp?sid=<%=sid%>&amp;action=save&amp;edit=edit">
  129. ???:
  130. <%If user_level=0 Then%>
  131. <br/><input name="username"/>
  132. <%Else
  133. Response.Write rs("username")
  134. End If%><br/>
  135. ??:<br/><input name="password" value="" /><br/>
  136. ????:<br/><input name="password2" value="" /><br/>
  137. <%if user_level=2 then%>
  138. ????:<br/><select name="keyvar">
  139. <option value="0">?????</option>
  140. <option value="2" <% if rs("key")=2 then w "selected"%>>?????</option>
  141. </select><br/>
  142. ????:<br/><input name="classids" value="<%=Trim(rs("classids"))%>"/>
  143. <%end if%>
  144. <br/>
  145. <input type="submit" value="??"/>
  146. <input type="hidden" name="id" value="<%=id%>"/>
  147. </form>
  148. <%if user_level=2 then%>
  149. ??????<br/>
  150. 1?????????????????????????????????????????????<br/>
  151. 2???????????????????1,2,4??1?2?4???????ID???????????????????<br/><br/>
  152. <%else%>
  153. ??????????????????????<br/>
  154. <%end if%>
  155. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  156. <%else%>
  157. <title>???</title></head><body><div class='main400'>
  158. ?????!<br/>
  159. <%end if
  160. Rs.close
  161. set rs=nothing
  162. end Function
  163. Function view()
  164. id=idd
  165. if id="" then%>
  166. <title>???</title></head><body><div class='main400'>
  167. ID??.<br/>
  168. <%else%>
  169. <title>????</title></head><body><div class='main400'>
  170. <p>
  171. <%
  172. Set Rs = Server.CreateObject("Adodb.Recordset")
  173. Sql = "SELECT username,dltime,lastip FROM 74hu_admin where id="&id
  174. Rs.Open Sql,conn,1,1
  175. if not (rs.bof and rs.eof) then %>
  176. ???:<%=rs("username")%><br/>
  177. ????:<%=fordate(rs("dltime"))%><br/>
  178. ???IP:<%=rs("lastip")%><br/>
  179. <a href='guanli.asp?sid=<%=sid%>&amp;action=edit&amp;id=<%=id%>'>[??]</a>
  180. <%if user_level=2 then%>
  181. <a href='guanli.asp?sid=<%=sid%>&amp;action=del&amp;id=<%=id%>'>[??]</a>
  182. <%end if%>
  183. <br/><a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  184. <%else%>
  185. ????!<br/>
  186. <%end if
  187. Rs.close
  188. set rs=nothing
  189. end if
  190. end Function
  191. Function del()
  192. id=idd
  193. if id="" then%>
  194. <title>???</title></head><body><div class='main400'>
  195. ID??.<br/>
  196. <%else
  197. if Request("del")="true" then
  198. set rs=server.CreateObject("adodb.recordset")
  199. Sql = "SELECT * FROM 74hu_admin where id="&id
  200. rs.open sql,conn,1,3
  201. if not (rs.bof and rs.eof) then
  202. if id=1 then
  203. Call Error2("<card title='?????'><p>???????")
  204. end if
  205. rs.delete
  206. end if
  207. Rs.close
  208. set rs=nothing%>
  209. <title>?????</title></head><body><div class='main400'>
  210. ?????????!<br/>
  211. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  212. <%else%>
  213. <title>?????</title></head><body><div class='main400'>
  214. ??????????<br/>
  215. <a href='guanli.asp?sid=<%=sid%>&amp;action=del&amp;del=true&amp;id=<%=id%>'>[????]</a><br/>
  216. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  217. <%end if
  218. end if
  219. end Function
  220. Function save()
  221. username=Trim(Request("username"))
  222. password=Trim(Request("password"))
  223. password2=Trim(Request("password2"))
  224. keyvar=Trim(Request("keyvar"))
  225. ids=Trim(Request("classids"))
  226. id=idd
  227. if user_level=2 then
  228. if keyvar="" or isnumeric(keyvar) =false then Call Error2("<title>??!</title></head><body><div class='main320'>?????")
  229. if ids<>"" and Not IsNumeric(replace(ids,",","")) then Call Error2("<title>??!</title></head><body><div class='main320'>???????")
  230. end if
  231. if user_level=0 and username="" then errmsg=errmsg&"????????<br/>":flag=0
  232. if password="" then errmsg=errmsg&"????????<br/>":flag=0
  233. if password2="" then errmsg=errmsg&"??????????<br/>":flag=0
  234. if Request("edit")="edit" then
  235. if id="" then errmsg=errmsg&"ID??<br/>":flag=0
  236. if user_level=0 then
  237. set rs=Server.CreateObject("ADODB.Recordset")
  238. rs.open"select ID from 74hu_admin where username='"&username&"' and id<>"&id,conn,1,1
  239. if not rs.eof then
  240. errmsg=errmsg&"??????????<br/>":flag=0
  241. end if
  242. rs.close
  243. set rs=nothing
  244. end if
  245. if flag<>"0" then
  246. set rs=server.CreateObject("adodb.recordset")
  247. sql="select * from 74hu_admin where id="&id
  248. rs.open sql,conn,1,3
  249. if rs.eof then
  250. errmsg=errmsg&"ID??<br/>":flag=0
  251. end if
  252. if user_level=0 then rs("username")=username
  253. rs("password")=md5(md5(password,16),32)
  254. rs("HU_admin")=md5(md5(password2,16),32)
  255. if user_level=2 then
  256. rs("key")=keyvar
  257. If ids<>"" Then rs("classids")=ids
  258. end if
  259. rs("sid")=onlysid()
  260. rs.update()
  261. rs.close
  262. set rs=nothing%>
  263. <meta http-equiv='refresh' content='1;url=guanli.asp?sid=<%=sid%>'>
  264. <title>????</title></head><body><div class='main400'>
  265. ??????<br/><br/>
  266. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  267. <%else
  268. Response.Write("<title>??????</title></head><body><div class='main320'>"&errmsg&"<br/>")
  269. end if
  270. else
  271. if keyid<>1 then errmsg=errmsg&"?????????<br/>":flag=0
  272. set rs=Server.CreateObject("ADODB.Recordset")
  273. rs.open"select ID from 74hu_admin where username='"&username&"' and id<>"&id,conn,1,1
  274. if not rs.eof then
  275. errmsg=errmsg&"??????????<br/>":flag=0
  276. end if
  277. rs.close
  278. set rs=nothing
  279. if flag<>"0" then
  280. set rs=server.CreateObject("adodb.recordset")
  281. sql="select * from 74hu_admin"
  282. rs.open sql,conn,1,3
  283. rs.addnew()
  284. rs("username")=username
  285. rs("password")=md5(md5(password,16),32)
  286. rs("HU_admin")=md5(md5(password2,16),32)
  287. rs("sid")=onlysid()
  288. rs("key")=keyvar
  289. rs("classids")=ids
  290. rs.update()
  291. Rs.close
  292. set rs=nothing%>
  293. <meta http-equiv='refresh' content='1;url=guanli.asp?sid=<%=sid%>'>
  294. <title>????</title></head><body><div class='main400'>
  295. ??????<br/><br/>
  296. <a href="guanli.asp?sid=<%=sid%>">[????]</a><br/>
  297. <%else
  298. Response.Write("<title>??????</title></head><body><div class='main320'>"&errmsg&"<br/>")
  299. end if
  300. END IF
  301. end Function
  302. call CloseConn
  303. %>
  304. <a href="index.asp?sid=<%=sid%>">[????]</a>
  305. </div></body></html>