Subversion Repositories ALCASAR

Rev

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

Rev 606 Rev 688
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 - 3abtux -->
2
<HTML><!-- written by Rexy - 3abtux -->
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>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
$mac_allowed_list="/usr/local/etc/alcasar-macallowed";
11
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
11
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
12
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
12
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
13
# Choice of language
13
# Choice of language
14
$Language = 'en';
14
$Language = 'en';
15
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
15
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
16
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
16
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
17
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
17
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
18
if($Language == 'fr'){
18
if($Language == 'fr'){
19
  $l_error_open_file = "Erreur d'ouverture du fichier";
19
  $l_error_open_file = "Erreur d'ouverture du fichier";
20
  $l_trusted_sites = "Sites Internet de confiance";
20
  $l_trusted_sites = "Domaines Internet et adresses IP de confiance";
21
  $l_trusted_sites_explain1 = "Entrez ici les noms de site ou d'URLs Internet pouvant &ecirc;tre joints sans authentification";
21
  $l_trusted_sites_explain1 = "Entrez ici les noms de domaine Internet ou les adresses IP pouvant &ecirc;tre joints sans authentification";
22
  $l_trusted_sites_explain2 = "Entrez un nom par ligne";
22
  $l_trusted_sites_explain2 = "Entrez un nom de domaine ou une adresse IP par ligne";
23
  $l_trusted_sites_list = "Liste de sites Internet de confiance";
23
  $l_trusted_sites_list = "Liste de nom de domaine de confiance";
24
  $l_trusted_urls_list = "Liste d'URLs Internet de confiance";
24
  $l_trusted_urls_list = "Liste d'adresses IP ou d'adresses de réseau de confiance";
25
  $l_trusted_mac = "&Eacute;quipements de confiance";
25
  $l_trusted_mac = "&Eacute;quipements de confiance";
26
  $l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
26
  $l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
27
  $l_trusted_mac_list = "Liste des adresses MAC de confiance";
27
  $l_trusted_mac_list = "Liste d'adresses MAC de confiance";
28
  $l_trusted_mac_address = "Adresses MAC autorisées";
28
  $l_trusted_mac_address = "Adresses MAC autorisées";
29
  $l_trusted_mac_info = "Information équipement";
29
  $l_trusted_mac_info = "Information équipement";
30
  $l_trusted_mac_del = "Supprimer de la liste";
30
  $l_trusted_mac_del = "Supprimer de la liste";
31
  $l_submit = "Enregistrer";
31
  $l_submit = "Enregistrer";
32
  $l_submit2 = "Appliquer";
32
  $l_submit2 = "Appliquer";
33
  $l_add_to_list = "Ajouter";
33
  $l_add_to_list = "Ajouter";
34
}
34
}
35
else {
35
else {
36
  $l_error_open_file = "File open error";
36
  $l_error_open_file = "File open error";
37
  $l_trusted_sites = "Trusted Internet sites";
37
  $l_trusted_sites = "Trusted Internet domain and IP addresses";
38
  $l_trusted_sites_explain1 = "Enter name of Internet sites or URLS that could be joined without authentication";
38
  $l_trusted_sites_explain1 = "Enter Internet domain name or IP addresses that could be joined without authentication";
39
  $l_trusted_sites_explain2 = "Enter one name per line";
39
  $l_trusted_sites_explain2 = "Enter one domain name ou one IP address per line";
40
  $l_trusted_sites_list = "Trusted Internet sites list";
40
  $l_trusted_sites_list = "Trusted Internet domain list";
41
  $l_trusted_urls_list = "Trusted Internet URLs list";
41
  $l_trusted_urls_list = "Trusted IP addresses or networks addresses list";
42
  $l_trusted_mac = "Trusted Equipments";
42
  $l_trusted_mac = "Trusted Equipments";
43
  $l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication";
43
  $l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication";
44
  $l_trusted_mac_list = "Trusted MAC addresses list";
44
  $l_trusted_mac_list = "Trusted MAC addresses list";
45
  $l_trusted_mac_address = "Allowed MAC adress"; 
45
  $l_trusted_mac_address = "Allowed MAC adress"; 
46
  $l_trusted_mac_info = "Equipment information";
46
  $l_trusted_mac_info = "Equipment information";
47
  $l_trusted_mac_del = "Delete from list";
47
  $l_trusted_mac_del = "Delete from list";
48
  $l_submit = "Submit";
48
  $l_submit = "Submit";
49
  $l_submit2 = "Apply";
49
  $l_submit2 = "Apply";
50
  $l_add_to_list = "Add";
50
  $l_add_to_list = "Add";
51
}
51
}
52
if (isset($_POST['choix'])){ 
52
if (isset($_POST['choix'])){ 
53
	switch ($_POST['choix'])
53
	switch ($_POST['choix'])
54
	{
54
	{
55
	case 'MAJ_UAMALLOWED' :
55
	case 'MAJ_UAMALLOWED' :
56
		$tab_domains = explode ("\n", $_POST['trusted_domains']);
56
		$tab_domains = explode ("\n", $_POST['trusted_domains']);
57
		$fichier=fopen($domain_allowed_list,"w+");
57
		$fichier=fopen($domain_allowed_list,"w+");
58
		foreach ($tab_domains as $domain ){
58
		foreach ($tab_domains as $domain ){
59
			$tr_domain=trim($domain);
59
			$tr_domain=trim($domain);
60
			if ($tr_domain != ""){
60
			if ($tr_domain != ""){
61
				fputs ($fichier, "uamdomain=\"".$tr_domain."\"\n");}
61
				fputs ($fichier, "uamdomain=\"".$tr_domain."\"\n");}
62
			}	
62
			}	
63
		fclose($fichier);
63
		fclose($fichier);
64
		unset($_POST['trusted_domains']);
64
		unset($_POST['trusted_domains']);
65
		$tab_urls = explode ("\n", $_POST['trusted_urls']);
65
		$tab_urls = explode ("\n", $_POST['trusted_urls']);
66
		$fichier=fopen($url_allowed_list,"w+");
66
		$fichier=fopen($url_allowed_list,"w+");
67
		foreach ($tab_urls as $url ){
67
		foreach ($tab_urls as $url ){
68
			$tr_url=trim($url);
68
			$tr_url=trim($url);
69
			if ($tr_url != ""){
69
			if ($tr_url != ""){
70
				fputs ($fichier, "uamallowed=\"".$tr_url."\"\n");}
70
				fputs ($fichier, "uamallowed=\"".$tr_url."\"\n");}
71
			}
71
			}
72
		fclose($fichier);
72
		fclose($fichier);
73
		unset($_POST['trusted_urls']);
73
		unset($_POST['trusted_urls']);
74
		exec ("sudo service chilli restart");
74
		exec ("sudo service chilli restart");
75
		unset ($_POST['choix']);
75
		unset ($_POST['choix']);
76
		break;
76
		break;
77
case 'new_mac' :
77
case 'new_mac' :
78
	if (trim($_POST['add_mac']) != "")
78
	if (trim($_POST['add_mac']) != "")
79
		{
79
		{
80
		if (is_file ($mac_allowed_list)) # le fichier existe
80
		if (is_file ($mac_allowed_list)) # le fichier existe
81
			{
81
			{
82
			$tab=file($mac_allowed_list);
82
			$tab=file($mac_allowed_list);
83
			$insert = true;
83
			$insert = true;
84
			if ($tab)  # le fichier n'est pas vide
84
			if ($tab)  # le fichier n'est pas vide
85
				{
85
				{
86
				foreach ($tab as $line)  # on teste si l'adresse mac n'est pas déjà présente
86
				foreach ($tab as $line)  # on teste si l'adresse mac n'est pas déjà présente
87
					{
87
					{
88
					$field=explode("#", $line);
88
					$field=explode("#", $line);
89
					$mac_addr=trim($field[0],"macallowed=");
89
					$mac_addr=trim($field[0],"macallowed=");
90
					if (trim($_POST['add_mac']) == trim ($mac_addr))
90
					if (trim($_POST['add_mac']) == trim ($mac_addr))
91
						{
91
						{
92
						$insert = false;;
92
						$insert = false;;
93
						break;
93
						break;
94
						}
94
						}
95
					}
95
					}
96
				}
96
				}
97
			if ($insert == true) 
97
			if ($insert == true) 
98
				{
98
				{
99
				$line = "macallowed=" . trim($_POST['add_mac']) . " #" . trim($_POST['add_comment']) . "\n";
99
				$line = "macallowed=" . trim($_POST['add_mac']) . " #" . trim($_POST['add_comment']) . "\n";
100
				$pointeur=fopen($mac_allowed_list,"a");
100
				$pointeur=fopen($mac_allowed_list,"a");
101
				fwrite ($pointeur, $line);
101
				fwrite ($pointeur, $line);
102
				fclose ($pointeur);
102
				fclose ($pointeur);
103
				exec ("sudo service chilli restart");
103
				exec ("sudo service chilli restart");
104
				}
104
				}
105
			}
105
			}
106
		else {echo "$l_error_open_file $mac_allowed_list";}
106
		else {echo "$l_error_open_file $mac_allowed_list";}
107
		}
107
		}
108
	break;
108
	break;
109
case 'del_mac' :
109
case 'del_mac' :
110
	$tab=file($mac_allowed_list);
110
	$tab=file($mac_allowed_list);
111
	if ($tab)
111
	if ($tab)
112
		{
112
		{
113
		$pointeur=fopen($mac_allowed_list,"w+");
113
		$pointeur=fopen($mac_allowed_list,"w+");
114
		foreach ($tab as $line)
114
		foreach ($tab as $line)
115
			{
115
			{
116
			$field=explode("#", $line);
116
			$field=explode("#", $line);
117
			$mac_addr=trim(trim($field[0],"macallowed="));
117
			$mac_addr=trim(trim($field[0],"macallowed="));
118
			$remove_line = false;
118
			$remove_line = false;
119
			foreach ($_POST as $key => $value)
119
			foreach ($_POST as $key => $value)
120
				{
120
				{
121
				if ($mac_addr == $key)
121
				if ($mac_addr == $key)
122
			       		{
122
			       		{
123
					$remove_line = True;
123
					$remove_line = True;
124
					break;
124
					break;
125
					}
125
					}
126
				}
126
				}
127
			if (! $remove_line) {fwrite($pointeur,$line);}
127
			if (! $remove_line) {fwrite($pointeur,$line);}
128
			}
128
			}
129
		fclose($pointeur);
129
		fclose($pointeur);
130
		exec ("sudo service chilli restart");
130
		exec ("sudo service chilli restart");
131
		}
131
		}
132
	else {echo "$l_error_open_file $mac_allowed_list";}
132
	else {echo "$l_error_open_file $mac_allowed_list";}
133
	break;
133
	break;
134
	}	
134
	}	
135
}
135
}
136
?>
136
?>
137
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
137
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
138
	<tr><th><?php echo $l_trusted_sites ;?></th></tr>
