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

时间:2009-02-02 09:31:00 





 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%>
<script>
alert("出错!新闻标题不能为空");
history.go(-1);
//window.location="news_add.asp";
</script>
<%Response.end
end if




if len(news_content)=0 then%>
<script>
alert("出错!新闻内容不能为空");
history.go(-1);
</script>
<%end if




 if len(news_src)=0 then%>
<script>
alert("出错!新闻来源不能为空");
history.go(-1);
</script>
<%Response.end
end if




 dim varchar
varchar=right(Fields("server1").value,3)
if len(varchar)<>0 then
if varchar<>"gif" and varchar<>"jpg" then
%>
<script>
alert("出错!不能上传该图片类型");
history.go(-1);
</script>
<% Response.end
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+"<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>


标签:新闻,系统,文本,asp
0
投稿

猜你喜欢

  • python爬虫之模拟登陆csdn的实例代码

    2021-05-04 22:49:47
  • Bootstrap基本插件学习笔记之轮播幻灯片(23)

    2024-04-19 10:13:30
  • vee-validate vue 2.0自定义表单验证的实例

    2023-07-02 17:09:33
  • asp如何实现歌曲在线点播?

    2010-05-19 21:32:00
  • 图文详解在Anaconda安装Pytorch的详细步骤

    2022-12-27 10:37:25
  • 浅谈python中真正关闭socket的方法

    2023-11-02 15:41:56
  • Python实现扫描局域网活动ip(扫描在线电脑)

    2022-10-02 02:38:52
  • javascript开发随笔一 preventDefault的必要

    2024-04-26 17:14:05
  • 微信小程序实现单个卡片左滑显示按钮并防止上下滑动干扰功能

    2024-04-18 10:03:54
  • python 包之 Pillow 图像处理教程分享

    2022-02-22 01:22:48
  • Python截图的五个方法实例总结

    2022-07-13 10:40:04
  • Python中self用法实例详解

    2022-12-18 08:27:48
  • SQLSERVER 创建索引实现代码

    2012-04-13 12:17:05
  • 名片管理系统python版

    2021-08-06 01:50:15
  • 如何利用opencv训练自己的模型实现特定物体的识别

    2022-06-19 02:05:39
  • MySQL优化之使用连接(join)代替子查询

    2024-01-25 18:26:33
  • Python利用format函数实现对齐打印(左对齐、右对齐与居中对齐)

    2021-07-30 05:16:16
  • python学习之使用Matplotlib画实时的动态折线图的示例代码

    2021-03-03 17:33:31
  • 浅谈python函数之作用域(python3.5)

    2021-09-22 05:49:42
  • 举例讲解Python中的死锁、可重入锁和互斥锁

    2023-12-21 07:35:03
  • asp之家 网络编程 m.aspxhome.com