Subversion Repositories ALCASAR

Rev

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

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