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

📄 main.asp

📁 这《ASP网络编程从入门到精通》书中的全部源程序
💻 ASP
字号:
<!--#include file="conn.asp"-->
<%
if session("admin")="" then
	response.write "<Script>window.alert('您目前还没有登录,请先登录!');location.replace('index.asp');</Script>"
end if
If Request("action")="delete" Then
	delid=replace(request("id"),",","")						'获得要删除记录的id,Replace 过程将获得的id 字符串中的"'"用空字符""替换
	if delid="" or isnull(delid) then						'要删除的记录id 为空
		'则给出提示
		response.write "<script>alert('操作失败,没有选择合适参数,请单击确定返回!');</script>"		
		response.redirect "main.asp"						'返回到网站管理界面
		response.end

	else										'id 存在
		'执行数据库中的删除操作,删除数据库中id 列的值在delid数组中的记录
		conn.Execute("delete * from web where ID in ("&delid&")")
		'删除成功,给出提示
		response.write "<script>alert('留言删除成功,请单击确定返回!');</script>"		
		response.redirect "main.asp"						'返回到网站管理界面
		response.end
	end if
End If

%>
<html>
<head>
<title>网站管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr> 
    <td><table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr bgcolor="#e9e9e9"> 
          <td width="65" height="25" valign="bottom"><table border="0" align="center" cellpadding="0" cellspacing="0">
              <tr align="center"> 
                <td width="55" height="21"><a href="main.asp"><font color="#000000">网站管理</font></a></td>
              </tr>
            </table></td>
          <td width="65" valign="bottom"><table border="0" align="center" cellpadding="0" cellspacing="0">
              <tr align="center"> 
                <td width="55" height="21"><a href="verify.asp"><font color="#000000">网站审核</font></a></td>
              </tr>
            </table></td>
         
          <td width="65" valign="bottom"><table border="0" align="center" cellpadding="0" cellspacing="0">
              <tr align="center"> 
                <td width="55" height="21"><a href="sort_manage.asp"><font color="#000000">分类管理</font></a></td>
              </tr>
            </table></td>

          <td width="65" valign="bottom"><table border="0" align="center" cellpadding="0" cellspacing="0">
              <tr align="center"> 
                <td width="55" height="21"><a href="login.asp?action=logout"><font color="#000000">退出系统</font></a></td>
              </tr>
            </table></td>
          <td></td>
        </tr>
        <tr bgcolor="#000000"> 
          <td height="3" colspan="10" valign="bottom"></td>
        </tr>
      </table></td>
  </tr>
    <tr> 
    <td> </td>
  </tr>
  <tr> 
    <td height="15"></td>
  </tr>
  <tr> 
    <td height="100%" valign="top" bgcolor="#FFFFFF">
<table width="100%" border="0" cellpadding="0" cellspacing="5">
        <form name="form" method="get" action="web_ok.asp">
          <tr> 
            <td> 
              <%
dim rs
set rs=server.createobject("adodb.recordset")				'建立RecordSet 对象

'从数据库中查询verify = 0 的记录,按照id 降序排列,并保存在rs中
rs.open "select id,sort_id,title,url,verify,click,time from web where verify=0 order by id desc",conn,1,1
if rs.eof and rs.bof then									'不存在满足条件的记录
'
else														'不存在满足添加的记录
	dim totalPut 											'记录总数  
	dim CurrentPage											'当前页
	dim TotalPages											'总共页数
	Const MaxPerPage=20    									'每页最大个数
	if Not isempty(Request.QueryString("page")) then		'isempty 函数指明变量是否初始化
		currentPage=Cint(Request.QueryString("page"))		'Request.QueryString("page")存在值,则将其转换为数字
	else													'Request.QueryString("page")没有值
		currentPage=1
	end if 
	totalPut=rs.recordcount									'记录总数
	if currentpage<1 then									'当前页小于1
		currentpage=1
	end if
	if (currentpage-1)*MaxPerPage>totalput then				'当前页大于总页数
		if (totalPut mod MaxPerPage)=0 then					'总记录数是每页记录数的整数倍
			currentpage= totalPut \ MaxPerPage				
		else												'总记录数不是每页记录数的整数倍
			currentpage= totalPut \ MaxPerPage + 1
		end if
	end if
	if currentPage=1 then									'当前为第一页
		showContent											'显示网站相关信息
		showpage totalput,MaxPerPage,"main.asp"				'显示页数信息
	else													'当前不是第一页
		if (currentPage-1)*MaxPerPage<totalPut then			'当前页数没有大于总页数
			rs.move  (currentPage-1)*MaxPerPage				'记录指针移到指定记录
			dim bookmark
			bookmark=rs.bookmark							'记录集书签
			showContent										'显示网站相关信息
			showpage totalput,MaxPerPage,"main.asp"			'显示页数信息
		else												'当前页数大于总页数
			currentPage=1									'当前页置为第一页
			showContent										'显示网站相关信息
			showpage totalput,MaxPerPage,"main.asp"			'显示页数信息
		end if
	end if
end if

sub showContent												'定义过程
	dim i													'定义变量
	i=0														'初始化变量
	do while not rs.eof										'循环显示所有记录
%>
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr> 
                  <td width="25" height="20">  </td>
                  <td width="700"> <a href="web_manage.asp?id=<%=rs("id")%>" target="_blank"><%=rs("title")%></a> 
                    [<a href="web_manage.asp?id=<%=rs("id")%>" target="_blank">修改</a>][<a href="?action=delete&id=<%=rs("id")%>">删除</a>]</td>
                </tr>
                <tr> 
                  <td height="20"></td>
                  <td><a href = <%=rs("url")%>><%=rs("url")%></a></td>
                </tr>
                <tr>
                  <td height="20"></td>
                  <td>                  
                    加入日期:<%=rs("time")%></td>
                </tr>
              </table>
              <br>
    <%
		i=i+1
		
		if i>=MaxPerPage then Exit Do						'显示的记录数大于或等于每页最大记录数
		rs.movenext											'指向下一条记录
	loop
	%>
              <br> <table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr> 
                  <td align="center"> 
<%  
End Sub   
Function showpage(totalnumber,maxperpage,filename)  
  	Dim n				
	If totalnumber Mod maxperpage=0 Then  
		n= totalnumber \ maxperpage  
	Else
		n= totalnumber \ maxperpage+1  
	End If 
    If CurrentPage<2 Then 
    %>
                    第一页 上一页 
    <%
    Else
    %>
                    <a href="<%=filename%>?page=1">第一页</a> <a href="<%=filename%>?page=<%=CurrentPage-1%>">上一页</a> 
    <%
    End If
    If n-currentpage<1 Then
    %>
                    下一页 最后一页 
                    <%Else%>
                    <a href="<%=filename%>?page=<%=CurrentPage+1%>">下一页</a> 
                    <a href="<%=filename%>?page=<%=n%>">最后一页</a> 
                    <%End If%>
                    共<%=totalnumber%>个网站 页次:<%=CurrentPage%>/<%=n%>页</td>
                </tr>
              </table>
<%
End Function
rs.close													'关闭recordset对象
set rs = nothing
%>
            </td>
          </tr>
          <tr> 
            <td height="20">&nbsp;
            </td>
          </tr>
        </form>
      </table></td>
  </tr>
</table>
</body>
</html>
<%
conn.close
set conn=nothing
%>

⌨️ 快捷键说明

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