威凡网全力打造:网页编程、软件开发编程、平面设计、服务器端开发、操作系统等在线学习平台!学编程,上威凡网!
ASP教程>> ASP基础 应用技巧 数据库相关 ASP类 存储过程 FSO专栏 ASP其他
当前位置:首页 > ASP教程 > FSO专栏
上一节 下一节
 fso实例
<!--#include file="config.asp"-->
<!--#include file="inc/articlechar.inc"-->
<%
function changechr(str)
changechr=replace(replace(replace(replace(changechr,"[pic]","<img src="),"[b]","<b>"),"[red]","<font color=cc0000>"),"[big]","<font size=7>")
changechr=replace(replace(replace(replace(changechr,"[/pic]","></img>"),"[/b]","</b>"),"[/red]","</font>"),"[/big]","</font>")
changechr=replace(replace(replace(replace(str,"<","<"),">",">"),chr(13),"<br>")," "," ")
end function
%>

<%
if request.cookies("newsadminok")="" then
response.redirect "login.asp"
end if
if request.form("txttitle")="" then
response.write "错误提示:请输入新闻标题!"
response.end
end if
if request.form("txtcontent")="" then
response.write "错误提示:请未输入新闻内容!"
response.end
end if
dim title
dim content
dim sql
dim rs
dim articleid
dim classid,nclassid
dim from

title=htmlencode2(request.form("txttitle"))
from=request.form("nfrom")
zznews=request.form("zznews")
typeid=request.form("typeid")
about=request.form("about")
headline=request.form("headline")
ftitle=htmlencode2(request.form("ftitle"))

dim sql1
dim rs1
dim typename
sql1="select * from type where typeid=" & typeid
set rs1=server.createobject("adodb.recordset")
rs1.open sql1,conn,1,1
typename=rs1("type")

if request.form("checkbox1")="1" then
tjnews=1
else
tjnews=2
end if

if request.form("yheadline")="1" then
yheadline=1
else
yheadline=0
end if

content=htmlencode(request.form("txtcontent"))

set rs = server.createobject("adodb.recordset")
strsql = "select e_memo from example"
set rs = conn.execute (strsql)




fname = makefilename(now())



dddd = year(now()) & "年" & month(now()) & "月" & day(now()) & "日" & hour(now())&":"&minute(now())
pencat=rs("e_memo")
pencat=replace(pencat,"lx",typename)
pencat=replace(pencat,"date",dddd)
if from="" then
pencat=replace(pencat,"from","")
else
pencat=replace(pencat,"from","摘自:" & from)
end if
if zznews="" then
pencat=replace(pencat,"fname",editor)
zznews=editor
else
pencat=replace(pencat,"fname",zznews)
end if
pencat=replace(pencat,"h_title",title)
pencat=replace(pencat,"h_memo",content)
pencat=replace(pencat,"labout",about)
pencat=replace(pencat,"ftitle",ftitle)

newsdate = year(now()) & "." & month(now()) & "." & day(now())
timepath = year(now()) & "-" & month(now()) & "-" & day(now())
folderpath = server.mappath(".")& "\" & timepath



rs.close
'将新闻保存入数据库

sql="select * from article where (newsid is null)"

rs.open sql,conn,1,3
rs.addnew
rs("title")=title
rs("content")=content
rs("nfrom")=from
rs("typeid")=typeid
rs("path")=timepath
rs("typename")=typename
rs("tjnews")=tjnews
rs("n_fname")=fname
rs("zznews")=zznews
rs("about")=about
rs("newsdate")=newsdate
rs("yheadline")=yheadline
rs("headline")=headline
if ftitle <> "" then rs("ftitle")=ftitle
rs.update

pencat=replace(pencat,"h_id",rs("newsid"))

set fso = server.createobject("scripting.filesystemobject")
if checkdir(folderpath) = true then
set fout = fso.createtextfile(folderpath & "\" & fname)
else
makenewsdir timepath
set fout = fso.createtextfile(folderpath & "\" & fname)
end if
fout.writeline pencat
fout.close

articleid=rs("newsid")
updatejs(news)
rs1.close
set rs1=nothing
rs.close
set rs=nothing
conn.close
set conn=nothing
response.redirect "addnews.asp"
%>


申明:本教程内容由威凡网编辑整理并提供IT程序员分享学习,如文中有侵权行为,请与站长联系(QQ:254677821)!
上一节 下一节
相关教程  
其他教程  
ASP基础
应用技巧
数据库相关
ASP类
存储过程
FSO专栏
ASP其他

违法和不良信息举报中心】邮箱:254677821@qq.com
Copyright©威凡网 版权所有 苏ICP备2023020142号
站长QQ:254677821