Subversion Repositories ALCASAR

Rev

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";
606 richard 11
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
12
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
318 richard 13
# Choice of language
14
$Language = 'en';
15
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
16
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
17
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
18
if($Language == 'fr'){
498 richard 19
  $l_error_open_file = "Erreur d'ouverture du fichier";
688 richard 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";
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";
24
  $l_trusted_urls_list = "Liste d'adresses IP ou d'adresses de réseau de confiance";
318 richard 25
  $l_trusted_mac = "&Eacute;quipements de confiance";
498 richard 26
  $l_trusted_mac_explain = "Entrez ici les adresses MAC des &eacute;quipements autorisés à joindre Internet sans authentification";
688 richard 27
  $l_trusted_mac_list = "Liste d'adresses MAC de confiance";
504 richard 28
  $l_trusted_mac_address = "Adresses MAC autorisées";
498 richard 29
  $l_trusted_mac_info = "Information équipement";
30
  $l_trusted_mac_del = "Supprimer de la liste";
318 richard 31
  $l_submit = "Enregistrer";
520 richard 32
  $l_submit2 = "Appliquer";
504 richard 33
  $l_add_to_list = "Ajouter";
318 richard 34
}
35
else {
498 richard 36
  $l_error_open_file = "File open error";
688 richard 37
  $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";
39
  $l_trusted_sites_explain2 = "Enter one domain name ou one IP address per line";
40
  $l_trusted_sites_list = "Trusted Internet domain list";
41
  $l_trusted_urls_list = "Trusted IP addresses or networks addresses list";
318 richard 42
  $l_trusted_mac = "Trusted Equipments";
504 richard 43
  $l_trusted_mac_explain = "Enter MAC address of equipments that could contact Internet without authentication";
318 richard 44
  $l_trusted_mac_list = "Trusted MAC addresses list";
504 richard 45
  $l_trusted_mac_address = "Allowed MAC adress"; 
498 richard 46
  $l_trusted_mac_info = "Equipment information";
47
  $l_trusted_mac_del = "Delete from list";
318 richard 48
  $l_submit = "Submit";
520 richard 49
  $l_submit2 = "Apply";
504 richard 50
  $l_add_to_list = "Add";
318 richard 51
}
52
if (isset($_POST['choix'])){ 
53
	switch ($_POST['choix'])
54
	{
55
	case 'MAJ_UAMALLOWED' :
56
		$tab_domains = explode ("\n", $_POST['trusted_domains']);
606 richard 57
		$fichier=fopen($domain_allowed_list,"w+");
318 richard 58
		foreach ($tab_domains as $domain ){
59
			$tr_domain=trim($domain);
60
			if ($tr_domain != ""){
606 richard 61
				fputs ($fichier, "uamdomain=\"".$tr_domain."\"\n");}
318 richard 62
			}	
63
		fclose($fichier);
64
		unset($_POST['trusted_domains']);
65
		$tab_urls = explode ("\n", $_POST['trusted_urls']);
606 richard 66
		$fichier=fopen($url_allowed_list,"w+");
318 richard 67
		foreach ($tab_urls as $url ){
68
			$tr_url=trim($url);
69
			if ($tr_url != ""){
606 richard 70
				fputs ($fichier, "uamallowed=\"".$tr_url."\"\n");}
318 richard 71
			}
72
		fclose($fichier);
73
		unset($_POST['trusted_urls']);
74
		exec ("sudo service chilli restart");
75
		unset ($_POST['choix']);
76
		break;
504 richard 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
					}
318 richard 96
				}
504 richard 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
				}
318 richard 105
			}
504 richard 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);
318 richard 130
		exec ("sudo service chilli restart");
504 richard 131
		}
132
	else {echo "$l_error_open_file $mac_allowed_list";}
133
	break;
318 richard 134
	}	
135
}
136
?>
137
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
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>
140
</TABLE>
141
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
142
	<tr bgcolor="#666666"><td>
143
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
144
		<tr><td valign="middle" align="left">
145
		<center><?php
146
		echo "$l_trusted_sites_explain1 <BR>";
147
		echo "$l_trusted_sites_explain2" ;
148
		echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
