'##############把新闻内容写入相应的文件中 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+"〈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