Using the FSO component in ASP to generate HTML pages

Source: Internet
Author: User
Tags html input text reset
fso| Generate html| Page


' A total of two pages index.htm is the home page. The program is simple, mainly using the ASP file Operation object.
<!--index.htm------------------------------------------------------------------------------->

<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<title>untitled document</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">

<body>
<table width= "770" border= "0" align= "center" cellpadding= "0" cellspacing= "0" >
<tr >
<td><form name= "Form1" method= "Post" action= "send.asp" >
<table width= "100%" border= "0" cellpadding= "0" cellspacing= "0" bgcolor= "#CCFFFF" >
<tr>
<td height= "><div align=" center "> Send message </div></td>
</tr>
<tr>
<td><div align=" center ">
< TextArea name= "msg" cols= "rows=" 6 "></textarea>
</div></td>
</tr>
<tr& Gt
<td><div align= "center" >
<input type= "Submit" name= "submit" value= "Submit" >
<input Type= "Reset" name= "Submit2" value= "reset" >
</div></td>
</tr>
</table>
</form></td>
</tr>
</table>
</body>
'//send.asp

<%
function Chan_time (Shijian) ' Convert date-time function
S_year=year (Shijian)
If Len (s_year) =2 then s_year= "&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 (Shijian)
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) ' Convert date-time function
S_year=year (Shijian)
If Len (s_year) =2 then s_year= "&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) ' Convert date-time function
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= "Botom= "</body>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
Set fs=server.createobject ("Scripting.FileSystemObject")
All_tree2=server.mappath ("News") & "\" &chan_data (now)
if (fs. FolderExists (all_tree2)) Then ' Judge if today's folder exists
Else
Fs. CreateFolder (ALL_TREE2)
End If
Pass=chan_file (now)
Randomize ' uses the system timer to initialize the number of Chaos generator
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) ' Write file
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 ' File generation

If err.number<>0 or Err then%>
<script language= "JavaScript" >
Alert ("Cannot complete")
</script>
<%else%>
<script language= "JavaScript" >
Alert (completed)
History.back ();
</script>
<%end if
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

%>

'//

Put send.asp and index.htm in your ASP directory, and then build a news folder. Open the browser, enter in the Address bar: http://your machine name/your ASP virtual directory name/index.html input text, then submit, ok! See if you have a new folder in the new News folder in your ASP directory, and it's named after the current date. It has the text you just submitted to see if the HTML file was generated. How, you can do a simple press release system on this basis.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.