Subversion Repositories ALCASAR

Rev

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

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