138
	<tr><th><?php echo $l_trusted_sites ;?></th></tr>
139
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
139
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
140
</TABLE>
140
</TABLE>
141
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
141
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
142
	<tr bgcolor="#666666"><td>
142
	<tr bgcolor="#666666"><td>
143
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
143
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
144
		<tr><td valign="middle" align="left">
144
		<tr><td valign="middle" align="left">
145
		<center><?php
145
		<center><?php
146
		echo "$l_trusted_sites_explain1 <BR>";
146
		echo "$l_trusted_sites_explain1 <BR>";
147
		echo "$l_trusted_sites_explain2" ;
147
		echo "$l_trusted_sites_explain2" ;
148
		echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
148
		echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
149
		<TABLE cellspacing=2 cellpadding=3 border=1>
149
		<TABLE cellspacing=2 cellpadding=3 border=1>
150
		<tr><td width=50% height=100% align=center>
150
		<tr><td width=50% height=100% align=center>
151
			<H3><?php echo $l_trusted_sites_list ;?></H3>
151
			<H3><?php echo $l_trusted_sites_list ;?></H3>
152
			exemple1 : www.domain1.org<BR>
152
			exemple1 : www.domain1.org<BR>
153
			exemple2 : domain2.net<BR>
153
			exemple2 : domain2.net<BR>
