网站首页 手机版
 注册 登录
您现在的位置: 畅无忧设计 >> 网络编程 >> ASP教程 >> 正文
最新文章
· FSO 组件asp生成html静态页面碰到缓存
· asp实现长文章自动分页插件
· 在ASP中访问和更新Cookies集合
· ASP错误提示大全
· 学习ASP的几个观点
· ASP用两级联动下拉列表来显示大类和小
· ASP取当前页面地址和参数
· ASP删除记录的同时删除相关图片
· asp将查询结果导出到excel
· ASP批量导入Excel到Access或者Sql Se
热门文章
 化境ASP无组件上传类 - upload_5xs
 一个获取ACCESS数据库表名以及表名
 asp将查询结果导出到excel
 艾恩ASP无组件上传修改版
 ASP批量导入Excel到Access或者Sql 
 ASP读取数据库的Flash+JS图片切换特
 ASP用两级联动下拉列表来显示大类和
 ASP+JS实现网页歌曲连播、点播功能
 使用ASP重启服务器
 asp批量替换access数据库中指定字段
相关文章
没有相关文章
用文本和ASP打造新闻发布系统
来源:本站原创 更新时间:2009/5/14 17:00:18 阅读次数:
字体:[ ] 我要投稿

//新闻删除
<!--#include file="news_session.asp"-->
<%
dim id
id=Request.QueryString ("id")
dim myfso
set myfso=createobject("scripting.filesystemobject")
if myfso.FileExists(server.mappath("./news_content/"&id&".txt"))then
myfso.DeleteFile (server.mappath("./news_content/"&id&".txt"))'#############删除新闻内容
end if

dim mytext2,myread2
set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
if myread2.atendofstream then
Response.Write "没有新闻内容"
myread2.close
Response.End
end if
mytext2=myread2.readall
myread2.close
dim listarray,i,h,count,sf,title
listarray=split(mytext2,"|") '#########读取记录并以#分割成listarray数组
count=ubound(listarray)
for i=0 to count '###########根据ID找到该新闻实现删除功能
sf=split(listarray(i),",")
if right(sf(0),7)=right(id,7) then
dim thisid
thisid=i

'#######为6说明上传了图片,删除新闻图片和该列表记录
if ubound(sf)=6 then
myfso.deletefile(server.MapPath ("./images/"&sf(6)))
end if
exit for
end if
next

dim mytext,mappath
mappath=server.mappath("./")
set mytext=myfso.createtextfile(mappath&"\new_list.asp",-1,0)
for i=0 to thisid-1' ##########把所有数据重新写入文件
mytext.write listarray(i)&"|"
next

for i=thisid+1 to ubound(listarray)
if i=ubound(listarray) then
mytext.write listarray(i)
exit for
else
mytext.write listarray(i)&"|"
end if
next
mytext.close
%>
<script language="javascript">
alert("删除成功");
location.href =("news_admin1.asp");
</script>
---------------

news_view.asp
<% Response.Expires=0
dim myid,myfso,myread,mytext1
myid=request.querystring("id")

if len(myid)=0 then
Response.Write "没有该新闻"
Response.End
end if

set myfso=createobject("scripting.filesystemobject")
set myread=myfso.opentextfile(server.mappath("./news_content/"&myid&".txt"),1,0)
if myread.atendofstream then
Response.Write "没有新闻内容"
Response.End
else
mytext1=myread.readall '#######打开对应的新闻内容文件,并读取用变量存储


