⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin.asp

📁 熟悉和掌握数据库的基本原理 2. 利用Micorsoft Sql Server工具建立C/S模式的论文数据库,并能提供论文的在线上传下载功能
💻 ASP
字号:
<!--#include file="Conn.asp"-->
<!--#include file="md5.asp"-->
<!--#include file=inc.asp-->
<%
Dim Rs,Sql
If Session("UserName")="" OR Session("UserId")="" Then
Response.Write("<script language=JavaScript>alert('您还没有登陆!');document.location.href='index.asp';</script>")
Response.End
End if
If Not Session("UserAdmin") Then
Response.Write("<script language=JavaScript>alert('您没有权限操作!');document.location.href='javascript:window.history.go(-1);';</script>")
Response.End
End If
If Request.QueryString("Action")="add" Then
If ChkPost=false Then
Response.Write("<script language=JavaScript>alert('请不要从外部提交信息!');document.location.href='index.asp';</script>")
Response.End
End If
Dim UserId,UserName,UserPwd,IP,UserMaxUp
UserId=Trim(Request.Form("UserId"))
UserName=Trim(Request.Form("UserName"))
UserPwd=Trim(Request.Form("UserPwd"))
UserMaxUp=Trim(Request.Form("UserMaxUp"))
If Userid="" or UserName="" or UserPwd="" Then
Response.Write("<script language=JavaScript>alert('请输入用户ID、用户名和用户密码!');document.location.href='javascript:window.history.go(-1);';</script>")
Response.End
End If
Userid=Replace(Userid,"'","")
UserName=Replace(UserName,"'","")
UserPwd=Replace(UserPwd,"'","")
If isInteger(Userid)=False Then
Response.Write("<script language=JavaScript>alert('用户ID必须是数字!');document.location.href='javascript:window.history.go(-1);';</script>")
Response.End
End If
If isInteger(UserMaxUp)=False Then
Response.Write("<script language=JavaScript>alert('上传文件大小必须是数字!');document.location.href='javascript:window.history.go(-1);';</script>")
Response.End
End If
Sql="Select * From Users Where Userid='"&Userid&"'"
Set Rs=server.CreateObject("adodb.recordset")
If Not IsObject(Conn) Then ConnectionDatabase()
Rs.open Sql,Conn,1,3
If Not Rs.Eof Then
Rs.close
Set Rs=Nothing
CloseDatabase()
Response.Write("<script language=JavaScript>alert('该用户ID已经存在!');document.location.href='javascript:window.history.go(-1);';</script>")
Else
Rs.AddNew
If Request.ServerVariables("HTTP_X_FORWARDED_FOR")<>"" then 
IP=Request.ServerVariables("HTTP_X_FORWARDED_FOR") 
Else
IP=Request.ServerVariables("REMOTE_ADDR")
End If
Rs("UserId")=Userid
Rs("UserName")=UserName
Rs("UserPwd")=md5(UserPwd,32)
Rs("UserSex")=Request.Form("UserSex")
Rs("UserRegIp")=IP
Rs("UserLastIp")=IP
Rs("UserMaxUp")=clng(UserMaxUp)
Rs("UserType")=CBool(Request.Form("UserType"))
Rs.UpDate
Rs.close
Set Rs=nothing
CloseDatabase()
Response.Write("<script language=JavaScript>alert('用户添加成功!');document.location.href='Index.asp';</script>")
End if
Response.End
End If