154
			<?php
154
			<?php
155
				echo "<textarea name='trusted_domains' rows=5 cols=40>";
155
				echo "<textarea name='trusted_domains' rows=5 cols=40>";
156
				$ouvre=fopen($domain_allowed_list,"r");
156
				$ouvre=fopen($domain_allowed_list,"r");
157
				if ($ouvre)
157
				if ($ouvre)
158
					{
158
					{
159
					while (!feof ($ouvre))
159
					while (!feof ($ouvre))
160
						{
160
						{
161
						$tampon = fgets($ouvre, 4096);
161
						$tampon = fgets($ouvre, 4096);
162
						$domain_list_l = substr($tampon,10);
162
						$domain_list_l = substr($tampon,10);
163
						$domain_list = trim ($domain_list_l,"\"\n\t ");
163
						$domain_list = trim ($domain_list_l,"\"\n\t ");
164
						$tab_domains = explode (",", $domain_list);
164
						$tab_domains = explode (",", $domain_list);
165
						foreach ($tab_domains as $domain ){
165
						foreach ($tab_domains as $domain ){
166
							if ($domain) { echo $domain."\n";}
166
							if ($domain) { echo $domain."\n";}
167
							}
167
							}
168
		  				}
168
		  				}
169
					}
169
					}
170
				else	{
170
				else	{
171
					echo "failed to open $domain_allowed_list";
171
					echo "failed to open $domain_allowed_list";
172
					}
172
					}
