Use the FSO component in ASP to generate HTML pages

Source: Internet
Author: User

'Has two sides 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 = "
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' 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.

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.