asp新闻发布系统 html,用文本+ASP打造新闻发布系统(二)新闻添加

.buttonface {

BACKGROUND-COLOR: #0079F2; BORDER-BOTTOM: #333333 1px outset; BORDER-LEFT: #333333 1px outset; BORDER-RIGHT: #ffffff 1px outset; BORDER-TOP: #ffffff 1px outset; COLOR: #ffffff; FONT-SIZE: 9pta {  color: #000000; text-decoration: none}

新闻发布系统
新闻发布系统后台管理--新闻添加
新闻标题
新闻内容
新闻来源
图片上传

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

news_input.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 news_title,news_content,news_src,mysession

mysession=Fields("mysession").value

if len(mysession)=0 then

Response.Write "非法登陆或超时请重新登陆"

Response.End

end if

news_title=Fields("news_title").value

news_title=replace(news_title,"|","|")

news_content=Fields("news_content").value

news_src=Fields("news_src").value

news_src=replace(news_src,"|","|")

if len(news_title)=0 then%>

alert("出错!新闻标题不能为空");

history.go(-1);

//window.location="news_add.asp";

end if

if len(news_content)=0 then%>

alert("出错!新闻内容不能为空");

history.go(-1);

if len(news_src)=0 then%>

alert("出错!新闻来源不能为空");

history.go(-1);

end if

dim varchar

varchar=right(Fields("server1").value,3)

if len(varchar)<>0 then

if varchar<>"gif" and varchar<>"jpg"  then

%>

alert("出错!不能上传该图片类型");

history.go(-1);

else

end if

end if

'###########将图片写入文件夹

set file_O=Server.CreateObject("Scripting.FileSystemObject")

'##########当前时间做图片名

dim newname,mytime,newfile,filename,id,image

endname=right(fields("server1").value,4)

mytime=now()

id=Year(mytime)&Month(mytime)&Day(mytime)&Hour(mytime)&Minute(MyTime)&Second(MyTime)

imageid=id&endname

'#############写入图片

newfile="client1"

filename=Fields("server1").value

If Fields(newfile).FileName<>"" Then

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

set outstream=file_O.CreateTextFile(file_name,true,false)

binstr=Fields(newfile).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_O.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

'###################################################################################### 把新闻数据结构写入newslist文件

dim mappath,mytext,myfso,contenttext,news_addtime,news_point

news_point=1

news_addtime=mytime

set myfso=createobject("scripting.filesystemobject")

mappath=server.mappath("./")

set mytext=myfso.opentextfile(mappath&"\new_list.asp",8,-1)

dim mytext2

if len(varchar)<>0 then

mytext2=trim(id&","&news_title&","&id&".txt"&","&news_src&","&news_point&","&news_addtime&","&imageid&"|")

else

mytext2=trim(id&","&news_title&","&id&".txt"&","&news_src&","&news_point&","&news_addtime&"|")

end if

mytext.writeline(mytext2)

mytext.close

'##############把新闻内容写入相应的文件中

set contenttext=myfso.OpenTextFile(mappath&"\news_content\"&id&".txt",8,-1)

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

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

contenttext.write htmlencode2(news_content)

contenttext.close

set myfso=nothing

%>

alert("发布成功");

window.location="news_add.asp";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值