This commit is contained in:
cmaffio
2015-10-14 10:59:50 +02:00
parent a158016e78
commit 6c42d75681
53 changed files with 363 additions and 877 deletions

245
remove/moddefrule.php Executable file
View File

@@ -0,0 +1,245 @@
<?php
include_once ("core/config.php");
$UTENTE = login();
//isadmin();
?>
<?php include_once ("top.php"); ?>
<?php
if (isset($_GET['id'])) {
$id = $_GET['id'];
$device = $_GET['device'];
if (isset($_GET['azione'])) {
switch ($_GET['azione']) {
case "attiva":
$risultato = defrule_att($id);
break;
case "disattiva":
$risultato = defrule_dis($id);
break;
case "rm":
$query = "UPDATE `defrule` SET stato=3, attivo=0 WHERE `id`=$id";
if (mysql_query( $query, $DB_ID )) {
$query_rule = "DELETE FROM rule WHERE iddefrule = $id";
if (mysql_query( $query_rule, $DB_ID )) {
$risultato = 1;
azioni ("defrule", $id, 3);
}
} else {
$risultato = "Non e' stato possibile eseguire l'operazione richiesta a causa di un errore: ".mysql_error();
}
break;
}
if ($risultato == 1) { ?>
<script type="text/javascript">
document.location.href='defrule.php?id=<?php print $device ?>'
</script>
<?php }
?>
<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 print $risultato ?></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 = 'defrule.php?id=<?php print $device ?>';"></button></td></tr>
<tr><td><img src="img/spazio.gif" width="1" height="10" alt=""></td></tr>
</table>
<?php
}
$bottone = "Modifica";
$modifica = 1;
$query = "SELECT * FROM defrule WHERE id =".$_GET['id'];
$res = mysql_query( $query, $DB_ID );
$dato = mysql_fetch_array ( $res );
$iddevice = $dato['idinterfacce'];
$parent = creanome ($_GET['id']);
$limitirate = maxrate ($id, $dato['idparent'], $iddevice);
$attivo = $dato['attivo'];
} else if (isset ($_POST['id'])) {
$modifica = 2;
$id = $_POST['id'];
$attivo = $_POST['attivo'];
$device = $_POST['device'];
$iddevice = $device;
$idparent = $_POST['idparent'];
$descrizione = $_POST['descrizione'];
$priorita = $_POST['priorita'];
$rate = $_POST['rate'];
$ceil = $_POST['ceil'];
if ($id > 0) {
$testo = "L'interfaccia e' stata correttamente aggiornata";
$query = "UPDATE `defrule` SET `descrizione`='$descrizione', `priorita`=$priorita, `rate`=$rate, `ceil`=$ceil, `attivo`=$attivo WHERE `id`=$id";
} else {
$testo = "L'interfaccia e' stata correttamente inserita";
$query = "INSERT INTO `defrule` SET idinterfacce=$device, `idparent`=$idparent, `descrizione`='$descrizione', `priorita`=$priorita, `rate`=$rate, `ceil`=$ceil, `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 ($attivo) {
azioni ("defrule", $id, 2);
}
?>
<?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 } ?>
</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 = 'defrule.php?id=<?php print $device ?>';"></button></td>
</tr>
<tr>
<td><img src="img/spazio.gif" width="1" height="10" alt=""></td>
</tr>
</table>
<?php
} else {
$bottone = "Aggiungi";
$modifica = 0;
$idparent = $_GET['idparent'];
if ($idparent == 0) {
$iddevice = $_GET['device'];
$querydev = "SELECT device FROM interfacce WHERE id = $iddevice";
$resdev = mysql_query( $querydev, $DB_ID );
$datodev = mysql_fetch_array ( $resdev );
$device = $datodev['device'];
$parent = $device."-2";
} else {
$iddevice = $_GET['device'];
$parent = creanome ($idparent);
}
$limitirate = maxrate (-1, $idparent, $iddevice);
$dato['rate'] = $limitirate['rate'];
$dato['ceil'] = $limitirate['ceil'];
$dato['priorita'] = $limitirate['pri'];
}
?>
<?php if (($modifica == 0 || $modifica == 1) && !isset($_GET['azione'])) { ?>
<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",
priorita: {
required: true,
max: 999,
},
rate: {
required: true,
min: 0.001,
max: <?php print $limitirate['rate'] ?>,
},
ceil: {
required: true,
max: <?php print $limitirate['ceil'] ?>,
},
},
messages: {
descrizione: "<br>Inserisci la descrizione!",
device: "<br>Inserire il nome del device!",
rate: "<br>Immettere un valore compreso fra 0.001 e <?php print $limitirate['rate'] ?>",
ceil: "<br>Immettere un valore minore di <?php print $limitirate['ceil'] ?>",
}
});
});
</script>
<form action="moddefrule.php" method="post" id="modulo" name="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 } ?>
<input type="hidden" name="idparent" value="<?php print $idparent ?>">
<input type="hidden" name="device" value="<?php print $iddevice ?>">
<tr>
<td><img src="img/spazio.gif" width="80" height="1" alt=""></td>
<td class="campo" width="110">Parent</td>
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
<td class="valore" width="200"><?php print $parent?></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['attivo'] ?>"></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">Priorita'</td>
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
<?php if ($dato['priorita'] < 1000) { ?>
<td class="valore" width="180"><input class="valore" type="text" name="priorita" id="priorita" size="5" maxlength="10" value="<?php print $dato['priorita'] ?>"></td>
<?php } else { ?>
<td class="valore" width="180"><?php print $dato['priorita'] ?></td>
<input type="hidden" name="priorita" value="<?php print $dato['priorita'] ?>">
<?php } ?>
<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>(Max. <?php print $limitirate['rate'] ?> Mb/sec)</td>
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
<td class="valore" width="150"><input class="valore" type="text" name="rate" id="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>(Max. <?php print $limitirate['ceil'] ?> Mb/sec)</td>
<td><img src="img/spazio.gif" width="10" height="1" alt=""></td>
<td class="valore" width="180"><input class="valore" type="text" name="ceil" id="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 ?>">
&nbsp;&nbsp;&nbsp;
<input type="button" value="Annulla" onclick="location.href = 'defrule.php?id=<?php print $iddevice ?>';"></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"); ?>