组织了下,写了个静态页生成类
Htmlmaker.asp 类文件
<%
'/*************************
'/ Janchie 2004/11/15 janchie@163.com
'/ 个人网站 http://ju1.com,http://g22.net
'/*************************
Class Htmlmaker
'/*************************
'/ 属性设置说明
'/ foldename "文件夹名"
'/ 如果不设置,将自动生成[年月日]时间格式的文件夹名
'/ Filename "文件名"(含前后缀)
'/ 如果不设置,将自动生成[时分秒]时间格式的文件名,后缀为.html
'/ Htmlstr "生成的代码内容"
'/*************************
Private HtmlFolder,HtmlFilename,HtmlContent
Public property let foldename(str)
HtmlFolder=str
End property
Public property let Filename(str)
HtmlFilename=str
End property
Public property let Htmlstr(str)
HtmlContent=str
End property
'/*************************
'/ 文件名转换日期函数
'/*************************
Private Function Datename1(timestr)
dim s_year,s_month,s_day
s_year=year(timestr)
if len(s_year)=2 then s_year="20"&s_year
s_month=month(timestr)
if s_month<10 then s_month="0"&s_month
s_day=day(timestr)
if s_day<10 then s_day="0"&s_day
Datename1=s_year & s_month & s_day
End Function
Private Function Datename2(timestr)
dim s_hour,s_minute,s_ss
s_hour=hour(timestr)
if s_hour<10 then s_hour="0"&s_hour
s_minute=minute(timestr)
if s_minute<10 then s_minute="0"&s_minute
s_ss=second(timestr)
if s_ss<10 then s_ss="0"&s_ss
Datename2 = s_hour & s_minute & s_ss
End Function
'/*************************
'/ 初试化
'/*************************
Private Sub class_initialize()
HtmlFolder=Datename1(now)
HtmlFilename=Datename2(now)&".html"
HtmlContent=""
End Sub
Private Sub class_terminate()
End Sub
'/*************************
'/ Html文件生成
'/*************************
Public Sub Htmlmake()
On Error Resume Next
dim filepath,fso,fout
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(HtmlFolder) Then
Else
fso.CreateFolder(Server.MapPath(HtmlFolder))
End If
Set fout = fso.CreateTextFile(Server.MapPath(filepath),true)
fout.WriteLine HtmlContent
fout.close
End Sub
'/*************************
'/ Html文件删除
'/*************************
Public Sub Htmldel()
dim filepath,fso
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Server.mappath(filepath))
Set fso = nothing
End Sub
End class
%>
应用示例:
test.asp
<!--#include file="Htmlmaker.asp" -->
<%
set myhtml= new Htmlmaker
'myhtml.foldename = "test"
'myhtml.Filename = "ok.shtml"
myhtml.Htmlstr = "<head></head><html><body>测试测试测试测试</body></html>"
myhtml.Htmlmake
set myhtml=nothing
Response.Write("生成成功!!")
%>
Htmlmaker.asp 类文件
<%
'/*************************
'/ Janchie 2004/11/15 janchie@163.com
'/ 个人网站 http://ju1.com,http://g22.net
'/*************************
Class Htmlmaker
'/*************************
'/ 属性设置说明
'/ foldename "文件夹名"
'/ 如果不设置,将自动生成[年月日]时间格式的文件夹名
'/ Filename "文件名"(含前后缀)
'/ 如果不设置,将自动生成[时分秒]时间格式的文件名,后缀为.html
'/ Htmlstr "生成的代码内容"
'/*************************
Private HtmlFolder,HtmlFilename,HtmlContent
Public property let foldename(str)
HtmlFolder=str
End property
Public property let Filename(str)
HtmlFilename=str
End property
Public property let Htmlstr(str)
HtmlContent=str
End property
'/*************************
'/ 文件名转换日期函数
'/*************************
Private Function Datename1(timestr)
dim s_year,s_month,s_day
s_year=year(timestr)
if len(s_year)=2 then s_year="20"&s_year
s_month=month(timestr)
if s_month<10 then s_month="0"&s_month
s_day=day(timestr)
if s_day<10 then s_day="0"&s_day
Datename1=s_year & s_month & s_day
End Function
Private Function Datename2(timestr)
dim s_hour,s_minute,s_ss
s_hour=hour(timestr)
if s_hour<10 then s_hour="0"&s_hour
s_minute=minute(timestr)
if s_minute<10 then s_minute="0"&s_minute
s_ss=second(timestr)
if s_ss<10 then s_ss="0"&s_ss
Datename2 = s_hour & s_minute & s_ss
End Function
'/*************************
'/ 初试化
'/*************************
Private Sub class_initialize()
HtmlFolder=Datename1(now)
HtmlFilename=Datename2(now)&".html"
HtmlContent=""
End Sub
Private Sub class_terminate()
End Sub
'/*************************
'/ Html文件生成
'/*************************
Public Sub Htmlmake()
On Error Resume Next
dim filepath,fso,fout
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If fso.FolderExists(HtmlFolder) Then
Else
fso.CreateFolder(Server.MapPath(HtmlFolder))
End If
Set fout = fso.CreateTextFile(Server.MapPath(filepath),true)
fout.WriteLine HtmlContent
fout.close
End Sub
'/*************************
'/ Html文件删除
'/*************************
Public Sub Htmldel()
dim filepath,fso
filepath = HtmlFolder&"/"&HtmlFilename
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile(Server.mappath(filepath))
Set fso = nothing
End Sub
End class
%>
应用示例:
test.asp
<!--#include file="Htmlmaker.asp" -->
<%
set myhtml= new Htmlmaker
'myhtml.foldename = "test"
'myhtml.Filename = "ok.shtml"
myhtml.Htmlstr = "<head></head><html><body>测试测试测试测试</body></html>"
myhtml.Htmlmake
set myhtml=nothing
Response.Write("生成成功!!")
%>