modulo condes

This commit is contained in:
cmaffio
2016-05-27 17:20:28 +02:00
parent 691a64e13a
commit 75adb3e6a1
5 changed files with 516 additions and 45 deletions

View File

@@ -7,50 +7,70 @@ view_top();
if (isset($_POST['utente'])) {
$utente = $_POST['utente'];
print "-- $utente --<br>";
$old = $new = array();
foreach ($_POST as $id => $valore) {
if ($id == "utente") continue;
print "---- $id => $valore<br>";
if (preg_match ("/^new-(\d+)/", $id, $ris)) $new[$ris[1]] = $valore;
if (preg_match ("/^old-(\d+)/", $id, $ris)) $old[$ris[1]] = $valore;
}
$query = " SELECT
proxy_acl_ip.id
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
JOIN
proxy_acl_ip
ON
proxy_acl_ip.idacllist = condes_regole.id_proxy_acl_list
AND
proxy_acl_ip.idpool = condes_macchine.id_proxy_pool
condes_regole.id_condes_macchine = condes_macchine.id
WHERE
condes_regole.id = $id
";
$res = mysql_query( $query, $DB_ID );
$dato = mysql_fetch_array ( $res );
print_r ($dato);
print "<br>";
$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 );
}
$query = " INSERT INTO
condes_regole
SET
id_utenti = $id_utenti,
id_condes_macchine = $id_macchine,
id_proxy_acl_list = $id_acl,
permanente = $perm,
data = NOW(),
attivo = 1
";
// $res = mysql_query( $query, $DB_ID );
}
$tabella = new html (0,"90%",array(15,2,20,2,15,2,5,0));
@@ -67,6 +87,7 @@ $tabella->riga ();
$query = " SELECT
condes_regole.id,
condes_regole.stato,
proxy_pool.nome,
proxy_pool.ip,
proxy_acl_list.nome AS acl,
@@ -103,11 +124,12 @@ while ($dato = mysql_fetch_array ( $res )) {
?>
<tr>
<td rowspan=2 class="textl">
<select name="<?php print $dato['id'] ?>">
<option value="0">Disattivo</option>
<option value="1">Attivo</option>
<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">Permanente</option>
<option value="2" <?php if ($dato['stato'] == 2 ) print "selected" ?>>Permanente</option>
<?php } ?>
</select>
</td>
@@ -118,7 +140,6 @@ while ($dato = mysql_fetch_array ( $res )) {
<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>
</td>
</tr>
<tr>
<td class="textl"><?php print $dato['ip']; if ($dato['nome'] != "") print "(".$dato['nome'].")" ?></td>