'共有兩個頁面index.htm是首頁.程式比較簡單,主要是用了asp裡的檔案操作物件。
br>"">
untitled document
'function chan_time(shijian)'轉換日期時間函式
s_year=year(shijian)
if len(s_year)=2 then s_year="20"&s_year
s_month=month(shijian)
if s_month<10 then s_month="0"&s_month
s_day=day(shijian)
if s_day<10 then s_day="0"&s_day
s_hour=hour(shijian)
if s_hour<10 then s_hour="0"&s_hour
s_minute=minute(shiwww.cppcns.comjian)
if s_minute<10 then s_minute="0"&s_minute
chan_time=s_year & s_month & s_day & s_hour & s_minute
end function
function chan_data(shijian) '轉換日期時間函式
s_year=year(shijian)
if len(s_year)=2 then s_year="20"&s_year
s_month=month(shijian)
if s_month<10 then s_month="0"&s_month
s_day=day(shijian)
if s_day<10 then s_day="0"&s_day
chan_data=s_year & s_month & s_day
end function
function chan_file(shijian)'轉換日期時間函式
s_month=month(shijian)
if s_month<10 then s_month="0"&s_month
s_day=day(shijian)
if s_day<10 then s_day="0"&s_day
s_hour=hour(shijian)
if s_hour<10 then s_hour="0"&s_hour
s_minute=minute(shijian)
if s_minute<10 then s_minute="0"&s_minute
s_ss=second(shijian)
if s_ss<10 then s_ss="0"&s_ss
chan_file = s_month & s_day & s_hour & s_minute & s_ss
end function
top="news"
botom=""
msg=request.form("msg")
msg=replace(msg,vbcrlf,"")
msg=replace(msg,chr(9),"")
msg=replace(msg," "," ")
msg=replace(msg,"\r\n","
")msg=replace(msg,"\n","
")msg=top&msg&botom
set fs=server.createobjewzfnwqvqfhct("scripting.filesystemobject")
all_tree2=server.mappath("news")&"\"&chan_data(now)
if (fs.folderexists(all_tree2)) then'判斷今天的資料夾是否存在
else
fs.createfolder(all_tree2)
end if
pass=chan_file(now)
randomize '使用系統計時器來初始化亂數產生器
pass=rnd(pass)
pass=get_pass(pass)
pass=left(pass,10)
file1=pass
files=file1&".txt"
filez=all_tree2&"\"&files
set ts = fs.createtextfile(filez,true) '寫檔案
for z=1 to len(msg)
write_now=mid(msg,z,1)
ts.write(write_now)
next
' ts.writeline(all_msg)
ts.close
set ts=nothing '檔案生成
if err.number<>0 or err then%>
set myfile = fs.getfile(filez)
all_tree2=server.mappath("news")&"\"&chan_data(now)
if (fs.folderexists(all_tree2)) then
else
fs.createfolder(all_tree2)
end if
myfile.name= left(myfile.name,len(myfile.name)-4)&".htm"
set myfile=nothing
set fs=nothing
set fdir=nothing
function get_pass(pass)
pass=cstr(pass)
pass=replace(pass," ","")
pass=replace(pass," ","")
pass=replace(pass,"-","")
pass=replace(pass," ","")
pass=replace(pass,":","")
pass=replace(pass,".","")
pass=replace(pass,"+","")
pass=replace(pass,"_","")
pass=replace(pass,"pass=replace(pass,">","")
pass=replace(pass,"!","")
pass=replace(pass,"@","")
pass=replace(pass,"#","")
pass=replace(pass,"$","")
pass=replace(pass,"%","")
pass=replace(pass,"^","")
pass=replace(pass,"&","")
程式設計客棧
pass=replace(pass,"*","")
pass=replace(pass,"(","")
pass=replace(pass,")","")
pass=replace(pass,"=","")
pass=replace(pass,"\","")
pass=replace(pass,"/","")
pass=replace(pass,"|","")
get_pass=pass
end function
%>
'//把send.asp和index.htm放到你的asp目錄下,然後再建乙個news資料夾。開啟瀏覽器,在位址列裡輸入:http://你的機器名/你的asp虛擬目錄名/index.html輸入文字,然後提交,ok!看看你的asp目錄裡新建的news資料夾裡是不是多了個新的資料夾,而且是以當前日期命名的。裡面有你剛剛提交的文字,看看是不是生成了html檔案。怎麼樣,你可以在此基礎上做個簡單的新聞發布系統。
本文標題: 在asp中使用fso元件生成html頁面
本文位址:
在ASP中使用FSO元件生成HTML頁面
function chan time shijian 轉換日期時間函式 s year year shijian if len s year 2 then s year 20 s year s month month shijian if s month 10 then s month 0 s mon...
在ASP中使用類
vbscript5中增加了許多新功能,最振奮人心的當屬類和正規表示式的出現。以下是本人寫的乙個解析html 的類。我是 學php的,語法有不習慣的地方,請大家多包含。class htmlparse 設定 initialize 事件。private sub class initialize myglo...
在ASP中使用儲存過程
學習使用儲存過程 stored procedure 是asp程式設計師的必須課之一。所有的大型資料庫都支援儲存過程,比如oracle ms sql等,但ms access不支援,不過,在access裡可以使用引數化的查詢 使用儲存過程有許多好處,它可以封裝複雜的資料邏輯,充分發揮大型資料庫本身的優勢...