28 |
richard |
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
|
2 |
<HTML><!-- written by Rexy -->
|
|
|
3 |
<HEAD>
|
|
|
4 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
5 |
<TITLE>Network Filter</TITLE>
|
|
|
6 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
|
|
7 |
</HEAD>
|
|
|
8 |
<body>
|
|
|
9 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
10 |
<?
|
|
|
11 |
$services_list="/usr/local/etc/alcasar-services";
|
|
|
12 |
# Choice of language
|
|
|
13 |
$Language = 'en';
|
|
|
14 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
15 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
16 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
17 |
if($Language == 'fr'){
|
|
|
18 |
$l_title = "Filtrage réseau";
|
|
|
19 |
$l_netfilter_on="Le filtrage réseau est actuellement activé";
|
|
|
20 |
$l_netfilter_off="Le filtrage réseau est actuellement désactivé";
|
|
|
21 |
$l_switch_on="Activer le filtrage réseau";
|
|
|
22 |
$l_switch_off="Désactiver le filtrage réseau";
|
161 |
richard |
23 |
$l_comment_on="À l'exclusion du WEB (port 80), les protocoles réseau sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
|
152 |
richard |
24 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
28 |
richard |
25 |
$l_protocols="Protocoles autorisés";
|
|
|
26 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
152 |
richard |
27 |
$l_proto="Protocole";
|
28 |
richard |
28 |
$l_enabled="Autorisé";
|
152 |
richard |
29 |
$l_delete="Supprimer de la liste";
|
|
|
30 |
$l_add_to_list="Ajouter à la liste";
|
28 |
richard |
31 |
$l_save_modif="Enregistrer les modifications";
|
|
|
32 |
}
|
|
|
33 |
else {
|
|
|
34 |
$l_title = "Network Filter";
|
|
|
35 |
$l_netfilter_on="Actually, the network filter is enable";
|
|
|
36 |
$l_netfilter_off="Actually, the network filter is disable";
|
|
|
37 |
$l_switch_on="Switch the Network Filter on";
|
|
|
38 |
$l_switch_off="Switch the Network Filter off";
|
|
|
39 |
$l_comment_on="(choose the authorized network protocols)";
|
|
|
40 |
$l_comment_off="(all the network protocols are allowed for authenticated users)";
|
|
|
41 |
$l_protocols="Authorize protocols";
|
|
|
42 |
$l_error_open_file="Error opening the file";
|
152 |
richard |
43 |
$l_proto="Protocol";
|
28 |
richard |
44 |
$l_enabled="Enable";
|
152 |
richard |
45 |
$l_delete="Delete from list";
|
|
|
46 |
$l_add_to_list="Add to the list";
|
28 |
richard |
47 |
$l_save_modif="Save modifications";
|
|
|
48 |
}
|
|
|
49 |
echo "
|
|
|
50 |
<tr><th>$l_title</th></tr>
|
|
|
51 |
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=1 height=2></td></tr>
|
|
|
52 |
</TABLE>";
|
|
|
53 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
54 |
switch ($choix)
|
|
|
55 |
{
|
|
|
56 |
case 'NF_On' :
|
|
|
57 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
58 |
break;
|
|
|
59 |
case 'NF_Off' :
|
|
|
60 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
|
|
|
61 |
break;
|
152 |
richard |
62 |
case 'new_proto' :
|
|
|
63 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
64 |
{
|
|
|
65 |
$tab=file($services_list);
|
|
|
66 |
if ($tab)
|
|
|
67 |
{
|
|
|
68 |
$pointeur=fopen($services_list,"r");
|
|
|
69 |
//on teste si le port n'est pas déjà présent
|
|
|
70 |
$insert = true;
|
|
|
71 |
foreach ($tab as $ligne)
|
|
|
72 |
{
|
|
|
73 |
$proto_f=explode(" ", $ligne);
|
|
|
74 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
75 |
}
|
|
|
76 |
fclose($pointeur);
|
|
|
77 |
if ($insert == true)
|
|
|
78 |
{
|
|
|
79 |
$line = "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
80 |
$pointeur=fopen($services_list,"a");
|
|
|
81 |
fwrite ($pointeur, $line);
|
|
|
82 |
fclose ($pointeur);
|
|
|
83 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
84 |
}
|
|
|
85 |
}
|
|
|
86 |
else {echo "$l_error_open_file $services_list";}
|
|
|
87 |
}
|
|
|
88 |
break;
|
28 |
richard |
89 |
case 'change' :
|
|
|
90 |
$tab=file($services_list);
|
|
|
91 |
if ($tab)
|
|
|
92 |
{
|
|
|
93 |
//on active|désactive les protocoles
|
|
|
94 |
$pointeur=fopen($services_list,"w+");
|
|
|
95 |
foreach ($tab as $ligne)
|
|
|
96 |
{
|
|
|
97 |
$proto_f=explode(" ", $ligne);
|
|
|
98 |
$name_svc1=trim($proto_f[0],"#");
|
152 |
richard |
99 |
$actif = False; $remove_line = false;
|
28 |
richard |
100 |
foreach ($_POST as $key => $value)
|
|
|
101 |
{
|
152 |
richard |
102 |
if (strstr($key,'del-'))
|
|
|
103 |
{
|
|
|
104 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
105 |
if ($name_svc1 == $name_svc2)
|
|
|
106 |
{
|
|
|
107 |
$remove_line = True;
|
|
|
108 |
break;
|
|
|
109 |
}
|
|
|
110 |
}
|
28 |
richard |
111 |
if (strstr($key,'chk-'))
|
|
|
112 |
{
|
|
|
113 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
114 |
if ($name_svc1 == $name_svc2)
|
|
|
115 |
{
|
|
|
116 |
$actif = True;
|
|
|
117 |
break;
|
|
|
118 |
}
|
|
|
119 |
}
|
|
|
120 |
}
|
152 |
richard |
121 |
if (! $remove_line)
|
28 |
richard |
122 |
{
|
152 |
richard |
123 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
124 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
125 |
fwrite($pointeur,$line);
|
28 |
richard |
126 |
}
|
|
|
127 |
}
|
|
|
128 |
fclose($pointeur);
|
|
|
129 |
}
|
|
|
130 |
else {echo "$l_error_open_file $services_list";}
|
|
|
131 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
132 |
break;
|
|
|
133 |
}
|
|
|
134 |
echo "<TABLE width=\"100%\" border=1 cellspacing=0 cellpadding=1>";
|
|
|
135 |
echo "<tr><td valign=\"middle\" align=\"left\">";
|
|
|
136 |
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
|
|
|
137 |
$result = False ;
|
|
|
138 |
if ($pointeur)
|
|
|
139 |
{
|
|
|
140 |
while (!feof($pointeur))
|
|
|
141 |
{
|
|
|
142 |
$ligne = fgets($pointeur);
|
|
|
143 |
if (preg_match('/^FILTERING="yes"/', $ligne, $r))
|
|
|
144 |
{
|
|
|
145 |
$result = True ;
|
|
|
146 |
break;
|
|
|
147 |
}
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
fclose($pointeur);
|
|
|
151 |
if ($result)
|
|
|
152 |
{
|
|
|
153 |
echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
154 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
155 |
echo "<input type=hidden name='choix' value=\"NF_Off\">";
|
|
|
156 |
echo "<input type=submit value=\"$l_switch_off\">";
|
|
|
157 |
}
|
|
|
158 |
else
|
|
|
159 |
{
|
|
|
160 |
echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
|
|
|
161 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
162 |
echo "<input type=hidden name='choix' value=\"NF_On\">";
|
|
|
163 |
echo "<input type=submit value=\"$l_switch_on\">";
|
|
|
164 |
}
|
|
|
165 |
echo "</FORM>";
|
|
|
166 |
echo "</td></tr>";
|
|
|
167 |
echo "</TABLE>";
|
|
|
168 |
if ($result) require ('net_filter2.php');
|
|
|
169 |
?>
|
|
|
170 |
</BODY>
|
|
|
171 |
</HTML>
|