Subversion Repositories ALCASAR

Compare Revisions

Problem with comparison.

Ignore whitespace Rev HEAD → Rev 40

/gestion/admin/net_filter.php
0,0 → 1,131
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><!-- written by Rexy -->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<TITLE>Network Filter</TITLE>
<link rel="stylesheet" href="/css/style.css" type="text/css">
</HEAD>
<body>
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
<?
$services_list="/usr/local/etc/alcasar-services";
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
$l_title = "Filtrage réseau";
$l_netfilter_on="Le filtrage réseau est actuellement activé";
$l_netfilter_off="Le filtrage réseau est actuellement désactivé";
$l_switch_on="Activer le filtrage r&eacute;seau";
$l_switch_off="Désactiver le filtrage réseau";
$l_comment_on="(choisissez les protocoles que vous voulez autoriser)";
$l_comment_off="(les usagers authentifiés peuvent exploiter tous les protocoles réseau)";
$l_protocols="Protocoles autorisés";
$l_error_open_file="Erreur d'ouverture du fichier";
$l_proto_port="Protocole / port";
$l_enabled="Autorisé";
$l_save_modif="Enregistrer les modifications";
}
else {
$l_title = "Network Filter";
$l_netfilter_on="Actually, the network filter is enable";
$l_netfilter_off="Actually, the network filter is disable";
$l_switch_on="Switch the Network Filter on";
$l_switch_off="Switch the Network Filter off";
$l_comment_on="(choose the authorized network protocols)";
$l_comment_off="(all the network protocols are allowed for authenticated users)";
$l_protocols="Authorize protocols";
$l_error_open_file="Error opening the file";
$l_proto_port="Protocol / port";
$l_enabled="Enable";
$l_save_modif="Save modifications";
}
echo "
<tr><th>$l_title</th></tr>
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=1 height=2></td></tr>
</TABLE>";
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
switch ($choix)
{
case 'NF_On' :
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
break;
case 'NF_Off' :
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
break;
case 'change' :
$tab=file($services_list);
if ($tab)
{
//on active|désactive les protocoles
$pointeur=fopen($services_list,"w+");
foreach ($tab as $ligne)
{
$proto_f=explode(" ", $ligne);
$name_svc1=trim($proto_f[0],"#");
$actif = False;
foreach ($_POST as $key => $value)
{
if (strstr($key,'chk-'))
{
$name_svc2 = str_replace('chk-','',$key);
if ($name_svc1 == $name_svc2)
{
$actif = True;
break;
}
}
}
if (! $actif)
{
$line="#$name_svc1 $proto_f[1]";
}
else { $line="$name_svc1 $proto_f[1]";}
fputs($pointeur,$line);
}
fclose($pointeur);
}
else {echo "$l_error_open_file $services_list";}
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
break;
}
echo "<TABLE width=\"100%\" border=1 cellspacing=0 cellpadding=1>";
echo "<tr><td valign=\"middle\" align=\"left\">";
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
$result = False ;
if ($pointeur)
{
while (!feof($pointeur))
{
$ligne = fgets($pointeur);
if (preg_match('/^FILTERING="yes"/', $ligne, $r))
{
$result = True ;
break;
}
}
}
fclose($pointeur);
if ($result)
{
echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
echo "<input type=hidden name='choix' value=\"NF_Off\">";
echo "<input type=submit value=\"$l_switch_off\">";
}
else
{
echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
echo "<input type=hidden name='choix' value=\"NF_On\">";
echo "<input type=submit value=\"$l_switch_on\">";
}
echo "</FORM>";
echo "</td></tr>";
echo "</TABLE>";
if ($result) require ('net_filter2.php');
?>
</BODY>
</HTML>