The code is too short to be commented out here.
Copy codeThe Code is as follows: <%
'The program has a problem when response. End () exists in the page containing the file # include on the target page.
'Note: This file must be stored in the same directory of the file to which 20041227111723.htm points
Dim hughchiu_rtcode
Function get_exe_code(20041227111723.htm)
Dim execode
Dim tmp_str
Dim re, re1, content, fso, f, aspStart, aspEnd
Dim MS, m
Execode = ""
Set fso = CreateObject ("Scripting. FileSystemObject ")
Set f=fso.OpenTextFile(server.mappath(20041227111723.htm ))
Content = f. ReadAll
F. close
Set f = nothing
Set fso = nothing
Set re = new regexp
Re. ignorecase = true
Re. global = true
Re. pattern = "\ <\ % \ @ [^ \ %] + \ % \>"
Content = re. replace (content ,"")
Re. global = false
Re. pattern = "\ <\! \-\ S * \ # include \ s * file \ s * = \ s * \ "" ([^ \ ""] +) \ "" \ s * \-\>"
Do
Set MS = re.exe cute (content)
If ms. count <> 0 then
Set m = MS (0)
Tmp_str = get_exe_code (m. submatches (0 ))
Content = re. replace (content, tmp_str)
Else
Exit do
End if
Loop
Set m = nothing
Set MS = nothing
Re. pattern = "^ \ s * ="
AspEnd = 1
AspStart = inStr (aspEnd, content, "<%") + 2
Set re1 = new RegExp
Re1.ignorecase = true
Re1.global = false
Re1.pattern = "response \. Write (. + )"
Do while aspStart> aspEnd + 1
Execode = execode & vbcrlf & "hughchiu_rtcode = hughchiu_rtcode &" "& replace (Mid (content, aspEnd, aspStart-aspEnd-2 ),"""", "), vbcrlf," & vbcrlf & "") & "& vbcrlf
AspEnd = inStr (aspStart, content, "% \>") + 2
Tmp_str = Mid (content, aspStart, aspEnd-aspStart-2)
Do
Set MS = re1.execute (tmp_str)
If ms. count <> 0 then
Set m = MS (0)
Tmp_str = re1.replace (tmp_str, "hughchiu_rtcode = hughchiu_rtcode &" & m. submatches (0 ))
Else
Exit do
End if
Loop
Set m = nothing
Set MS = nothing
Execode = execode & re. replace (tmp_str, "hughchiu_rtcode = hughchiu_rtcode &")
AspStart = inStr (aspEnd, content, "<%") + 2
Loop
Set re1 = nothing
Set re = nothing
Execode = execode & vbcrlf & "hughchiu_rtcode = hughchiu_rtcode &" "& replace (Mid (content, aspEnd ),"""",""""""), vbcrlf, "" & vbcrlf & "") & "& vbcrlf
Get_exe_code = "<%" & execode & "% \>"
End Function
Function asp2html(20041227111723.htm)
Dim code
Code = replace (get_exe_code(20041227111723.htm), "hughchiu_rtcode = hughchiu_rtcode &" & vbcrlf, ""), "<% ",""), "% \> ","")
'Response. Write (code)
Execute (code)
'Response. Write (hughchiu_rtcode)
Asp2html = hughchiu_rtcode
End function
%>
Example:Copy codeThe Code is as follows: set fso = CreateObject ("Scripting. FileSystemObject ")
Set f = fso. CreateTextFile (server. mappath ("youpage.htm"), true)
F. WriteLine (asp2html ("youpage. asp "))
F. close
Set f = nothing
Set fso = nothing