Subversion Repositories ALCASAR

Rev

Rev 520 | 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' :
76
	if ((trim($_POST['add_port']) != "80") and ($_POST['add_port'] != "") and ($_POST['add_proto'] != "") and (is_numeric($_POST['add_port'])))
77
		{
78
		$tab=file($services_list);
79
		if ($tab)
80
			{
81
			$pointeur=fopen($services_list,"r");
82
			//on teste si le port n'est pas déjà présent
83
			$insert = true;
84
			foreach ($tab as $ligne)
85
				{
86
				$proto_f=explode(" ", $ligne);
87
				if (trim($_POST['add_port']) == trim($proto_f[1])) {$insert = false;}
88
				}
89
			fclose($pointeur);
90
			if ($insert == true) 
91
				{
92
				$line = "#" . trim($_POST['add_proto']) . " " . trim($_POST['add_port']);
93
				$pointeur=fopen($services_list,"a");
94
				fwrite ($pointeur, $line);
95
				fclose ($pointeur);
96
				exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
97
				}
98
			}
99
		else {echo "$l_error_open_file $services_list";}
100
		}
101
	break;
102
case 'change' :
103
	$tab=file($services_list);
104
	if ($tab)
105
		{
106
//on active|désactive les protocoles
107
		$pointeur=fopen($services_list,"w+");
108
		foreach ($tab as $ligne)
109
			{
110
			$proto_f=explode(" ", $ligne);
111
			$name_svc1=trim($proto_f[0],"#");
112
			$actif = False; $remove_line = false;
113
			foreach ($_POST as $key => $value)
114
				{
115
				if (strstr($key,'del-'))
116
					{
117
					$name_svc2 = str_replace('del-','',$key);
118
					if ($name_svc1 == $name_svc2)
119
				       		{
120
						$remove_line = True;
121
						break;
122
						}
123
					}
124
				if (strstr($key,'chk-'))
125
					{
126
					$name_svc2 = str_replace('chk-','',$key);
127
					if ($name_svc1 == $name_svc2)
128
				       		{
129
						$actif = True;
130
						break;
131
						}
132
					}
133
				}
134
			if (! $remove_line)
135
				{
136
				if (! $actif) {	$line="#$name_svc1 $proto_f[1]";}
137
				else { $line="$name_svc1 $proto_f[1]";}
138
				fwrite($pointeur,$line);
139
				}
140
			}
141
		fclose($pointeur);
142
		}
143
	else {echo "$l_error_open_file $services_list";}
144
	exec ("sudo /usr/local/sbin/alcasar-nf.sh -on");
145
	break;
146
	}
612 richard 147
# default values
148
if (is_file ($conf_file))
149
	{
150
	$tab=file($conf_file);
151
	if ($tab)
152
		{
153
		foreach ($tab as $line)
154
			{
155
			$field=explode("=", $line);
156
			if ($field[0] == "PROTOCOLS_FILTERING")	{$PROTOCOLS_FILTERING=trim($field[1]);}
157
			if ($field[0] == "WEB_ANTIVIRUS")	{$WEB_ANTIVIRUS=trim($field[1]);}
158
			}
159
		}
160
	}
161
else { echo "$l_error_open_file $conf_file";}
162
echo "<tr><th>$l_title_antivir</th></tr>";
318 richard 163
?>
612 richard 164
<tr bgcolor=#FFCC66><td><img src=/images/pix.gif width=1 height=2></td></tr>
165
</TABLE>
318 richard 166
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
167
	<tr><td valign="middle" align="left">
168
<?php
612 richard 169
if ($WEB_ANTIVIRUS == "on")
318 richard 170
	{
171
	echo "<CENTER><H3>$l_antivir_on</H3></CENTER>";
172
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
173
	echo "<input type=hidden name='choix' value=\"AV_Off\">";
174
	echo "<input type=submit value=\"$l_switch_antivir_off\">";
175
}
176
else
177
	{
178
	echo "<CENTER><H3>$l_antivir_off</H3></CENTER>";
179
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
180
	echo "<input type=hidden name='choix' value=\"AV_On\">";
181
	echo "<input type=submit value=\"$l_switch_antivir_on\">";
182
	}
183
?>
184
</FORM>
185
</td></tr>
372 richard 186
</table>
187
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
188
<tr><th><?echo "$l_title_proto";?></th></tr>
189
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
190
</table>
191
<TABLE width="100%" border=1 cellspacing=0 cellpadding=0>
318 richard 192
<tr><td valign="middle" align="left">
193
<?
612 richard 194
if ($PROTOCOLS_FILTERING == "on")
318 richard 195
	{
196
	echo "<CENTER><H3>$l_netfilter_on</H3>$l_comment_on</CENTER>";
197
	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
198
	echo "<input type=hidden name='choix' value=\"NF_Off\">";
199
	echo "<input type=submit value=\"$l_switch_off\">";
200
	}
201
else
202
	{
203
	echo "<CENTER><H3>$l_netfilter_off</H3>$l_comment_off</CENTER>";
204
 	echo "<FORM action='$_SERVER[PHP_SELF]' method=POST>";
205
	echo "<input type=hidden name='choix' value=\"NF_On\">";
206
	echo "<input type=submit value=\"$l_switch_on\">";
207
	}
208
echo "</FORM>";
209
echo "</td></tr>";
210
echo "</TABLE>";
612 richard 211
if ($PROTOCOLS_FILTERING == "on") require ('net_filter2.php');
318 richard 212
?>
213
</BODY>
214
</HTML>