173
				fclose($ouvre);
173
				fclose($ouvre);
174
				echo "</textarea>";
174
				echo "</textarea>";
175
			?>
175
			?>
176
		</td>
176
		</td>
177
		<td  width=50% height=100% align=center>
177
		<td  width=50% height=100% align=center>
178
			<H3><?php echo $l_trusted_urls_list ;?></H3>
178
			<H3><?php echo $l_trusted_urls_list ;?></H3>
179
			exemple1 : www.domain3.net/admin/index.htm<BR>
179
			exemple1 : 192.168.0.10<BR>
180
			exemple2 : domain4.org/~polux/index.html<BR>
180
			exemple2 : 172.16.20.0/24<BR>
181
			<?php
181
			<?php
182
				echo "<textarea name='trusted_urls' rows=5 cols=40>";
182
				echo "<textarea name='trusted_urls' rows=5 cols=40>";
183
				$ouvre=fopen($url_allowed_list,"r");
183
				$ouvre=fopen($url_allowed_list,"r");
184
				if ($ouvre)
184
				if ($ouvre)
185
			       		{
185
			       		{
186
					while (!feof ($ouvre))
186
					while (!feof ($ouvre))
187
						{
187
						{
188
						$tampon = fgets($ouvre, 4096);
188
						$tampon = fgets($ouvre, 4096);
189
						$url_list_l = substr($tampon,11);
189
						$url_list_l = substr($tampon,11);
190
						$url_list = trim ($url_list_l,"\"\n\t ");
190
						$url_list = trim ($url_list_l,"\"\n\t ");
191
						$tab_urls = explode (",", $url_list);
191
						$tab_urls = explode (",", $url_list);
192
						foreach ($tab_urls as $url ){
192
						foreach ($tab_urls as $url ){
193
							if ($url) echo $url."\n";
193
							if ($url) echo $url."\n";
194
							}
194
							}
195
						}
195
						}
196
					}
196
					}
197
				else	{
197
				else	{
198
					echo "failed to open $url_allowed_list";
198
					echo "failed to open $url_allowed_list";
199
					}
199
					}
200
				fclose($ouvre);
200
				fclose($ouvre);
201
				echo "</textarea>";
201
				echo "</textarea>";
202
			?>
202
			?>
203
		</td></tr>
203
		</td></tr>
204
		</TABLE>
204
		</TABLE>
205
		<input type='hidden' name='choix' value='MAJ_UAMALLOWED'>
205
		<input type='hidden' name='choix' value='MAJ_UAMALLOWED'>
206
		<input type='submit' value='<?php echo $l_submit ;?>'>
206
		<input type='submit' value='<?php echo $l_submit ;?>'>
207
		</FORM>
207
		</FORM>
208
	</td></tr>
208
	</td></tr>
209
	</TABLE>
209
	</TABLE>
210
</TABLE>
210
</TABLE>
211
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
211
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
212
	<tr><th><?php echo $l_trusted_mac ;?></th></tr>
212
	<tr><th><?php echo $l_trusted_mac ;?></th></tr>
