用文本+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>


猜你喜欢
- 说到这个话题,我们有个产品叫群组,为什么人们需要群组?简单说,群组就是个圈子,是有共同爱好和话题的人群聚在一起讨论、分享的地方。这个产品的诞
- 面试某某公司BI岗位的时候,面试题中的一道sql题,咋看一下很简单,写的时候发现自己缺乏总结,没有很快的写出来。题目如下:求每个品牌的促销天
- 关于Java和Mysql 8.0.18版本的连接方式,供大家参考,具体内容如下1.官网下载mysql-server.(Connector/J
- 1、说明在使用selenium时,不可避免的会遇到一些异常情况,比如超时、没有找到节点的错误等等。一旦出现这样的错误,程序就不能再运行了。这
- 用python实现21点小游戏,供大家参考,具体内容如下from random import shuffleimport randomimp
- Python综合应用——宿舍管理系统,供大家参考,具体内容如下/p>通过对 python 的函数,变量的应用,编写简单的关系系统实现功
- 很多jsp程序员都遇到过这样的情况,jsp页面传递参数到servlet,只要参数有中文就是乱码,且大多数是??????乱码,尝试了网上比较普
- 问题公司项目使用Laravel的开发的两个项目在同一个测试服务器部署,公用同一个redis。在使用laravel中的队列时,产生冲突干扰。查
- declare @Table_name varchar(60) set @Table_name = 'Pay_inputpay
- 本文介绍在Anaconda环境中,安装Python语言pydot与graphviz两个模块的方法。最近进行随机森林(RF)的树的可视化操作,
- <!DOCTYPE html> <html> <head> <meta charset="
- Application Name(应用程序名称):应用程序的名称。如果没有被指定的话,它的值为.NET SqlClient Data Pro
- ESLint简介关于ESLint的介绍网上很多,这里就简单说些有用的。 ESLint的作用是检查代码错误和统一代码风格的。由于每个人写代码的
- MySQL是一个开源的关系型数据库管理系统,支持多种操作语言,其中最基础、最常用的命令之一就是SELECT语句。在本篇文章中,这里将详细介绍
- 本文记录了PyCharm安装的图文教程,供大家参考,具体内容如下PyCharm的官网 1.在官网下载安装包2.选择Windows系
- 本文实例讲述了Python实现PS图像调整颜色梯度效果。分享给大家供大家参考,具体如下:这里用 Python 实现 PS 中的色彩图,可以看
- Python是动态语言,在创建对象后,可以动态地绑定属性和方法定义类:class Student: #定义类 &nb
- 目前,各大搜索引擎如google、百度、雅虎已经对动态页面诸如asp,php有着不错的支持了,只要动态页面后面的参数不要太长,如控制在3个参
- 1、安装 python3sudo apt install python32、卸载 python2.7 (可选)sudo apt remove
- 在用python的bottle框架开发时,前端使用ajax跨域访问时,js代码老是进入不了success,而是进入了error,而返回的状态