Skip to content

Commit

Permalink
- updated for squid >= 3.4 (done by Sebastian Szczepański)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sławomir Paszkiewicz committed Aug 17, 2017
1 parent 300341e commit 2c97ec0
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions contrib/squid_redirector/lms-squid
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ while ($adres = <STDIN>)
{
if ((!defined($dbase))||($dbase->state))
{
if($dbtype =~ /mysql/)
{
$dbase = DBI->connect_cached("DBI:mysql:database=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 });
}
elsif($dbtype eq "postgres")
{
$dbase = DBI->connect_cached("DBI:Pg:dbname=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 });
}
else
{
print STDERR "Fatal error: unsupported database type: $dbtype, exiting.\n";
exit 1;
}
if($dbtype =~ /mysql/)
{
$dbase = DBI->connect_cached("DBI:mysql:database=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 });
}
elsif($dbtype eq "postgres")
{
$dbase = DBI->connect_cached("DBI:Pg:dbname=$dbname;host=$dbhost","$dbuser","$dbpasswd", { RaiseError => 1 });
}
else
{
print STDERR "Fatal error: unsupported database type: $dbtype, exiting.\n";
exit 1;
}
$dbq = $dbase->prepare_cached("SELECT access,warning FROM vnodes WHERE ipaddr=INET_ATON(?)");
}
@lista = split(' ', $adres);
Expand All @@ -65,10 +65,12 @@ while ($adres = <STDIN>)
if ($row->{'warning'}==1 || $row->{'access'}==0)
{
if (!($lista[0] =~ m/$redirect/))
{
{
$lista[0] = $redirect."?oldurl=".$lista[0];
$adres = '302:'.join(' ',@lista)."\n";
$adres = '302:'.$lista[0]."\n";
}
} else {
$adres = $lista[0]."\n";
}
print $adres;
}
Expand Down

0 comments on commit 2c97ec0

Please sign in to comment.