Subversion Repositories ALCASAR

Rev

Rev 790 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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