%@Language="VBScript"%>
<%Option Explicit%>
<%
'--------------------------------
' UNIVERSAL "PRINTER-FRIENDLY" MINI-APPLICATION
'--------------------------------
' The purpose of this page is to trim content
' from existing html pages to make them printer
' friendly. All pages must have identifiable
' starting and ending points for useful content
'--------------------------------
dim debug, tmpRefPage, tmpRefPath, tmpServerName
debug = false
' Get the name of the page to be spun, from the HTTP-Referer
tmpRefPage = "http://nature.org/wherewework/northamerica/states/florida/preserves/art5523.html"
tmpRefPage = Request.ServerVariables("HTTP_REFERER")
tmpServerName = "http://" & Request.ServerVariables("SERVER_NAME")
if debug = true then
response.write("tmpRefPage: " & tmpRefPage)
response.write("
tmpServerName: " & tmpServerName)
end if
tmpRefPage = Replace(tmpRefPage, tmpServerName, "")
If Right(tmpRefPage, 1) = "/" then
tmpRefPage = tmpRefPage & "index.html"
End if
if debug = true then
response.write("
tmpRefPage without HTTP_SERVER: " & tmpRefPage)
end if
' Get the path only - for later use
tmpRefPath = Left(tmpRefPage, InStrRev(tmpRefPage, "/"))
if debug = true then
response.write("
tmpRefPath: " & tmpRefPath)
end if
'--------------------------------
' Convert the entire page code into a string
'--------------------------------
const ForReading = 1
const TristateFalse = 0
dim strFile
dim objFS
dim objFile
dim objTS
set objFS = Server.CreateObject("Scripting.FileSystemObject")
' Check to see if the file actually exists AND make sure it is not an ASP file or it will display the code... very bad
dim thisPath
thisPath = Server.MapPath(tmpRefPage)
if debug = true then
response.write("
Server.MapPath: " & thisPath)
end if
If Right(tmpRefPage, 4) <> ".asp" AND objFS.FileExists(thisPath) Then
set objFile = objFS.GetFile(thisPath)
set objTS = objFile.OpenAsTextStream(ForReading, TristateFalse)
strFile = objTS.Read(objFile.Size)
Set objFile=Nothing
Set objTS=Nothing
Set objFS=Nothing
' You now have the entire page code in the strFile string
'--------------------------------
' Clean up the code to make it printer friendly
'--------------------------------
' Cut out those nasty header, footer, and navigation sections
dim fileArray, fileArray2, varContent, varFind, varStart, varFinish
dim varString
fileArray = Split(strFile, "")
fileArray2 = Split(fileArray(1), "")
varContent = fileArray2(0)
' Remove the image and link to the print function
varFind = Instr(varContent, "print.asp")
if varFind > 0 then
varStart = InstrRev(varContent, "")
varString = Mid(varContent, varStart, (varFinish-varStart)+2)
varContent = replace(varContent, varString, "")
end if
' If this is a Press Release, remove the associated TABLE
If Instr(varContent, "prinside_gr_downloads.gif") > 0 and Instr(varContent, "prinside_gr_contact.gif") > 0 Then
varStart = InstrRev(varContent, "
![]() |
Go Back |
|
<%=varContent%> |
|