All pastes #2837 Raw Edit

squid redirector for loko

public text v1 · immutable
#2837 ·published 2004-12-10 03:41 UTC
rendered paste body
#!/usr/bin/perl
use strict;
#---
my $url="";
my $addr="";
my $fqdn="";
my $ident="";
my $method="";
my $fail=0;
my $goParse="no";
#---
$|=1;
while (<>)
{
        # Init, assign and reset needed vars
        ($url, $addr, $fqdn, $ident, $method) = split; #m:(\S*) (\S*)/(\S*) (\S*) (\S*):;
        $goParse="no";
        # Perform work
        if ( $fail==0 )
        {
                # Determine if we send through parse.cgi
                #       + Extension contains 'htm', 'asp' or 'php'
                if ( $url =~ /.*?\.\w?(htm|asp|php)\w?([\?#].*|)$/i ) { $goParse="yes"; }
                #       + Is a directory
                if ( $url =~ /.*\/$/i ) { $goParse="yes"; }
                #       + Extension contains 'php'
                #if ( $url =~ /.*?\.\w?php\w?([\?#].*|)$/i ) { $goParse="yes"; }

                if ( $goParse eq "yes" )
                {
                        print "http://proxy-private.redrival.com/mpr-bin/squid/parse.cgi?target=$url\n";
                }
                else
                {
                        print "$url\n";
                }
        }
        else
        {
                print "http://www.rivalpro.com/modperl/_rr/squid/error.cgi\n";
        }
}

1;