<%@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. ' Assumes that your page has printable content within two comments ' content_starts_here and content_ends_here. Gets the page, strips of the ' the content, gets the BaseURL and prints the stripped out page ' Needs MSXML 3.0 or above installed ' ' S Babu. vsbabu-removethis@vsbabu.org. 05/23/2001 ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' If Request.ServerVariables("HTTP_REFERER") <> "" Then ' if this didn't come from anywhere, ignore. Dim strContent Dim xml_http 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 Dim regex Dim reg_matches Dim strtitle Dim strbody 'On Error Resume Next ' Get the body Set regex = New RegExp regex.Pattern = "(.|\n)*" regex.IgnoreCase = True regex.Global = True strbody = strContent Set reg_matches = regex.Execute(strbody) If reg_matches.Count > 0 Then strbody = reg_matches.Item(0).Value End If Set regex = Nothing Set reg_matches = Nothing ' Get the title Set regex = New RegExp regex.Pattern = "(.|\n)*<\/title>" regex.IgnoreCase = True regex.Global = True strtitle = strContent Set reg_matches = regex.Execute(strtitle) If reg_matches.Count > 0 Then strtitle = reg_matches.Item(0).Value End If Set regex = Nothing Set reg_matches = Nothing ' if we didn't get any different content, regex failed. So print ' out the existing content If strContent = strbody Then Response.Write strContent Else 'Print the stripped version Response.Write "<html><head>" & strtitle & "</head><body>" & vbCrLf Response.Write "<base href=""" & GetBaseHref(Request.ServerVariables("HTTP_REFERER")) &""">" & vbCrLf Response.Write strbody Response.Write "<HR><center>" & Request.ServerVariables("HTTP_REFERER") & "</center></body></html>" End If End If '''Given a full URL, gets the base URL. Assumes that URLs to the '''default document is atleast terminated by / Function GetBaseHref(strURL) Dim arrParts, i arrParts = split(strURL,"/") GetBaseHref = "" For i = 0 To (UBound(arrParts)-1) GetBaseHref = GetBaseHref & arrParts(i) & "/" Next End Function %>