news1.asp
来自「1.理解Winsock编程模型; 2.掌握Winsock编程的基本方法」· ASP 代码 · 共 813 行 · 第 1/3 页
ASP
813 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<% if session("uname")="" then
%>
<script language="javascript">
if (confirm("您进行的是非法登录,请重新登录!"))
location.href="admin.asp";
</script>
<%
session.Abandon()
else
%>
<html>
<head>
<META content="" name=keywords>
<META content="" name=description>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新闻管理</title>
<base target="_self">
<STYLE type="text/css">
<!--
a:link {text-decoration: none; font-family: AdobeSm; color: #000000 }
a:visited {text-decoration: none; color: #000000 }
A:hover {COLOR: green; FONT-FAMILY: "宋体,MingLiU"; TEXT-DECORATION: underline}
body {font-size: 9pt; font-family: 宋体,MingLiU, Arial;color: #000000}
TD {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000;table-layout:fixed;word-break:break-all}
p {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
input {FONT-SIZE: 9pt; FONT-FAMILY: "宋体,MingLiU, Arial";color: #000000}
body {margin-top: 0; margin-bottom: 0;margin-left:0;margin-right:0; color: #000000}
select {FONT-SIZE: 9PT;}
option {FONT-SIZE: 9pt;}
textarea {FONT-SIZE: 9pt;}
-->
</STYLE>
<base target="_self">
<script language="JavaScript" type="text/JavaScript">
function CheckAll(form) {
for (var i=0;i<form.elements.length;i++) {
var e = form.elements[i];
if (e.name != 'chkall') e.checked = form.chkall.checked;
}
}
function news(URL)
{ window.open(URL,"news","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width=550,height=300");
}
</script>
</head>
<body topmargin="0" text=#ffffff>
<div id=menuDiv style='Z-INDEX: 1000; VISIBILITY: hidden; WIDTH: 1px; POSITION: absolute; HEIGHT: 1px; BACKGROUND-COLOR: #9cc5f8'></div>
<table width="788" border="0" align="center" cellpadding="2" cellspacing="2">
<tr>
<td><table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFF00" bgcolor="#66CCFF" style="border-collapse: collapse">
<tr>
<td width="100%" background="images/nihao.gif" height="27"><span class="style2"> 当前位置:<a href="admin.asp" class="style2"><font color="black">网站管理中心</font></a>--新闻管理</span></td>
</tr>
<tr>
<td>
<%action=request("action")%>
<%if action="" then%>
<table width=100% border="1" cellpadding=0 cellspacing="0" bordercolor="#333333" style="border-collapse: collapse;border:dotted 1px" >
<form name=Newslist action=news1.asp method=post>
<tr bgcolor="#003366">
<td bgcolor="#3399FF" ><span class="style2">选</span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">预览号</font></span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">标题(编辑)</font></span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">新闻类型</font></span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">图片</font></span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">发布时间</font></span></td>
<td bgcolor="#3399FF"><span class="style2"><font color="#00FF00">状态</font></span></td>
</tr>
<%
sousuo=request("sousuo")
dim rs,msg_per_page
dim sql
msg_per_page = 10 '定义每页显示记录条数
if sousuo="" or sousuo="++请选择类型++" then
sql = "select * from News where newsclass='学院动态' or newsclass='院内公告' order by PubDate desc"
else
sql = "select * from News where newsclass='"&sousuo&"' order by PubDate desc"
end if
set rs=Server.CreateObject("ADODB.RecordSet")
rs.cursorlocation = 3 '使用客户端游标,可以使效率提高
rs.pagesize = msg_per_page '定义分页记录集每页显示记录数
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if not (rs.eof and rs.bof) then '检测记录集是否为空
totalrec = RS.RecordCount 'totalrec:总记录条数
if rs.recordcount mod msg_per_page = 0 then '计算总页数,recordcount:数据的总记录数
n = rs.recordcount\msg_per_page 'n:总页数
else
n = rs.recordcount\msg_per_page+1
end if
currentpage = request("page") 'currentpage:当前页
If currentpage <> "" then
currentpage = cint(currentpage)
if currentpage < 1 then
currentpage = 1
end if
if err.number <> 0 then
err.clear
currentpage = 1
end if
else
currentpage = 1
End if
if currentpage*msg_per_page > totalrec and not((currentpage-1)*msg_per_page < totalrec)then
currentPage=1
end if
rs.absolutepage = currentpage 'absolutepage:设置指针指向某页开头
rowcount = rs.pagesize 'pagesize:设置每一页的数据记录数
dim i
dim k
%>
<%
do while not rs.eof and rowcount>0
%>
<tr>
<td class=b><input type='checkbox' value='<%=Cstr(rs("NewsId"))%>' name=id></td>
<% if rs("tupian")=true then %>
<td><a href="tshownews1.asp?id=<%=rs("newsid")%>" target="_blank"><font color="#000000"><%=rs("newsid")%></font></a></td>
<% else %>
<td><a href="shownews1.asp?id=<%=rs("newsid")%>" target="_blank"><font color="#000000"><%=rs("newsid")%></font></a></td>
<% end if %>
<td><a href="news1.asp?action=修改&id=<%=Cstr(rs("NewsId"))%>" ><font color="black"><%=rs("title")%></font></a></td>
<td><a href="news1.asp?action=修改&id=<%=Cstr(rs("NewsId"))%>" ><font color="black"><%=rs("newsclass")%></font></a></td>
<td><a href="javascript:news('tnews1.asp?id=<%=Cstr(rs("NewsId"))%>')"><font color="black">有<%=rs("jizhang")%>张</font></a></td>
<td><font color="black"><%=rs("PubDate")%></font></td>
<td><font color="black"><% if rs("Online")=true then response.write "在线" else response.write "<font color=black><b>离线</b></font>" end if%></font></td>
</tr>
<%
rowcount=rowcount-1
rs.movenext
loop
end if
end if
rs.close
conn.close
set rs=nothing
set coon=nothing
%>
<tr>
<td colspan=5 class=b><input type='checkbox' name=chkall onclick='CheckAll(this.form)'>
全选
<input type="submit" name="action" value="删除" onclick="{if(confirm('该操作不可恢复!\n\n确定删除选定的新闻?')){this.document.Newslist.submit();return true;}return false;}">
<input type="submit" name="action" value="关闭" onclick="{if(confirm('确定关闭选定的新闻在线?')){this.document.Newslist.submit();return true;}return false;}">
<input type="submit" name="action" value="打开" onclick="{if(confirm('确定打开选定的新闻在线?')){this.document.Newslist.submit();return true;}return false;}"></td>
<td class=b colspan=3><input type="button" name="action22" onclick="javascript:location.href='news1.asp?action=加新闻';" value="加新闻"></td>
</tr>
<tr>
<td class=b><div align="center"><font color="#000000">按类型搜索:</font>
</div></td>
<td class=b><select name="sousuo">
<option>++请选择类型++</option>
<option>学院动态</option>
<option>院内公告</option>
<option>专业介绍</option>
<option>领导风采</option>
<option>教务管理</option>
<option>升本专栏</option>
<option>团委</option>
<option>学生会</option>
<option>院办杂志</option>
</select></td>
<td colspan=3 class=b><input type="submit" name="Submit" value="搜索"></td>
<td class=b colspan=3>
</td>
</tr>
</form>
</table>
<%call listPages()%>
<%end if
if action="关闭" then
NewsId=replace(request("id")," ","")
call prodclose()
end if
if action="打开" then
NewsId=replace(request("id")," ","")
call prodopen()
end if
if action="删除" then
delid=replace(request("id")," ","")
aa=replace(request("id")," ","")
call proddel()
end if
if action="加新闻" then
call newsadd()
end if
if action="修改" then
id=replace(request("id")," ","")
call modify()
end if%>
</table></td>
</tr>
</table>
</body>
<% end if %>
</html>
<%
sub listPages()
if n <= 1 then exit sub
%>
<p><font color=black face="arial">>></font>
<%if currentpage = 1 then%>
<font color=black>首页</font>
<%else%>
<a href="<%=request.ServerVariables("script_name")%>?page=1">
<font color=black face="arial">首页</font></a>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage-1%>">
<font color=black face="arial" >前页</font></a>
<%end if%>
<%if currentpage = n then%>
<font color=black face="arial" >后页</font>
<%else%>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=currentpage+1%>"><font color=black face="arial" >下页</font></a>
<a href="<%=request.ServerVariables("script_name")%>?page=<%=n%>"><font color=black face="arial" >末页</font></a>
<%end if%>
<font color=black face="arial" >
总:<%=currentpage%>/<%=n%>页 <%=msg_per_page%>新闻/页 共:<%=totalrec%>新闻</font></p>
<%end sub
sub prodopen()
if NewsId="" or isnull(NewsId) then
Response.write "<BLOCKQUOTE><br><br>操作失败,没有选择合适参数!<A HREF='news1.asp'><b>点击返回</b></A><BR><br><meta http-equiv=refresh content=""2;URL=news1.asp""></BLOCKQUOTE>"
else
Set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from News where NewsId in ("&NewsId&")"
rs.open sql,conn,3,2
if err.number<>0 then '错误处理
response.write "数据库操作失败:" & err.description
err.clear
else
if rs.eof and rs.bof then
response.write "<script language='javascript'>"
response.write "alert('该新闻不存在,或者被删除了!');"
response.write "location.href='news1.asp';"
response.write "</script>"
else
Do while not rs.eof
rs("online")=true
rs.update
rs.movenext
loop
response.write "<script language='javascript'>"
response.write "alert('新闻 在线显示 设置成功!');"
response.write "location.href='news1.asp';"
response.write "</script>"
end if
rs.close
conn.close
set rs=nothing
set conn=nothing
end if
end if
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?