產生html
共有兩個頁面index.htm是首頁.程式比較簡單,主要是用了ASP裡的檔案操作對象。
<!--index.htm---------------------->
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN"
"">
<html>
<head>
<title>UntitledDocument</title>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
</head>
<body>
<tablewidth="770"border="0"align="center"cellpadding="0"cellspacing="0">
<tr>
<td><formname="form1"method="post"action="send.asp">
<tablewidth="100%" border="0"cellpadding="0"cellspacing="0"bgcolor="#CCFFFF">
<tr>
<tdheight="20"><divalign="center">發送訊息</div></td>
</tr>
<tr>
<td><divalign="center">
<textareaname="msg"cols="100"rows="6"></textarea>
</div></td>
</tr>
<tr>
<td><divalign="center">
<inputtype="submit"name="Submit"value="Submit">
<inputtype="reset"name="Submit2"value="Reset">
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
</html>
'//send.asp
<%
functionchan_time(shijian)'轉換日期時間函數
s_year=year(shijian)
iflen(s_year)=2thens_year="20"&s_year
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
s_hour=hour(shijian)
ifs_hour<10thens_hour="0"&s_hour
s_minute=minute(shijian)
ifs_minute<10thens_minute="0"&s_minute
chan_time=s_year&s_month&s_day&s_hour&s_minute
endfunction
functionchan_data(shijian) '轉換日期時間函數
s_year=year(shijian)
iflen(s_year)=2thens_year="20"&s_year
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
chan_data=s_year&s_month&s_day
endfunction
functionchan_file(shijian)'轉換日期時間函數
s_month=month(shijian)
ifs_month<10thens_month="0"&s_month
s_day=day(shijian)
ifs_day<10thens_day="0"&s_day
s_hour=hour(shijian)
ifs_hour<10thens_hour="0"&s_hour
s_minute=minute(shijian)
ifs_minute<10thens_minute="0"&s_minute
s_ss=second(shijian)
ifs_ss<10thens_ss="0"&s_ss
chan_file=s_month&s_day&s_hour&s_minute&s_ss
endfunction
top="<html><head><title>news</title></head><body>"
botom="</body></html>"
msg=request.Form("msg")
msg=replace(msg,vbcrlf,"")
msg=replace(msg,chr(9),"")
msg=replace(msg,""," ")
msg=replace(msg,"\r\n","<br>")
msg=replace(msg,"\n","<br>")
msg=top&msg&botom
Setfs=Server.CreateObject("Scripting.FileSystemObject")
all_tree2=server.mappath("news")&"\"&chan_data(now)
if(fs.FolderExists(all_tree2))then'判斷今天的檔案夾是否存在
else
fs.CreateFolder(all_tree2)
endif
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
setts=fs.createtextfile(filez,true)'寫檔案
forz=1tolen(msg)
write_now=mid(msg,z,1)
ts.write(write_now)
next
'ts.writeline(all_msg)
ts.close
setts=nothing '檔案產生
iferr.number<>0orerrthen%>
<scriptlanguage="javascript">
alert("不能完成")
</script>