网络编程 
首页 > 网络编程 > 浏览文章

fso实例

(编辑:jimmy 日期: 2024/11/16 浏览:3 次 )
<!--#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,"<","&lt;"),">","&gt;"),chr(13),"<br>")," ","&nbsp;")
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"
%>

上一篇:硬盘文件搜索代码(ASP类)
下一篇:用asp实现的代码批量修改程序,fso相关
一句话新闻
微软与英特尔等合作伙伴联合定义“AI PC”:键盘需配有Copilot物理按键
几个月来,英特尔、微软、AMD和其它厂商都在共同推动“AI PC”的想法,朝着更多的AI功能迈进。在近日,英特尔在台北举行的开发者活动中,也宣布了关于AI PC加速计划、新的PC开发者计划和独立硬件供应商计划。
在此次发布会上,英特尔还发布了全新的全新的酷睿Ultra Meteor Lake NUC开发套件,以及联合微软等合作伙伴联合定义“AI PC”的定义标准。