<?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(); 
?>