149
		<TABLE cellspacing=2 cellpadding=3 border=1>
150
		<tr><td width=50% height=100% align=center>
151
			<H3><?php echo $l_trusted_sites_list ;?></H3>
152
			exemple1 : www.domain1.org<BR>
153
			exemple2 : domain2.net<BR>
154
			<?php
155
				echo "<textarea name='trusted_domains' rows=5 cols=40>";
606 richard 156
				$ouvre=fopen($domain_allowed_list,"r");
318 richard 157
				if ($ouvre)
158
					{
159
					while (!feof ($ouvre))
160
						{
161
						$tampon = fgets($ouvre, 4096);
356 richard 162
						$domain_list_l = substr($tampon,10);
163
						$domain_list = trim ($domain_list_l,"\"\n\t ");
346 richard 164
						$tab_domains = explode (",", $domain_list);
318 richard 165
						foreach ($tab_domains as $domain ){
346 richard 166
							if ($domain) { echo $domain."\n";}
318 richard 167
							}
168
		  				}
169
					}
170
				else	{
606 richard 171
					echo "failed to open $domain_allowed_list";
318 richard 172
					}
173
				fclose($ouvre);
174
				echo "</textarea>";
175
			?>
176
		</td>
177
		<td  width=50% height=100% align=center>
178
			<H3><?php echo $l_trusted_urls_list ;?></H3>
688 richard 179
			exemple1 : 192.168.0.10<BR>
180
			exemple2 : 172.16.20.0/24<BR>
318 richard 181
			<?php
182
				echo "<textarea name='trusted_urls' rows=5 cols=40>";
606 richard 183
				$ouvre=fopen($url_allowed_list,"r");
318 richard 184
				if ($ouvre)
185
			       		{
186
					while (!feof ($ouvre))
187
						{
188
						$tampon = fgets($ouvre, 4096);
356 richard 189
						$url_list_l = substr($tampon,11);
190
						$url_list = trim ($url_list_l,"\"\n\t ");
191
						$tab_urls = explode (",", $url_list);
318 richard 192
						foreach ($tab_urls as $url ){
346 richard 193
							if ($url) echo $url."\n";
318 richard 194
							}
195
						}
196
					}
197
				else	{
606 richard 198
					echo "failed to open $url_allowed_list";
318 richard 199
					}
200
				fclose($ouvre);
201
				echo "</textarea>";
202
			?>
203
		</td></tr>
204
		</TABLE>
205
		<input type='hidden' name='choix' value='MAJ_UAMALLOWED'>
206
		<input type='submit' value='<?php echo $l_submit ;?>'>
207
		</FORM>
208
	</td></tr>
209
	</TABLE>
210
</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>
498 richard 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>";
504 richard 224
// On lit et on affiche le fichier d'exception
225
$display_form = true;
226
if (is_file ($mac_allowed_list))
498 richard 227
	{
504 richard 228
	$tab=file($mac_allowed_list);
229
	if ($tab)  # le fichier n'est pas vide
498 richard 230
		{
504 richard 231
		foreach ($tab as $line)
498 richard 232
			{
504 richard 233
			$field=explode("#", $line);
234
			$mac_addr=trim(trim($field[0],"macallowed="));
235
			$mac_info=trim($field[1],"#");
236
			echo "<tr><td>$mac_addr";
498 richard 237
			echo "<td>$mac_info";
504 richard 238
			echo "<td><input type='checkbox' name='$mac_addr'>";
498 richard 239
			echo "</tr>";
240
			}
241
		}
504 richard 242
	else { $display_form = false;}
498 richard 243
	}
244
else	{
504 richard 245
	echo "$l_error_open_file $mac_allowed_list";
246
	$display_form = false;
498 richard 247
	}
504 richard 248
echo "</table>";
249
if ($display_form)
250
	{
251
	echo "<input type='hidden' name='choix' value='del_mac'>";
520 richard 252
	echo "<input type='submit' value='$l_submit2'>";
504 richard 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";
498 richard 258
?>
504 richard 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'>
498 richard 264
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
265
</tr></table>
266
</form>
267
</td></tr>
268
</table>
318 richard 269
</BODY>
270
</HTML>