您的位置:首页精文荟萃软件资讯 → 用文本+ASP打造新闻发布系统五新闻修改

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

时间:2004/10/7 19:09:00来源:本站整理作者:蓝点我要评论(0)


            
             
              
             
            

               
               

            



            ‘#######news_update.asp



<% 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,"
",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



%>






























新闻发布系统后台管理--新闻修改
新闻标题












新闻来源

图片上传












##########
news_updating.asp


<%
'Fields("xxx").Name 取得Form中xxx(Form Object)的名字
'Fields("xxx").FilePath 如果是file Object 取得文件的完整路径
'Fields("xxx").FileName 如果是file Object 取得文件名
'Fields("xxx").ContentType 如果是file Object 取得文件的类型
'Fields("xxx").Length 取得Form中xxx(Form Object)的数据长度
'Fields("xxx").Value 取得Form中xxx(Form Object)的数据内容
Dim FormData,FormSize,gnote,bnote,notes,binlen,binstr
FormSize=Request.TotalBytes
FormData=Request.BinaryRead(FormSize)
Set Fields = GetUpload(FormData)

'############判断输入错误
dim mytitle,content,src,id,mysession
mysession=Fields("newtitle").value
if len(mysession)=0 then
Response.Write "非法登陆或超时间,请重新登陆"
Response.End
end if

mytitle=Fields("newtitle").value
mytitle=replace(mytitle,"|","|")
mytitle=replace(mytitle,"
","")

content=Fields("newcontent").value

src=Fields("newssrc").value
src=replace(src,"|","|")
src=replace(src,"
","")
id=trim(right(Fields("myid").value,12))

if len(mytitle)=0 then
Response.Write ""
end if

if len(content)=0 then
Response.Write ""
end if

if len(src)=0 then
Response.Write ""

end if


'############################################################################################图片更该功能的实现
newfile="client1"
If Fields(newfile).FileName<>"" Then
set file_0=Server.CreateObject("Scripting.FileSystemObject")
dim contextname
contextname=right(Fields("client1").FileName,4)
imageid=id&contextname

if contextname<>".gif" and contextname<>".jpg" then '#########判断上传文件格式
Response.Write ""
end if

file_name=Server.MapPath("./images/"&imageid&"")

'#####################################如果原来有图片文件主名为id的则删除该图片
if file_0.fileexists(server.MapPath ("./images/"&id&".gif")) then
Set f3 = file_0.GetFile(server.MapPath ("./images/"&id&".gif"))
f3.Delete

end if
if file_0.fileexists(server.MapPath ("./images/"&id&".jpg")) then
Set f3 = file_0.GetFile(server.MapPath ("./images/"&id&".jpg"))
f3.Delete
end if
'########################################写入图片

set outstream=file_0.openTextFile(file_name,8,-1)
binstr=Fields("client1").Value

binlen=1
varlen=lenb(binstr)
for i=1 to varlen
clow = MidB(binstr,i,1)
If AscB(clow) = 255 then
outstream.write chr(255)
binlen=binlen+1
if (i mod 2)=0 then
notes=gnote
exit for
end if
elseif AscB(clow) > 128 then
clow1=MidB(binstr,i+1,1)
if AscB(clow1) <64 or AscB(clow1) =127 or AscB(clow1) = 255 then
binlen=binlen+1
'if (binlen mod 2)=0 then
binlen=binlen+1
outstream.write Chr(AscW(ChrB(128)&clow))
'end if
notes=bnote
exit for
else
outstream.write Chr(AscW(clow1&clow))
binlen=binlen+2
i=i+1
if (i mod 2)=0 then
notes=gnote
exit for
end if
end if
else
outstream.write chr(AscB(clow))
binlen=binlen+1
if (i mod 2)=0 then
notes=gnote
exit for
end if
end if
next
outstream.close
set outstream=file_0.OpenTextFile(file_name,8,false,-1)
outstream.write midb(Fields(newfile).Value,binlen)
outstream.close
if notes=bnote then notes=notes&(binlen-1)&"字节处。"

End If

'#######################################################################################################

dim myfso,mywrite '#######修改新闻详细内容
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
set mywrite=myfso.createtextfile(server.mappath("./news_content/"&id&".txt"),-1,0)
mywrite.write content


dim mytext2,myread2 '#########修改新闻的标题来源
set myread2=myfso.opentextfile(server.mappath("./new_list.asp"),1,0)
mytext2=myread2.readall
dim listarray,i,h,count,sf
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
sf(1)=mytitle
sf(3)=src

'#######为6说明上传了图片,存储新的数组实现查看记录点击次数加1
if ubound(sf)=6 then
If Fields(newfile).FileName<>"" Then
sf(6)=imageid
end if
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)&","&sf(6)
else
listarray(i)=sf(0)&","&sf(1)&","&sf(2)&","&sf(3)&","&sf(4)&","&sf(5)
end if
'##################
exit for
end if

next


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+"
"
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
'##########################
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 htmlencode2(listarray(i))
else
mytext.write htmlencode2(listarray(i)&"|")
end if
next
%>

相关阅读 Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么

文章评论
发表评论

热门文章 360快剪辑怎么使用 36金山词霸如何屏幕取词百度收购PPS已敲定!3

最新文章 微信3.6.0测试版更新了微信支付漏洞会造成哪 360快剪辑怎么使用 360快剪辑软件使用方法介酷骑单车是什么 酷骑单车有什么用Apple pay与支付宝有什么区别 Apple pay与贝贝特卖是正品吗 贝贝特卖网可靠吗

人气排行 xp系统停止服务怎么办?xp系统升级win7系统方电脑闹钟怎么设置 win7电脑闹钟怎么设置office2013安装教程图解:手把手教你安装与qq影音闪退怎么办 QQ影音闪退解决方法VeryCD镜像网站逐个数,电驴资料库全集同步推是什么?同步推使用方法介绍QQ2012什么时候出 最新版下载EDiary——一款好用的电子日记本