Files
pannello/firewall/index.php
2016-06-16 17:04:05 +02:00

133 lines
3.4 KiB
PHP
Executable File

<?php
include_once ("../core/config.php");
include_once ("firewall_library.php");
$UTENTE = login();
$DIRITTI = diritti('Utente');
view_top();
if (isset($_POST['utente'])) {
$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;
}
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 );
}
if ($modificato) genera();
}
$tabella = new html (0,"90%",array(15,2,20,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 ();
$query = " SELECT
firewall_versoesterno_regole.id,
firewall_versoesterno_regole.stato,
firewall_versoesterno.nome,
firewall_versoesterno_regole.permanente
FROM
firewall_versoesterno_regole
JOIN
utenti
ON
firewall_versoesterno_regole.id_utenti = utenti.id
AND
utenti.id = ".$UTENTE['id']."
JOIN
firewall_versoesterno
ON
firewall_versoesterno_regole.id_firewall_versoesterno = firewall_versoesterno.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">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['nome'] ?></td>
<td class="textc"><?php if ($dato['permanente']) print "Si"; else print "No"; ?></td>
</tr>
<?php
$tabella->riga ();
} ?>
</form>
<?php
$tabella->close ();
view_footer();
?>