Sie sind auf Seite 1von 21

<%@LANGUAGE=VBScript%> <%Option Explicit Response.Buffer = True Response.CacheControl = "Private" Response.

Expires = -1 'We don't want this to be cached anywhere '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Version 1.0 22-August-2002 ' 1.2 03-October-2002 Delete occurrences of <object..< /object>. ' Correction to Re turn to Graphics version link ' at bottom of pag e. ' 1.3 15-October-2002 Tags <h1>, <h2> etc replaced wit h <b>..</b> ' 1.4 17-October-2002 Delete occurrences of other tabl e tags removed ' <thead>..</thead > etc ' 1.5 31-October-2002 Added in tags to define text to be excluded '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' 'Globals Dim STRTHISDIR, STRCONTENT, STRSERVERNAME Dim tagStart, tagEnd, strEmailTo, strEmailFrom Dim strImportance, strSubject, strText Dim strFileID, strHomePage, strHomeRoot, strHomeRoot1 Dim strRefer 'the referer 'Uses the XMLHTTP Module 'Search for 'XMLHTTP Module' in www.microsoft.com '------------------------------------------'SET UP CONFIGURATIONS strEmailTo = "paulvgibbs@o2.co.uk" 'The to address strEmailFrom = "textonly@webconcersns.co.uk" 'the from address strImportance = "2" '<!-- content_starts_here //--> '<!-- content_ends_here //--> tagStart = "<!--\s+content_starts_here\s+\/\/-->" tagEnd = "<!--\s+content_ends_here\s+\/\/-->" '<!-- text_starts_here //--> '<!-- text_ends_here //--> 'tagStart = "<!--\s+text_starts_here\s+\/\/-->" 'tagEnd = "<!--\s+text_ends_here\s+\/\/-->" 'To define the menu use : '<!-- menu_starts_here //--> '<!-- menu_ends_here //--> 'define the home site 'these are needed because you can call a web site by 'http://www.server.com/ and it assumes default.htm 'this can confuse the program later on strHomePage = "http://www.webconcerns.co.uk/default.asp" strHomeRoot = "http://www.webconcerns.co.uk/"

'the home page 'the roo

t directory with '/' strHomeRoot1 = "http://www.webconcerns.co.uk" t directory without '/' '------------------------------------------'------------------------------------sub main() Dim xml_http, post_item Dim MyItem, strPostInfo, i Dim strType, url 'Response.Write Request.ServerVariables ("ALL_HTTP") 'Response.End strRefer = Request.ServerVariables("HTTP_REFERER") 'Response.Write strRefer 'Response.End

'the roo

If strRefer <> "" Then 'If this didn't come from anywhere, ignore. if strRefer = strHomeRoot or strRefer = strHomeRoot1 then strRefer = strHomePage end if strType = Request.ServerVariables ("REQUEST_METHOD") 'this will be POST or GET strPostInfo = "" i = 0 For Each MyItem in Request.Form if i = 0 then strPostInfo = MyItem & "=" & Request.Form(MyItem ).Item i = i + 1 else strPostInfo = strPostInfo & "&" & MyItem & "=" & Request.Form(MyItem).Item end if Next For Each MyItem in Request.QueryString if i = 0 then strPostInfo = MyItem & "=" & Request.QueryString (MyItem).Item i = i + 1 else strPostInfo = strPostInfo & "&" & MyItem & "=" & Request.QueryString(MyItem).Item end if Next if instr(1,strPostInfo,"?") > 0 then strPostInfo = mid(strPostInfo,instr(1,strPostInfo,"?") + 1) end if

