Sviluppo forward in firewall
This commit is contained in:
145
firewall/firewall_gest.php
Executable file
145
firewall/firewall_gest.php
Executable file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
function confirmation(testo) {
|
||||
alert(testo)
|
||||
document.location.href='main.php'
|
||||
}
|
||||
//-->
|
||||
</script>
|
||||
|
||||
<?php
|
||||
if (isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
if (isset($_GET['azione'])) {
|
||||
$azione = $_GET['azione'];
|
||||
$genera = 0;
|
||||
switch ($azione) {
|
||||
case "macchina_rm":
|
||||
$query = "DELETE FROM firewall_macchine WHERE id = $id";
|
||||
$testo = "Confermate la rimozione della macchina da quelle disponibili?";
|
||||
break;
|
||||
case "macchina_up":
|
||||
$query = "UPDATE firewall_macchine SET attivo = 1 WHERE id = $id";
|
||||
$testo = "Confermate l'attivazione della macchina?";
|
||||
break;
|
||||
case "macchina_down":
|
||||
$query = "UPDATE firewall_macchine SET attivo = 0 WHERE id = $id";
|
||||
$testo = "Confermate la disattivazione della macchina?";
|
||||
break;
|
||||
|
||||
case "macchina_ext_rm":
|
||||
$query = "DELETE FROM firewall_macchine_ext WHERE id = $id";
|
||||
$testo = "Confermate la rimozione della macchina da quelle disponibili?";
|
||||
break;
|
||||
case "macchina_ext_up":
|
||||
$query = "UPDATE firewall_macchine_ext SET attivo = 1 WHERE id = $id";
|
||||
$testo = "Confermate l'attivazione della macchina?";
|
||||
break;
|
||||
case "macchina_ext_down":
|
||||
$query = "UPDATE firewall_macchine_ext SET attivo = 0 WHERE id = $id";
|
||||
$testo = "Confermate la disattivazione della macchina?";
|
||||
break;
|
||||
|
||||
case "regolaext_rm":
|
||||
$query = "DELETE FROM firewall_versoesterno WHERE id = $id";
|
||||
$testo = "Confermate la rimozione della regola da quelle disponibili?";
|
||||
break;
|
||||
case "regolaext_up":
|
||||
$query = "UPDATE firewall_versoesterno SET attivo = 1 WHERE id = $id";
|
||||
$testo = "Confermate l'attivazione della regola?";
|
||||
break;
|
||||
case "regolaext_down":
|
||||
$query = "UPDATE firewall_versoesterno SET attivo = 0 WHERE id = $id";
|
||||
$testo = "Confermate la disattivazione della regola?";
|
||||
break;
|
||||
|
||||
case "regolaversoext_rm":
|
||||
$query = "DELETE FROM firewall_versoesterno_regole WHERE id = $id";
|
||||
$testo = "Confermate la rimozione della regola da quelle disponibili?";
|
||||
break;
|
||||
case "regolaversoext_up":
|
||||
$query = "UPDATE firewall_versoesterno_regole SET attivo = 1 WHERE id = $id";
|
||||
$testo = "Confermate l'attivazione della regola?";
|
||||
break;
|
||||
case "regolaversoext_down":
|
||||
$query = "UPDATE firewall_versoesterno_regole SET attivo = 0 WHERE id = $id";
|
||||
$testo = "Confermate la disattivazione della regola?";
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
$testo = "Regola non implementata";
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($_GET['ref'])) {
|
||||
$ref = pack ('H*', $_GET['ref']);
|
||||
mysql_query( $query, $DB_ID );
|
||||
if ($genera) genera($DB_ID);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
document.location.href="<?php print $ref ?>"
|
||||
</script>
|
||||
<?php } else {
|
||||
$ref = unpack ('H*', $_SERVER["HTTP_REFERER"]);
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
var r = confirm("<?php print $testo ?>");
|
||||
if (r == true) {
|
||||
document.location.href="<?php print $_SERVER['REQUEST_URI']?>&ref=<?php print $ref[1] ?>"
|
||||
} else {
|
||||
document.location.href="<?php print $_SERVER['HTTP_REFERER']?>"
|
||||
}
|
||||
</script>
|
||||
<?php }
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
function genera ($DB_ID) {
|
||||
$file = 'squid_acl/listip';
|
||||
$fp = fopen($file, 'w');
|
||||
|
||||
$query = "SELECT ip FROM proxy_pool WHERE attivo = 1 AND pool = 1";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
fwrite($fp, $dato['ip']."\n");
|
||||
}
|
||||
fclose($fp);
|
||||
exec ("sudo /opt/squid/sbin/squid -k reconfigure");
|
||||
remote ($DB_ID);
|
||||
}
|
||||
|
||||
function remote ($DB_ID) {
|
||||
$query = " SELECT
|
||||
host,
|
||||
port,
|
||||
usr,
|
||||
pwd,
|
||||
path,
|
||||
command
|
||||
FROM
|
||||
proxy_remote
|
||||
WHERE
|
||||
attivo = 1
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
$connection = ssh2_connect($dato['host'], $dato['port']);
|
||||
ssh2_auth_password($connection, $dato['usr'], $dato['pwd']);
|
||||
|
||||
ssh2_scp_send($connection, 'squid_acl/listip', $dato['path'].'/listip', 0644);
|
||||
$stream = ssh2_exec($connection, $dato['command']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
101
firewall/firewall_macchine.php
Executable file
101
firewall/firewall_macchine.php
Executable file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['id'])) {
|
||||
$id = $_POST['id'];
|
||||
$query = " INSERT INTO
|
||||
firewall_macchine
|
||||
SET
|
||||
id_proxy_pool = $id,
|
||||
data = NOW(),
|
||||
attivo = 1
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
id,
|
||||
ip,
|
||||
nome
|
||||
FROM
|
||||
proxy_pool
|
||||
WHERE
|
||||
id NOT IN (SELECT id_proxy_pool FROM firewall_macchine)
|
||||
ORDER BY
|
||||
-nome DESC,
|
||||
INET_ATON(ip) ASC
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
|
||||
$tabella = new html (0,"90%",array(3,3,2,15,2,15,2,15,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<tr>
|
||||
<td colspan=3 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="spazioh"><input type="image" src="<?php print $CONF['base_url'] ?>/img/addresource.png" border="0" alt="Inserisci" /></td>
|
||||
<td colspan=4 class="spazioh">
|
||||
<select name="id">
|
||||
<option value="" selected="selected">---</option>
|
||||
<?php while ($dato = mysql_fetch_array ( $res )) { ?>
|
||||
<option value="<?php print $dato['id'] ?>"><?php print $dato['nome']." - ".$dato['ip'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
$query = " SELECT
|
||||
firewall_macchine.id,
|
||||
firewall_macchine.data,
|
||||
firewall_macchine.attivo,
|
||||
proxy_pool.ip,
|
||||
proxy_pool.nome
|
||||
FROM
|
||||
firewall_macchine
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
firewall_macchine.id_proxy_pool = proxy_pool.id
|
||||
ORDER BY
|
||||
INET_ATON(ip) ASC
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="col3btn">
|
||||
<?php if ($dato['attivo']) { ?>
|
||||
<a href="firewall_gest.php?azione=macchina_down&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="IP attivo" TITLE="IP attivo"></a>
|
||||
<?php } else { ?>
|
||||
<a href="firewall_gest.php?azione=macchina_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="IP non attivo" TITLE="IP non attivo"></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><a href="firewall_gest.php?azione=macchina_rm&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/trash.png"></a></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">IP</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Nome</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Ultima Modifica</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="colip"><?php print $dato['ip'] ?></td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colip"><?php print $dato['nome'] ?></td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colip"><?php print $dato['data'] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga ();
|
||||
}
|
||||
$tabella->close();
|
||||
view_footer();
|
||||
?>
|
||||
83
firewall/firewall_macchine_ext.php
Executable file
83
firewall/firewall_macchine_ext.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['ip'])) {
|
||||
$ip = $_POST['ip'];
|
||||
$nome = $_POST['nome'];
|
||||
$query = " INSERT INTO
|
||||
firewall_macchine_ext
|
||||
SET
|
||||
ip = '$ip',
|
||||
nome = '$nome',
|
||||
data = NOW(),
|
||||
attivo = 1
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
|
||||
$tabella = new html (0,"90%",array(3,3,2,15,2,15,2,15,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<tr>
|
||||
<td rowspan=2 colspan=3 class="spazioh"><input type="image" src="<?php print $CONF['base_url'] ?>/img/addresource.png" border="0" alt="Inserisci" /></td>
|
||||
<td class="descrizione">IP</td>
|
||||
<td rowspan=2 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Nome</td>
|
||||
<td rowspan=2 colspan=3 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="colip"><input type="text" size="15" name="ip"></td>
|
||||
<td class="colip"><input type="text" size="30" name="nome"></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
$tabella->riga();
|
||||
$query = " SELECT
|
||||
id,
|
||||
data,
|
||||
attivo,
|
||||
ip,
|
||||
nome
|
||||
FROM
|
||||
firewall_macchine_ext
|
||||
ORDER BY
|
||||
INET_ATON(ip) ASC
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="col3btn">
|
||||
<?php if ($dato['attivo']) { ?>
|
||||
<a href="firewall_gest.php?azione=macchina_ext_down&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="IP attivo" TITLE="IP attivo"></a>
|
||||
<?php } else { ?>
|
||||
<a href="firewall_gest.php?azione=macchina_ext_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="IP non attivo" TITLE="IP non attivo"></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><a href="firewall_gest.php?azione=macchina_ext_rm&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/trash.png"></a></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">IP</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Nome</td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Ultima Modifica</td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="colip"><?php print $dato['ip'] ?></td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colip"><?php print $dato['nome'] ?></td>
|
||||
<td class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="colip"><?php print $dato['data'] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga ();
|
||||
}
|
||||
$tabella->close();
|
||||
view_footer();
|
||||
?>
|
||||
148
firewall/firewall_regole_versoesterno.php
Executable file
148
firewall/firewall_regole_versoesterno.php
Executable file
@@ -0,0 +1,148 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['id_utenti'])) {
|
||||
$id_utenti = $_POST['id_utenti'];
|
||||
$id_macchine = $_POST['id_macchine'];
|
||||
if (isset($_POST['perm'])) {
|
||||
$perm = $_POST['perm'];
|
||||
} else {
|
||||
$perm = 0;
|
||||
}
|
||||
$query = " INSERT INTO
|
||||
firewall_versoesterno_regole
|
||||
SET
|
||||
id_utenti = $id_utenti,
|
||||
id_firewall_versoesterno = $id_macchine,
|
||||
permanente = $perm,
|
||||
data = NOW(),
|
||||
attivo = 1
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
utenti.id,
|
||||
utenti.utente
|
||||
FROM
|
||||
utenti
|
||||
JOIN
|
||||
permessi
|
||||
ON
|
||||
permessi.id_utenti = utenti.id
|
||||
JOIN
|
||||
livelli
|
||||
ON
|
||||
livelli.nome = 'Utente'
|
||||
AND
|
||||
permessi.accesso <= livelli.livello
|
||||
WHERE
|
||||
permessi.id_moduli = ".$MODULO['id']."
|
||||
AND
|
||||
utenti.attivo = 1
|
||||
ORDER BY
|
||||
utente
|
||||
";
|
||||
$res_utenti = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " SELECT
|
||||
firewall_versoesterno.id,
|
||||
firewall_versoesterno.nome
|
||||
FROM
|
||||
firewall_versoesterno
|
||||
WHERE
|
||||
firewall_versoesterno.attivo = 1
|
||||
ORDER BY
|
||||
nome
|
||||
";
|
||||
$res_macchine = mysql_query( $query, $DB_ID );
|
||||
|
||||
$tabella = new html (0,"90%",array(3,3,2,15,2,15,2,5,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<tr>
|
||||
<td colspan=2 class="spazioh"><input type="image" src="<?php print $CONF['base_url'] ?>/img/addresource.png" border="0" alt="Inserisci" /></td>
|
||||
|
||||
<td class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="spazioh">
|
||||
<select name="id_utenti">
|
||||
<option value="" selected="selected">---</option>
|
||||
<?php while ($dato = mysql_fetch_array ( $res_utenti )) { ?>
|
||||
<option value="<?php print $dato['id'] ?>"><?php print $dato['utente'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="spazioh">
|
||||
<select name="id_macchine">
|
||||
<option value="" selected="selected">---</option>
|
||||
<?php while ($dato = mysql_fetch_array ( $res_macchine )) { ?>
|
||||
<option value="<?php print $dato['id'] ?>"><?php print $dato['nome'] ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="radio"><input type="checkbox" name="perm" value="1"></td>
|
||||
|
||||
<td class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
$query = " SELECT
|
||||
firewall_versoesterno_regole.id,
|
||||
utenti.utente,
|
||||
firewall_versoesterno.nome,
|
||||
firewall_versoesterno_regole.permanente,
|
||||
firewall_versoesterno_regole.attivo
|
||||
FROM
|
||||
firewall_versoesterno_regole
|
||||
JOIN
|
||||
utenti
|
||||
ON
|
||||
firewall_versoesterno_regole.id_utenti = utenti.id
|
||||
JOIN
|
||||
firewall_versoesterno
|
||||
ON
|
||||
firewall_versoesterno_regole.id_firewall_versoesterno = firewall_versoesterno.id
|
||||
ORDER BY
|
||||
utenti.utente,
|
||||
firewall_versoesterno.nome
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="col3btn">
|
||||
<?php if ($dato['attivo']) { ?>
|
||||
<a href="firewall_gest.php?azione=regolaversoext_down&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="Utente attivo" TITLE="Utente attivo"></a>
|
||||
<?php } else { ?>
|
||||
<a href="firewall_gest.php?azione=regolaversoext_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="Utente non attivo" TITLE="Utente non attivo"></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><a href="firewall_gest.php?azione=regolaversoext_rm&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/trash.png"></a></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Utenza</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 rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="textl"><?php print $dato['utente'] ?></td>
|
||||
<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();
|
||||
}
|
||||
$tabella->close();
|
||||
view_footer();
|
||||
?>
|
||||
163
firewall/firewall_regolesterno.php
Executable file
163
firewall/firewall_regolesterno.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Admin');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['nome'])) {
|
||||
$nome = $_POST['nome'];
|
||||
$int_id = $_POST['int_id'];
|
||||
$int_port = $_POST['int_port'];
|
||||
$ext_id = $_POST['ext_id'];
|
||||
$ext_port = $_POST['ext_port'];
|
||||
|
||||
$query = " INSERT INTO
|
||||
firewall_versoesterno
|
||||
SET
|
||||
nome = '$nome',
|
||||
id_firewall_macchine = $int_id,
|
||||
int_port = $int_port,
|
||||
id_firewall_macchine_ext = $ext_id,
|
||||
ext_port = $ext_port,
|
||||
data = NOW(),
|
||||
attivo = 1
|
||||
";
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
}
|
||||
|
||||
$query = " SELECT
|
||||
firewall_macchine.id,
|
||||
proxy_pool.ip,
|
||||
proxy_pool.nome
|
||||
FROM
|
||||
firewall_macchine
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
firewall_macchine.id_proxy_pool = proxy_pool.id
|
||||
ORDER BY
|
||||
-nome DESC,
|
||||
INET_ATON(ip) ASC
|
||||
";
|
||||
$res_macchine = mysql_query( $query, $DB_ID );
|
||||
|
||||
$query = " SELECT
|
||||
id,
|
||||
nome,
|
||||
ip
|
||||
FROM
|
||||
firewall_macchine_ext
|
||||
WHERE
|
||||
attivo = 1
|
||||
ORDER BY
|
||||
-nome DESC,
|
||||
INET_ATON(ip) ASC
|
||||
";
|
||||
$res_macchine_ext = mysql_query( $query, $DB_ID );
|
||||
|
||||
$tabella = new html (0,"90%",array(3,3,2,15,2,15,5,2,15,5,2,15,0));
|
||||
?>
|
||||
<form name="" method="post">
|
||||
<tr>
|
||||
<td rowspan=2 colspan=2 class="spazioh"><input type="image" src="<?php print $CONF['base_url'] ?>/img/addresource.png" border="0" alt="Inserisci" /></td>
|
||||
<td rowspan=2 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Nome regola</td>
|
||||
<td rowspan=2 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Macchina interna</td>
|
||||
<td class="descrizione">Porta</td>
|
||||
<td rowspan=2 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione">Macchina esterna</td>
|
||||
<td class="descrizione">Porta</td>
|
||||
<td rowspan=2 colspan=3 class="spaziov"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="colip"><input type="text" size="14" name="nome"></td>
|
||||
<td class="colip">
|
||||
<select name="int_id">
|
||||
<option value="" selected="selected">---</option>
|
||||
<?php while ($dato = mysql_fetch_array ( $res_macchine )) { ?>
|
||||
<option value="<?php print $dato['id'] ?>"><?php if ($dato['nome'] != "") { print $dato['nome']; } else { print $dato['ip']; } ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="colip"><input type="text" size="3" name="int_port"></td>
|
||||
<td class="colip">
|
||||
<select name="ext_id">
|
||||
<option value="" selected="selected">---</option>
|
||||
<?php while ($dato = mysql_fetch_array ( $res_macchine_ext )) { ?>
|
||||
<option value="<?php print $dato['id'] ?>"><?php if ($dato['nome'] != "") { print $dato['nome']; } else { print $dato['ip']; } ?></option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
</td>
|
||||
<td class="colip"><input type="text" size="3" name="ext_port"></td>
|
||||
|
||||
</tr>
|
||||
</form>
|
||||
<?php
|
||||
$tabella->riga();
|
||||
$query = " SELECT
|
||||
firewall_versoesterno.id,
|
||||
firewall_versoesterno.nome,
|
||||
proxy_pool.ip AS int_ip,
|
||||
proxy_pool.nome AS int_nome,
|
||||
firewall_versoesterno.int_port,
|
||||
firewall_macchine_ext.ip AS ext_ip,
|
||||
firewall_macchine_ext.nome AS ext_nome,
|
||||
firewall_versoesterno.ext_port,
|
||||
DATE_FORMAT(firewall_versoesterno.data, '%d.%m.%Y %H:%i:%s') AS data,
|
||||
firewall_versoesterno.attivo
|
||||
FROM
|
||||
firewall_versoesterno
|
||||
JOIN
|
||||
firewall_macchine
|
||||
ON
|
||||
firewall_versoesterno.id_firewall_macchine = firewall_macchine.id
|
||||
JOIN
|
||||
proxy_pool
|
||||
ON
|
||||
firewall_macchine.id_proxy_pool = proxy_pool.id
|
||||
JOIN
|
||||
firewall_macchine_ext
|
||||
ON
|
||||
firewall_versoesterno.id_firewall_macchine_ext = firewall_macchine_ext.id
|
||||
ORDER BY
|
||||
firewall_versoesterno.nome
|
||||
";
|
||||
|
||||
$res = mysql_query( $query, $DB_ID );
|
||||
while ($dato = mysql_fetch_array ( $res )) {
|
||||
?>
|
||||
<tr>
|
||||
<td rowspan=2 class="col3btn">
|
||||
<?php if ($dato['attivo']) { ?>
|
||||
<a href="firewall_gest.php?azione=regolaext_down&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/attivo.gif" ALT="Regola attiva" TITLE="Regola attiva"></a>
|
||||
<?php } else { ?>
|
||||
<a href="firewall_gest.php?azione=regolaext_up&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/non_attivo.gif" ALT="Regola non attiva" TITLE="Regola non attiva"></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td rowspan=2 class="spazioh"><a href="firewall_gest.php?azione=regolaext_rm&id=<?php print $dato['id']?>"><img src="<?php print $CONF['base_url'] ?>/img/trash.png"></a></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td rowspan=2 class="descrizione"><?php print $dato['nome'] ?></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione"><?php print $dato['int_nome'] ?></td>
|
||||
<td rowspan=2 class="descrizione"><?php print $dato['int_port'] ?></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td class="descrizione"><?php print $dato['ext_nome'] ?></td>
|
||||
<td rowspan=2 class="descrizione"><?php print $dato['ext_port'] ?></td>
|
||||
<td rowspan=2 class="spazioh"><img src="<?php print $CONF['base_url'] ?>/img/spazio.gif"></td>
|
||||
<td rowspan=2 class="descrizione"><?php print $dato['data'] ?></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['int_ip'] ?></td>
|
||||
<td class="textl"><?php print $dato['ext_ip'] ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$tabella->riga();
|
||||
}
|
||||
$tabella->close();
|
||||
view_footer();
|
||||
?>
|
||||
@@ -1,17 +1,123 @@
|
||||
<?php
|
||||
include_once ("../core/config.php");
|
||||
$UTENTE = login();
|
||||
$DIRITTI = diritti('Libero');
|
||||
$DIRITTI = diritti('Utente');
|
||||
view_top();
|
||||
|
||||
if (isset($_POST['utente'])) {
|
||||
$utente = $_POST['utente'];
|
||||
|
||||
$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;
|
||||
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
$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'] ?>">
|
||||
|
||||
<?php view_top(); ?>
|
||||
<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
|
||||
";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?php view_footer(); ?>
|
||||
$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();
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user