Subversion Repositories ALCASAR

Rev

Rev 498 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 498 Rev 504
Line 5... Line 5...
5
<TITLE>Exceptions</TITLE>
5
<TITLE>Exceptions</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
<?
9
<?
-
 
10
$mac_allowed_list="/usr/local/etc/alcasar-macallowed";
10
# Choice of language
11
# Choice of language
11
$Language = 'en';
12
$Language = 'en';
12
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
13
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
13
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
14
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
15
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
Line 20... Line 21...
20
  $l_trusted_sites_list = "Liste de sites Internet de confiance";
21
  $l_trusted_sites_list = "Liste de sites Internet de confiance";
21
  $l_trusted_urls_list = "Liste d'URLs Internet de confiance";
22
  $l_trusted_urls_list = "Liste d'URLs Internet de confiance";
22
  $l_trusted_mac = "&Eacute;quipements de confiance";
23
  $l_trusted_mac = "&Eacute;quipements de confiance";
23
  $l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
24
  $l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
24
  $l_trusted_mac_list = "Liste des adresses MAC de confiance";
25
  $l_trusted_mac_list = "Liste des adresses MAC de confiance";
25
  $l_trusted_mac_address = "Adresse MAC autorisées";
26
  $l_trusted_mac_address = "Adresses MAC autorisées";
26
  $l_trusted_mac_info = "Information équipement";
27
  $l_trusted_mac_info = "Information équipement";
27
  $l_trusted_mac_del = "Supprimer de la liste";
28
  $l_trusted_mac_del = "Supprimer de la liste";
28
  $l_submit = "Enregistrer";
29
  $l_submit = "Enregistrer";
-
 
30
  $l_add_to_list = "Ajouter";
