National Review Online (http://www.nationalreview.com)
<%
Const ForReading = 1
Dim strReferrer, strFrom, objFSO, objOpenFile, strLine, dontWrite
strReferrer = Request.QueryString("REF")
strFrom = Request.ServerVariables("HTTP_REFERER")
strFrom = LCase(Left(strFrom, 29))
'If strFrom <> "http://www.nationalreview.com" then
' response.redirect "http://www.nationalreview.com" & strReferrer
'end if
If Len(strReferrer) < 1 then
strReferrer = Request.ServerVariables("HTTP_REFERER")
If Len(strReferrer) < 1 then
Response.Write "An Error occurred! We could not" & _
" determine what page you wanted to view..."
Response.End
Else
'With the HTTP_REFERER, the entire URL is passed along... we
'need to hack out the http://www.4guysfromrolla.com part
strReferrer = Right(strReferrer,len(strReferrer)-7)
strReferrer = Right(strReferrer,len(strReferrer) - _
instr(1,strReferrer,"/")+1)
End If
End If
'Make sure the user isn't trying to view ASP source
'(You should alter this below statement to make sure that the
' reader is trying to view an article in the proper directory.
' If you do not care where the user views the articles from,
' simply remove the If statement altogether...)
If InStr(1,strReferrer, "..") <> 0 OR _
InStr(1,strReferrer, ":") <> 0 OR _
InStr(1,strReferrer, "//") <> 0 then
Response.Write "You specified an incorrect path. Please try again."
Response.End
End If
' If InStr(1,UCase(strReferrer),"/WEBTECH/") = 0 OR _
' InStr(1,strReferrer,"..") <> 0 then
' 'Shame on you, trying to view a page you're not suppose to...
' Response.Write "Only pages in the /webtech/" & _
' " directory may be viewed in printer-friendly format..."
' Response.End
' End If
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objOpenFile = objFSO.OpenTextFile(Server.MapPath(strReferrer), _
ForReading)
dontWrite = ""
'Output each line of the file...
Do Until objOpenFile.AtEndOfStream
strLine = objOpenFile.ReadLine
If strLine = " " Then
dontWrite = "yes"
End If
If dontWrite <> "yes" Then
Response.Write strLine & vbCrLf
End If
Loop
objOpenFile.Close
Set objOpenFile = Nothing
Set objFSO = Nothing
%>