196 lines
6.9 KiB
PHP
Executable File
196 lines
6.9 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 interfacce WHERE id =".$_GET['id'];
|
|
$res = mysql_query( $query, $DB_ID );
|
|
$dato = mysql_fetch_array ( $res );
|
|
$query_limiti = "SELECT SUM(rate) AS rate, MAX(ceil) AS ceil FROM defrule WHERE idparent = 0 AND idinterfacce = ".$_GET['id'];
|
|
$res_limiti = mysql_query( $query_limiti, $DB_ID );
|
|
$dato_limiti = mysql_fetch_array ( $res_limiti );
|
|
$min_rate = $dato_limiti['rate'];
|
|
$min_ceil = $dato_limiti['ceil'];
|
|
} else if (isset ($_POST['id'])) {
|
|
$modifica = 2;
|
|
$id = $_POST['id'];
|
|
$device = $_POST['device'];
|
|
$descrizione = $_POST['descrizione'];
|
|
$attivo = $_POST['attivo'];
|
|
$rate = $_POST['rate'];
|
|
$ceil = $_POST['ceil'];
|
|
$inout = $_POST['inout'];
|
|
|
|
if ($id > 0) {
|
|
$testo = "L'interfaccia e' stata correttamente aggiornata";
|
|
$query = "UPDATE `interfacce` SET `device`='$device', `descrizione`='$descrizione', `rate`=$rate, `ceil`=$ceil, `inout`='$inout', `stato`=2 WHERE `id`=$id";
|
|
} else {
|
|
$testo = "L'interfaccia e' stata correttamente inserita";
|
|
$query = "INSERT INTO `interfacce` SET `device`='$device', `descrizione`='$descrizione', `rate`=$rate, `ceil`=$ceil, `inout`='$inout', `stato`=1, `attivo`=0";
|
|
}
|
|
?>
|
|
<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 )) {
|
|
if ($id > 0) {
|
|
if ($attivo) {
|
|
azioni ("interfacce", $id, 2);
|
|
}
|
|
} else {
|
|
$iddevice = mysql_insert_id ($DB_ID);
|
|
$querydefrule = "INSERT INTO `defrule` SET `idparent`=0, `idinterfacce`=$iddevice, `descrizione`='DEFAULT', `priorita`=1000, `rate`=$rate, `ceil`=$ceil, `stato`=1, `default`=1, `attivo`=0";
|
|
mysql_query( $querydefrule, $DB_ID );
|
|
}
|
|
?>
|
|
<?php print $testo ?><br>
|
|
<?php } else { ?>
|
|
Non e' stato possibile eseguire l'operazione richiesta a causa di un errore: <?php print mysql_error() ?><br>
|
|
<?php print $query ?><br>
|
|
<?php } ?>
|
|
</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 = 'device.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="moddevice.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><img src="img/spazio.gif" width="80" height="1" alt=""></td>
|
|
<td class="campo" width="110">Device</td>
|
|
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
|
|
<td class="valore" width="200"><input type="text" id="device" name="device" size="10" maxlength="20" value="<?php print $dato['device']?>"></td>
|
|
<td><img src="img/spazio.gif" width="310" height="1" alt=""></td>
|
|
<td colspan=4><input type="hidden" name="attivo" value="<?php print $dato['stato'] ?>"></td>
|
|
</tr>
|
|
|
|
<tr><td colspan="9"><img src="img/spazio.gif" width="1" height="5" alt=""></td></tr>
|
|
<tr>
|
|
<td class="col1" colspan="9">
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
<tr>
|
|
<td><img src="img/spazio.gif" width="40" height="1" alt=""></td>
|
|
<td class="campo" width="200">Descrizione</td>
|
|
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
|
|
<td class="valore" width="150"><input class="valore" type="text" name="descrizione" id="descrizione" size="30" maxlength="128" value="<?php print $dato['descrizione'] ?>"></td>
|
|
<td><img src="img/spazio.gif" width="110" height="1" alt=""></td>
|
|
<td class="campo" width="150">Posizione</td>
|
|
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
|
|
<?php
|
|
if ($dato['inout'] == 'interna') {
|
|
$checkin = "selected";
|
|
$checkout = "";
|
|
} else {
|
|
$checkin = "";
|
|
$checkout = "selected";
|
|
} ?>
|
|
<td class="valore" width="180">
|
|
<select name='inout'>
|
|
<option name='inout' value='interna' <?php print $checkin ?>>Interna</option>
|
|
<option name='inout' value='esterna' <?php print $checkout ?>>Esterna</option>
|
|
</select>
|
|
</td>
|
|
<td><img src="img/spazio.gif" width="50" height="1" alt=""></td>
|
|
</tr>
|
|
<tr><td colspan="9" class="spaziov"><img src="img/spazio.gif" width="1" alt=""></td></tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr><td colspan="9"><img src="img/spazio.gif" width="1" height="5" alt=""></td></tr>
|
|
<tr>
|
|
<td class="col1" colspan="9">
|
|
<table cellpadding="0" cellspacing="0" border="0" width="100%">
|
|
<tr>
|
|
<td colspan="9">Limitazioni</td>
|
|
</tr>
|
|
<tr>
|
|
<td><img src="img/spazio.gif" width="40" height="1" alt=""></td>
|
|
<td class="campo" width="200">Banda Garantita<br>(Min. <?php print $min_rate?>)</td>
|
|
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
|
|
<td class="valore" width="150"><input class="valore" id="rate" type="text" name="rate" size="5" maxlength="10" value="<?php print $dato['rate'] ?>"> Mb/sec</td>
|
|
<td><img src="img/spazio.gif" width="110" height="1" alt=""></td>
|
|
<td class="campo" width="150">Banda Massima<br>(Min. <?php print $min_ceil?>)</td>
|
|
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
|
|
<td class="valore" width="180"><input class="valore" id="ceil" type="text" name="ceil" size="5" maxlength="10" value="<?php print $dato['ceil'] ?>"> Mb/sec</td>
|
|
<td><img src="img/spazio.gif" width="50" height="1" alt=""></td>
|
|
</tr>
|
|
<tr><td colspan="9" class="spaziov"><img src="img/spazio.gif" width="1" alt=""></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 ?>">
|
|
|
|
<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"); ?>
|