1521 |
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 |
# Choice of language
|
|
|
12 |
$Language = 'en';
|
|
|
13 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
|
|
14 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
15 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
|
|
16 |
if($Language == 'fr'){
|
|
|
17 |
$l_remove="Retirer de la liste";
|
|
|
18 |
$l_title_proto = "Filtrage de protocoles réseau";
|
|
|
19 |
$l_protocolsfilter_on="Le filtrage de protocoles réseau est actuellement activé";
|
|
|
20 |
$l_protocolsfilter_off="Le filtrage de protocoles réseau est actuellement désactivé";
|
|
|
21 |
$l_switch_on="Activer le filtrage";
|
|
|
22 |
$l_switch_off="Désactiver le filtrage";
|
|
|
23 |
$l_comment_on="À l'exclusion du WEB (port 80), les protocoles réseaux sont interdits.<BR>Choisissez ci-dessous les protocoles que vous autorisez";
|
|
|
24 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
|
|
25 |
$l_protocols="Protocoles autorisés";
|
|
|
26 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
|
|
27 |
$l_port="Numéro de port";
|
|
|
28 |
$l_proto="Nom du protocole";
|
|
|
29 |
$l_enabled="Autorisé";
|
|
|
30 |
$l_add_to_list="Ajouter à la liste";
|
|
|
31 |
$l_save="Enregistrer les modifications";
|
|
|
32 |
}
|
|
|
33 |
else {
|
|
|
34 |
$l_remove="Remove from list";
|
|
|
35 |
$l_title_proto = "Network protocols filter";
|
|
|
36 |
$l_protocolsfilter_on="Actually, the network protocols filter is enable";
|
|
|
37 |
$l_protocolsfilter_off="Actually, the network protocols filter is disable";
|
|
|
38 |
$l_switch_on="Switch the Filter on";
|
|
|
39 |
$l_switch_off="Switch the Filter off";
|
|
|
40 |
$l_comment_on="(choose the authorized network protocols)";
|
|
|
41 |
$l_comment_on="Except for the WEB (port 80), all protocols are blocked.<BR>Choose in the list below, the protocols you want authorize";
|
|
|
42 |
$l_comment_off="(all the network protocols are allowed for authenticated users)";
|
|
|
43 |
$l_protocols="Authorize protocols";
|
|
|
44 |
$l_error_open_file="Error opening the file";
|
|
|
45 |
$l_port="Port number";
|
|
|
46 |
$l_proto="protocol name";
|
|
|
47 |
$l_enabled="Authorized";
|
|
|
48 |
$l_add_to_list="Add to the list";
|
|
|
49 |
$l_save="Save changes";
|
|
|
50 |
}
|
|
|
51 |
/********************
|
|
|
52 |
* TEST CONF FILES *
|
|
|
53 |
*********************/
|
|
|
54 |
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
|
|
|
55 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
|
|
56 |
$conf_files=array(SERVICES_LIST,CONF_FILE);
|
|
|
57 |
foreach ($conf_files as $file){
|
|
|
58 |
if (!file_exists($file)){
|
|
|
59 |
exit("Requested file ".$file." isn't present");}
|
|
|
60 |
if (!is_readable($file)){
|
|
|
61 |
exit("Can't read the file ".$file);}
|
|
|
62 |
}
|
|
|
63 |
/**********************************
|
|
|
64 |
* Read ALCASAR CONF_FILE *
|
|
|
65 |
***********************************/
|
|
|
66 |
$ouvre=fopen(CONF_FILE,"r");
|
|
|
67 |
if ($ouvre){
|
|
|
68 |
while (!feof ($ouvre))
|
|
|
69 |
{
|
|
|
70 |
$tampon = fgets($ouvre, 4096);
|
|
|
71 |
if (strpos($tampon,"=")!==false){
|
|
|
72 |
$tmp = explode("=",$tampon);
|
|
|
73 |
$conf[$tmp[0]] = $tmp[1];
|
|
|
74 |
}
|
|
|
75 |
}
|
|
|
76 |
fclose($ouvre);
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";}
|
|
|
80 |
switch ($choix)
|
|
|
81 |
{
|
|
|
82 |
case 'NF_On' :
|
|
|
83 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
|
|
|
84 |
break;
|
|
|
85 |
case 'NF_Off' :
|
|
|
86 |
exec ("sudo /usr/local/sbin/alcasar-nf.sh -off");
|
|
|
87 |
break;
|
|
|
88 |
case 'new_port' :
|
|
|
89 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
90 |
{
|
|
|
91 |
$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
|
|
|
92 |
$tab=file(SERVICES_LIST);
|
|
|
93 |
$insert = true;
|
|
|
94 |
if ($tab) // file isn't empty
|
|
|
95 |
{
|
|
|
96 |
foreach ($tab as $line) //test if port doesn't already exist
|
|
|
97 |
{
|
|
|
98 |
$proto_f=explode(" ", $line);
|
|
|
99 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
100 |
}
|
|
|
101 |
}
|
|
|
102 |
if ($insert == true)
|
|
|
103 |
{
|
|
|
104 |
$line = "\n" . "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
|
|
|
105 |
$pointeur=fopen(SERVICES_LIST,"a");
|
|
|
106 |
fwrite ($pointeur, $line);
|
|
|
107 |
fclose ($pointeur);
|
|
|
108 |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
|
|
|
109 |
}
|
|
|
110 |
}
|
|
|
111 |
break;
|
|
|
112 |
case 'change_port' :
|
|
|
113 |
$tab=file(SERVICES_LIST);
|
|
|
114 |
if ($tab)
|
|
|
115 |
{
|
|
|
116 |
// authorize/block protocols
|
|
|
117 |
$pointeur=fopen(SERVICES_LIST,"w+");
|
|
|
118 |
foreach ($tab as $ligne)
|
|
|
119 |
{
|
|
|
120 |
$proto_f=explode(" ", $ligne);
|
|
|
121 |
$name_svc1=trim($proto_f[0],"#");
|
|
|
122 |
$actif = False; $remove_line = false;
|
|
|
123 |
foreach ($_POST as $key => $value)
|
|
|
124 |
{
|
|
|
125 |
if (strstr($key,'del-'))
|
|
|
126 |
{
|
|
|
127 |
$name_svc2 = str_replace('del-','',$key);
|
|
|
128 |
if ($name_svc1 == $name_svc2)
|
|
|
129 |
{
|
|
|
130 |
$remove_line = True;
|
|
|
131 |
}
|
|
|
132 |
}
|
|
|
133 |
if (strstr($key,'chk-'))
|
|
|
134 |
{
|
|
|
135 |
$name_svc2 = str_replace('chk-','',$key);
|
|
|
136 |
if ($name_svc1 == $name_svc2)
|
|
|
137 |
{
|
|
|
138 |
$actif = True;
|
|
|
139 |
break;
|
|
|
140 |
}
|
|
|
141 |
}
|
|
|
142 |
}
|
|
|
143 |
if (! $remove_line)
|
|
|
144 |
{
|
|
|
145 |
if (! $actif) { $line="#$name_svc1 $proto_f[1]";}
|
|
|
146 |
else { $line="$name_svc1 $proto_f[1]";}
|
|
|
147 |
fwrite($pointeur,$line);
|
|
|
148 |
}
|
|
|
149 |
}
|
|
|
150 |
fclose($pointeur);
|
|
|
151 |
}
|
|
|
152 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
|
|
|
153 |
break;
|
|
|
154 |
}
|
|
|
155 |
# default values
|
|
|
156 |
if (is_file (CONF_FILE))
|
|
|
157 |
{
|
|
|
158 |
$tab=file(CONF_FILE);
|
|
|
159 |
if ($tab)
|
|
|
160 |
{
|
|
|
161 |
foreach ($tab as $line)
|
|
|
162 |
{
|
|
|
163 |
$field=explode("=", $line);
|
|
|
164 |
if ($field[0] == "PROTOCOLS_FILTERING") {$PROTOCOLS_FILTERING=trim($field[1]);}
|
|
|
165 |
}
|
|
|
166 |
}
|
|
|
167 |
}
|
|
|
168 |
?>
|
|
|
169 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
|
|
170 |
<tr><th><?echo "$l_title_proto";?></th></tr>
|
|
|
171 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
|
|
|
172 |
</table>
|
|
|
173 |
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
|
|
|
174 |
<tr>
|
|
|
175 |
<?
|
|
|
176 |
if ($PROTOCOLS_FILTERING == "on")
|
|
|
177 |
{
|
|
|
178 |
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
|
|
|
179 |
echo "<CENTER><H3>$l_protocolsfilter_on</H3>$l_comment_on</CENTER>";
|
|
|
180 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
181 |
echo "<input type=hidden name='choix' value=\"NF_Off\">";
|
|
|
182 |
echo "<input type=submit value=\"$l_switch_off\">";
|
|
|
183 |
echo "</FORM></td></tr>";
|
|
|
184 |
require ('protocols_filter2.php');
|
|
|
185 |
}
|
|
|
186 |
else
|
|
|
187 |
{
|
|
|
188 |
echo "<td valign=\"middle\" align=\"left\">";
|
|
|
189 |
echo "<CENTER><H3>$l_protocolsfilter_off</H3>$l_comment_off</CENTER>";
|
|
|
190 |
echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
|
|
|
191 |
echo "<input type=hidden name='choix' value=\"NF_On\">";
|
|
|
192 |
echo "<input type=submit value=\"$l_switch_on\">";
|
|
|
193 |
echo "</FORM></td></tr>";
|
|
|
194 |
echo "</table></body></html>";
|
|
|
195 |
}
|
|
|
196 |
?>
|