Files
pannello/remove/modcluster.php
2015-10-14 10:59:50 +02:00

184 lines
6.2 KiB
PHP
Executable File

<?php
include_once ("core/config.php");
$UTENTE = login();
isadmin();
?>
<?php include_once ("top.php"); ?>
<?php
if (isset($_GET['id'])) {
$bottone = "Modifica";
$modifica = 1;
$query = "SELECT * FROM indirizzi WHERE id =".$_GET['id'];
$res = mysql_query( $query, $DB_ID );
$dato = mysql_fetch_array ( $res );
} else if (isset ($_POST['id'])) {
$modifica = 2;
$id = $_POST['id'];
$ip = $_POST['ip'];
$netmask = $_POST['netmask'];
if (defined ($_POST['attivo'])) {
$attivo = $_POST['attivo'];
} else {
$attivo = 0;
}
$idfirewall = $_POST['idfirewall'];
$idinterfaccia = $_POST['idinterfaccia'];
$vf = $_POST['vf'];
$commento = $_POST['commento'];
if ($id > 0) {
$testo = "L'indirizzo IP e' stato correttamente aggiornata";
$query = "UPDATE indirizzi SET ip='$ip', netmask = $netmask, attivo = $attivo, idfirewall = $idfirewall, idinterfaccia = $idinterfaccia, commento = '$commento' WHERE `id`=$id";
} else {
$testo = "L'indirizzo IP e' stato correttamento inserito";
$query = "INSERT INTO indirizzi SET ip='$ip', netmask = $netmask, attivo = $attivo, idfirewall = $idfirewall, idinterfaccia = $idinterfaccia, vf = 0, commento = '$commento'";
}
?>
<table cellpadding="0" cellspacing="0" border="0" width="90%">
<tr>
<td><img src="img/spazio.gif" width="1" height="10" alt=""><td>
</tr>
<tr>
<td>
<?php if (mysql_query( $query, $DB_ID )) {
print $testo."<br>";
print $query."<br>";
} else {
print "Non e' stato possibile eseguire l'operazione richiesta a causa di un errore: ".mysql_error()."<br>";
print $query."<br>";
} ?>
</td>
</tr>
<tr>
<td><img src="img/spazio.gif" width="1" height="5" alt=""></td>
</tr>
<tr>
<td><input type="button" value="Ok" onclick="location.href = 'cluster.php';"></button></td>
</tr>
<tr>
<td><img src="img/spazio.gif" width="1" height="10" alt=""></td>
</tr>
</table>
<?php
} else {
$bottone = "Aggiungi";
$modifica = 0;
}
?>
<?php if (($modifica == 0 || $modifica == 1) && !isset($_GET['rm'])) { ?>
<script type="text/javascript" src="jquery/jquery.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#modulo").validate( {
rules: {
descrizione: "required",
device: "required",
rate: {
required: true,
min: <?php print $min_rate ?>,
},
ceil: {
required: true,
min: <?php print $min_ceil ?>,
},
},
messages: {
descrizione: "<br>Inserisci la descrizione!",
device: "<br>Immettereil nome del device",
rate: "<br>Immettere un valore non minore di <?php print $min_rate ?>",
ceil: "<br>Immettere un valore non minore di <?php print $min_ceil ?>",
}
});
});
</script>
<form action="modcluster.php" method="post" id="modulo">
<table cellpadding="0" cellspacing="0" border="0" width="90%">
<?php if ($modifica == 1) { ?>
<input type="hidden" name="id" value="<?php print $dato['id'] ?>">
<?php } else { ?>
<input type="hidden" name="id" value="-1">
<?php } ?>
<tr>
<td width="20"><img src="img/spazio.gif" width="20" height="1" alt=""></td>
<td class="campo" width="20">IP</td>
<td class="valore" width="100"><input type="text" id="ip" name="ip" size="15" maxlength="15" value="<?php print $dato['ip']?>"></td>
<td width="30"><img src="img/spazio.gif" width="30" height="1" alt=""></td>
<td class="campo" width="80">Netmask</td>
<td class="valore" width="100"><input type="text" id="netmask" name="netmask" size="2" maxlength="2" value="<?php print $dato['netmask']?>"></td>
<td width="300"><img src="img/spazio.gif" width="30" height="1" alt=""></td>
<td>Attivo<input name="attivo" type="checkbox" value=1 <?php if ($dato['attivo']) { print "checked=\"checked\""; } ?>></td>
</tr>
<tr><td colspan="8"><img src="img/spazio.gif" width="1" height="5" alt=""></td></tr>
<tr>
<td class="col1" colspan="8">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20"><img src="img/spazio.gif" width="20" height="1" alt=""></td>
<td class="campo" width="150">Firewall di default</td>
<td class="valore" width="50">
<select name='idfirewall'>
<option name='idfirewall' value='0'>Seleziona</option>
<?php
$queryfw = "SELECT id, nome FROM firewall WHERE id > 0 ORDER BY nome";
$resfw = mysql_query( $queryfw, $DB_ID );
while ($datofw = mysql_fetch_array ($resfw)) {
?>
<option name='idfirewall' value='<?php print $datofw['id']?>' <?php if ($dato['idfirewall'] == $datofw['id']) {print "selected";}?>><?php print $datofw['nome'] ?></option>
<?php } ?>
</select>
</td>
<td width="60"><img src="img/spazio.gif" width="60" height="1" alt=""></td>
<td class="campo" width="100">Interfaccia</td>
<td width="50">
<select name='idinterfaccia'>
<option name='idinterfaccia' value='0'>Seleziona</option>
<?php
$queryfw = "SELECT id, device FROM interfacce WHERE attivo = 1 ORDER BY device";
$resfw = mysql_query( $queryfw, $DB_ID );
while ($datofw = mysql_fetch_array ($resfw)) {
?>
<option name='idinterfaccia' value='<?php print $datofw['id']?>' <?php if ($dato['idinterfaccia'] == $datofw['id']) {print "selected";}?>><?php print $datofw['device'] ?></option>
<?php } ?>
</select>
</td>
<td><img src="img/spazio.gif"></td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="8"><img src="img/spazio.gif" width="1" height="5" alt=""></td></tr>
<tr>
<td class="col1" colspan="8">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="20"><img src="img/spazio.gif" width="20" height="1" alt=""></td>
<td class="campo" width="150">Descrizione</td>
<td class="valore" width="300"><input class="valore" type="text" name="commento" id="commento" size="60" maxlength="128" value="<?php print $dato['commento'] ?>"></td>
<td><img src="img/spazio.gif"></td>
</tr>
</table>
</td>
</tr>
<tr><td colspan="9"><img src="img/spazio.gif" width="1" height="5" alt=""></td></tr>
<tr><td align="center" colspan="9">
<input type="submit" value="<?php print $bottone ?>">
&nbsp;&nbsp;&nbsp;
<input type="button" value="Annulla" onclick="location.href = 'device.php';"></button>
</td></tr>
<tr><td colspan="9"><img src="img/spazio.gif" width="1" height="10" alt=""></td></tr>
</table>
</form>
<?php } ?>
<?php include_once ("footer.php"); ?>