If Request.QueryString("Action")="del" Then
If ChkPost=false Then
Response.Write("<script language=JavaScript>alert('请不要从外部提交信息!');document.location.href='index.asp';</script>")
Response.End
End If
Dim Id,objFSO
Id= trim(request.QueryString("id"))
if id="" Then
Response.write"参数丢失!"
Elseif not isnumeric(id) Then
response.Write("参数类型错误!")
else
Sql="Select * From Files where id="&clng(id)
set Rs=server.CreateObject("adodb.recordset")
If Not IsObject(Conn) Then ConnectionDatabase()
Rs.open sql,conn,1,3
if rs.eof then
Rs.close
Set Rs=nothing
CloseDatabase()
Response.Write("<script language=JavaScript>alert('文件不存在!');document.location.href='javascript:window.history.go(-1);';</script>")
Response.End
else
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
if objfso.FileExists(Server.MapPath("UpLoadFile/"&rs("FileUrl"))) then
objFSO.DeleteFile(Server.MapPath("UpLoadFile/"&rs("FileUrl")))
end if
Set objFSO =nothing
Conn.Execute("Update Users set UpFiles=UpFiles+1 Where UserId='"&rs("UserId"))&"'"
Rs.delete
rs.close
set rs=nothing
CloseDatabase()
Response.Write("<script language=JavaScript>alert('删除成功!');document.location.href='index.asp';</script>")
End if
End if
Response.End
End if
%>
<%Call Top("添加用户","Admin.asp")%>
<TABLE style="BORDER-RIGHT: #c0c0c0 1px solid; BORDER-LEFT: #c0c0c0 1px solid" 
cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#f7f7f7 border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width=220>
      <TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
        <TBODY>
        <TR>
          <TD 
          background=images/side_bg_r1_c1.gif 
          height=34>
            <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
              <TBODY>
              <TR>
                <TD width=10></TD>
                <TD width=20><IMG height=14 
                  src="images/ico_015.gif" 
                  width=13 border=0></TD>
                <TD width=100>用户登陆</TD>
                <TD width=85></TD>
                <TD width=5></TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD 
          background=images/side_bg_r2_c1.gif>
            <TABLE cellSpacing=0 cellPadding=0 width=200 align=center 
              border=0><TBODY>
              <TR>
                <TD align="center">
					<table width="90%" border="0" cellspacing="0" cellpadding="0">
					  <tr>
                        <td width="34%" align="right">欢 迎 您:</td>
                        <td width="66%"><%=Session("UserName")%></td>
                      </tr>
                      <tr>
                        <td align="right">登陆次数:</td>
                        <td><b><%=Session("UserLogins")%></b></td>
                      </tr>
					   <tr>
                        <td align="right"><p>上传论文:</p>
                          </td>
                        <td><font color=red>
						<%If Not IsObject(Conn) Then ConnectionDatabase()%>
						<%=Conn.execute("Select UpFiles from Users Where UserId='"&Session("UserId")&"'")(0)%>
						</font>个</td>
                      </tr>
					   <tr>
                        <td align="right">相关操作:</td>
                        <td><p><a href="UpLoad.asp">上传论文</font></a>
                              <a href="Edit.asp?ID=<%=Session("UserId")%>">修改资料</a> <a href="chaxun.asp">论文查询</a>
                              
                              <%If Session("UserAdmin") Then Response.Write"<a href=Admin.asp>添加用户</a>"%>
                        </p>
                          </td>
                      </tr>
					  <tr>
                        <td height="3" colspan="2"></td>
                        </tr>
                      <tr>
                        <td></td>
                        <td align="right"><input name="Logout" type="button" id="Logout" value="退出" onClick="location.href='Login.asp?action=logout'">                        </td>
                      </tr>
                    </table>
					</TD></TR></TBODY></TABLE></TD></TR>
        <TR>
          <TD 
          background=images/side_bg_r3_c1.gif 
          height=4></TD></TR></TBODY></TABLE>
	  </TD>
    <TD width=1 bgColor=#b4b4b4></TD>
    <TD width=1 bgColor=#ffffff></TD>
    <TD width=1></TD>
    <TD vAlign=top width=553>
      <TABLE cellSpacing=0 cellPadding=0 width=553 align=center border=0>
        <TBODY>
        <TR>
          <TD width=2 rowSpan=2></TD>
          <TD width=548>
            <TABLE cellSpacing=0 cellPadding=0 width=548 border=0>
              <TBODY>
              <TR>
                <TD width=120 
                background=images/ad_title.gif 
                height=30>
                  <TABLE cellSpacing=0 cellPadding=0 width=120 border=0>
                    <TBODY>
                    <TR>
                      <TD colSpan=2 height=6></TD></TR>
                    <TR>
                      <TD width=10></TD>
                      <TD noWrap>▍添加用户</TD>
                    </TR>
                    <TR>
                      <TD colSpan=2 height=0></TD></TR></TBODY></TABLE></TD>
                <TD align=middle width=428 
                background=images/ad_title_bg.gif 
                height=30></TD>
              </TR></TBODY></TABLE></TD>
          <TD width=3 rowSpan=2></TD></TR>
        <TR>
          <TD width=548>
            <TABLE cellSpacing=0 cellPadding=0 width=548 border=0>
              <TBODY>
              <TR>
                <TD>
                  <TABLE cellSpacing=0 cellPadding=0 width=548 border=0>
                    <TBODY>
                    <TR>
                      <TD width=1 bgColor=#d4d4d4></TD>
                      <TD width=1 bgColor=#ffffff></TD>
                      <TD valign=top width=544 height=100>
					  <form id="form2" name="form2" method="post" action="?Action=add">
					  <table width="90%" border="0" cellspacing="2" cellpadding="5">
                        <tr>
                          <td width="24%" align="right">用户ID:</td>
                          <td width="76%"><label>
                            <input name="UserId" type="text" id="UserId" size="20" maxlength="20" style="height:20px;width:160px"/>
                          </label></td>
                        </tr>
                        <tr>
                          <td align="right">用户名:</td>
                          <td><label>
                            <input name="UserName" type="text" id="UserName" size="20" maxlength="20" style="height:20px;width:160px"/>
                          </label></td>
                        </tr>
                        <tr>
                          <td align="right">密 码:</td>
                          <td><label>
                            <input name="UserPwd" type="password" id="UserPwd" size="20" maxlength="20" style="height:20px;width:160px" />
                          </label></td>
                        </tr>
                        <tr>
                          <td align="right">性 别:</td>
                          <td><label>
                            <input name="UserSex" type="radio" value="True" checked="checked" />
                            <input type="radio" name="UserSex" value="False" />
                          女</label></td>
                        </tr>
                        <tr>
                          <td align="right">文 件:</td>
                          <td><input name="UserMaxUp" type="text" id="UserMaxUp" value="0" size="5" maxlength="10" /> 
                            KB  允许上传文件大小,为0不允许上传</td>
                        </tr>
						<tr>
                          <td align="right">类 型:</td>
                          <td><label>
                            <input name="UserType" type="checkbox" id="UserType" value="True" />
                          是否管理员</label></td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td><label>
                            <input type="submit" name="Submit" value="添加" />
                          </label></td>
                        </tr>
                      </table>
                        </form>
                        </TD>
                      <TD width=1 bgColor=#ffffff></TD>
                      <TD width=1 bgColor=#d4d4d4></TD></TR></TBODY></TABLE></TD></TR>
              <TR>
                <TD>
                  <TABLE cellSpacing=0 cellPadding=0 width=548 border=0>
                    <TBODY>
                    <TR>
                      <TD width=1 bgColor=#d4d4d4></TD>
                      <TD bgColor=#ffffff height=1></TD>
                      <TD width=1 bgColor=#d4d4d4></TD></TR>
                    <TR>
                      <TD bgColor=#d4d4d4 colSpan=3 
                  height=1></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<TABLE 
style="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT: #c0c0c0 1px solid; BORDER-BOTTOM-WIDTH: 1px; BORDER-LEFT: #c0c0c0 1px solid" 
cellSpacing=0 cellPadding=0 width=778 align=center bgColor=#ffffff border=0>
  <TBODY>
  <TR>
    <TD bgColor=#dbe2e8 height=1></TD></TR>
  <TR>
    <TD bgColor=#ffffff height=1></TD></TR>
  <TR>
    <TD bgColor=#c5cfd9 height=1></TD></TR>
  <TR>
    <TD bgColor=#dbe2e8 height=1></TD></TR></TBODY></TABLE>
	<%Call Bottom()%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -