Subversion Repositories ALCASAR

Rev

Rev 364 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

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