#!/usr/bin/perl -w # $Id: squid-redirector_en.txt,v 1.1 2003/03/24 09:04:34 jfranken Exp $ # Redirector for squid, which filters out common ads # use strict; my $blankfile="http://localhost/blank."; # Extension will be added my $is_image="\.(gif|jpg|jpeg|png|bmp|xpm|pnm)\$"; my ($ext, $blacklist); $|=1; # no stdout buffering # Store a list of unwanted URLs as regex in $blacklist open (URLS,") { chomp; $_ && ($blacklist .= ($blacklist?"|":"").$_); } close URLS; $blacklist or die "No blacklist URLs have been defined"; # Unadvertize the URLS squid is passing over while () { chomp; $ext=lc($_); $ext=~s/^.*\.//g; # extract file extension $_=$blankfile . (/$is_image/i ? $ext : "html") if /$blacklist/; print "$_\n"; }