Subversion Repositories ALCASAR

Rev

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