29
}
31
}
30
else {
32
else {
31
  $l_error_open_file = "File open error";
33
  $l_error_open_file = "File open error";
32
  $l_trusted_sites = "Trusted Internet sites";
34
  $l_trusted_sites = "Trusted Internet sites";
33
  $l_trusted_sites_explain1 = "Enter name of Internet sites or URLS that could be joined without authentication";
35
  $l_trusted_sites_explain1 = "Enter name of Internet sites or URLS that could be joined without authentication";
34
  $l_trusted_sites_explain2 = "Enter one name per line";
36
  $l_trusted_sites_explain2 = "Enter one name per line";
35
  $l_trusted_sites_list = "Trusted Internet sites list";
37
  $l_trusted_sites_list = "Trusted Internet sites list";
36
  $l_trusted_urls_list = "Trusted Internet URLs list";
38
  $l_trusted_urls_list = "Trusted Internet URLs list";
37
  $l_trusted_mac = "Trusted Equipments";
39
  $l_trusted_mac = "Trusted Equipments";
38
  $l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentification";
40
  $l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication";
39
  $l_trusted_mac_list = "Trusted MAC addresses list";
41
  $l_trusted_mac_list = "Trusted MAC addresses list";
40
  $l_trusted_mac_address = "Allowed MAC adress MAC"; 
42
  $l_trusted_mac_address = "Allowed MAC adress"; 
41
  $l_trusted_mac_info = "Equipment information";
43
  $l_trusted_mac_info = "Equipment information";
42
  $l_trusted_mac_del = "Delete from list";
44
  $l_trusted_mac_del = "Delete from list";
43
  $l_submit = "Submit";
45
  $l_submit = "Submit";
44
 
-
 
-
 
46
  $l_add_to_list = "Add";
45
}
47
}
46
if (isset($_POST['choix'])){ 
48
if (isset($_POST['choix'])){ 
47
	switch ($_POST['choix'])
49
	switch ($_POST['choix'])
48
	{
50
	{
49
	case 'MAJ_UAMALLOWED' :
51
	case 'MAJ_UAMALLOWED' :
Line 80... Line 82...
80
		unset($_POST['trusted_urls']);
82
		unset($_POST['trusted_urls']);
81
		unset($nb_url);
83
		unset($nb_url);
82
		exec ("sudo service chilli restart");
84
		exec ("sudo service chilli restart");
83
		unset ($_POST['choix']);
85
		unset ($_POST['choix']);
84
		break;
86
		break;
85
	case 'MAJ_MACALLOWED' :
87
case 'new_mac' :
-
 
88
	if (trim($_POST['add_mac']) != "")
-
 
89
		{
-
 
90
		if (is_file ($mac_allowed_list)) # le fichier existe
-
 
91
			{
-
 
92
			$tab=file($mac_allowed_list);
86
		$nb_mac=0;
93
			$insert = true;
87
		$tab_macs = explode ("\n", $_POST['trusted_macs']);
94
			if ($tab)  # le fichier n'est pas vide
-
 
95
				{
88
		$fichier=fopen("/usr/local/etc/alcasar-macallowed","w+");
96
				foreach ($tab as $line)  # on teste si l'adresse mac n'est pas déjà présente
-
 
97
					{
-
 
98
					$field=explode("#", $line);
89
		fputs ($fichier, "macallowed=\"");
99
					$mac_addr=trim($field[0],"macallowed=");
90
		foreach ($tab_macs as $macs ){
100
					if (trim($_POST['add_mac']) == trim ($mac_addr))
-
 
101
						{
91
			$tr_macs=trim($macs);
102
						$insert = false;;
92
			$nb_mac++;
103
						break;
-
 
104
						}
-
 
105
					}
-
 
106
				}
93
			if ($tr_macs != ""){
107
			if ($insert == true) 
-
 
108
				{
-
 
109
				$line = "macallowed=" . trim($_POST['add_mac']) . " #" . trim($_POST['add_comment']) . "\n";
94
				if ($nb_mac>1) fputs ($fichier, ",".$tr_macs);
110
				$pointeur=fopen($mac_allowed_list,"a");
95
				else fputs ($fichier, $tr_macs);
111
				fwrite ($pointeur, $line);
-
 
112
				fclose ($pointeur);
-
 
113
				exec ("sudo service chilli restart");
96
				}
114
				}
97
			}
115
			}
-
 
116
		else {echo "$l_error_open_file $mac_allowed_list";}
-
 
117
		}
-
 
118
	break;
-
 
119
case 'del_mac' :
-
 
120
	$tab=file($mac_allowed_list);
-
 
121
	if ($tab)
-
 
122
		{
-
 
123
		$pointeur=fopen($mac_allowed_list,"w+");
98
		fputs($fichier, "\"");
124
		foreach ($tab as $line)
-
 
125
			{
99
		fclose($fichier);
126
			$field=explode("#", $line);
-
 
127
			$mac_addr=trim(trim($field[0],"macallowed="));
-
 
128
			$remove_line = false;
100
		unset($_POST['trusted_macs']);
129
			foreach ($_POST as $key => $value)
-
 
130
				{
-
 
131
				if ($mac_addr == $key)
-
 
132
			       		{
-
 
133
					$remove_line = True;
-
 
134
					break;
-
 
135
					}
-
 
136
				}
-
 
137
			if (! $remove_line) {fwrite($pointeur,$line);}
-
 
138
			}
101
		unset($nb_mac);
139
		fclose($pointeur);
102
		exec ("sudo service chilli restart");
140
		exec ("sudo service chilli restart");
-
 
141
		}
103
		unset ($_POST['choix']);
142
	else {echo "$l_error_open_file $mac_allowed_list";}
104
		break;
143
	break;
105
	}	
144
	}	
106
}
145
}
107
?>
146
?>
108
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
147
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
109
	<tr><th><?php echo $l_trusted_sites ;?></th></tr>
148
	<tr><th><?php echo $l_trusted_sites ;?></th></tr>
Line 192... Line 231...
192
echo "$l_trusted_mac_explain</td></tr>";
231
echo "$l_trusted_mac_explain</td></tr>";
193
echo "<tr><td align='center' valign='middle'>";
232
echo "<tr><td align='center' valign='middle'>";
194
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
233
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
195
echo "<table cellspacing=2 cellpadding=3 border=1>";
234
echo "<table cellspacing=2 cellpadding=3 border=1>";
196
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>";
235
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>";
197
// On lit et on interprète le fichier de filtrage de protocoles
236
// On lit et on affiche le fichier d'exception
198
$trusted_mac_file="/usr/local/etc/alcasar-macallowed";
237
$display_form = true;
199
if (file_exists($trusted_mac_file))
238
if (is_file ($mac_allowed_list))
200
	{
239
	{
201
	$pointeur=fopen($trusted_mac_file,"r");
240
	$tab=file($mac_allowed_list);
202
	while (!feof ($pointeur))
241
	if ($tab)  # le fichier n'est pas vide
203
		{
242
		{
204
		$ligne=fgets($pointeur, 4096);
-
 
205
		if ($ligne)
243
		foreach ($tab as $line)
206
			{
244
			{
207
			$field=explode(" ", $ligne);
245
			$field=explode("#", $line);
-
 
246
			$mac_addr=trim(trim($field[0],"macallowed="));
208
			$mac_info=trim($field[2],"#");
247
			$mac_info=trim($field[1],"#");
209
			echo "<tr><td>$field[1]";
248
			echo "<tr><td>$mac_addr";
210
			echo "<td>$mac_info";
249
			echo "<td>$mac_info";
211
			echo "<td><input type='checkbox' name='del-$field[1]'>";
250
			echo "<td><input type='checkbox' name='$mac_addr'>";
212
			echo "</tr>";
251
			echo "</tr>";
213
			}
252
			}
214
		}
253
		}
215
	fclose($pointeur);
254
	else { $display_form = false;}
216
	}
255
	}
