'共有两个页面index.htm是首页.程序比较简单,主要是用了ASP里的文件操作对象。
1<html>
2<head>
3<title>Untitled Document</title>
4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
5</head>
6<body>
7<table align="center" border="0" cellpadding="0" cellspacing="0" width="770">
8<tr>
9<td><form action="send.asp" method="post" name="form1">
10<table bgcolor="#CCFFFF" border="0" cellpadding="0" cellspacing="0" width="100%">
11<tr>
12<td height="20"><div align="center">发送消息</div></td>
13</tr>
14<tr>
15<td><div align="center">
16<textarea cols="100" name="msg" rows="6"></textarea>
17</div></td>
18</tr>
19<tr>
20<td><div align="center">
21<input name="Submit" type="submit" value="Submit"/>
22<input name="Submit2" type="reset" value="Reset"/>
23</div></td>
24</tr>
25</table>
26</form></td>
27</tr>
28</table>
29</body>
30</html>
'//send.asp
1
2function chan_time(shijian)'转换日期时间函数
3s_year=year(shijian)
4if len(s_year)=2 then s_year="20"&s_year
5s_month=month(shijian)
6if s_month<10 then s_month="0"&s_month
7s_day=day(shijian)
8if s_day<10 then s_day="0"&s_day
9s_hour=hour(shijian)
10if s_hour<10 then s_hour="0"&s_hour
11s_minute=minute(shijian)
12if s_minute<10 then s_minute="0"&s_minute
13chan_time=s_year & s_month & s_day & s_hour & s_minute
14end function
15
16function chan_data(shijian) '转换日期时间函数
17s_year=year(shijian)
18if len(s_year)=2 then s_year="20"&s_year
19s_month=month(shijian)
20if s_month<10 then s_month="0"&s_month
21s_day=day(shijian)
22if s_day<10 then s_day="0"&s_day
23chan_data=s_year & s_month & s_day
24end function
25
26function chan_file(shijian)'转换日期时间函数
27s_month=month(shijian)
28if s_month<10 then s_month="0"&s_month
29s_day=day(shijian)
30if s_day<10 then s_day="0"&s_day
31s_hour=hour(shijian)
32if s_hour<10 then s_hour="0"&s_hour
33s_minute=minute(shijian)
34if s_minute<10 then s_minute="0"&s_minute
35s_ss=second(shijian)
36if s_ss<10 then s_ss="0"&s_ss
37chan_file = s_month & s_day & s_hour & s_minute & s_ss
38end function
39top="
<html><head><title>news</title></head><body>"
botom="</body></html>
1"
2msg=request.Form("msg")
3msg=replace(msg,vbcrlf,"")
4msg=replace(msg,chr(9),"")
5msg=replace(msg," "," ")
6msg=replace(msg,"\r\n","
<br/>
1")
2msg=replace(msg,"\n","
<br/>
1")
2msg=top&msg&botom
3Set fs=Server.CreateObject("Scripting.FileSystemObject")
4all_tree2=server.mappath("news")&"\"&chan_data(now)
5if (fs.FolderExists(all_tree2)) then'判断今天的文件夹是否存在
6else
7fs.CreateFolder(all_tree2)
8end if
9pass=chan_file(now)
10randomize '使用系统计时器来初始化乱数产生器
11pass=rnd(pass)
12pass=get_pass(pass)
13pass=left(pass,10)
14
15file1=pass
16files=file1&".txt"
17filez=all_tree2&"\"&files
18
19set ts = fs.createtextfile(filez,true) '写文件
20for z=1 to len(msg)
21write_now=mid(msg,z,1)
22ts.write(write_now)
23next
24' ts.writeline(all_msg)
25ts.close
26set ts=nothing '文件生成
27
28if err.number<>0 or err then
1<script language="javascript">
2alert("不能完成")
3</script>
1else
1<script language="javascript">
2alert("已完成")
3history.back();
4</script>
1end if
2Set MyFile = fs.GetFile(filez)
3all_tree2=server.mappath("news")&"\"&chan_data(now)
4if (fs.FolderExists(all_tree2)) then
5else
6fs.CreateFolder(all_tree2)
7end if
8MyFile.name= left(MyFile.name,len(MyFile.name)-4)&".htm"
9set MyFile=nothing
10set fs=nothing
11set fdir=nothing
12function get_pass(pass)
13
14pass=cstr(pass)
15pass=replace(pass," ","")
16pass=replace(pass," ","")
17pass=replace(pass,"-","")
18pass=replace(pass," ","")
19pass=replace(pass,":","")
20pass=replace(pass,".","")
21pass=replace(pass,"+","")
22pass=replace(pass,"_","")
23pass=replace(pass,"<","")
24pass=replace(pass,">","")
25pass=replace(pass,"!","")
26pass=replace(pass,"@","")
27pass=replace(pass,"#","")
28pass=replace(pass,"$","")
29pass=replace(pass,"%","")
30pass=replace(pass,"^","")
31pass=replace(pass,"&","")
32pass=replace(pass,"*","")
33pass=replace(pass,"(","")
34pass=replace(pass,")","")
35pass=replace(pass,"=","")
36pass=replace(pass,"\","")
37pass=replace(pass,"/","")
38pass=replace(pass,"|","")
39get_pass=pass
40
41end function
42
'//
把send.asp和index.htm放到你的ASP目录下,然后再建一个news文件夹。打开浏览器,在地址栏里输入:http://你的机器名/你的ASP虚拟目录名/index.html输入文字,然后提交,OK!看看你的ASP目录里新建的news文件夹里是不是多了个新的文件夹,而且是以当前日期命名的。里面有你刚刚提交的文字,看看是不是生成了HTML文件。怎么样,你可以在此基础上做个简单的新闻发布系统。