Inizializzazione progetto pannello

This commit is contained in:
cmaffio
2017-08-11 14:46:38 +02:00
parent d9f2a18a05
commit 1ee0356a30
10 changed files with 0 additions and 897 deletions

View File

@@ -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();
?>

View File

@@ -1,6 +0,0 @@
our $DBhost = '127.0.0.1';
our $DBname = 'pannello_vbc';
our $DBuser = 'pannello_proxy';
our $DBpass = 'CuQlM1lfF4VZDCIP';
return 1;

View File

@@ -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;