Dirty and Quickie deep linking prevention
rouvas at di.uoa.gr
rouvas at di.uoa.gr
Fri Sep 25 18:14:13 EEST 2009
Christos Ricudis wrote:
> Exete bare8ei na linkarei olo to sympan to directory sas me tis
> 452973493 lolcats apo diafora hli8ia forums?
>
> Taiste tous ena Cthulhu Goatse!
>
> mod_perl required. Modify it to suit your site.
>
> apache.conf :
>
> PerlModule Perlomodula::Taisthri
> PerlTransHandler Perlomodula::Taisthri
>
> Taisthri.pl :
>
> package Perlomodula::Taisthri;
>
> use strict;
> use Apache2::RequestRec ();
> use Apache2::Log ();
> use APR::Table ();
> use Apache2::Const -compile => qw(DECLINED);
>
> sub handler {
> my $r = shift;
>
> my $kot=$r->uri();
> my $lala=$r->headers_in->{Referer} || '';
> my $isimage=0;
> my $islinked=0;
>
> if
> (!($lala=~m/.*(localhost|myserver|127.0.0.1|192.168|mydomain.com).*/i)) {
> $islinked=1;
> }
>
> if ($kot=~m/(.*)\/pictures\/lolcats\/(.*)\.jpg/i) {
> $isimage=1;
> }
>
> if (($islinked==1)&&($isimage==1)) {
> $r->uri("/cthulhu-goatse.jpg");
> $r->log_error("Bad referer $lala linked to $kot, fed him a
> goatse-cthulhu");
> }
>
> return Apache2::Const::DECLINED;
>
> }
> 1;
>
Ginetai kai me to mod_rewrite tou Apache, kapos etsi:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_REFERER} .*myspace.*
RewriteRule .* /dont-link-to-me [G]
RewriteCond %{HTTP_REFERER} .*hi5.*
RewriteRule .* /dont-link-to-me [G]
RewriteCond %{HTTP_REFERER} .*youtube.*
RewriteRule .* /dont-link-to-me [G]
</IfModule>
sto .htaccess tou directory.
-Stathis
>
>
> --
> linux-greek-users mailing list -- http://lists.hellug.gr
More information about the Linux-greek-users
mailing list