STRSERVERNAME = Request.ServerVariables ("SERVER_NAME") Set xml_http = Server.CreateObject("Microsoft.XMLHTTP") url = Request.QueryString ("url") 'if this is a query string the n reconstruct the url with any gets. if instr(1,url,"?") > 0 then url = mid(url,1,instr(1,url,"?") - 1) end if if url <> "" then STRTHISDIR = mid(url,1,inStrRev(url,"/") ) if strType = "POST" then xml_http.Open "POST", url, False else xml_http.Open "GET", url & "?" & strPostInfo, Fa lse strFileID = url & "?" & strPostInfo end if else STRTHISDIR = mid(strRefer,1,inStrRev(strRefer,"/")) if strType = "POST" then xml_http.Open "POST", strRefer, False else xml_http.Open "GET", strRefer, False end if end if 'This is needed to overcome the problem with .htm pages which gi ve an error 'if do xml_http.Send (strPostInfo) Don't understand it though. if strType = "POST" then xml_http.setRequestHeader "Content-Type", "application/x -www-form-urlencoded" if strPostInfo <> "" then xml_http.Send (strPostInfo) else xml_http.Send end if else xml_http.Send end if STRCONTENT = xml_http.responseText Set xml_http = Nothing '---------------------'Handle Response.Status '200 or 401 is not an error, anything else is an error '3xx is a redirect if instr(STRCONTENT, "404 Error") > 0 then %> <html> <head> <title>Page Error</title> <link rel="stylesheet" href="text.css"> </head> <body> <br><br> <span class="text">

The page cannot be found or there is a bug<br> in the text only display script<br><br> <a href="javascript:history.go(-1)">Back</a></span> </body> </html> <% strSubject = "Error in Text Only Version" strText = "Error in " & Request.ServerVariables("HTTP_RE FERER") call sendmail(strEMailTo, strEMailFrom, "", "", strSubje ct, strImportance, strText) Response.End end if call process() end if end sub '---------------------------------------------sub process() Dim strBody, strMenu, strTitle, strHead, strJavascript strBody = getBody() strMenu = getMenu() strTitle = getTitle() strHead = getHead() strJavascript = getJavascript(strHead) strBody o be excluded strBody strBody strBody span> strBody strBody strBody strBody strBody strBody ctions strBody strBody strBody orms strBody strBody strBody strBody strBody strBody = Exclude(strBody) = Comments(strBody) = fonts(strBody) = span(strBody) = = = = = = applets(strBody) shockwave(strBody) map(strBody) markExtRefs(strBody) JSRollOver(strBody) markJSFunctions(strBody) 'remove text which has t 'remove comments 'remove <fonts ..> 'remove <span ..> and </ 'remove applets 'remove shockwave 'deal with <map ..> 'mark external links 'JScript rollover 'Mark href="Javascript: type fun 'deal with hrefs 'correct mailto links 'deal with ACTION= in <f 'For GET put a hidden field in 'Remove bgcolor 'Remove background image 'Remove divs 'Remove graphics 'Remove img

= hrefs(strBody) = mailto(strBody) = action(strBody) = = = = = = actionGET(strBody) bgcolor(strBody) background(strBody) divs(strBody) graphics(strBody) img(strBody)

'We don't want to touch some href links 'Those with .doc,.xls,.pdf,.zip extensions strBody = DOC(strBody) 'Put .DOC http refs back to original strBody = XLS(strBody) 'Put .XLS http refs back to original

strBody = PDF(strBody) 'Put .PDF http refs back to original strBody = ZIP(strBody) 'Put .ZIP http refs back to original strBody strBody strBody strBody = = = = blanks(strBody) hr(strBody) tables(strBody) unMarkExtRefs(strBody) 'Remove blanks 'Remove hr 'Remove table 'Re-make external links 'remove text whi 'remove comments 'remove <fonts . 'mark external links 'Remove JScript 'Mark href="Javascript: 'deal with hrefs 'Remove divs 'Remove graphics 'Remove img 'remove blanks 'remove tables 're-make external links

if strMenu <> "" then strMenu = Exclude(strMenu) ch has to be excluded strMenu = Comments(strMenu) strMenu = fonts(strMenu) .> strMenu = markExtRefs(strMenu) strMenu = JSRollOver(strMenu) strMenu = markJSFunctions(strMenu) (needs to be after JSRollOver) strMenu = hrefs(strMenu) strMenu = divs(strMenu) strMenu = graphics(strMenu) strMenu = img(strMenu) strMenu = blanks(strMenu) strMenu = tables(strMenu) strMenu = unMarkExtRefs(strMenu) end if

