|
ASPÉú³É¾²Ì¬HtmlÎļþ¼¼ÊõÔÓ̸
À´Ô´£º
»¥ÁªÍø
ÈÕÆÚ£º2006-8-18
ÍøÒ³Éú³É¾²Ì¬HtmlÎļþÓÐÐí¶àºÃ´¦,±ÈÈçÉú³ÉhtmlÍøÒ³ÓÐÀûÓÚ±»ËÑË÷ÒýÇæÊÕ¼,²»½ö±»ÊÕ¼µÄ¿ì»¹ÊÕ¼µÄÈ«.ǰ̨ÍÑÀëÁËÊý¾Ý·ÃÎÊ,¼õÇá¶ÔÊý¾Ý¿â·ÃÎʵÄѹÁ¦,¼Ó¿ìÍøÒ³´ò¿ªËÙ¶È. Ïñwww.aspid.cnµÄÖ÷Õ¾¾Í²ÉÓÃÁËTSYSÉú³ÉhtmlÎļþ! ËùÒÔÒ÷Çå×î½ü¶ÔÉú³Éhtml±È½Ï¸ÐÐËȤ,¿´Á˲»ÉÙÎÄÕÂ,Ò²ÓÐÒ»µãµãÊÕ»ñ.
1,ÏÂÃæÕâ¸öÀý×ÓÖ±½ÓÀûÓÃFSO°Ñhtml´úÂëдÈëµ½ÎļþÖÐÈ»ºóÉú³É.html¸ñʽµÄÎļþ <% filename="test.htm" if request("body")<>"" then set fso = Server.CreateObject("Scripting.FileSystemObject") set htmlwrite = fso.CreateTextFile(server.mappath(""&filename&"")) htmlwrite.write "<html><head><title>" & request.form("title") & "</title></head>" htmlwrite.write "<body>Êä³öTitleÄÚÈÝ: " & request.form("title") & "<br /> Êä³öBodyÄÚÈÝ:" & request.form("body")& "</body></html>" htmlwrite.close set fout=nothing set fso=nothing end if %> <form name="form" method="post" action=""> <input name="title" value="Title" size=26> <br> <textarea name="body">Body</textarea> <br> <br> <input type="submit" name="Submit" value="Éú³Éhtml"> </form>
2,µ«Êǰ´ÕÕÉÏÃæµÄ·½·¨Éú³ÉhtmlÎļþ·Ç³£²»·½±ã,µÚ¶þÖÖ·½·¨¾ÍÊÇÀûÓÃÄ£°å¼¼Êõ,½«Ä£°åÖÐÌØÊâ´úÂëµÄÖµÌæ»»Îª´Ó±íµ¥»òÊÇÊý¾Ý¿â×Ö¶ÎÖнÓÊܹýÀ´µÄÖµ,Íê³ÉÄ£°å¹¦ÄÜ;½«×îÖÕÌæ»»¹ýµÄËùÓÐÄ£°å´úÂëÉú³ÉHTMLÎļþ.ÕâÖÖ¼¼Êõ²ÉÓõñȽ϶à,´ó²¿·ÖµÄCMS¶¼ÊÇʹÓÃÕâÀà·½·¨. template.htm ' //Ä£°åÎļþ <html> <head> <title>$title$ by aspid.cn</title> </head> <body> $body$ </body> </html> ÿ
TestTemplate.asp '// Éú³ÉHtml <% Dim fso,htmlwrite Dim strTitle,strContent,strOut '// ´´½¨Îļþϵͳ¶ÔÏó Set fso=Server.CreateObject("Scripting.FileSystemObject") '// ´ò¿ªÍøÒ³Ä£°åÎļþ£¬¶Áȡģ°åÄÚÈÝ Set htmlwrite=fso.OpenTextFile(Server.MapPath("Template.htm")) strOut=f.ReadAll htmlwrite.close
strTitle="Éú³ÉµÄÍøÒ³±êÌâ" strContent="Éú³ÉµÄÍøÒ³ÄÚÈÝ"
'// ÓÃÕæÊµÄÚÈÝÌæ»»Ä£°åÖеıê¼Ç strOut=Replace(strOut,"$title$",strTitle) strOut=Replace(strOut,"$body$",strContent)
'// ´´½¨ÒªÉú³ÉµÄ¾²Ì¬Ò³ Set htmlwrite=fso.CreateTextFile(Server.MapPath("test.htm"),true)
'// дÈëÍøÒ³ÄÚÈÝ htmlwrite.WriteLine strOut htmlwrite.close
Response.Write "Éú³É¾²Ì¬Ò³³É¹¦£¡"
'// ÊÍ·ÅÎļþϵͳ¶ÔÏó set htmlwrite=Nothing set fso=Nothing %>
3,µÚÈýÖÖ·½·¨¾ÍÊÇÓÃXMLHTTP»ñÈ¡¶¯Ì¬Ò³Éú³ÉµÄHTMLÄÚÈÝ£¬ÔÙÓÃADODB.Stream»òÕßScripting.FileSystemObject±£´æ³ÉhtmlÎļþ¡£Õâ¾ä»°ÊÇÔÚÀ¶É«ÀíÏëÉÏ¿´µ½µÄ,¶ÔXMLHTTPÒ÷Ç廹²»ÊìϤÕýÔÚÕÒ×ÊÁÏÁ˽â.ÕÒµ½Ò»¶ÎXMLHTTPÉú³ÉHtmlµÄ´úÂë²Î¿¼Ò»ÏÂ.
<%
'³£Óú¯Êý '1¡¢ÊäÈëurlÄ¿±êÍøÒ³µØÖ·£¬·µ»ØÖµgetHTTPPageÊÇÄ¿±êÍøÒ³µÄhtml´úÂë function getHTTPPage(url) dim Http set Http=server.createobject("MSXML2.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate<>4 then exit function end if getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") set http=nothing if err.number<>0 then err.Clear end function
'2¡¢×ª»»ÂÒÂֱ꣬½ÓÓÃxmlhttpµ÷ÓÃÓÐÖÐÎÄ×Ö·ûµÄÍøÒ³µÃµ½µÄ½«ÊÇÂÒÂ꣬¿ÉÒÔͨ¹ýadodb.stream×é¼þ½øÐÐת»» Function BytesToBstr(body,Cset) dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = Cset BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing End Function
txtURL=server.MapPath("../index.asp")
sText = getHTTPPage(txtURL)
Set FileObject=Server.CreateObject("Scripting.FileSystemObject") filename="../index.htm" Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'trueΪ²»´æÔÚ×ÔÐн¨Á¢ openFile.writeline(sText) Set OpenFile=nothing
%> <script> alert("¾²Ì¬ÍøÒ³Éú³ÉÍê±Ï"); history.back(); </script>
¸ü¶àµÄASPÉú³É¾²Ì¬HtmlÎļþ¼¼ÊõÔÓ̸Çëµ½ÂÛ̳²é¿´: http://BBS.TC711.COM
¡¾ Ë«»÷¹öÆÁ ¡¿ ¡¾ ÆÀÂÛ ¡¿ ¡¾ ÊÕ²Ø ¡¿ ¡¾ ´òÓ¡ ¡¿ ¡¾ ¹Ø±Õ ¡¿
À´Ô´£º
»¥ÁªÍø
ÈÕÆÚ£º2006-8-18
|
|
|
|
| ¾«Æ·ÍƼö |
|
 |
| ±¾ÔÂÍÆ¼ö |
|
 |
| ÓÑÇéÔÞÖú |
|
|
|