%@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 and replace with
objRegExp.Pattern = "
]*)>"
strAns = objRegExp.Replace (strBody,"
")
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()
%>
<%=strTitle%>
|
<%=strbody%>
|
| |
| Source: http://www.tenth.org/music/ |
<%
End sub
%>