Use the FSO component in ASP to generate html

Source: Internet
Author: User
The two page index.htm is the home page. The program is relatively simple, mainly using files in ASP to operate objects.

<! --Index.htm --------------------------------------------------------------------------------->

<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"
Http://www.w3.org/TR/html4/loose.dtd>
<HTML>
<Head>
<Title> untitled document </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
</Head>

<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 = "20"> <Div align = "center"> send messages </div> </TD>
</Tr>
<Tr>
<TD> <Div align = "center">
<Textarea name = "MSG" Cols = "100" rows = "6"> </textarea>
</Div> </TD>
</Tr>
<Tr>
<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>
</Html>

'// Send. asp
<%
Function chan_time (Shijian) 'converts a datetime function.
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 (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) 'converts a datetime function.
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) 'converts a datetime 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 = "<HTML> Botom = "</body> MSG = request. Form ("MSG ")
MSG = Replace (MSG, vbcrlf ,"")
MSG = Replace (MSG, CHR (9 ),"")
MSG = Replace (MSG ,"","")
MSG = Replace (MSG, "", "<br> ")
MSG = Replace (MSG, "", "<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' checks whether the current folder exists.
Else
FS. createfolder (all_tree2)
End if
Pass = chan_file (now)
Randomize' uses the system timer to initialize the random 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 be completed ")
</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.aspand index.htm in your ASP Directory, and then create a news folder. Open your browser and enter http: // your machine name/your asp virtual directory name/index.html in the address bar. Then, submit the file. OK! Check whether the new news folder in your ASP Directory contains a new folder named after the current date. There is the text you just submitted to see if an HTML file is generated. On this basis, you can build a simple news publishing system.

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.