Subversion Repositories ALCASAR

Rev

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

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