function htmlencode2(str)'###########字符处理函数
dim result
dim l
l=len(str)
result=""
dim i
for i = 1 to l
select case mid(str,i,1)
case chr(34)
result=result+""""
case "&"
result=result+"&"
case chr(13)
result=result+"<br>"
case " "
result=result+" "
case chr(9)
result=result+" "
case chr(32)
result=result+" "
if i+1<=l and i-1>0 then
if mid(str,i+1,1)=chr(32) or mid(str,i+1,1)=chr(9) or mid(str,i-1,1)=chr(32) or mid(str,i-1,1)=chr(9) then
result=result+" "
else
result=result+" "
end if
else
result=result+" "
end if
case else
result=result+mid(str,i,1)
end select
next
htmlencode2=result
end function


myread.close
end if

dim mytext2,myread2
set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)

if myread2.atendofstream then
Response.Write "没有新闻内容"
Response.End
else
mytext2=myread2.readall
myread2.close
dim listarray,i,h
listarray=split(mytext2,"|") '#########读取记录并以#分割成listarray数组

dim count,sf,title,src
count=ubound(listarray)

for i=0 to count '###########根据ID找到该新闻并把文章点击次数加1
sf=split(listarray(i),",")
if right(sf(0),7)=right(myid,7) then
title=sf(1)
src=sf(3)
sf(4)=sf(4)+1

'#######为6说明上传了图片,存储为新的数组
if ubound(sf)=6 then
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)&","&sf(6)
dim mypic
mypic=sf(6)
else
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)
end if
'##################
exit for
end if
next

dim k,mytext,mappath
mappath=server.mappath("./")
set mytext=myfso.createtextfile(mappath&"\new_list.asp",-1,0)
for i=0 to ubound(listarray)' ##########把所有数据重新写入文件
if i=ubound(listarray) then
mytext.write listarray(i)
else
mytext.write listarray(i)&"|"
end if
next
Response.Write "<body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0>"
Response.Write"<div align=center style=font-size:13pt><strong>"&title&"</strong><span></div><br>"
Response.Write "<hr size=1>"
if len(mypic)<>0 then
Response.write "<center><img src='./images/"&mypic&"'></center>"
end if
Response.Write "<span style=font-size:10pt>"&htmlencode2(mytext1)&"</span>"
Response.Write "<br><div align=right style='font-size:9pt'>新闻来源:<font color=red>"&src&"</font></div>"
%>

<OBJECT id=closes type="application/x-oleobject" classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11">
<param name="Command" value="Close">
</object>
<center><input type="button" value="关闭窗口" onclick="closes.Click();"></center>

<% end if%>
//新闻修改
‘#######news_update.asp
<!--#include file="news_session.asp"-->
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function client_onblur(ii) {
server=eval("form1.server"+ii)
if(server.value==""){
client=eval("form1.client"+ii)
clientvalue=client.value+""
varlen=clientvalue.length
a=clientvalue.lastIndexOf('\\')
clientvalue=clientvalue.substring(a+1)
//alert(clientvalue);
server.value=clientvalue
}
}
function form1_onsubmit() {
for(i=1;i<1;i++){
client=eval("form1.client"+i)
server=eval("form1.server"+i)
if(client.value!="" && server.value==""){alert("上传后的文件名不能空!");server.focus();return false}
}
}
//-->
</SCRIPT>
<% dim myid
myid=Request.QueryString ("id")
if len(myid)=0 then
Response.Write "没有该新闻"
Response.End
end if
dim myfso,myread,mytext,newscontent
'#######打开对应的新闻内容文件,并读取用变量存储
set myfso=createobject("scripting.filesystemobject")
if myfso.FileExists (server.mappath("./news_content/"&myid&".txt")) then
set myread=myfso.opentextfile(server.mappath("./news_content/"&myid&".txt"),1,0)
newscontent=myread.readall
myread.close
newscontent=replace(newscontent,"<br>",chr(13))
newscontent=replace(newscontent," "," ")
newscontent=replace(newscontent," ",chr(32))
newscontent=replace(newscontent,"'' ",chr(34))
else
Response.Write "该新闻已被删除"
Response.End
end if
dim mytext2,myread2 '#######打开新闻列表文件
set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
if myread2.atendofstream then
Response.Write "没有新闻内容"
Response.End
end if
mytext2=myread2.readall
dim listarray
listarray=split(mytext2,"|") '#########读取记录并以#分割成listarray数组
dim count,sf,i,title,src
count=ubound(listarray)
for i=0 to count '###########根据ID找到该新闻并用变量存储给新闻的标题
sf=split(listarray(i),",")
if right(sf(0),7)=right(myid,7) then
title=sf(1)
src=sf(3)
exit for
end if
next
%>
<head>
<style>
td {font-size:9pt}
INPUT.buttonface {
BACKGROUND-COLOR: #0079F2; BORDER-BOTTOM: #333333 1px outset; BORDER-LEFT: #333333 1px outset; BORDER-RIGHT: #ffffff 1px outset; BORDER-TOP: #ffffff 1px inset; COLOR: black; FONT-SIZE: 9pta { color: #000000; text-decoration: none}
.text {font-size:11pt}
INPUT.buttonface2 {
BACKGROUND-COLOR: #EDF0F5; COLOR: black; FONT-SIZE: 9pta { color: #000000; text-decoration: none}
a:hover { color: white; text-decoration: underline overline; background: #007EBB}
.text {font-size:11pt}
</style>
</head>
<body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0>
<form method="POST" action="news_updateing.asp" name="form1" enctype="multipart/form-data" onsubmit="return form1_onsubmit()">
<div align="left">
<table border="1" width="752" height="240" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" height="12" align="center" width="800" style="font-size:12pt"><strong>新闻发布系统后台管理--新闻修改</strong></td>
</tr>
<tr>
<td width="119" height="12" style="font-size:9pt">新闻标题</td>
<td width="675" height="12">
<input type="text" name="newtitle" size="94" value="<%=title%>" class="buttonface2 ">
</td>
</tr>
<tr>
<td width="119" height="213" style="font-size:9pt">
新<br>
闻<br>
内<br>
容</td>
<td width="675" height="213">
<textarea rows="14" name="newcontent" cols="93" style="BACKGROUND-COLOR: #EDF0F5"><%=newscontent%></textarea>
<br>
</td>
</tr>
<tr>
<td width="119" height="4" style="font-size:9pt">新闻来源</td>
<td width="675" height="4">
<input type=text name="newssrc" value="<%=src%>" size="93" class="buttonface2 ">
</td>
</tr>
<tr>
<td width="119" height="5" style="font-size:9pt">图片上传</td>
<td width="675" height="5"> <input type="file" name="client1" size="20" readonly LANGUAGE=javascript onblur="return client_onblur(1)" ></td>
</tr>
</table>
</div>
<p>
<input type="submit" value="确认" name="B1" style="font-size: 10pt; color: #000000; " class="buttonface">
<input type="reset" value="全部重写" name="B2" style="font-size:10pt;color:#000000;" class="buttonface">
<input type="button" value="帐号修改" onclick="location.href='admin/news_chadmin.asp'" name="B2" style="font-size:10pt;color:#000000;" class="buttonface">
<input type="button" value="新闻添加" onclick="location.href='news_add.asp'" name="B2" style="font-size:10pt;color:#000000;" class="buttonface"></p>
<input type=hidden name="myid" value="<%=myid%>">
<INPUT type="hidden" name="server1">
<input type="hidden" name="mysession" value="mysession">
</form>

上一页  [1] [2] [3] [4] 下一页

  • 上一篇文章:
  • 下一篇文章:
  • 关于我们 - 联系我们 - 广告服务 - 在线投稿 - 友情链接 - 网站地图 - 版权声明
    CopyRight 2008-2010, CWYDESIGN.COM - 畅无忧设计, Inc. All Rights Reserved
    滇ICP备09005765号