318 |
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'){
|
372 |
richard |
18 |
$l_title_antivir = "Antivirus de flux WEB";
|
|
|
19 |
$l_title_proto = "Filtrage de protocoles réseau";
|
364 |
franck |
20 |
$l_antivir_on="L'antivirus de flux WEB est actuellement activé";
|
|
|
21 |
$l_antivir_off="L'antivirus de flux WEB est actuellement désactivé";
|
318 |
richard |
22 |
$l_switch_antivir_on="Activer l'antivirus";
|
364 |
franck |
23 |
$l_switch_antivir_off="Désactiver l'antivirus";
|
372 |
richard |
24 |
$l_netfilter_on="Le filtrage de protocoles réseau est actuellement activé";
|
|
|
25 |
$l_netfilter_off="Le filtrage de protocoles réseau est actuellement désactivé";
|
|
|
26 |
$l_switch_on="Activer le filtrage";
|
|
|
27 |
$l_switch_off="Désactiver le filtrage";
|
318 |
richard |
28 |
$l_comment_on="À l'exclusion du WEB (port 80), les protocoles réseau sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
|
364 |
franck |
29 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
|
|
30 |
$l_protocols="Protocoles autorisés";
|
318 |
richard |
31 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
|
|
32 |
$l_proto="Protocole";
|
364 |
franck |
33 |
$l_enabled="Autorisé";
|
318 |
richard |
34 |
$l_delete="Supprimer de la liste";
|
|
|
35 |
$l_add_to_list="Ajouter à la liste";
|
|
|
36 |
$l_save_modif="Enregistrer les modifications";
|
372 |
richard |
37 |
$l_exception_txt="Entrez ici les adresses IP des stations du réseau de consultation ne subissant ce filtrage de protocoles<BR>Entrez une adresse IP par ligne";
|
318 |
richard |
38 |
}
|
|
|
39 |
else {
|
372 |
richard |
40 |
$l_title_antivir = "WEB antivirus";
|
|
|
41 |
$l_title_proto = "Network protocols filter";
|
|
|
42 |
$l_antivir_on="Actually, the WEB antivirus is on";
|
|
|
43 |
$l_antivir_off="Actually, the WEB antivirus is off";
|
318 |
richard |
44 |
$l_switch_antivir_on="Switch the antivirus on";
|
|
|
45 |
$l_switch_antivir_off="Switch the antivirus off";
|
372 |
richard |
46 |
$l_netfilter_on="Actually, the network protocols filter is enable";
|
|
|
47 |
$l_netfilter_off="Actually, the network protocols filter is disable";
|
|
|
48 |
$l_switch_on="Switch the Filter on";
|
|
|
49 |
$l_switch_off="Switch the Filter off";
|
318 |
richard |
50 |
$l_comment_on="(choose the authorized network protocols)";
|
|
|
51 |
$l_comment_off="(all the network protocols are allowed for authenticated users)";
|
|
|
52 |
$l_protocols="Authorize protocols";
|
|
|
53 |
$l_error_open_file="Error opening the file";
|
|
|
54 |
$l_proto="Protocol";
|
|
|
55 |
$l_enabled="Enable";
|
|
|
56 |
$l_delete="Delete from list";
|
|
|
57 |
$l_add_to_list="Add to the list";
|
|
|
58 |
$l_save_modif="Save modifications";
|
372 |
richard |
59 |
$l_exception_txt="Put here the stations IP address that won't be protocols filtered<BR>Put one IP adress per row";
|
318 |
richard |
60 |
}
|
|
|
61 |
echo "
|
372 |
richard |
62 |
<tr><th>$l_title_antivir</th></tr>
|
318 |
richard |
63 |
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=1 height=2></td></tr>
|
|
|
64 |
</TABLE>";
|
|
|
65 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
66 |
switch ($choix)
|
|
|
67 |
{
|
|
|
68 |
case 'AV_On' :
|
|
|
69 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -on");
|
|
|
70 |
break;
|
|
|
71 |
case 'AV_Off' :
|
|
|
72 |
exec ("sudo /usr/local/sbin/alcasar-havp.sh -off");
|
|
|
73 |
break;
|
|
|
74 |
case 'NF_On' :
|
|
|
75 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
76 |
break;
|
|
|
77 |
case 'NF_Off' :
|
|
|
78 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
|
|
|
79 |
break;
|
|
|
80 |
case 'new_proto' :
|
|
|
81 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
82 |
{
|
|
|
83 |
$tab=file($services_list);
|
|
|
84 |
if ($tab)
|
|
|
85 |
{
|
|
|
86 |
$pointeur=fopen($services_list,"r");
|
|
|
87 |
//on teste si le port n'est pas déjà présent
|
|
|
88 |
$insert = true;
|
|
|
89 |
foreach ($tab as $ligne)
|
|
|
90 |
{
|
|
|
91 |
$proto_f=explode(" ", $ligne);
|
|
|
92 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
93 |
}
|
|
|
94 |
fclose($pointeur);
|
|
|
95 |
if ($insert == true)
|
|
|
96 |
{
|
|
|
97 |
$line = "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
98 |
$pointeur=fopen($services_list,"a");
|
|
|
99 |
fwrite ($pointeur, $line);
|
|
|
100 |
fclose ($pointeur);
|
|
|
101 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
102 |
}
|
|
|
103 |
}
|
|
|
104 |
else {echo "$l_error_open_file $services_list";}
|
|
|
105 |
}
|
|
|
106 |
break;
|
|
|
107 |
case 'change' :
|
|
|
108 |
$tab=file($services_list);
|
|
|
109 |
if ($tab)
|
|
|
110 |
{
|
|
|
111 |
//on active|désactive les protocoles
|
|
|
112 |
$pointeur=fopen($services_list,"w+");
|
|
|
113 |
foreach ($tab as $ligne)
|
|
|
114 |
{
|
|
|
115 |
$proto_f=explode(" ", $ligne);
|
|
|
116 |
$name_svc1=trim($proto_f[0],"#");
|
|
|
117 |
$actif = False; $remove_line = false;
|
|
|
118 |
foreach ($_POST as $key => $value)
|
|
|
119 |
{
|
|
|
120 |
if (strstr($key,'del-'))
|
|
|
121 |
{
|
|
|
122 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
123 |
if ($name_svc1 == $name_svc2)
|
|
|
124 |
{
|
|
|
125 |
$remove_line = True;
|
|
|
126 |
break;
|
|
|
127 |
}
|
|
|
128 |
}
|
|
|
129 |
if (strstr($key,'chk-'))
|
|
|
130 |
{
|
|
|
131 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
132 |
if ($name_svc1 == $name_svc2)
|
|
|
133 |
{
|
|
|
134 |
$actif = True;
|
|
|
135 |
break;
|
|
|
136 |
}
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
if (! $remove_line)
|
|
|
140 |
{
|
|
|
141 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
142 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
143 |
fwrite($pointeur,$line);
|
|
|
144 |
}
|
|
|
145 |
}
|
|
|
146 |
fclose($pointeur);
|
|
|
147 |
}
|
|
|
148 |
else {echo "$l_error_open_file $services_list";}
|
|
|
149 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
150 |
break;
|
372 |
richard |
151 |
case 'IP_exceptions' :
|
|
|
152 |
// réencodage iso + format unix + rc fin de ligne (ouf...)
|
|
|
153 |
$ip_list = str_replace("\r\n", "\n", utf8_decode($_POST['exception_list']));
|
|
|
154 |
if (strlen($ip_list) != 0){
|
|
|
155 |
if ($ip_list[strlen($ip_list)-1] != "\n") { $ip_list[strlen($ip_list)]="\n";} ;} ;
|
|
|
156 |
unset($_POST['exception_list']);
|
|
|
157 |
// écriture exception pour filtrage réseau
|
|
|
158 |
$fichier=fopen("/usr/local/etc/alcasar-filter-exceptions", "w+");
|
|
|
159 |
fputs($fichier, $ip_list);
|
|
|
160 |
fclose($fichier);
|
|
|
161 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
162 |
break;
|
318 |
richard |
163 |
}
|
|
|
164 |
?>
|
|
|
165 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
166 |
<tr><td valign="middle" align="left">
|
|
|
167 |
<?php
|
|
|
168 |
$pointeur = fopen("/etc/dansguardian/dansguardian.conf", "r");
|
372 |
richard |
169 |
$antivir_filter = false; $DG_filter = false; $out=0;
|
318 |
richard |
170 |
if ($pointeur)
|
|
|
171 |
{
|
|
|
172 |
while (!feof($pointeur))
|
|
|
173 |
{
|
|
|
174 |
$ligne = fgets($pointeur);
|
|
|
175 |
if (preg_match("/^proxyport = 8090/", $ligne, $r))
|
|
|
176 |
{
|
372 |
richard |
177 |
$antivir_filter = true;
|
318 |
richard |
178 |
$out++;
|
|
|
179 |
}
|
372 |
richard |
180 |
if (preg_match("/^reportinglevel = 3/", $ligne, $r)) // non utilisé mais on garde pour l'exemple
|
318 |
richard |
181 |
{
|
372 |
richard |
182 |
$DG_filter = true;
|
318 |
richard |
183 |
$out++;
|
|
|
184 |
}
|
|
|
185 |
if ($out == 2) break;
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
fclose($pointeur);
|
372 |
richard |
189 |
if ($antivir_filter)
|
318 |
richard |
190 |
{
|
|
|
191 |
echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
|
|
|
192 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
193 |
echo "<input type=hidden name='choix' value=\"AV_Off\">";
|
|
|
194 |
echo "<input type=submit value=\"$l_switch_antivir_off\">";
|
|
|
195 |
}
|
|
|
196 |
else
|
|
|
197 |
{
|
|
|
198 |
echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
|
|
|
199 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
200 |
echo "<input type=hidden name='choix' value=\"AV_On\">";
|
|
|
201 |
echo "<input type=submit value=\"$l_switch_antivir_on\">";
|
|
|
202 |
}
|
|
|
203 |
?>
|
|
|
204 |
</FORM>
|
|
|
205 |
</td></tr>
|
372 |
richard |
206 |
</table>
|
|
|
207 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
208 |
<tr><th><?echo "$l_title_proto";?></th></tr>
|
|
|
209 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
210 |
</table>
|
|
|
211 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
318 |
richard |
212 |
<tr><td valign="middle" align="left">
|
|
|
213 |
<?
|
|
|
214 |
$pointeur = fopen("/usr/local/bin/alcasar-iptables.sh", "r");
|
|
|
215 |
$result = False ;
|
|
|
216 |
if ($pointeur)
|
|
|
217 |
{
|
|
|
218 |
while (!feof($pointeur))
|
|
|
219 |
{
|
|
|
220 |
$ligne = fgets($pointeur);
|
|
|
221 |
if (preg_match('/^FILTERING="yes"/', $ligne, $r))
|
|
|
222 |
{
|
|
|
223 |
$result = True ;
|
|
|
224 |
break;
|
|
|
225 |
}
|
|
|
226 |
}
|
|
|
227 |
}
|
|
|
228 |
fclose($pointeur);
|
|
|
229 |
if ($result)
|
|
|
230 |
{
|
|
|
231 |
echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
232 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
233 |
echo "<input type=hidden name='choix' value=\"NF_Off\">";
|
|
|
234 |
echo "<input type=submit value=\"$l_switch_off\">";
|
|
|
235 |
}
|
|
|
236 |
else
|
|
|
237 |
{
|
|
|
238 |
echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
|
|
|
239 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
240 |
echo "<input type=hidden name='choix' value=\"NF_On\">";
|
|
|
241 |
echo "<input type=submit value=\"$l_switch_on\">";
|
|
|
242 |
}
|
|
|
243 |
echo "</FORM>";
|
|
|
244 |
echo "</td></tr>";
|
|
|
245 |
echo "</TABLE>";
|
|
|
246 |
if ($result) require ('net_filter2.php');
|
|
|
247 |
?>
|
|
|
248 |
</BODY>
|
|
|
249 |
</HTML>
|