📄 addnews.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="config.asp"-->
<%
If Cint(AdminGroup(1))<>1 then
Response.Redirect("Default.asp")
Response.End()
End If
%>
<!--#include file="top.asp"-->
<%
dim listid
listid=request("listid")
if listid="" or not isnumeric(listid) then
response.Write("<script>alert('参数错误!');history.back()</script>")
response.End()
end if
dim rslt,lt
set rslt=conn.execute("select title from list where id="&clng(listid))
if rslt.bof and rslt.eof then
response.Write("<script>alert('该栏目不存在或者已被删除!');history.back()</script>")
response.End()
end if
lt=rslt(0)
rslt.close
set rslt=nothing
response.Write("<table border=0 align=center cellpadding=3 cellspacing=1 class=tablecolor>")
response.Write("<tr><td height=25 align=center class=banner>"&htmlcode(lt)&"</td><td width='20%' align=center class=banner><a href=addnews.asp?listid="&listid&">添加数据</a></td></tr></table>")
select case request("action")
case "savenews"
call savenews()
case else
call normal()
end select
sub normal()
dim id,title,content,titlecolor,hits
id=request.QueryString("id")
if id<>"" then
dim rs
set rs=conn.execute("select * from news where id="&clng(id))
if rs.bof and rs.eof then
response.Write("<script>alert('该条新闻不存在或者已被删除!');history.back()</script>")
response.End()
end if
title=rs("title")
titlecolor=rs("titlecolor")
content=rs("content")
hits=rs("hits")
rs.close
set rs=nothing
end if
response.Write("<script src='../inc/ubbcode.js'></script>")
response.Write("<table border='0' align='center' cellpadding='3' cellspacing='1' class='tablecolor'>")
response.Write("<form action='?action=savenews' method=POST name=frmAnnounce>")
response.Write("<tr><td width='30%' class='tablebody'><strong>新闻标题</strong></td><td class='tablebody'><input name=subject class=FormClass value='"&title&"' size=60 maxlength=80></td></tr>")
response.Write("<tr><td class='tablebody'><strong>标题颜色</strong></td><td class='tablebody'><input name='titlecolor' type='text' id='titlecolor' value='"&titlecolor&"' maxlength='8'> 可以输入颜色代码,如:<font color='#FF0000'>Red</font>,<font color='#0033FF'>#0033FF</font>等</td></tr>")
response.Write("<tr><td class='tablebody'><strong>点击数</strong><td class='tablebody'><input name='hits' type='text' value='"&hits&"'size=5></td>")
response.Write("<tr><td class='tablebody' style='font-weight: bold'>图片上传</td><td class='tablebody'><iframe name='ad' frameborder=0 width=100% height=24 scrolling=no src=news_upload.asp></iframe></td></tr>")
response.Write("<tr><td valign='top' class='tablebody'><b>内容</b><br><li>HTML标签:√<li>UBB标签:√<li>贴图标签:√<li>多媒体标签:√<p><br><br></p></td>")
response.Write("<td valign='top' class='tablebody'>")
%>
<!--#include file="../inc/getubb.asp"-->
<%
response.Write("<textarea cols=60 name=Content rows=12 wrap=VIRTUAL>"&content&"</textarea></td></tr>")
response.Write("<tr><td align='center' class='tablebody'> </td><td class='tablebody'> <input type='hidden' name='listid' value='"&listid&"'><input type='hidden' name='id' value='"&id&"'><input type=Submit value='发 表' name=Submit> <input type=reset name=Submit2 value='清 除'></td></tr></form></table>")
end sub
sub savenews()
dim title,titlecolor,content,id,userid,listid,hits
listid=request.Form("listid")
userid=request.Cookies("admin")("userid")
id=request.Form("id")
title=checkStr(request.Form("subject"))
titlecolor=checkStr(request.Form("titlecolor"))
content=checkStr(request.Form("content"))
hits=checkstr(request.Form("hits"))
if title="" then
response.Write("<script>alert('新闻标题不能为空!');history.back()</script>")
response.End()
end if
If hits="" then
hits=0
end if
if not isnumeric(hits) then
response.Write("<script>alert('点击数错误!');history.back()</script>")
response.End()
end if
if content="" then
response.Write("<script>alert('新闻内容不能为空!');history.back()</script>")
response.End()
end if
dim ip
ip=Request.ServerVariables("HTTP_REFERER")
if id<>"" then
conn.execute("update news set title='"&title&"',titlecolor='"&titlecolor&"',content='"&content&"',hits="&hits&",userid="&clng(userid)&" where id="&clng(id)&"")
response.Write("<script>alert('更新成功!');location='"&ip&"'</script>")
response.End()
else
conn.execute("insert into news (title,titlecolor,content,userid,listid,istop,isview,hits) values('"&title&"','"&titlecolor&"','"&content&"',"&userid&","&listid&",0,1,"&hits&")")
response.Write("<script>alert('添加成功!');location='"&ip&"'</script>")
response.End()
end if
end sub
%>
<%CloseConn%>
<!--#include file="end.asp"-->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -