Subversion Repositories ALCASAR

Rev

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