<%@LANGUAGE=VBScript%> <%Option Explicit Response.Buffer = True Response.CacheControl = "Private" Response.Expires = -1 'We don't want this to be cached anywhere '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' print.asp - Make a link to this page from your page. ' optional argument of width which is 650 by default ' Assumes that your page has printable content within two comments ' content_starts_here and content_ends_here. ' ' ' Needs MSXML 3.0 or above installed '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Request.ServerVariables("HTTP_REFERER") <> "" Then ' if this didn't come from anywhere, ignore. Dim strContent, xml_http Dim objRegExp, reg_matches, strTitle , strBody, strAns, strString, strServerName Dim lngPosition1, lngPosition2, lngPosition3 Dim strStart, strEnd, strTD, strTemp, strStartTD, strEndTD Dim strThisDir Dim strWidth Set xml_http = Server.CreateObject("Microsoft.XMLHTTP") xml_http.Open "GET", Request.ServerVariables("HTTP_REFERER"), False xml_http.Send strContent = xml_http.responseText Set xml_http = Nothing strServerName=Request.ServerVariables ("SERVER_NAME") strThisDir = mid(Request.ServerVariables ("HTTP_REFERER"),1,inStrRev(Request.ServerVariables ("HTTP_REFERER"),"/") ) strWidth = Request.QueryString ("width") if strWidth = "" then strWidth = 650 end if '---------------------------------------------- 'Get the body Set objRegExp = New RegExp objRegExp.Pattern = "(.|\n)*" objRegExp.IgnoreCase = True objRegExp.Global = True strBody = strContent Set reg_matches = objRegExp.Execute(strBody) If reg_matches.Count > 0 Then strBody = reg_matches.Item(0).Value End If Set objRegExp = Nothing Set reg_matches = Nothing '---------------------------------------------- 'Get the title 'Extract everything between and including ' and Set objRegExp = New RegExp objRegExp.IgnoreCase = True objRegExp.Global = True objRegExp.Pattern = "(.|\n)*<\/title>" strTitle = strContent Set reg_matches = objRegExp.Execute(strTitle) If reg_matches.Count > 0 Then strTitle = reg_matches.Item(0).Value else strTitle = "" End If Set objRegExp = New RegExp '---------------------------------------------- 'Look for comments <! ... > and delete '(Comments are acutally <!-- ... --> but datamart uses <! ... > objRegExp.Pattern = "<!([^>]*)>" strAns = objRegExp.Replace (strBody,"") strBody = strAns '---------------------------------------------- 'Look for href="/files/..." replace with href="http://rootwebdirectory/graphics/..." 'So if there is / then put in the server name because the / represents relative to the rootweb strString = "href=" & chr(34) & "/" objRegExp.Pattern = strString strAns = objRegExp.Replace (strBody,"href=" & chr(34) & "http://" & strServerName & "/") strBody = strAns '---------------------------------------------- 'Look for href="graphics/..." replace with href="http://rootwebdirectory/graphics/..." 'href="http://hostname/graphics./.. is ignored objRegExp.Pattern = "href=""(.{4})([^:])([^>]*)(>|\n)" '$1 = any four characters '$2 = not : '$3 = all other characters '$4 = upto > or end of line strAns = objRegExp.Replace (strBody, "href=" & chr(34) & strThisDir & "$1$2$3$4") strBody = strAns '---------------------------------------------- ' Look for bgcolor^=^"#xxxxxx" and delete 'strString = "bgcolor(\s*?)=(\s*?)\" & chr(34) & "#" & "\w{6}" & "\" & chr(34) strString = "bgcolor([\s]*)=([\s]*)\" & chr(34) & "#" & "\w{6}" & "\" & chr(34) objRegExp.Pattern = strString strAns = objRegExp.Replace (strBody,"") strBody = strAns '---------------------------------------------- ' Replace <tr> and replace with <tr class="text"> objRegExp.Pattern = "<tr([^>]*)>" strAns = objRegExp.Replace (strBody,"<tr class=" & chr(34) & "text" & chr(34) & ">") strBody = strAns '---------------------------------------------- 'Look for src="/graphics/..." replace with src="http://rootwebdirectory/graphics/..." 'So if there is / then put in the server name because the / represents relative to the rootweb strString = "src=" & chr(34) & "/" objRegExp.Pattern = strString strAns = objRegExp.Replace (strBody,"src=" & chr(34) & "http://" & strServerName & "/") strBody = strAns '---------------------------------------------- 'Look for src="graphics/..." replace with src="http://rootwebdirectory/graphics/..." 'src="http://hostname/graphics./.. is ignored objRegExp.Pattern = "src=""(.{4})([^:])([^>]*)(>|\n)" '$1 = any four characters '$2 = not : '$3 = all other characters '$4 = upto > or end of line strAns = objRegExp.Replace (strBody, "src=" & chr(34) & strThisDir & "$1$2$3$4") Set objRegExp = Nothing strBody = strAns call display() End If '--------------------------------------------------------- 'display the page Sub display() %> <html> <head> <%=strTitle%> <!--- <link rel="stylesheet" href="printver.css"> ---> </head> <body> <!--- <table border="0" width="<%=strWidth%>"> ---> <!--- <tr class="text"> ---> <!--- <Tr> <TD> <FONT size="+1" style="Trebuchet MS"><I> Tenth Presbyterian Church Music Ministry<BR> http://www.tenth.org/music/index.html </FONT></I> </TD> <TD><img height="135" width="72" src="http://localhost/Tenth_v4/tenth_logo.jpg"></TD> </tr> </table> ---> <br> <table border="0" width="<%=strWidth%>"> <tr class="text"> <td> <%=strbody%> </td> </tr> <TR><TD> </TD></TR> <TR> <TD><i><FONT size="-1">Source: http://www.tenth.org/music/</FONT></i></TD> </TR> </table> <!--- <table border="0" width="<%=strWidth%>"> <tr class="text"> <td> <center> <%=Request.ServerVariables("HTTP_REFERER")%> </center> </td> </tr> </table> ---> </body> </html> <% End sub %>