Inizializzazione progetto pannello
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -4,4 +4,3 @@ squid_pool.log
|
||||
script/*.sql
|
||||
squid_acl/listip
|
||||
.gitignore
|
||||
whitefox/*
|
||||
|
||||
161
condes/index.php
161
condes/index.php
@@ -1,161 +0,0 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Utente');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['utente'])) {
|
||||
$utente = $_POST['utente'];
|
||||
|
||||
$old = $new = array();
|
||||
foreach ($_POST as $id => $valore) {
|
||||
if (preg_match ("/^new-(\d+)/", $id, $ris)) $new[$ris[1]] = $valore;
|
||||
if (preg_match ("/^old-(\d+)/", $id, $ris)) $old[$ris[1]] = $valore;
|
||||
}
|
||||
|
||||
foreach ($new as $id => $valore) {
|
||||
if ($new[$id] == $old[$id]) continue;
|
||||
|
||||
if ($valore >1)
|
||||
$stato = 1;
|
||||
else
|
||||
$stato = $valore;
|
||||
|
||||
$query = " SELECT
|
||||
condes_regole.id_condes_macchine,
|
||||
condes_regole.id_proxy_acl_list,
|
||||
condes_macchine.id_proxy_pool
|
||||
FROM
|
||||
condes_regole
|
||||
JOIN
|
||||
condes_macchine
|
||||
ON
|
||||
condes_regole.id_condes_macchine = condes_macchine.id
|
||||
WHERE
|
||||
condes_regole.id = $id
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
$dato = mysql_fetch_array ( $res );
|
||||
|
||||
$query = " UPDATE
|
||||
condes_regole
|
||||
SET
|
||||
stato = $valore,
|
||||
modifica = NOW()
|
||||
WHERE
|
||||
id_condes_macchine = ".$dato['id_condes_macchine']."
|
||||
AND
|
||||
id_proxy_acl_list = ".$dato['id_proxy_acl_list'];
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " INSERT INTO
|
||||
proxy_acl_ip
|
||||
SET
|
||||
idacllist = ".$dato['id_proxy_acl_list'].",
|
||||
idpool = ".$dato['id_proxy_pool'].",
|
||||
stato = $stato,
|
||||
data = NOW()
|
||||
ON DUPLICATE KEY UPDATE
|
||||
stato = $stato,
|
||||
data = NOW()
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " INSERT INTO
|
||||
condes_logs
|
||||
SET
|
||||
id_utenti = ".$UTENTE['id'].",
|
||||
id_condes_regole = $id,
|
||||
stato = $valore,
|
||||
data = NOW()
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
}
|
||||
|
||||
$tabella = new html (0,"90%",array(15,2,20,2,15,2,5,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<input type="hidden" name="utente" value="<?php print $UTENTE['id'] ?>">
|
||||
|
||||
<tr>
|
||||
<td><input type="submit" value="Applica"></td>
|
||||
<td colspan="7" class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga ();
|
||||
|
||||
if ($DIRITTI < 10) {
|
||||
$admin = " AND utenti.id = ".$UTENTE['id'];
|
||||
} else {
|
||||
$admin = "";
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
condes_regole.id,
|
||||
condes_regole.stato,
|
||||
proxy_pool.nome,
|
||||
proxy_pool.ip,
|
||||
proxy_acl_list.nome AS acl,
|
||||
condes_regole.permanente
|
||||
FROM
|
||||
condes_regole
|
||||
JOIN
|
||||
utenti
|
||||
ON
|
||||
condes_regole.id_utenti = utenti.id
|
||||
$admin
|
||||
JOIN
|
||||
condes_macchine
|
||||
ON
|
||||
condes_regole.id_condes_macchine = condes_macchine.id
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
condes_macchine.id_proxy_pool = proxy_pool.id
|
||||
JOIN
|
||||
proxy_acl_list
|
||||
ON
|
||||
condes_regole.id_proxy_acl_list = proxy_acl_list.id
|
||||
WHERE
|
||||
condes_regole.attivo = 1
|
||||
ORDER BY
|
||||
-proxy_pool.nome DESC,
|
||||
proxy_pool.ip
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="textl">
|
||||
<input type="hidden" name="old-<?php print $dato['id'] ?>" value="<?php print $dato['stato'] ?>">
|
||||
<select name="new-<?php print $dato['id'] ?>">
|
||||
<option value="0" <?php if ($dato['stato'] == 0 ) print "selected" ?>>Disattivo</option>
|
||||
<option value="1" <?php if ($dato['stato'] == 1 ) print "selected" ?>>Attivo</option>
|
||||
<?php if ($dato['permanente']) { ?>
|
||||
<option value="2" <?php if ($dato['stato'] == 2 ) print "selected" ?>>Permanente</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Macchina</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">ACL</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="radio">Perm</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="textl"><?php print $dato['ip']; if ($dato['nome'] != "") print "(".$dato['nome'].")" ?></td>
|
||||
<td class="textl"><?php print $dato['acl'] ?></td>
|
||||
<td class="textc"><?php if ($dato['permanente']) print "Si"; else print "No"; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga ();
|
||||
} ?>
|
||||
</form>
|
||||
<?php
|
||||
$tabella->close ();
|
||||
view_footer();
|
||||
?>
|
||||
@@ -1,6 +0,0 @@
|
||||
our $DBhost = '127.0.0.1';
|
||||
our $DBname = 'pannello_vbc';
|
||||
our $DBuser = 'pannello_proxy';
|
||||
our $DBpass = 'CuQlM1lfF4VZDCIP';
|
||||
|
||||
return 1;
|
||||
@@ -1,96 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
$|=1;
|
||||
|
||||
use DBI;
|
||||
use FindBin qw($Bin);
|
||||
|
||||
my $param = shift @ARGV;
|
||||
|
||||
our $verbose = 0;
|
||||
if ($param eq '-v') {
|
||||
$verbose = 1;
|
||||
} elsif ($param eq '-vv') {
|
||||
$verbose = 2;
|
||||
}
|
||||
|
||||
require "$Bin/condes.conf";
|
||||
|
||||
my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die ($DBI::errstr);
|
||||
$sts = $dbmysql->prepare("use $DBname");
|
||||
$sts->execute ();
|
||||
|
||||
$query = " SELECT
|
||||
condes_regole.id,
|
||||
condes_regole.id_condes_macchine,
|
||||
condes_regole.id_proxy_acl_list,
|
||||
condes_macchine.id_proxy_pool,
|
||||
proxy_pool.ip,
|
||||
proxy_pool.nome,
|
||||
proxy_acl_list.nome AS acl
|
||||
FROM
|
||||
condes_regole
|
||||
JOIN
|
||||
condes_macchine
|
||||
ON
|
||||
condes_regole.id_condes_macchine = condes_macchine.id
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
condes_macchine.id_proxy_pool = proxy_pool.id
|
||||
JOIN
|
||||
proxy_acl_list
|
||||
ON
|
||||
condes_regole.id_proxy_acl_list = proxy_acl_list.id
|
||||
WHERE
|
||||
condes_regole.stato = 1
|
||||
";
|
||||
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
while ( $ref = $sts->fetchrow_hashref ) {
|
||||
$id = $$ref{'id'};
|
||||
$condes_macchine = $$ref{'id_condes_macchine'};
|
||||
$proxy_acl_list = $$ref{'id_proxy_acl_list'};
|
||||
$proxy_pool = $$ref{'id_proxy_pool'};
|
||||
$proxy_pool_ip = $$ref{'ip'};
|
||||
$proxy_pool_nome = $$ref{'nome'};
|
||||
$acl = $$ref{'acl'};
|
||||
|
||||
printf "Rimosso %-15s (%-10s) con lista %s\n", $proxy_pool_ip, $proxy_pool_nome, $acl if ($verbose);
|
||||
|
||||
$query = " UPDATE
|
||||
proxy_acl_ip
|
||||
SET
|
||||
stato = 0,
|
||||
data = NOW()
|
||||
WHERE
|
||||
idacllist = $proxy_acl_list
|
||||
AND
|
||||
idpool = $proxy_pool
|
||||
";
|
||||
my $sts = $dbmysql->prepare($query); $sts->execute ();
|
||||
|
||||
$query = " INSERT INTO
|
||||
condes_logs
|
||||
SET
|
||||
id_utenti = 0,
|
||||
id_condes_regole = $id,
|
||||
stato = 0,
|
||||
data = NOW()
|
||||
";
|
||||
$sts = $dbmysql->prepare($query); $sts->execute ();
|
||||
|
||||
$query = " UPDATE
|
||||
condes_regole
|
||||
SET
|
||||
stato = 0,
|
||||
modifica = NOW()
|
||||
WHERE
|
||||
id_condes_macchine = $condes_macchine
|
||||
AND
|
||||
id_proxy_acl_list = $proxy_acl_list
|
||||
";
|
||||
$sts = $dbmysql->prepare($query); $sts->execute ();
|
||||
}
|
||||
|
||||
exit;
|
||||
@@ -1,318 +0,0 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
include_once ("firewall_library.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Utente');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['regola'])) {
|
||||
|
||||
$utente = $_POST['utente'];
|
||||
$modificato = 0;
|
||||
$old = $new = array();
|
||||
foreach ($_POST as $id => $valore) {
|
||||
if (preg_match ("/^new-(\d+)/", $id, $ris)) $new[$ris[1]] = $valore;
|
||||
if (preg_match ("/^old-(\d+)/", $id, $ris)) $old[$ris[1]] = $valore;
|
||||
}
|
||||
|
||||
if ($_POST['regola'] == "intext") {
|
||||
foreach ($new as $id => $valore) {
|
||||
if ($new[$id] == $old[$id]) continue;
|
||||
|
||||
$modificato = 1;
|
||||
if ($valore >1)
|
||||
$stato = 1;
|
||||
else
|
||||
$stato = $valore;
|
||||
|
||||
$query = " SELECT
|
||||
firewall_versoesterno_regole.id_firewall_versoesterno
|
||||
FROM
|
||||
firewall_versoesterno_regole
|
||||
WHERE
|
||||
firewall_versoesterno_regole.id = $id
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
$dato = mysql_fetch_array ( $res );
|
||||
|
||||
$query = " UPDATE
|
||||
firewall_versoesterno_regole
|
||||
SET
|
||||
stato = $valore,
|
||||
modifica = NOW()
|
||||
WHERE
|
||||
id_firewall_versoesterno = ".$dato['id_firewall_versoesterno'];
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " INSERT INTO
|
||||
firewall_logs
|
||||
SET
|
||||
id_utenti = ".$UTENTE['id'].",
|
||||
tabella = 'versoesterno',
|
||||
id_regole = $id,
|
||||
stato = $valore,
|
||||
data = NOW()
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
} else if ($_POST['regola'] == "extint") {
|
||||
foreach ($new as $id => $valore) {
|
||||
if ($new[$id] == $old[$id]) continue;
|
||||
|
||||
$modificato = 1;
|
||||
if ($valore >1)
|
||||
$stato = 1;
|
||||
else
|
||||
$stato = $valore;
|
||||
|
||||
$query = " SELECT
|
||||
firewall_versointerno_regole.id_firewall_versointerno
|
||||
FROM
|
||||
firewall_versointerno_regole
|
||||
WHERE
|
||||
firewall_versointerno_regole.id = $id
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
$dato = mysql_fetch_array ( $res );
|
||||
|
||||
$query = " UPDATE
|
||||
firewall_versointerno_regole
|
||||
SET
|
||||
stato = $valore,
|
||||
modifica = NOW()
|
||||
WHERE
|
||||
id_firewall_versointerno = ".$dato['id_firewall_versointerno'];
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " INSERT INTO
|
||||
firewall_logs
|
||||
SET
|
||||
id_utenti = ".$UTENTE['id'].",
|
||||
tabella = 'versointerno',
|
||||
id_regole = $id,
|
||||
stato = $valore,
|
||||
data = NOW()
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
}
|
||||
|
||||
// if ($modificato) genera();
|
||||
if ($modificato) attiva_aggiornamento();
|
||||
}
|
||||
|
||||
$tabella = new html (0,"90%",array(15,2,20,2,50,2,5,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<input type="hidden" name="utente" value="<?php print $UTENTE['id'] ?>">
|
||||
<input type="hidden" name="regola" value="extint">
|
||||
<tr>
|
||||
<td><input type="submit" value="Applica"></td>
|
||||
<td colspan="1" class="spazioh"></td>
|
||||
<td colspan="5" class="descrizione_c">Regole Esterno -> Interno</td>
|
||||
<td colspan="1" class="spazioh"></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga (10);
|
||||
|
||||
if ($DIRITTI < 10) {
|
||||
$admin = " AND utenti.id = ".$UTENTE['id'];
|
||||
} else {
|
||||
$admin = "";
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
firewall_versointerno_regole.id,
|
||||
firewall_versointerno_regole.permanente,
|
||||
firewall_versointerno_regole.stato,
|
||||
firewall_versointerno.nome,
|
||||
firewall_versointerno.int_port,
|
||||
firewall_versointerno.fw_port,
|
||||
firewall_versointerno.proto,
|
||||
proxy_pool.nome AS int_nome,
|
||||
proxy_pool.ip AS int_ip,
|
||||
firewall_vpn.utenza,
|
||||
firewall_vpn.ip AS vpn_ip,
|
||||
utenti.utente
|
||||
FROM
|
||||
firewall_versointerno_regole
|
||||
JOIN
|
||||
firewall_versointerno
|
||||
ON
|
||||
firewall_versointerno_regole.id_firewall_versointerno = firewall_versointerno.id
|
||||
JOIN
|
||||
firewall_macchine
|
||||
ON
|
||||
firewall_versointerno.id_firewall_macchine = firewall_macchine.id
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
firewall_macchine.id_proxy_pool = proxy_pool.id
|
||||
JOIN
|
||||
firewall_vpn
|
||||
ON
|
||||
firewall_versointerno.id_firewall_vpn = firewall_vpn.id
|
||||
JOIN
|
||||
utenti
|
||||
ON
|
||||
firewall_versointerno_regole.id_utenti = utenti.id
|
||||
$admin
|
||||
WHERE
|
||||
firewall_versointerno_regole.attivo = 1
|
||||
ORDER BY
|
||||
firewall_versointerno.nome
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) { ?>
|
||||
<tr>
|
||||
<td rowspan=2 class="textl">
|
||||
<input type="hidden" name="old-<?php print $dato['id'] ?>" value="<?php print $dato['stato'] ?>">
|
||||
<select name="new-<?php print $dato['id'] ?>">
|
||||
<option value="0" <?php if ($dato['stato'] == 0 ) print "selected" ?>>Disattivo</option>
|
||||
<option value="1" <?php if ($dato['stato'] == 1 ) print "selected" ?>>Attivo</option>
|
||||
<?php if ($dato['permanente']) { ?>
|
||||
<option value="2" <?php if ($dato['stato'] == 2 ) print "selected" ?>>Permanente</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Utente</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Regola</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="radio">Perm</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="textl"><?php print $dato['utente']?></td>
|
||||
<td class="textl"><?php
|
||||
print $dato['nome'].": ";
|
||||
print $dato['utenza'];
|
||||
print ":".$dato['fw_port']." -> ";
|
||||
if ($dato['int_nome'] != "") {
|
||||
print $dato['int_nome'];
|
||||
} else {
|
||||
print $dato['int_ip'];
|
||||
}
|
||||
print ":".$dato['int_port']." (".$dato['proto'].")";;
|
||||
?></td>
|
||||
<td class="textc"><?php if ($dato['permanente']) print "Si"; else print "No"; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga (5);
|
||||
} ?>
|
||||
</form>
|
||||
|
||||
<?php $tabella->riga (30) ?>
|
||||
<form name="" method="post">
|
||||
<input type="hidden" name="utente" value="<?php print $UTENTE['id'] ?>">
|
||||
<input type="hidden" name="regola" value="intext">
|
||||
<tr>
|
||||
<td><input type="submit" value="Applica"></td>
|
||||
<td colspan="1" class="spazioh"></td>
|
||||
<td colspan="5" class="descrizione_c">Regole Interno -> Esterno</td>
|
||||
<td colspan="1" class="spazioh"></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga (10);
|
||||
|
||||
$query = " SELECT
|
||||
firewall_versoesterno_regole.id,
|
||||
firewall_versoesterno_regole.stato,
|
||||
firewall_versoesterno.nome,
|
||||
firewall_versoesterno.int_port,
|
||||
firewall_versoesterno.ext_port,
|
||||
firewall_versoesterno.proto,
|
||||
firewall_versoesterno_regole.permanente,
|
||||
proxy_pool.nome AS int_nome,
|
||||
proxy_pool.ip AS int_ip,
|
||||
firewall_macchine_ext.nome AS ext_nome,
|
||||
firewall_macchine_ext.ip AS ext_ip,
|
||||
utenti.utente
|
||||
FROM
|
||||
firewall_versoesterno_regole
|
||||
JOIN
|
||||
firewall_versoesterno
|
||||
ON
|
||||
firewall_versoesterno_regole.id_firewall_versoesterno = firewall_versoesterno.id
|
||||
JOIN
|
||||
firewall_macchine
|
||||
ON
|
||||
firewall_versoesterno.id_firewall_macchine = firewall_macchine.id
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
firewall_macchine.id_proxy_pool = proxy_pool.id
|
||||
JOIN
|
||||
utenti
|
||||
ON
|
||||
firewall_versoesterno_regole.id_utenti = utenti.id
|
||||
$admin
|
||||
JOIN
|
||||
firewall_macchine_ext
|
||||
ON
|
||||
firewall_versoesterno.id_firewall_macchine_ext = firewall_macchine_ext.id
|
||||
WHERE
|
||||
firewall_versoesterno_regole.attivo = 1
|
||||
ORDER BY
|
||||
firewall_versoesterno.nome
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="textl">
|
||||
<input type="hidden" name="old-<?php print $dato['id'] ?>" value="<?php print $dato['stato'] ?>">
|
||||
<select name="new-<?php print $dato['id'] ?>">
|
||||
<option value="0" <?php if ($dato['stato'] == 0 ) print "selected" ?>>Disattivo</option>
|
||||
<option value="1" <?php if ($dato['stato'] == 1 ) print "selected" ?>>Attivo</option>
|
||||
<?php if ($dato['permanente']) { ?>
|
||||
<option value="2" <?php if ($dato['stato'] == 2 ) print "selected" ?>>Permanente</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Utente</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Regola</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="radio">Perm</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="textl"><?php print $dato['utente'] ?></td>
|
||||
<td class="textl"><?php
|
||||
print $dato['nome'].": ";
|
||||
if ($dato['int_nome'] != "") {
|
||||
print $dato['int_nome'];
|
||||
} else {
|
||||
print $dato['int_ip'];
|
||||
}
|
||||
print ":".$dato['int_port']." -> ";
|
||||
if ($dato['ext_nome'] != "") {
|
||||
print $dato['ext_nome'];
|
||||
} else {
|
||||
print $dato['ext_ip'];
|
||||
}
|
||||
print ":".$dato['ext_port']." (".$dato['proto'].")";;
|
||||
|
||||
|
||||
?></td>
|
||||
<td class="textc"><?php if ($dato['permanente']) print "Si"; else print "No"; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga (5);
|
||||
} ?>
|
||||
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
<?php
|
||||
$tabella->close ();
|
||||
view_footer();
|
||||
?>
|
||||
@@ -1,74 +0,0 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Utente');
|
||||
view_top();
|
||||
?>
|
||||
<meta http-equiv="refresh" content="10">
|
||||
<?php
|
||||
$query = " SELECT
|
||||
GREATEST (max(inviati), max(ricevuti)) AS max
|
||||
FROM
|
||||
proxy_speed
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
$valori = mysql_fetch_array ( $res );
|
||||
$max = $valori['max'];
|
||||
|
||||
$query = " SELECT
|
||||
proxy_speed.ip,
|
||||
proxy_speed.ricevuti,
|
||||
proxy_speed.inviati,
|
||||
proxy_pool.attivo,
|
||||
proxy_pool.id,
|
||||
proxy_pool.nome
|
||||
FROM
|
||||
proxy_speed
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
proxy_speed.ip = proxy_pool.ip
|
||||
ORDER BY
|
||||
ricevuti desc ,
|
||||
inviati desc
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$tabella = new html (0,"90%", array (3,3,2,20,2,8,2,10,2,0));
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<?php
|
||||
if ($dato['attivo']) {
|
||||
?>
|
||||
<td rowspan=2 class="col3btn"><a href="proxy_gest.php?azione=pool_rem&id=<?php print $dato['ip']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="Utente limitato" TITLE="Utente limitato"></a></td>
|
||||
<?php } else { ?>
|
||||
<td rowspan=2 class="col3btn"><a href="proxy_gest.php?azione=pool_ins&id=<?php print $dato['ip']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="Utente non limitato" TITLE="Utente non limitato"></a></td>
|
||||
<?php } ?>
|
||||
<td rowspan=2 class="col3btn"><a href="pool_ip.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="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colip"><?php print $dato['ip'] ?></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Inviati</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colspeed"><?php print byteConvert($dato['inviati']) ?> </td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colimg"><img border="0" src="barra.php?max=<?php print $max ?>&val=<?php print $dato['inviati'] ?>&col=red"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="colip"><?php if ($dato['nome'] != "") { print $dato['nome']; } else { $host = gethostbyaddr ($dato['ip']); print substr($host, 0, strpos($host, ".")); } ?></td>
|
||||
<td class="descrizione">Ricevuti</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colspeed"><?php print byteConvert($dato['ricevuti']) ?></td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colimg"><img border="0" src="barra.php?max=<?php print $max ?>&val=<?php print $dato['ricevuti'] ?>&col=blue"></td>
|
||||
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga();
|
||||
}
|
||||
$tabella->close();
|
||||
view_footer();
|
||||
?>
|
||||
@@ -1,6 +0,0 @@
|
||||
our $DBhost = '127.0.0.1';
|
||||
our $DBname = 'pannello_vbc';
|
||||
our $DBuser = 'pannello_proxy';
|
||||
our $DBpass = 'CuQlM1lfF4VZDCIP';
|
||||
|
||||
return 1;
|
||||
@@ -1,215 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
$|=1;
|
||||
|
||||
use DBI;
|
||||
use FindBin qw($Bin);
|
||||
use threads;
|
||||
use threads::shared;
|
||||
use Thread::Semaphore;
|
||||
|
||||
my $param = shift @ARGV;
|
||||
|
||||
our $verbose = 0;
|
||||
if ($param eq '-v') {
|
||||
$verbose = 1;
|
||||
} elsif ($param eq '-vv') {
|
||||
$verbose = 2;
|
||||
}
|
||||
|
||||
require "$Bin/conntrack.conf";
|
||||
|
||||
`sysctl -w net.netfilter.nf_conntrack_acct=1`;
|
||||
|
||||
my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass) or die ($DBI::errstr);
|
||||
$sts = $dbmysql->prepare("use $DBname");
|
||||
$sts->execute ();
|
||||
|
||||
$query = "SELECT valore FROM conf WHERE variabile = 'lthread'";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
$ref = $sts->fetchrow_hashref;
|
||||
our $limit_thread = $$ref{'valore'};
|
||||
|
||||
$query = "SELECT ip FROM proxy_pool GROUP BY ip";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
|
||||
our @listaip = ();
|
||||
while ( $ref = $sts->fetchrow_hashref ) {
|
||||
push @listaip, $$ref{'ip'};
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
id,
|
||||
ip,
|
||||
nome,
|
||||
port
|
||||
FROM
|
||||
proxy_conn
|
||||
WHERE
|
||||
attivo = 1
|
||||
";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
|
||||
$queryDB = "";
|
||||
share ($queryDB);
|
||||
$sem1 = Thread::Semaphore->new(1);
|
||||
$sem2 = Thread::Semaphore->new(0);
|
||||
|
||||
my %proc;
|
||||
# Generazione figli per DB
|
||||
$proc{'database'} = threads->create(\&database);
|
||||
# Generazione figli per cattura pacchetti
|
||||
while ( $ref = $sts->fetchrow_hashref ) {
|
||||
my $id = $$ref{'id'};
|
||||
my $ip = $$ref{'ip'};
|
||||
my $port = $$ref{'port'};
|
||||
my $nome = $$ref{'nome'};
|
||||
$proc{$nome} = threads->create(\&conntrack, $id, $ip, $port);
|
||||
print "Attivato processo $nome\n" if ($verbose);
|
||||
}
|
||||
|
||||
while (1) {
|
||||
sleep 30;
|
||||
|
||||
foreach my $variabile (keys %proc) {
|
||||
$puntatore = $proc{$variabile};
|
||||
if(!$puntatore or !$puntatore->is_running ) {
|
||||
print "Rilevato termine processo $variabile\n" if ($verbose);
|
||||
delete $proc{$variabile};
|
||||
#$puntatore->join();
|
||||
|
||||
if ($variabile eq "database") {
|
||||
$proc{'database'} = threads->create(\&database);
|
||||
} else {
|
||||
$query = "SELECT id, ip, port FROM proxy_conn WHERE nome = '$variabile'";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
$ref = $sts->fetchrow_hashref;
|
||||
my $id = $$ref{'id'};
|
||||
my $ip = $$ref{'ip'};
|
||||
my $port = $$ref{'port'};
|
||||
$proc{$variabile} = threads->create(\&conntrack, $id, $ip, $port);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit;
|
||||
|
||||
sub conntrack {
|
||||
my $sess_id = shift;
|
||||
my $proxy_IP = shift;
|
||||
my $proxy_PORT = shift;
|
||||
|
||||
$SIG{INT} = \&end;
|
||||
|
||||
my $conta = 0;
|
||||
|
||||
print "Attivato agente $sess_id su $proxy_IP:$proxy_PORT\n" if ($verbose);
|
||||
|
||||
my $proc_id = open CT, "/usr/sbin/conntrack -E -eNEW,DESTROY -otimestamp,id -p tcp -d $proxy_IP --dport $proxy_PORT 2>/dev/null |" or die "non va\n";
|
||||
|
||||
while (<CT>) {
|
||||
my $riga = $_;
|
||||
|
||||
if ( $riga =~ /^\s*\[(\d+)\.\d+\]\s+\[NEW\] tcp\s+\d+ \d+ \S*\s*src=(\S+) dst=(\S+) sport=\d+ dport=(\d+)\s+\[\w+\] src=\S+ dst=\S+ sport=\d+ dport=\d+ id=(\d+)/ ) {
|
||||
my $remote_START = $1;
|
||||
my $remote_IP = $2;
|
||||
my $local_IP = $3;
|
||||
my $local_PORT = $4;
|
||||
my $thread_ID = $5;
|
||||
|
||||
my $query = " INSERT INTO
|
||||
proxy_dati
|
||||
(ip, thread, data_new)
|
||||
VALUES
|
||||
('$remote_IP', $thread_ID, FROM_UNIXTIME($remote_START))
|
||||
";
|
||||
|
||||
$sem1->down();
|
||||
$queryDB = $query;
|
||||
$sem2->up();
|
||||
print "Invio query INSERT\n" if ($verbose > 1);
|
||||
|
||||
if (!grep( /^$remote_IP$/, @listaip )) {
|
||||
$sem1->down();
|
||||
$queryDB = "INSERT INTO proxy_pool (ip,pool,attivo,ins) VALUE ('$remote_IP', 1, 0,now())";
|
||||
$sem2->up();
|
||||
push @listaip, $remote_IP;
|
||||
print "Invio query INSERT in proxy_pool\n" if ($verbose > 1);
|
||||
}
|
||||
}
|
||||
|
||||
if ( $riga =~ /^\s*\[(\d+)\.\d+\]\s+\[DESTROY\] tcp\s+\d+ src=(\S+) dst=(\S+) sport=\d+ dport=(\d+) packets=\d+ bytes=(\d+) src=\S+ dst=\S+ sport=\d+ dport=\d+ packets=\d+ bytes=(\d+) \[\w+\] id=(\d+)/) {
|
||||
my $remote_DESTROY = $1;
|
||||
my $remote_IP = $2;
|
||||
my $local_IP = $3;
|
||||
my $local_PORT = $4;
|
||||
my $remote_SEND = $5;
|
||||
my $remote_RECEIVE = $6;
|
||||
my $thread_ID = $7;
|
||||
|
||||
$conta++;
|
||||
printf ("$conta/$limit_thread - $sess_id - IP: %-15s - ID: %-12s - Inviati: %10d - Ricevuti: %10d\n", $remote_IP, $thread_ID, $remote_SEND, $remote_RECEIVE) if ($verbose);
|
||||
|
||||
my $query = " UPDATE
|
||||
proxy_dati
|
||||
SET
|
||||
data_destroy = FROM_UNIXTIME($remote_DESTROY),
|
||||
inviati = $remote_SEND,
|
||||
ricevuti = $remote_RECEIVE,
|
||||
tempo = TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY)),
|
||||
vel_inv = $remote_SEND / TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY)),
|
||||
vel_ric = $remote_RECEIVE / TIMESTAMPDIFF(SECOND, data_new, FROM_UNIXTIME($remote_DESTROY))
|
||||
WHERE
|
||||
thread = $thread_ID
|
||||
AND
|
||||
ip = '$remote_IP'
|
||||
AND
|
||||
data_destroy = '1970-01-01 00:00:00'
|
||||
";
|
||||
|
||||
$sem1->down();
|
||||
$queryDB = $query;
|
||||
$sem2->up();
|
||||
print "Invio query UPDATE\n" if ($verbose > 1);
|
||||
}
|
||||
if ($conta >= $limit_thread) {
|
||||
last;
|
||||
}
|
||||
}
|
||||
kill 9, $proc_id;
|
||||
return;
|
||||
}
|
||||
|
||||
sub database {
|
||||
print "Attivato thread DB\n" if ($verbose);
|
||||
|
||||
$dbmysql = DBConn ();
|
||||
|
||||
while (1) {
|
||||
print "DB in attesa\n" if ($verbose > 1);
|
||||
$sem2->down();
|
||||
print "Query arrivata\n" if ($verbose > 1);
|
||||
|
||||
if ( not $dbmysql->ping ) {
|
||||
$dbmysql = DBConn ();
|
||||
}
|
||||
|
||||
my $sts = $dbmysql->prepare($queryDB);
|
||||
$sts->execute ();
|
||||
|
||||
$sts->finish;
|
||||
$sem1->up();
|
||||
}
|
||||
}
|
||||
|
||||
sub DBConn {
|
||||
print "Connessione DB\n" if ($verbose > 1);
|
||||
my $dbmysql = DBI->connect("DBI:mysql:;host=$DBhost", $DBuser, $DBpass, {PrintError => 0, RaiseError => 0, AutoCommit =>1, mysql_auto_reconnect=>1} ) or die ($DBI::errstr);
|
||||
$sts = $dbmysql->prepare("use $DBname");
|
||||
$sts->execute ();
|
||||
|
||||
return $dbmysql;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
our $DBhost = '';
|
||||
our $DBname = '';
|
||||
our $DBuser = '';
|
||||
our $DBpass = '';
|
||||
|
||||
return 1;
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
view_top();
|
||||
|
||||
$conf_route = carica_conf('Routing');
|
||||
?>
|
||||
|
||||
<?php print_r ($conf_route); ?>
|
||||
|
||||
|
||||
|
||||
<?php view_footer(); ?>
|
||||
Reference in New Issue
Block a user