Use ASP to generate HTML files 'Has two sides index.htm is the home page. The program is relatively simple, mainly using files in ASP to operate objects. <! --Index.htm ----------------------> <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, "", "& nbsp ;") 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 .. Author: Unknown Source: Unknown |