Fix script per squid
This commit is contained in:
@@ -57,7 +57,6 @@ while ($dato = mysql_fetch_array ( $res )) {
|
|||||||
<?php
|
<?php
|
||||||
if ($dato['sys']) { ?>
|
if ($dato['sys']) { ?>
|
||||||
<td rowspan=2><img src="<?php print $CONF['base_url'] ?>/img/attivo_grey.gif" ALT="ACL non modificabile" TITLE="ACL non modificabile"></td>
|
<td rowspan=2><img src="<?php print $CONF['base_url'] ?>/img/attivo_grey.gif" ALT="ACL non modificabile" TITLE="ACL non modificabile"></td>
|
||||||
<td rowspan=2><img src="<?php print $CONF['base_url'] ?>/img/modify_grey.gif" ALT="ACL non modificabile" TITLE="ACL non modificabile"></td>
|
|
||||||
<?php } else {
|
<?php } else {
|
||||||
if ($dato['attivo']) {
|
if ($dato['attivo']) {
|
||||||
?>
|
?>
|
||||||
@@ -65,8 +64,8 @@ while ($dato = mysql_fetch_array ( $res )) {
|
|||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<td rowspan=2 class="spazio"><a href="proxy_gest.php?azione=acl_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="ACL non attiva" TITLE="ACL non attiva"></a></td>
|
<td rowspan=2 class="spazio"><a href="proxy_gest.php?azione=acl_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="ACL non attiva" TITLE="ACL non attiva"></a></td>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<td rowspan=2><a href="acl_edit.php?id=<?php print $dato['id'] ?>"><img src="<?php print $CONF['base_url'] ?>/img/modify.gif" ALT="Dettaglio" TITLE="Dettaglio"></a></td>
|
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
<td rowspan=2><a href="acl_edit.php?id=<?php print $dato['id'] ?>"><img src="<?php print $CONF['base_url'] ?>/img/modify.gif" ALT="Dettaglio" TITLE="Dettaglio"></a></td>
|
||||||
<td rowspan=2 class="spazio"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
<td rowspan=2 class="spazio"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
<td class="descrizione">Nome lista</td>
|
<td class="descrizione">Nome lista</td>
|
||||||
<td rowspan=2 class="spazio"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
<td rowspan=2 class="spazio"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
192.168.1.1
|
172.16.0.254
|
||||||
|
|||||||
38
proxy/squid_acl/shellwords.pl
Normal file
38
proxy/squid_acl/shellwords.pl
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
sub shellwords {
|
||||||
|
package shellwords;
|
||||||
|
local($_) = join('', @_) if @_;
|
||||||
|
local(@words,$snippet,$field);
|
||||||
|
|
||||||
|
s/^\s+//;
|
||||||
|
while ($_ ne '') {
|
||||||
|
$field = '';
|
||||||
|
for (;;) {
|
||||||
|
if (s/^"(([^"\\]|\\[\\"])*)"//) {
|
||||||
|
($snippet = $1) =~ s#\\(.)#$1#g;
|
||||||
|
}
|
||||||
|
elsif (/^"/) {
|
||||||
|
die "Unmatched double quote: $_\n";
|
||||||
|
}
|
||||||
|
elsif (s/^'(([^'\\]|\\[\\'])*)'//) {
|
||||||
|
($snippet = $1) =~ s#\\(.)#$1#g;
|
||||||
|
}
|
||||||
|
elsif (/^'/) {
|
||||||
|
die "Unmatched single quote: $_\n";
|
||||||
|
}
|
||||||
|
elsif (s/^\\(.)//) {
|
||||||
|
$snippet = $1;
|
||||||
|
}
|
||||||
|
elsif (s/^([^\s\\'"]+)//) {
|
||||||
|
$snippet = $1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
s/^\s+//;
|
||||||
|
last;
|
||||||
|
}
|
||||||
|
$field .= $snippet;
|
||||||
|
}
|
||||||
|
push(@words, $field);
|
||||||
|
}
|
||||||
|
@words;
|
||||||
|
}
|
||||||
|
1;
|
||||||
@@ -6,10 +6,11 @@ use Switch;
|
|||||||
use FindBin qw($Bin);
|
use FindBin qw($Bin);
|
||||||
|
|
||||||
require "$Bin/../script/conntrack.conf";
|
require "$Bin/../script/conntrack.conf";
|
||||||
|
require "$Bin/shellwords.pl";
|
||||||
|
|
||||||
local $SIG{ALRM} = sub {
|
local $SIG{ALRM} = sub {
|
||||||
my $time = localtime; # scalar context
|
my $time = localtime; # scalar context
|
||||||
# print LOG "$$ - $time - Exit\n";
|
print LOG "$$ - $time - Exit\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -21,31 +22,26 @@ my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die (
|
|||||||
$sts = $dbmysql->prepare("use $DBname");
|
$sts = $dbmysql->prepare("use $DBname");
|
||||||
$sts->execute ();
|
$sts->execute ();
|
||||||
|
|
||||||
#open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
|
open LOG, ">> /usr/local/mybin/proxy/squid_acl/squid_pool.log";
|
||||||
#LOG->autoflush(1);
|
LOG->autoflush(1);
|
||||||
|
|
||||||
while($limit) {
|
my $time = localtime; # scalar context
|
||||||
alarm $timeout;
|
print LOG "$$ - $time - Start\n";
|
||||||
my $query = "";
|
|
||||||
my $input = <>;
|
|
||||||
chop $input;
|
|
||||||
|
|
||||||
my @param = split / /, $input;
|
while (<>) {
|
||||||
|
print LOG "$$ - $time - $_\n";
|
||||||
my $ritorno = cerca ($param[1],$param[2], -1);
|
my ($name, $ip, $host) = &shellwords;
|
||||||
$limit--;
|
|
||||||
if ($ritorno) {
|
if (cerca($ip,$host, -1)) {
|
||||||
# print LOG "$param[0] - $param[1] - $param[2] - ERR\n";
|
print LOG "$ip, $host, -1 - ERR\n";
|
||||||
print "DENY\n";
|
print "ERR\n";
|
||||||
} else {
|
} else {
|
||||||
$ritorno = cerca ($param[1],$param[2], 1);
|
if (cerca($ip,$host, 1)) {
|
||||||
if ($ritorno) {
|
print LOG "$ip, $host, -1 - OK\n";
|
||||||
# print LOG "$param[0] - $param[1] - $param[2] - OK\n";
|
|
||||||
print "OK\n";
|
print "OK\n";
|
||||||
} else {
|
} else {
|
||||||
# print LOG "$param[0] - $param[1] - $param[2] - ERR\n";
|
print LOG "$ip, $host, -1 - ERR\n";
|
||||||
# print "DENY\n";
|
print "ERR\n";
|
||||||
print "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -131,9 +127,10 @@ sub cerca {
|
|||||||
WHERE
|
WHERE
|
||||||
proxy_pool.ip = '$ip'
|
proxy_pool.ip = '$ip'
|
||||||
)
|
)
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
# print "$query\n";
|
# print LOG "$query\n";
|
||||||
$sts = $dbmysql->prepare($query);
|
$sts = $dbmysql->prepare($query);
|
||||||
$sts->execute ();
|
$sts->execute ();
|
||||||
|
|
||||||
|
|||||||
@@ -20,19 +20,33 @@ my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die (
|
|||||||
$sts = $dbmysql->prepare("use $DBname");
|
$sts = $dbmysql->prepare("use $DBname");
|
||||||
$sts->execute ();
|
$sts->execute ();
|
||||||
|
|
||||||
#open LOG, ">> /srv/www/htdocs/pannello_vbc/proxy/squid_acl/squid_pool.log";
|
open LOG, ">> /usr/local/mybin/proxy/squid_acl/squid_pool.log";
|
||||||
#LOG->autoflush(1);
|
LOG->autoflush(1);
|
||||||
|
# pass = PASSWORD('".$param[1]."')
|
||||||
|
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
while($limit) {
|
while($limit) {
|
||||||
my $query = "";
|
my $query = "";
|
||||||
my $input = <>;
|
my $input = <>;
|
||||||
|
print LOG "AUTH -- $input\n";
|
||||||
chop $input;
|
chop $input;
|
||||||
|
|
||||||
my @param = split / /, $input;
|
my @param = split / /, $input;
|
||||||
|
|
||||||
if ($param[0] ne "") {
|
if ($param[0] ne "") {
|
||||||
$query = "SELECT id, primo, (tempo*3600)-time_to_sec(timediff(ultimo, primo)) AS rimasto, tempo FROM proxy_utenti WHERE user = '".$param[0]."' AND pass = PASSWORD('".$param[1]."') AND attivo = 1";
|
$query = " SELECT
|
||||||
|
id,
|
||||||
|
primo,
|
||||||
|
(tempo*3600)-time_to_sec(timediff(ultimo, primo)) AS rimasto,
|
||||||
|
tempo
|
||||||
|
FROM
|
||||||
|
proxy_utenti
|
||||||
|
WHERE
|
||||||
|
user = '".$param[0]."'
|
||||||
|
AND
|
||||||
|
pass = ENCRYPT('".$param[1]."',LEFT(pass, 2))
|
||||||
|
AND
|
||||||
|
attivo = 1";
|
||||||
$limit--;
|
$limit--;
|
||||||
alarm $timeout;
|
alarm $timeout;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ if (isset($_POST['id'])) {
|
|||||||
$pwd2 = $_POST['pwd2'];
|
$pwd2 = $_POST['pwd2'];
|
||||||
|
|
||||||
if ($pwd1 == $pwd2) {
|
if ($pwd1 == $pwd2) {
|
||||||
$pwd = "pass = PASSWORD('$pwd1'),";
|
$pwd = "pass = ENCRYPT('$pwd1'),";
|
||||||
} else {
|
} else {
|
||||||
$pwd = -1;
|
$pwd = -1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if (isset($_POST['id'])) {
|
|||||||
proxy_utenti
|
proxy_utenti
|
||||||
SET
|
SET
|
||||||
user = '$utgruppo',
|
user = '$utgruppo',
|
||||||
pass = PASSWORD('$pwgruppo'),
|
pass = ENCRYPT('$pwgruppo'),
|
||||||
fullname = 'Utente Guest',
|
fullname = 'Utente Guest',
|
||||||
data = NOW(),
|
data = NOW(),
|
||||||
modifica = NOW(),
|
modifica = NOW(),
|
||||||
|
|||||||
Reference in New Issue
Block a user