| 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 |
# 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'){
|
| 859 |
richard |
17 |
$l_remove="Retirer de la liste";
|
| 791 |
richard |
18 |
$l_title_proto = "Filtrage de protocoles réseau";
|
| 372 |
richard |
19 |
$l_netfilter_on="Le filtrage de protocoles réseau est actuellement activé";
|
|
|
20 |
$l_netfilter_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";
|
| 934 |
franck |
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";
|
| 364 |
franck |
24 |
$l_comment_off="(tous les protocoles réseau sont autorisés)";
|
|
|
25 |
$l_protocols="Protocoles autorisés";
|
| 318 |
richard |
26 |
$l_error_open_file="Erreur d'ouverture du fichier";
|
| 859 |
richard |
27 |
$l_port="Numéro de port";
|
|
|
28 |
$l_proto="Nom du protocole";
|
| 364 |
franck |
29 |
$l_enabled="Autorisé";
|
| 318 |
richard |
30 |
$l_add_to_list="Ajouter à la liste";
|
| 861 |
richard |
31 |
$l_save="Enregistrer les modifications";
|
| 318 |
richard |
32 |
}
|
|
|
33 |
else {
|
| 859 |
richard |
34 |
$l_remove="Remove from list";
|
| 791 |
richard |
35 |
$l_title_proto = "Network protocols filter";
|
| 372 |
richard |
36 |
$l_netfilter_on="Actually, the network protocols filter is enable";
|
|
|
37 |
$l_netfilter_off="Actually, the network protocols filter is disable";
|
|
|
38 |
$l_switch_on="Switch the Filter on";
|
|
|
39 |
$l_switch_off="Switch the Filter off";
|
| 318 |
richard |
40 |
$l_comment_on="(choose the authorized network protocols)";
|
| 859 |
richard |
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";
|
| 318 |
richard |
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";
|
| 859 |
richard |
45 |
$l_port="Port number";
|
|
|
46 |
$l_proto="protocol name";
|
|
|
47 |
$l_enabled="Authorized";
|
| 318 |
richard |
48 |
$l_add_to_list="Add to the list";
|
| 861 |
richard |
49 |
$l_save="Save changes";
|
| 318 |
richard |
50 |
}
|
| 859 |
richard |
51 |
/********************
|
|
|
52 |
* TEST CONF FILES *
|
|
|
53 |
*********************/
|
|
|
54 |
define ("SERVICES_LIST", "/usr/local/etc/alcasar-services");
|
|
|
55 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
| 1339 |
richard |
56 |
$conf_files=array(SERVICES_LIST,CONF_FILE);
|
| 859 |
richard |
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 |
}
|
| 861 |
richard |
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 |
}
|
| 879 |
richard |
76 |
fclose($ouvre);
|
| 861 |
richard |
77 |
}
|
| 859 |
richard |
78 |
|
| 318 |
richard |
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;
|
| 859 |
richard |
88 |
case 'new_port' :
|
| 318 |
richard |
89 |
if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
|
|
|
90 |
{
|
| 860 |
richard |
91 |
$_POST['add_proto'] = str_replace (CHR(32),"-",$_POST['add_proto']);
|
| 859 |
richard |
92 |
$tab=file(SERVICES_LIST);
|
| 860 |
richard |
93 |
$insert = true;
|
|
|
94 |
if ($tab) // file isn't empty
|
| 318 |
richard |
95 |
{
|
| 860 |
richard |
96 |
foreach ($tab as $line) //test if port doesn't already exist
|
| 318 |
richard |
97 |
{
|
| 859 |
richard |
98 |
$proto_f=explode(" ", $line);
|
| 318 |
richard |
99 |
if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
|
|
|
100 |
}
|
|
|
101 |
}
|
| 860 |
richard |
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 |
}
|
| 318 |
richard |
110 |
}
|
|
|
111 |
break;
|
| 859 |
richard |
112 |
case 'change_port' :
|
|
|
113 |
$tab=file(SERVICES_LIST);
|
| 318 |
richard |
114 |
if ($tab)
|
|
|
115 |
{
|
| 859 |
richard |
116 |
// authorize/block protocols
|
|
|
117 |
$pointeur=fopen(SERVICES_LIST,"w+");
|
| 318 |
richard |
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 |
}
|
| 860 |
richard |
152 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh -on");
|
| 318 |
richard |
153 |
break;
|
|
|
154 |
}
|
| 612 |
richard |
155 |
# default values
|
| 859 |
richard |
156 |
if (is_file (CONF_FILE))
|
| 612 |
richard |
157 |
{
|
| 859 |
richard |
158 |
$tab=file(CONF_FILE);
|
| 612 |
richard |
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 |
}
|
| 318 |
richard |
168 |
?>
|
| 372 |
richard |
169 |
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
|
| 790 |
richard |
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>
|
| 859 |
richard |
174 |
<tr>
|
| 318 |
richard |
175 |
<?
|
| 612 |
richard |
176 |
if ($PROTOCOLS_FILTERING == "on")
|
| 318 |
richard |
177 |
{
|
| 859 |
richard |
178 |
echo "<td colspan=\"2\" valign=\"middle\" align=\"left\">";
|
| 318 |
richard |
179 |
echo "<CENTER><H3>$l_netfilter_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\">";
|
| 859 |
richard |
183 |
echo "</FORM></td></tr>";
|
|
|
184 |
require ('net_filter2.php');
|
| 318 |
richard |
185 |
}
|
|
|
186 |
else
|
|
|
187 |
{
|
| 859 |
richard |
188 |
echo "<td valign=\"middle\" align=\"left\">";
|
| 318 |
richard |
189 |
echo "<CENTER><H3>$l_netfilter_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\">";
|
| 859 |
richard |
193 |
echo "</FORM></td></tr>";
|
|
|
194 |
echo "</table></body></html>";
|
| 318 |
richard |
195 |
}
|
|
|
196 |
?>
|