213
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
213
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
214
</TABLE>
214
</TABLE>
215
 
215
 
216
<table width="100%" border=1 cellspacing=0 cellpadding=1>
216
<table width="100%" border=1 cellspacing=0 cellpadding=1>
217
<tr><td colspan=2 align="center">
217
<tr><td colspan=2 align="center">
218
<?
218
<?
219
echo "$l_trusted_mac_explain</td></tr>";
219
echo "$l_trusted_mac_explain</td></tr>";
220
echo "<tr><td align='center' valign='middle'>";
220
echo "<tr><td align='center' valign='middle'>";
221
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
221
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
222
echo "<table cellspacing=2 cellpadding=3 border=1>";
222
echo "<table cellspacing=2 cellpadding=3 border=1>";
223
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>";
223
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info<th>$l_trusted_mac_del</tr>";
224
// On lit et on affiche le fichier d'exception
224
// On lit et on affiche le fichier d'exception
225
$display_form = true;
225
$display_form = true;
226
if (is_file ($mac_allowed_list))
226
if (is_file ($mac_allowed_list))
227
	{
227
	{
228
	$tab=file($mac_allowed_list);
228
	$tab=file($mac_allowed_list);
229
	if ($tab)  # le fichier n'est pas vide
229
	if ($tab)  # le fichier n'est pas vide
230
		{
230
		{
231
		foreach ($tab as $line)
231
		foreach ($tab as $line)
232
			{
232
			{
233
			$field=explode("#", $line);
233
			$field=explode("#", $line);
234
			$mac_addr=trim(trim($field[0],"macallowed="));
234
			$mac_addr=trim(trim($field[0],"macallowed="));
235
			$mac_info=trim($field[1],"#");
235
			$mac_info=trim($field[1],"#");
236
			echo "<tr><td>$mac_addr";
236
			echo "<tr><td>$mac_addr";
237
			echo "<td>$mac_info";
237
			echo "<td>$mac_info";
238
			echo "<td><input type='checkbox' name='$mac_addr'>";
238
			echo "<td><input type='checkbox' name='$mac_addr'>";
239
			echo "</tr>";
239
			echo "</tr>";
240
			}
240
			}
241
		}
241
		}
242
	else { $display_form = false;}
242
	else { $display_form = false;}
243
	}
243
	}
244
else	{
244
else	{
245
	echo "$l_error_open_file $mac_allowed_list";
245
	echo "$l_error_open_file $mac_allowed_list";
246
	$display_form = false;
246
	$display_form = false;
247
	}
247
	}
248
echo "</table>";
248
echo "</table>";
249
if ($display_form)
249
if ($display_form)
250
	{
250
	{
251
	echo "<input type='hidden' name='choix' value='del_mac'>";
251
	echo "<input type='hidden' name='choix' value='del_mac'>";
252
	echo "<input type='submit' value='$l_submit2'>";
252
	echo "<input type='submit' value='$l_submit2'>";
253
	}
253
	}
254
echo "</form></td><td valign='middle' align='center'>";
254
echo "</form></td><td valign='middle' align='center'>";
255
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
255
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
256
echo "<table cellspacing=2 cellpadding=3 border=1>";
256
echo "<table cellspacing=2 cellpadding=3 border=1>";
257
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info";
257
echo "<tr><th>$l_trusted_mac_address<th>$l_trusted_mac_info";
258
?>
258
?>
259
<td></td></tr>
259
<td></td></tr>
260
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : PC of the boss</td><td></td></tr>
260
<tr><td>exemple : 12-2f-36-a4-df-43</td><td>exemple : PC of the boss</td><td></td></tr>
261
<tr><td><input type='text' name='add_mac' size='17'></td>
261
<tr><td><input type='text' name='add_mac' size='17'></td>
262
<td><input type='text' name='add_comment' size='10'></td>
262
<td><input type='text' name='add_comment' size='10'></td>
263
<input type='hidden' name='choix' value='new_mac'>
263
<input type='hidden' name='choix' value='new_mac'>
264
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
264
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
265
</tr></table>
265
</tr></table>
266
</form>
266
</form>
267
</td></tr>
267
</td></tr>
268
</table>
268
</table>
269
</BODY>
269
</BODY>
270
</HTML>
270
</HTML>
271
 
271