📄 admin_new.asp
字号:
<!--#include file=INC/skin.asp-->
<%
Dim const_txl_HomeUrl
const_txl_HomeUrl = ""
%>
<!--#include file=admin_login_check.asp-->
<%
opendatabase
txl_SiteHead const_txlname&"- 管理员"
call showinfo
select case Request.QueryString("action")
case "add": call saveadd
case "edit": call showedit
case "new": call addform
case "editsave": call saveedit
case "del": call del
case "show": call show
end select
closedatabase
web_end
%>
<%sub showinfo
'on error resume next
dim rs
set rs=conn.execute("select * from [news] order by adddate desc")
%>
<br><table border="1" cellspacing="0" width="720" bgcolor="#FFFFFF" bordercolorlight="#cccccc" bordercolordark="#FFFFFF" cellpadding="0" align="center">
<tr align="center">
<td width="35" height="20" bgcolor="#efefef"><b>ID</b></td>
<td bgcolor="#efefef"><b>标题</b></td>
<td width="92" bgcolor="#efefef"><b>时间</b></td>
<td width="97" bgcolor="#efefef"><b>操作</b><b></b></td>
</tr>
<%
if rs.eof then
Response.Write("<tr><td colspan=5 align=center>还没有添加新闻!</td></tr>")
else
while not rs.eof
%>
<tr>
<td height="23" align="center"><%=rs("id")%></td>
<td align="center"><font color=<%=rs("titlecolor")%>><%=rs("title")%></font></td>
<td align="center"><%=datevalue(rs("adddate"))%></td>
<td align="center"><a href="?id=<%=rs("id")%>&action=show">查看</a> | <a href="?id=<%=rs("id")%>&action=edit">编辑</a>
| <a href="?id=<%=rs("id")%>&action=del" onclick="javascript:return confirm('你确实要删除这个记录吗?')">删除</a></td>
</tr>
<%
rs.movenext
wend
end if
rs.close
set rs=nothing
%>
<tr align="center">
<td height="23" colspan="4"><font color="#FF0000"><a href="?action=new">新增新闻</a></font></td>
</tr>
</table>
<br>
<%end sub%>
<%sub addform%>
<script>
function CheckForm(frm){
var title=frm.title.value
if (title==""){
alert("请输入标题!")
frm.title.focus();
return false;
}
var content=frm.content.value
if (content==""){
alert("请输入内容!")
frm.content.focus();
return false;
}
return true
}
</script>
<form name="myform" method="post" action="?action=add" onSubmit="return CheckForm(this);">
<table width="720" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#E8E8E8">
<tr bgcolor="#FFFFFF">
<td colspan="2" align="center" valign="top"><font color="#FF0000">新增新闻</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="75" valign="top"><font color="#FF0000">公告</font><font color="#FF0000">标题:
<input name="titlecolor" type="hidden" id="titlecolor">
</font></td>
<td width="627"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%"><input type="text" name="title" size="50" class="editbox" id="title" style="color:#000000">
支持HTML
<script language=JavaScript src="inc/title_color.js"></script> <table id=ColorPanel cellspacing=0 cellpadding=0 border=0>
<tbody>
<tr>
<td id=ColorUsed
onClick="if(this.bgColor.length > 0) insertTag(this.bgColor)"
valign=center align=middle> </td>
<script language=JavaScript>rgb(pas,width1,height1)</script>
</tr>
</tbody>
</table></td>
</tr>
</table></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top">公告内容:<br>
(Html支持) </td>
<td> <textarea name="content" cols="60" rows="8" id="content"></textarea></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top"> </td>
<td> <input type="submit" name="Submit" value="提交"> <input type="reset" name="Submit2" value="重置"></td>
</tr>
</table>
</form>
<%end sub%>
<%sub show()
dim rs
set rs=conn.execute ("select * from news where id="&Request.QueryString("id"))
%>
<table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#E8E8E8">
<tr bgcolor="#FFFFFF">
<td colspan="2" align="center" valign="top"><font color="#FF0000">查看新闻</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="75" valign="top">公告标题:</td>
<td width="627"><font color="<%=rs("titlecolor")%>"><%=rs("title")%></font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top">发布时间:</td>
<td><%=rs("adddate")%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top">点击量:</td>
<td><%=rs("hits")%></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top">内容:<br> </td>
<td valign="top"><%=rs("content")%> </td>
</tr>
</table>
<%
rs.close
set rs=nothing
end sub
%>
<%sub showedit
dim rs
set rs=conn.execute ("select * from news where id="&Request.QueryString("id"))
%>
<form name="myform" method="post" action="?action=editsave&id=<%=Request("id")%>" onSubmit="return CheckForm(this);">
<table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#E8E8E8">
<tr bgcolor="#FFFFFF">
<td colspan="2" align="center" valign="top">
<script>
function CheckForm(frm){
var title=frm.title.value
if (title==""){
alert("请输入标题!")
frm.title.focus();
return false;
}
var content=frm.content.value
if (content==""){
alert("请输入内容!")
frm.content.focus();
return false;
}
return true
}
</script> <font color="#FF0000">编辑新闻</font></td>
</tr>
<tr bgcolor="#FFFFFF">
<td width="75" valign="top"><font color="#FF0000">公告</font><font color="#FF0000">标题:
<input name="titlecolor" type="hidden" id="titlecolor3" value="<%=rs("titlecolor")%>">
</font></td>
<td width="627"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="40%"><input name="title" type="text" class="editbox" id="title3" style="color:<%=rs("titlecolor")%>" value="<%=rs("title")%>" size="50">
支持HTML
<script language=JavaScript src="inc/title_color.js"></script> <table id=ColorPanel cellspacing=0 cellpadding=0 border=0>
<tbody>
<tr>
<td id=ColorUsed
onClick="if(this.bgColor.length > 0) insertTag(this.bgColor)"
valign=center align=middle> </td>
<script language=JavaScript>rgb(pas,width1,height1)</script>
</tr>
</tbody>
</table></td>
</tr>
</table></td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top">公告内容:<br>
(Html支持) </td>
<td> <textarea name="content" cols="60" rows="8" id="content"><%=HtmlUNEncode(rs("content"))%></textarea>
</td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top"> </td>
<td> </td>
</tr>
<tr bgcolor="#FFFFFF">
<td valign="top"> </td>
<td> <input type="submit" name="Submit3" value="提交"> <input type="reset" name="Submit22" value="重置">
</td>
</tr>
</table>
</form>
<%
rs.close
set rs=nothing
end sub
%>
<%sub saveadd
dim title,titlecolor,content,rs
title=Trim(Request.Form("title"))
titlecolor=Trim(Request.Form("titlecolor"))
content=HtmlEncode(Request.Form("content"))
set rs=server.CreateObject("Adodb.Recordset")
rs.open "select * from news where 1=2",conn,1,3
rs.addnew()
rs("title")=title
rs("titlecolor")=titlecolor
rs("content")=content
rs("adddate")=now()
rs.update
rs.close
set rs=nothing
Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
end sub
sub saveedit
dim title,titlecolor,content,rs
title=Trim(Request.Form("title"))
titlecolor=Trim(Request.Form("titlecolor"))
content=HtmlEncode(Request.Form("content"))
set rs=server.CreateObject("Adodb.Recordset")
rs.open "select * from news where id="&Request.QueryString("id"),conn,1,3
rs("title")=title
rs("titlecolor")=titlecolor
rs("content")=content
rs.update
rs.close
set rs=nothing
Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
end sub
sub del
conn.execute ("delete from news where id="&Request.QueryString("id"))
Response.Redirect(Request.ServerVariables("SCRIPT_NAME"))
end sub
Function HtmlUNEncode(str)
dim tempstr
tempstr=str
If Trim(tempstr)="" Or IsNull(tempstr) Then Exit Function
tempstr=Replace(tempstr,"<br>",Chr(10))
tempstr=Replace(tempstr,"<p></p>",Chr(10) & Chr(10) )
tempstr=Replace(tempstr,"",Chr(13))
tempstr=Replace(tempstr,"'",Chr(39))
tempstr=Replace(tempstr,""",Chr(34))
tempstr=Replace(tempstr," ",Chr(9))
tempstr=Replace(tempstr," ",Chr(32))
' tempstr=Replace(tempstr,"<","<")
' tempstr=Replace(tempstr,">",">")
HtmlUNEncode=tempstr
End Function
Function HtmlEncode(str)
If Trim(Str)="" Or IsNull(str) Then Exit Function
' str=Replace(str,">",">")
' str=Replace(str,"<","<")
str=Replace(str,Chr(32)," ")
str=Replace(str,Chr(9)," ")
str=Replace(str,Chr(34),""")
str=Replace(str,Chr(39),"'")
str=Replace(str,Chr(13),"")
str=Replace(str,Chr(10) & Chr(10), "</p><p>")
str=Replace(str,Chr(10),"<br> ")
HtmlEncode=str
End Function
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -