Subversion Repositories ALCASAR

Rev

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