call display(strTitle, strMenu, strBody, strJavascript) end sub '---------------------------------------------'Get the body 'objRegExp.Pattern = "<!--\s+content_starts_here\s+\/\/-->(. \n)*<!--\s+content_ ends_here\s+\/\/-->" 'objRegExp.Pattern = "<!--\s+text_starts_here\s+\/\/-->(. \n)*<!--\s+text_ends_h ere\s+\/\/-->" 'If comments are not in the page then only extract between <body and </body> Function getBody() Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = tagStart & "(. \n)*" & tagEnd Set reg_matches = objRegExp.Execute(STRCONTENT) If reg_matches.Count > 0 Then getBody = reg_matches.Item(0).Value Set reg_matches = Nothing else objRegExp.Pattern = "<body(. \n)*</body>" Set reg_matches = objRegExp.Execute(STRCONTENT) if reg_matches.Count > 0 then getBody = reg_matches.Item(0).Value end if Set reg_matches = Nothing End If Set objRegExp = Nothing

End Function '---------------------------------------------'Get the menu Function getmenu() Dim bolMenuExists, objRegExp, reg_matches bolMenuExists = false 'First check if <!-- menu_starts_here --> exists in the file Set objRegExp = New RegExp objRegExp.Pattern = "<!--\s+menu_starts_here\s+\/\/-->" objRegExp.IgnoreCase = True objRegExp.Global = True Set reg_matches = objRegExp.Execute(STRCONTENT) If reg_matches.Count > 0 Then bolMenuExists = true End If Set objRegExp = Nothing Set reg_matches = Nothing if bolMenuExists = true then 'if it exists then continue Set objRegExp = New RegExp objRegExp.Pattern = "<!--\s+menu_starts_here\s+\/\/-->(. \n)*<!-\s+menu_ends_here\s+\/\/-->" objRegExp.IgnoreCase = True objRegExp.Global = True Set reg_matches = objRegExp.Execute(STRCONTENT) If reg_matches.Count > 0 Then getmenu = reg_matches.Item(0).Value End If Set objRegExp = Nothing Set reg_matches = Nothing else getmenu = "" end if End Function '---------------------------------------------'Extract everything between and including '<title> and </title> Function getTitle() Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<title>(. \n)*?<\/title>" Set reg_matches = objRegExp.Execute(STRCONTENT) If reg_matches.Count > 0 Then getTitle = reg_matches.Item(0).Value else getTitle = "" End If

Set objRegExp = Nothing Set reg_matches = Nothing end function '---------------------------------------------'Extract everything between and including '<head> and </head> Function getHead() Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<head>(. \n)*?<\/head>" Set reg_matches = objRegExp.Execute(STRCONTENT) If reg_matches.Count > 0 Then getHead = reg_matches.Item(0).Value else getHead = "" End If Set objRegExp = Nothing Set reg_matches = Nothing end function '---------------------------------------------'Extract everything between and including '"<script" and "</script>" 'This assumes that Javascript is in the head of the document 'First get the head of the document 'Then extract the Javascript code from the head ' 'For <SCRIPT language=JavaScript1.2 src="location.js"></SCRIPT> 'it is necessary to convert src="location.js" to src="http://www.server.com/lear ning/location.js" Function getJavascript(text) Dim objRegExp, reg_matches, i, TempJScript, strScript TempJScript = "" Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<script(. \n)*?<\/script>" Set reg_matches = objRegExp.Execute(text) If reg_matches.Count > 0 Then for i = 0 to reg_matches.Count - 1 TempJScript = TempJScript + reg_matches.Item(i).Value next strScript = TempJScript else strScript = "" End If 'Deal with src="location.js" and convert to full path objRegExp.Pattern = "src=""(.*?)"

