校园学生学习娱乐资源第一门户 校园第一站 源于校园 服务于校园 分享资源和快乐 网站地图 高级搜索 RSS订阅 收藏本站 设为首页
首页 | 校园 | 教育 | 考试 | 电脑 | 英语 | 读书 | 就业 | 论文 | 体育 | 健康 | 图片 | 分类信息
Q Q | 下载 | 游戏 | 音乐 | 影视 | 专题 | 祝福 | 百科 | 问答 | 博客 | 会员 | 社区 | 校园论坛
·偶像剧免费在线收看
·DEDECMS免费模板规则下载
·
·全能空间、网站建设仅200
XML | 文章搜索:
  当前位置: 主页>电脑>网络编程>ASP> 文章正文

用文本+ASP打造新闻发布系统

http://www.xydyz.com 来源:校园第一站 2007-11-12 阅读: 评论



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)
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
'############################################################################
contenttext.write htmlencode2(news_content)
contenttext.close
set myfso=nothing
%〉
〈script〉
alert("发布成功");
window.location="news_add.asp";
〈/script〉

//新闻列表显示
〈%
dim myfso,myread
set myfso=createobject("scripting.filesystemobject")
set myread=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)

if myread.atendofstream then
Response.Write "目前没有添加新闻"
Response.End
else

dim mytext,listarray
mytext=myread.readall
listarray=split(mytext,"|") '#######把所有记录分割成一个数组a
dim recordcount,pagecount, pagesize, pagenum
recordcount=ubound(listarray)'############记录条数
pagesize=2
pagecount=recordcount/pagesize '#######取得页面数
if instr(1,pagecount,".")=null or instr(1,pagecount,".")=0 then
pagenum=pagecount
else
pagenum=int(pagecount)+1
end if

dim topage
topage=cint(Request.QueryString ("topage")) '########取得要显示的页面
if topage〈=0 then
topage=1
end if
if topage〉pagenum then
topage=pagenum
end if


dim i,j,n
b=listarray
for i=0 to recordcount-1 '########把每一条记录组成一个数组
j=split(listarray(i),",")
if ubound(j)=6 then
b(i)="〈SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'〉〈li〉〈/SPAN〉〈span style='font-size:10pt'〉〈a href='news_view.asp?id=" & j(0) & "' target=blank〉" & j(1) & "(图)〈/a〉 点击:" & j(4)&"次 最后发布时间:"&j(5)&"〈/span〉"
else
b(i)="〈SPAN style='COLOR: #ffbd00; FONT-SIZE: 7px'〉〈li〉〈/SPAN〉〈span style='font-size:10pt'〉〈a href='news_view.asp?id=" & j(0) & "' target=blank〉" & j(1) & "〈/a〉 点击:" & j(4)&"次 最后发布时间:"&j(5)&"〈/span〉"
end if
next

'########把记录反排序存储在新的数组实现按时间反排序
dim c(100)
n=0
for i=recordcount to 0 step -1
c(n)=b(i)
n=n+1
next


dim currentrecord
currentrecord=pagesize*(topage-1)+1 '#########显示每一页
for k=1 to pagesize
if len(c(currentrecord))=0 then
exit for
end if
Response.Write c(currentrecord)&"〈br〉"
currentrecord=currentrecord+1
next
Response.Write "〈body bgcolor=#EDF0F5 topmargin=10 marginheight=5 leftmargin=4 marginwidth=0〉"
for m=1 to pagenum
response.write "〈span style=font-size:10pt〉〈a href=news_list.asp?topage="&m&"〉"&m&"〈/a〉〈/span〉 "
next

end if%>
//新闻删除
〈!--#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



【责任编辑:admin 】




评论
用户名: 新注册) 密码: 匿名评论
评论内容:不能超过250字,请自觉遵守互联网相关政策法规。
  相关文章
为自己的ASP网站系统构建一套标记语言
ASP中Request对象获取客户端数据的顺序
彻底解决“Microsoft JET Database Engine 错误 80004005”
一段用ASP查看ASP文件源码的程序
Web在线代理(Asp版)
  最新图片
为自己的ASP网站系统构建一套标记语言
为自己的ASP网站系统
24小时TOP
   
·AspJpeg组件下载注册码及用途
·“Operation Must Use an Updateable Query
·Web在线代理(Asp版)
·asp分页代码
·ASP二进制流方法隐藏图片文件真实地址
·ASP函数库
·彻底解决“Microsoft JET Database Engine
·UTF-8怎么转GB2312?
热门图片
  更多>>>
为自己的ASP网站系统构建一套标记语言
为自己的ASP网站系
焦点聚焦
  更多>>>
 
论坛精华
  更多>>>
·真钱斗地主轧金花龙虎板玖和百家乐http://c
·22岁女大学生要嫁48岁乞丐(图)
·一条短信毁了一种水果 “蛆橘”传言流变调
·蒙古风情十四怪 (一)
·《中国高新技术企业》--www.txrb.com--科信
·东莞大金空调官方介绍 13559702882卢生
·乐众国际最新博彩游戏!真实!新鲜!刺激!
·快国庆了大家怎么安排
最新图片
  更多>>>
为自己的ASP网站系统构建一套标记语言
为自己的ASP网站系
推荐文章
  更多>>>
·为自己的ASP网站系统构建一套标记语言
关于我们 - 版权声明 - 免责声明 - 欢迎投稿 - 广告服务 - 友情链接 - 网站建设 - 诚聘英才 - 联系我们 - -
Copyright @2007-2009 www.xydyz.com © All rights reserved.
校园第一站 版权所有 客服E-Mail:hyperblue@163.comn 点击这里给我发消息
Site design by hyperblue 鄂ICP备07009403号 Powered by DedeCms