I wrote:
> I hope someone will write a DTML thing that can check referrer
> from a list of domain names and regexps and return a "403
> Forbidden" if the referrer matches that list.
Not quite. Here's a quick and dirty hack that prevents all visitors
with a .info-domain in the HTTP_REFERER variable from viewing any
page.
First a Python script, checkReferrer.py:
#v+
## Script (Python) "checkReferrer"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=d
##title=Check HTTP_REFERER
##
# -*- mode: Python; TAB: 4; coding: iso-8859-1 -*-
ref = d.get('HTTP_REFERER', None)
if ref is not None:
elms = ref.split('/')
if len(elms) > 2:
host = elms[2]
elms = host.split('.')
if len(elms) > 1:
return elms[-1] == 'info'
# end if
# end if
# end if
return 0 == 1
# eof
#v-
and next I put the following lines at the top of my blog_header
DTML file:
#v+
<dtml-if "checkReferrer(REQUEST)">
<dtml-call "RESPONSE.redirect('http://127.0.0.1/',status=403)">
</dtml-if>
#v-
Use at your own risk.
Cheers,
--
Klaus Alexander Seistrup � Copenhagen � Denmark
http://www.magnetic-ink.dk/ � http://www.pnx.dk/
_______________________________________________
COREblog-en mailing list
[EMAIL PROTECTED]
http://postaria.com/cgi-bin/mailman/listinfo/coreblog-en
Unsubscription writing to [EMAIL PROTECTED]