0 GROUP BY firewall_versoesterno_regole.id_firewall_versoesterno "; $nomi = array (); $file = array (); $esegui = array (); $res = mysql_query( $query, $DB_ID ); while ($dato = mysql_fetch_array ( $res )) { $id = $dato['id']; $proto = $dato['proto']; $stato = $dato['stato']; $int_port = $dato['int_port']; $ext_port = $dato['ext_port']; $int_ip = $dato['int_ip']; $ext_ip = $dato['ext_ip']; $portaIN = $FW_conf['portaIN']; array_push($nomi, "REGOLA-U$id"); if ($stato == 2) $perm = "PERMANENTE"; else $perm = ""; if ($int_ip != "") { $ipint1 = "-s $int_ip"; $ipint2 = "-d $int_ip"; } else { $ipint1 = ""; $ipint2 = ""; } if ($ext_ip != "") { $ipext1 = "-d $ext_ip"; $ipext2 = "-s $ext_ip"; } else { $ipext1 = ""; $ipext2 = ""; } if ($int_port != "") { $ptint1 = "--sport $int_port"; $ptint2 = "--dport $int_port"; } else { $ptint1 = ""; $ptint2 = ""; } if ($ext_port != "") { $ptext1 = "--dport $ext_port"; $ptext2 = "--sport $ext_port"; } else { $ptext1 = ""; $ptext2 = ""; } $regola = "### START REGOLA-U$id $perm ###\n"; $regola .= "iptables -N REGOLA-U$id\n"; $regola .= "iptables -I REGOLA-U$id -p $proto -o $portaIN $ipint1 $ptint1 $ipext1 $ptext1 -j ACCEPT\n"; $regola .= "iptables -I REGOLA-U$id -p $proto -i $portaIN $ipint2 $ptint2 $ipext2 $ptext2 -j ACCEPT\n"; $regola .= "iptables -I FORWARD -j REGOLA-U$id\n"; $regola .= "### STOP REGOLA-U$id $perm ###\n"; array_push($file, $regola); $regola = "sudo iptables -N REGOLA-U$id; "; $regola .= "sudo iptables -I REGOLA-U$id -p $proto -o $portaIN $ipint1 $ptint1 $ipext1 $ptext1 -j ACCEPT; "; $regola .= "sudo iptables -I REGOLA-U$id -p $proto -i $portaIN $ipint2 $ptint2 $ipext2 $ptext2 -j ACCEPT; "; $regola .= "sudo iptables -I FORWARD -j REGOLA-U$id"; $esegui['REGOLA-U'.$id] = $regola; } $ritorna[0] = $nomi; $ritorna[1] = $file; $ritorna[2] = $esegui; return $ritorna; } function elimina ($cerca) { exec ("sudo iptables -nL FORWARD --line-numbers | grep $cerca", $ritorno); foreach (array_reverse($ritorno) as $riga) { $pezzi = explode (" " , $riga); exec ("sudo iptables -D FORWARD ".$pezzi[0]); exec ("sudo iptables -F $cerca"); exec ("sudo iptables -X $cerca"); } } ?>