getJavascript = objRegExp.Replace (strScript,"src=" & chr(34) & STRTHISD IR & "$1") Set objRegExp = Nothing Set reg_matches = Nothing End Function '---------------------------------------------'Mark and unmark external refs are a pair 'The first one identifies all those links which are 'not this domain name e.g. www.google.com 'It marks them by adding xxx into the line 'The unmark function removes them at the end of 'the process. 'STRSERVERNAME being the name of this domain Function markExtRefs(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=" & Chr(34) & "http://(?!" & STRSERVERNAME & " )" markExtRefs = objRegExp.Replace(text, "hrefxxx=" & Chr(34) & "http://") Set objRegExp = Nothing End Function '---------------------------------------------Function markJSFunctions(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=" & Chr(34) & "javascript:" markJSFunctions = objRegExp.Replace(text, "hrefxxx=" & Chr(34) & "javasc ript:") Set objRegExp = Nothing End Function '---------------------------------------------Function unMarkExtRefs(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "hrefxxx=" unMarkExtRefs = objRegExp.Replace (text,"href=") Set objRegExp = Nothing

End Function '---------------------------------------------'Convert 'href="http://www.server.com/text/text.asp?url=http://www.server.com/learning/tu torial_file.doc" 'to 'href="http://www.server.com/learning/tutorial_file.doc" Function DOC(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=(.*?)url=http(.*?)\.doc" & chr(34) DOC = objRegExp.Replace (text,"href=" & chr(34) & "http$2.doc" & chr(34) ) Set objRegExp = Nothing End Function '---------------------------------------------'Convert 'href="http://www.server.com/text/text.asp?url=http://www.server.com/learning/tu torial_file.xls" 'to 'href="http://www.server.com/learning/tutorial_file.xls" Function XLS(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=(.*?)url=http(.*?)\.xls" & chr(34) XLS = objRegExp.Replace (text,"href=" & chr(34) & "http$2.xls" & chr(34) ) Set objRegExp = Nothing End Function '---------------------------------------------'Convert 'href="http://www.server.com/text/text.asp?url=http://www.server.com/learning/tu torial_file.pdf" 'to 'href="http://www.server.com/learning/tutorial_file.pdf" Function PDF(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True

objRegExp.Global = True objRegExp.Pattern = "href=(.*?)url=http(.*?)\.pdf" & chr(34) PDF = objRegExp.Replace (text,"href=" & chr(34) & "http$2.pdf" & chr(34) ) Set objRegExp = Nothing End Function '---------------------------------------------'Convert 'href="http://www.server.com/text/text.asp?url=http://www.server.com/learning/tu torial_file.zip" 'to 'href="http://www.server.com/learning/tutorial_file.zip" Function ZIP(text) Dim objRegExp, reg_matches Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=(.*?)url=http(.*?)\.zip" & chr(34) ZIP = objRegExp.Replace (text,"href=" & chr(34) & "http$2.zip" & chr(34) ) Set objRegExp = Nothing End Function '---------------------------------------------'Delete the text from within this area '<!-- exclude_starts_here //--> '<!-- exclude_ends_here //--> Function Exclude(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<!--\s+exclude_starts_here\s+\/\/-->(. \n)*?<!--\s+ exclude_ends_here\s+\/\/-->" Exclude = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Look for comments <! ... > and delete '(Comments are acutally <!-- ... --> but datamart uses <! ... > Function Comments(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True

objRegExp.Pattern = "<!--(.*?)-->" Comments = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Look for <font ... > and delete 'Look for </font> and delete 'Look for <h1> <h2> etc tags and delete Function fonts(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<font(.*?)>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</font>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<h\d>" text = objRegExp.Replace (text,"<b>") objRegExp.Pattern = "</h\d>" fonts = objRegExp.Replace (text,"</b><br><br>") Set objRegExp = Nothing End Function '---------------------------------------------'Look for comments <span ... > and delete 'Look for </span> and delete Function span(text) Dim objRegExp Dim temp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<span(.*?)>" temp = objRegExp.Replace (text,"") objRegExp.Pattern = "</span>" span = objRegExp.Replace (temp,"") Set objRegExp = Nothing End Function '---------------------------------------------'Deal with hrefs Function hrefs(text)

Dim objRegExp ' Dim STRTHISDIR_Less1 ' Dim STRTHISDIR_Less2 ' ' 'Look for href="../graphics/email.gif" and replace with href="http://www .server.com/graphics/email.gif" ' 'First take STRTHISDIR and drop back one directory level e.g. if STRTHIS DIR = "http://www.server.com/textonly/ ' 'then this should become http://www.server.com/ ' Set objRegExp = New RegExp ' objRegExp.IgnoreCase = True ' objRegExp.Global = True ' objRegExp.Pattern = "http://(.*?)/(.*?)/" ' STRTHISDIR_Less1 = objRegExp.Replace (STRTHISDIR, "http://$1/") ' Set objRegExp = New RegExp ' objRegExp.IgnoreCase = True ' objRegExp.Global = True ' objRegExp.Pattern = "href=" & chr(34) & "\.\./" ' text = objRegExp.Replace (text,"href=" & chr(34) & STRTHISDIR_less1) ' ' ' 'Look for href="../../graphics/email.gif" and replace with href="http:// www.server.com/graphics/email.gif" ' 'First take STRTHISDIR and drop back two directory levels e.g. if STRTHI SDIR = "http://www.server.com/textonly/files/ ' 'then this should become http://www.server.com/ ' Set objRegExp = New RegExp ' objRegExp.IgnoreCase = True ' objRegExp.Global = True ' objRegExp.Pattern = "http://(.*?)/(.*?)/(.*?)/" ' STRTHISDIR_Less2 = objRegExp.Replace (STRTHISDIR, "http://$1/") ' Set objRegExp = New RegExp ' objRegExp.IgnoreCase = True ' objRegExp.Global = True ' objRegExp.Pattern = "href=" & chr(34) & "\.\./\.\./" ' text = objRegExp.Replace (text,"href=" & chr(34) & STRTHISDIR_less2) 'Look for href="/files/default.asp" replace with href="http://www.se rver.com/graphics/files/default.asp" 'So if there is / then put in the server name because the / represents r elative to the rootweb Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=" & chr(34) & "/" text = objRegExp.Replace (text,"href=" & chr(34) & "http://" & STRSERVER NAME & "/") 'Look for href="graphics/default.asp" replace with href="http://www.serv er.com/graphics/default.asp" 'href="http://www.server.com/graphics/default.asp is ignored objRegExp.Pattern = "href=""(.{4})([^:])(.*?)(> \n)" '$1 = any four characters '$2 = not : '$3 = all other characters '$4 = upto > or end of line text = objRegExp.Replace (text, "href=" & chr(34) & STRTHISDIR & "$1$2$3 $4")

'Modify href i.e. change http://www.server.com/webconcerns/asp/default.a sp 'to http://www.server.com/webconcerns/text/text.asp?url=http://www.serve r.com/webconcerns/asp/default.asp objRegExp.Pattern = "<a\s+href=""(.*?)>" text = objRegExp.Replace (text, "<a href=" & chr(34) & "text.asp?" & "ur l=$1" & ">") 'Deal with anchor links 'http://www.server.com/textonly/text.asp?url=http://www.server.com/texto nly/test.asp#go 'should become http://www.server.com/textonly/text.asp#go 'Note that we use [^&] for not & character infront of # to overcome the use of &#149 Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=(.*?)?url=http://(.*?)[^&]#(.*?)" text = objRegExp.Replace (text,"href=""#$3") Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "href=(.*?)?url=http://[^&]#(.*?)" text = objRegExp.Replace (text,"href=""#$3") Set objRegExp = Nothing hrefs = text End Function '---------------------------------------------'Removes Javascript from hrefs. This is normally used to 'clean up the menu bar of Javascript rollovers. 'Change <a href="learning_gateway.asp" target="_parent" onmouseout="rollImage('4 ','out')" onmouseover="rollImage('4','over')">link</a> Function JSRollOver(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True 'this assumes that the string is <a href="....." followed by one or more blank spaces objRegExp.Pattern = "<a href=" & chr(34) & "(.*?)" & chr(34) & "\s+" & " (.*?)" & ">" text = objRegExp.Replace(text, "<a href=" & chr(34) & "$1" & chr(34) & " >") Set objRegExp = Nothing JSRollOver = text End Function '----------------------------------------------

'Need to deal with href="mailto:..." 'At the moment this puts in all the directory info etc 'infront of href. Need to remove all this Function mailto(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<a href(\s*?)=(.*?)mailto:(.*?)>" mailto = objRegExp.Replace (text, "<a href=" & chr(34) & "mailto:$3>") Set objRegExp = Nothing End function '---------------------------------------------'Look for : '<form method="post" action = "default.asp?action=update" 'and replace with : '<form method="post" action="text.asp?url=http://rootdirectory/webconcerns/feedb ack/default.asp?action=update" 'If it is method="get" do the same except add in : '<input type="hidden" name="url" value="http://rootdirectory/webconcerns/feedbac k/default.asp?action=update"> Function action(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "action(\s*?)=(\s*?)" & chr(34) action = objRegExp.Replace (text, "action=" & chr(34) & "text.asp?url=" & STRTHISDIR) Set objRegExp = Nothing End Function 'The structure order of a 'get' method needs to be as below : '<FORM METHOD = "get" action="text.asp?url=http://www.server.com/temp/get1/reque stsniffer.asp" NAME = "frmSearchCode"> Function actionGET(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<form(.*?)method(\s*?)=(\s*?)" & chr(34) & "get" & chr(34) & "(\s*?)action(\s*?)=(\s*?)" & chr(34) & "(.*?)?url=(.*?)" & chr(34) & "(.*?)>" actionGet = objRegExp.Replace (text,"<form$1method=" & chr(34) & "get" & chr(34) & " action=$7$8 $9><input type=" & chr(34) & "hidden" & chr(34) & " nam e=" & chr(34) & "url" & chr(34) & " value=" & chr(34) & "$8" & chr(34) & ">") Set objRegExp = Nothing

End Function '---------------------------------------------'Look for bgcolor^=^"#xxxxxx" and delete Function bgcolor(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "bgcolor(\s*?)=(\s*?)\" & chr(34) & "#" & "\w{6}" & "\" & chr(34) bgcolor = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Look for backgound image in '<body marginwidth="0" marginheight="0" background="bkgd_w_blue.gif" leftmargin= "0" topmargin="0"> 'and remove it Function background(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<body(.*?)background=" & chr(34) & "(.*?)" & chr(34 ) & "(.*?)>" background = objRegExp.Replace (text,"<body $1 $3>") Set objRegExp = Nothing End Function '---------------------------------------------'Remove <applet...> and </applet> Function applets(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<applet(.*?)</applet>" applets = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Remove shockwave and other objects '<object...> and </object>

Function shockwave(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<object(. \n)*?</object>" shockwave = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Deal with <map...></map> 'Dosn't work at the moment because the still have shape="" and coords="" within the <area > 'Not sure how to do this yet as it may interfere with other process 'Should I explicity look for shape="" and coords="" and remove Function map(text) Dim objRegExp '<area shape="rect" coords="145,139,228,218" href="/info/gen_info_menu.a sp" alt="General Information menu" title="General Information menu"> Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<area(.*?)shape=" & chr(34) & "(.*?)" & chr(34) & " (.*?)>" text = objRegExp.Replace (text,"<area$1$3>") Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<area(.*?)coords=" & chr(34) & "(.*?)" & chr(34) & "(.*?)>" text = objRegExp.Replace (text,"<area$1$3>") 'remove <map name="map"> Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<map(.*?)>" text = objRegExp.Replace (text,"") 'remove </map> Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "</map>" text = objRegExp.Replace (text,"") 'replace "<area href='xxx' alt='yyy'>" with "<a href='xxx'>yyy</a>" Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True

objRegExp.Pattern = "<area(.*?)alt(\s*?)=(\s*?)" & chr(34) & "(.*?)" & c hr(34) & "(.*?)>" text = objRegExp.Replace (text,"<a$1>$4</a><br>") Set objRegExp = Nothing map = text End Function '---------------------------------------------'Remove <div...> and </div> Function divs(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<div(.*?)>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</div>" divs = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Deal with graphics by looking for <img=....> 'and display only the alt text Function graphics(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<img\s+(.*?)alt=""(.*?)""(.*?)>" graphics = objRegExp.Replace (text,"$2") Set objRegExp = Nothing End Function '---------------------------------------------'Remove any remaining <img=....> Function img(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<img(.*?)>" img = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function

'---------------------------------------------'Remove blank lines Function blanks(text) Dim objRegExp 'objRegExp.Pattern = "<br>(. \n)*?<br>" 'objRegExp.Pattern = "<br>" 'strbody = objRegExp.Replace (strbody,"") Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern ="<br>(\s+?)<br>" blanks = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Remove <hr...> Function hr(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern ="<hr(.*?)>" hr = objRegExp.Replace (text,"") Set objRegExp = Nothing End Function '---------------------------------------------'Remove tables and replace </tr> with <br> Function tables(text) Dim objRegExp Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "<table(.*?)>" text = objRegExp.Replace (text,"<br>") objRegExp.Pattern = "</table(.*?)>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<td(.*?)>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<tr(.*?)>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</tr>"

text = objRegExp.Replace (text,"<br><br>") objRegExp.Pattern = "</td>" text = objRegExp.Replace (text,"&nbsp;&nbsp;") objRegExp.Pattern = "<thead>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</thead>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<tbody>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</tbody>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<tfoot>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</tfoot>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "<caption>" text = objRegExp.Replace (text,"") objRegExp.Pattern = "</caption>" text = objRegExp.Replace (text,"") Set objRegExp = Nothing tables = text End Function '------------------------------------Function sendmail(CDOTo, CDOFrom, CDOBcc, CDOReplyTo, CDOSubject, CDOImportance, CDOBody) Dim ObjNewmail Set ObjNewmail = Server.CreateObject("CDONTS.NewMail") ObjNewmail.To = CDOTo ObjNewmail.From = CDOFrom 'ObjNewmail.Bcc = CDOBcc 'ObjNewmail.Value("ReplyTo") = CDOReplyTo ObjNewmail.Subject = CDOSubject ObjNewmail.Importance = CDOImportance ObjNewmail.Body = CDOBody ObjNewmail.Send() Set ObjNewmail = Nothing sendmail=1 End Function '--------------------------------------------------------'display the page

sub display(title, menu, body, javascript) 'Response.Write body 'Response.End %> <html> <head> <meta name="ROBOTS" content="NOINDEX, NOFOLLOW"> <%=title%> <link rel="stylesheet" href="text.css"> <%=javascript%> </head> <body> <table border="1" width="650"> <tr class="text"> <td align="center">A text only version of a page from <%=STRSERVERNAME%> <br> </td> </tr> </table> <br> <%if menu <> "" then%> <table border="0" width="650"> <tr class="text"> <td> <%=menu%> </td> </tr> </table> <%end if%> <table border="0" width="650"> <tr class="text"> <td> <%=body%> </td> </tr> </table> <table border="1" width="650"> <tr class="text"> <td> <center> <% if Request.QueryString("url") = "" then %><a href="<%=strRefer%>">Return to graphics version</a><% elseif strFileID <> "" then %><a href="<%=strFileID%>">Return to graphics version</a><% else %><a href="<%=Request.QueryString("url")%>">Return to graphics version</ a><% end if %> </center> </td> </tr> </table> </body> </html>

<% End sub '---------------------------------------------call main() %>

Das könnte Ihnen auch gefallen