217
else	{
256
else	{
218
	echo "$l_error_open_file $trusted_mac_file";
257
	echo "$l_error_open_file $mac_allowed_list";
-
 
258
	$display_form = false;
219
	}
259
	}
-
 
260
echo "</table>";
-
 
261
if ($display_form)
-
 
262
	{
-
 
263
	echo "<input type='hidden' name='choix' value='del_mac'>";
-
 
264
	echo "<input type='submit' value='$l_submit'>";
-
 
265
	}
-
 
266
echo "</form></td><td valign='middle' align='center'>";
-
 
267
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
-
 
268
echo "<table cellspacing=2 cellpadding=3 border=1>";
-
 
269
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info";
220
?>
270
?>
221
</table>
271
<td></td></tr>
222
<input type='hidden' name='choix' value='change'>
-
 
223
<input type='submit' value='<?echo"$l_submit";?>'>
-
 
224
</form>
-
 
225
</td>
-
 
226
<td valign='middle' align='center'>
-
 
227
<form action='net_filter.php' method='POST'>
-
 
228
<table cellspacing=2 cellpadding=3 border=1>
-
 
229
<tr><th><?echo"$l_trusted_mac_address<th>$l_trusted_mac_info";?></tr>
272
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : PC of the boss</td><td></td></tr>
230
<tr><td><input type='text' name='add_proto' size='10'></td>
273
<tr><td><input type='text' name='add_mac' size='17'></td>
231
<td><input type='text' name='add_port' size='5'></td>
274
<td><input type='text' name='add_comment' size='10'></td>
232
<input type='hidden' name='choix' value='new_proto'>
275
<input type='hidden' name='choix' value='new_mac'>
233
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
276
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
234
</tr></table>
277
</tr></table>
235
</form>
278
</form>
236
</td></tr>
279
</td></tr>
237
</table>
280
</table>
238
 
-
 
239
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
-
 
240
	<tr bgcolor="#666666"><td>
-
 
241
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
-
 
242
		<tr><td valign="middle" align="left">
-
 
243
		<center><?php
-
 
244
		echo "$l_trusted_mac_explain1 <BR>";
-
 
245
		echo "$l_trusted_mac_explain2";
-
 
246
		echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
-
 
247
		<TABLE cellspacing=2 cellpadding=3 border=1>
-
 
248
		<tr><td width=60% height=100% align=center>
-
 
249
			<H3><?php echo $l_trusted_mac_list ;?></H3>
-
 
250
			exemple : 12-2f-36-a4-df-43<BR>
-
 
251
			<?php
-
 
252
				echo "<textarea name='trusted_macs' rows=5 cols=40>";
-
 
253
				$trusted_macs_file="/usr/local/etc/alcasar-macallowed";
-
 
254
				$ouvre=fopen($trusted_macs_file,"r");
-
 
255
				if ($ouvre)
-
 
256
					{
-
 
257
					while (!feof ($ouvre))
-
 
258
						{
-
 
259
						$tampon = fgets($ouvre, 4096);
-
 
260
						$mac_list_l = substr($tampon,11);
-
 
261
						$mac_list = trim ($mac_list_l,"\"\n\t ");
-
 
262
						$tab_macs = explode (",", $mac_list);
-
 
263
						foreach ($tab_macs as $macs ){
-
 
264
							if ($macs) echo $macs."\n";
-
 
265
							}
-
 
266
		  				}
-
 
267
					}
-
 
268
				else	{
-
 
269
					echo "failed to open $trusted_macs_file";
-
 
270
					}
-
 
271
				fclose($ouvre);
-
 
272
				echo "</textarea>";
-
 
273
			?>
-
 
274
		</td></tr>
-
 
275
		</TABLE>
-
 
276
		<input type='hidden' name='choix' value='MAJ_MACALLOWED'>
-
 
277
		<input type='submit' value='<?php echo $l_submit ;?>'>
-
 
278
		</FORM>
-
 
279
	</td></tr>
-
 
280
</TABLE>
-
 
281
</BODY>
281
</BODY>
282
</HTML>
282
</HTML>