Subversion Repositories ALCASAR

Rev

Rev 868 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 868 Rev 870
Line 5... Line 5...
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
/********************
-
 
11
*  TEST CONF FILES  *
-
 
12
*********************/
-
 
13
define ("DOMAIN_ALLOWED_LIST", "/usr/local/etc/alcasar-uamdomain");
10
$mac_allowed_list="/usr/local/etc/alcasar-macallowed";
14
define ("IP_ALLOWED_LIST", "/usr/local/etc/alcasar-uamallowed");
-
 
15
$conf_files=array(DOMAIN_ALLOWED_LIST,IP_ALLOWED_LIST);
-
 
16
foreach ($conf_files as $file){
-
 
17
if (!file_exists($file)){
-
 
18
	exit("Requested file ".$file." isn't present");}
-
 
19
if (!is_readable($file)){
-
 
20
	exit("Can't read the file ".$file);}
-
 
21
}
11
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
22
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
12
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
23
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
13
# Choice of language
24
# Choice of language
14
$Language = 'en';
25
$Language = 'en';
15
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
26
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
16
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
27
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
17
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
28
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
18
if($Language == 'fr'){
29
if($Language == 'fr'){
19
  $l_error_open_file = "Erreur d'ouverture du fichier";
30
	$l_error_open_file	= "Erreur d'ouverture du fichier";
20
  $l_trusted_sites = "Noms de domaine et adresses IP Internet de confiance";
31
	$l_trusted_domain	= "Noms de domaine Internet de confiance";
-
 
32
	$l_domain		= "Noms de domaine";
21
  $l_trusted_sites_explain1 = "Entrez ici les noms de domaine ou les adresses IP situés sur Internet pouvant &ecirc;tre joints sans authentification";
33
	$l_comment_explain	= "Lien de la page d'interception";
22
  $l_trusted_sites_explain2 = "Entrez un nom de domaine ou une adresse IP par ligne";
34
	$l_comment_explain2	= "Laissez vide si non affiché";
-
 
35
	$l_remove		= "Retirer de la liste";
23
  $l_trusted_sites_list = "Liste des noms de domaine de confiance";
36
	$l_trusted_ip		= "adresses IP de confiance";
-
 
37
	$l_comment		= "Commentaires";
-
 
38
	$l_trusted_domain_explain = "Gérez ici les noms de domaine Internet pouvant &ecirc;tre joints sans authentification";
24
  $l_trusted_urls_list = "Liste d'adresses IP ou d'adresses de réseau de confiance";
39
	$l_trusted_ip_explain	= "Gérez ici les adresses IP de systèmes ou de réseaux pouvant être joints sans authentification";
25
  $l_submit = "Enregistrer";
40
	$l_submit		= "Enregistrer";
-
 
41
	$l_add_to_list		= "Ajouter à la liste";
-
 
42
	$l_apply		= "Appliquer les changements";
26
}
43
}
27
else {
44
else {
28
  $l_error_open_file = "File open error";
45
	$l_error_open_file	= "File open error";
29
  $l_trusted_sites = "Trusted Internet domain names and IP addresses";
46
	$l_trusted_domain	= "Trusted Internet domain names";
-
 
47
	$l_domain		= "Domain names";
30
  $l_trusted_sites_explain1 = "Enter domain names or IP addresses situated on Internet that could be joined without authentication";
48
	$l_comment_explain	= "Link showed in intercep page";
31
  $l_trusted_sites_explain2 = "Enter one domain name ou one IP address per line";
49
	$l_comment_explain2	= "Let empty for no link";
-
 
50
	$l_remove		= "Remove from list";
32
  $l_trusted_sites_list = "Trusted Internet domain names list";
51
	$l_trusted_ip		= "Trusted Internet domain and IP addresses";
-
 
52
	$l_comment		= "Comments";
-
 
53
	$l_trusted_domain_explain = "Manage Internet domain names that can be joined without authentication";
33
  $l_trusted_urls_list = "Trusted IP addresses or networks addresses list";
54
	$l_trusted_ip_explain	= "Manage systems or networks IP addresses that can be joined without authentication";
34
  $l_submit = "Submit";
55
	$l_submit		= "Submit";
-
 
56
	$l_add_to_list		= "Add to list";
-
 
57
	$l_apply		= "Apply changes";
35
}
58
}
36
if (isset($_POST['choix'])){ 
59
if (isset($_POST['choix'])){ 
37
	switch ($_POST['choix'])
60
	switch ($_POST['choix'])
38
	{
61
	{
39
	case 'MAJ_UAMALLOWED' :
62
	case 'new_uamdomain' :
-
 
63
	if (trim($_POST['add_uamdomain']) != "") 
-
 
64
		{
-
 
65
		$tab=file(DOMAIN_ALLOWED_LIST);
-
 
66
		$insert = true;
-
 
67
		if ($tab) // file isn't empty
-
 
68
			{
-
 
69
			foreach ($tab as $line) // test if domain address doesn't already exist
-
 
70
				{
40
		$tab_domains = explode ("\n", $_POST['trusted_domains']);
71
				$domain=explode("\"", $line);
-
 
72
				if (strcmp(trim($_POST['add_uamdomain']),$domain[1]) == 0)
-
 
73
			       		{
-
 
74
					$insert = false;
-
 
75
					break;
-
 
76
					}
-
 
77
				}
-
 
78
			}
-
 
79
		if ($insert == true) 
-
 
80
			{
-
 
81
			$line ="\nuamdomain=\"" . trim($_POST['add_uamdomain']) . "\" #" . trim($_POST['add_domain_comment']);
-
 
82
			$pointeur=fopen(DOMAIN_ALLOWED_LIST,"a");
-
 
83
			fwrite ($pointeur, $line);
-
 
84
			fclose ($pointeur);
-
 
85
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
-
 
86
			exec ("sudo service chilli restart");
-
 
87
			}
-
 
88
		}
-
 
89
	break;
-
 
90
	case 'change_uamdomain' :
-
 
91
	$tab=file(DOMAIN_ALLOWED_LIST);
-
 
92
	if ($tab)
-
 
93
		{
41
		$fichier=fopen($domain_allowed_list,"w+");
94
		$pointeur=fopen(DOMAIN_ALLOWED_LIST,"w+");
42
		foreach ($tab_domains as $domain ){
95
		foreach ($tab as $ligne)
-
 
96
			{
43
			$tr_domain=trim($domain);
97
			$uamdomain1=explode("\"", $ligne);
-
 
98
			$remove_line = false;
-
 
99
			foreach ($_POST as $key => $value)
-
 
100
				{
-
 
101
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
44
			if ($tr_domain != ""){
102
				if (strstr($key,'del-'))
-
 
103
					{
-
 
104
					$uamdomain2 = str_replace('del-','',$key);
45
				fputs ($fichier, "uamdomain=\"".$tr_domain."\"\n");}
105
					if (strcmp($uamdomain1[1],$uamdomain2) == 0)
-
 
106
				       		{
-
 
107
						$remove_line = True;
-
 
108
						break;
-
 
109
						}
-
 
110
					}
-
 
111
				}
-
 
112
			if (! $remove_line)
-
 
113
				{
-
 
114
				fwrite($pointeur,$ligne);
-
 
115
				}
46
			}	
116
			}
47
		fclose($fichier);
117
		fclose($pointeur);
-
 
118
		}
-
 
119
	exec ("sudo service chilli restart");
-
 
120
	break;
-
 
121
	case 'new_ip' :
48
		unset($_POST['trusted_domains']);
122
	if (trim($_POST['add_ip']) != "") 
-
 
123
		{
-
 
124
		$tab=file(IP_ALLOWED_LIST);
-
 
125
		$insert = true;
-
 
126
		if ($tab) // file isn't empty
-
 
127
			{
-
 
128
			foreach ($tab as $line) // test if domain address doesn't already exist
-
 
129
				{
49
		$tab_urls = explode ("\n", $_POST['trusted_urls']);
130
				$ip=explode("\"", $line);
-
 
131
				if (strcmp(trim($_POST['add_ip']),$ip[1]) == 0)
-
 
132
			       		{
-
 
133
					$insert = false;
-
 
134
					break;
-
 
135
					}
-
 
136
				}
-
 
137
			}
-
 
138
		if ($insert == true) 
-
 
139
			{
-
 
140
			$line ="\nuamallowed=\"" . trim($_POST['add_ip']) ."\" #" . trim($_POST['add_ip_comment']);
-
 
141
			$pointeur=fopen(IP_ALLOWED_LIST,"a");
-
 
142
			fwrite ($pointeur, $line);
-
 
143
			fclose ($pointeur);
-
 
144
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
-
 
145
			exec ("sudo service chilli restart");
-
 
146
			}
-
 
147
		}
-
 
148
	break;
-
 
149
	case 'change_ip' :
-
 
150
	$tab=file(IP_ALLOWED_LIST);
-
 
151
	if ($tab)
-
 
152
		{
50
		$fichier=fopen($url_allowed_list,"w+");
153
		$pointeur=fopen(IP_ALLOWED_LIST,"w+");
51
		foreach ($tab_urls as $url ){
154
		foreach ($tab as $ligne)
-
 
155
			{
-
 
156
			$ip1=explode("\"", $ligne);
52
			$tr_url=trim($url);
157
			$remove_line = false;
-
 
158
			foreach ($_POST as $key => $value)
-
 
159
				{
-
 
160
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
53
			if ($tr_url != ""){
161
				if (strstr($key,'del-'))
-
 
162
					{
54
				fputs ($fichier, "uamallowed=\"".$tr_url."\"\n");}
163
					$ip2 = str_replace('del-','',$key);
-
 
164
					if (strcmp($ip1[1],$ip2) == 0)
-
 
165
				       		{
-
 
166
						$remove_line = True;
-
 
167
						break;
-
 
168
						}
-
 
169
					}
55
			}
170
				}
-
 
171
			if (! $remove_line)
-
 
172
				{
56
		fclose($fichier);
173
				fwrite($pointeur,$ligne);
-
 
174
				}
-
 
175
			}
57
		unset($_POST['trusted_urls']);
176
		fclose($pointeur);
-
 
177
		}
58
		exec ("sudo service chilli restart");
178
	exec ("sudo service chilli restart");
59
		unset ($_POST['choix']);
-
 
60
		break;
179
	break;
61
	}	
180
	}
62
}
181
}
63
?>
182
?>
-
 
183
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
-
 
184
<tr><th><?echo "$l_trusted_domain";?></th></tr>
-
 
185
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
-
 
186
</table>
-
 
187
<table width="100%" border=1 cellspacing=0 cellpadding=1>
-
 
188
<tr><td colspan=2 align="center">
-
 
189
<?
-
 
190
echo "$l_trusted_domain_explain</td></tr>";
-
 
191
echo "<tr><td align='center' valign='middle'>";
-
 
192
echo "<table cellspacing=2 cellpadding=2 border=1>";
-
 
193
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
-
 
194
echo "<tr><th>$l_domain<th>$l_comment_explain<th>$l_remove</tr>";
-
 
195
// Read the "Domain alowed" file
-
 
196
$tab=file(DOMAIN_ALLOWED_LIST);
-
 
197
if ($tab)  # the file isn't empty
-
 
198
	{
-
 
199
	foreach ($tab as $line)
-
 
200
		{
-
 
201
		if (trim($line) != '') # the line isn't empty
-
 
202
			{
-
 
203
			$domain_allowed=explode("#", $line);
-
 
204
			$uamdomain=trim($domain_allowed[0],"#");
-
 
205
			$domain=explode("\"", $uamdomain);
-
 
206
			echo "<tr><td>$domain[1]";
-
 
207
			echo "<td>";
-
 
208
			if (isset ($domain_allowed[1])) {
-
 
209
				echo trim($domain_allowed[1]);}
-
 
210
			else echo "&nbsp";
-
 
211
			echo "<td>";
-
 
212
			echo "<input type='checkbox' name='del-$domain[1]'>";
-
 
213
			echo "</tr>";
-
 
214
			}
-
 
215
		}
-
 
216
	}
-
 
217
echo "</table>";
-
 
218
if ($tab)
-
 
219
	{
-
 
220
	echo "<input type='hidden' name='choix' value='change_uamdomain'>";
-
 
221
	echo "<input type='submit' value='$l_apply'>";
-
 
222
	}
-
 
223
?>
-
 
224
</form>
-
 
225
</td><td valign='middle' align='center'>
-
 
226
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
-
 
227
<table cellspacing=2 cellpadding=3 border=1>
-
 
228
<tr><th><?echo"$l_domain</th><th>$l_comment_explain";?>
-
 
229
<td></td></tr>
-
 
230
<tr><td>exemple1 : www.mydomain.com <br>exemple2 : .yourdomain.net</td>
-
 
231
<td>My domain<br><?echo"$l_comment_explain2";?></td></tr>
-
 
232
<tr><td><input type='text' name='add_uamdomain' size='20'></td>
-
 
233
<td><input type='text' name='add_domain_comment' size='15'></td>
-
 
234
<input type='hidden' name='choix' value='new_uamdomain'>
-
 
235
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
-
 
236
</tr></table>
-
 
237
</form>
-
 
238
</td></tr>
-
 
239
</table>
64
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
240
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
65
	<tr><th><?php echo $l_trusted_sites ;?></th></tr>
241
	<tr><th><?php echo $l_trusted_ip ;?></th></tr>
66
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
242
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
67
</TABLE>
243
</TABLE>
68
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
244
<TABLE width="100%" border=0 cellspacing=0 cellpadding=1>
69
	<tr bgcolor="#666666"><td>
-
 
70
	<TABLE width="100%" border=0 cellspacing=0 cellpadding=2>
-
 
71
		<tr><td valign="middle" align="left">
-
 
72
		<center><?php
-
 
73
		echo "$l_trusted_sites_explain1 <BR>";
-
 
74
		echo "$l_trusted_sites_explain2" ;
-
 
75
		echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";?>
-
 
76
		<TABLE cellspacing=2 cellpadding=3 border=1>
-
 
77
		<tr><td width=50% height=100% align=center>
-
 
78
			<H3><?php echo $l_trusted_sites_list ;?></H3>
-
 
79
			exemple1 : www.domain1.org<BR>
-
 
80
			exemple2 : domain2.net<BR>
-
 
81
			<?php
-
 
82
				echo "<textarea name='trusted_domains' rows=5 cols=40>";
-
 
83
				$ouvre=fopen($domain_allowed_list,"r");
-
 
84
				if ($ouvre)
-
 
85
					{
-
 
86
					while (!feof ($ouvre))
-
 
87
						{
-
 
88
						$tampon = fgets($ouvre, 4096);
-
 
89
						$domain_list_l = substr($tampon,10);
-
 
90
						$domain_list = trim ($domain_list_l,"\"\n\t ");
-
 
91
						$tab_domains = explode (",", $domain_list);
-
 
92
						foreach ($tab_domains as $domain ){
-
 
93
							if ($domain) { echo $domain."\n";}
-
 
94
							}
-
 
95
		  				}
-
 
96
					}
-
 
97
				else	{
-
 
98
					echo "failed to open $domain_allowed_list";
-
 
99
					}
-
 
100
				fclose($ouvre);
-
 
101
				echo "</textarea>";
-
 
102
			?>
-
 
103
		</td>
-
 
104
		<td  width=50% height=100% align=center>
-
 
105
			<H3><?php echo $l_trusted_urls_list ;?></H3>
-
 
106
			exemple1 : 192.168.0.10<BR>
-
 
107
			exemple2 : 172.16.20.0/24<BR>
-
 
108
			<?php
-
 
109
				echo "<textarea name='trusted_urls' rows=5 cols=40>";
-
 
110
				$ouvre=fopen($url_allowed_list,"r");
-
 
111
				if ($ouvre)
-
 
112
			       		{
-
 
113
					while (!feof ($ouvre))
-
 
114
						{
-
 
115
						$tampon = fgets($ouvre, 4096);
-
 
116
						$url_list_l = substr($tampon,11);
-
 
117
						$url_list = trim ($url_list_l,"\"\n\t ");
-
 
118
						$tab_urls = explode (",", $url_list);
-
 
119
						foreach ($tab_urls as $url ){
-
 
120
							if ($url) echo $url."\n";
-
 
121
							}
-
 
122
						}
-
 
123
					}
-
 
124
				else	{
-
 
125
					echo "failed to open $url_allowed_list";
-
 
126
					}
-
 
127
				fclose($ouvre);
-
 
128
				echo "</textarea>";
-
 
129
			?>
-
 
130
		</td></tr>
-
 
131
		</TABLE>
-
 
132
		<input type='hidden' name='choix' value='MAJ_UAMALLOWED'>
-
 
133
		<input type='submit' value='<?php echo $l_submit ;?>'>
-
 
134
		</FORM>
-
 
135
	</td></tr>
-
 
136
	</TABLE>
-
 
137
</TABLE>
245
</TABLE>
-
 
246
<table width="100%" border=1 cellspacing=0 cellpadding=1>
-
 
247
<tr><td colspan=2 align="center">
-
 
248
<?
-
 
249
echo "$l_trusted_ip_explain</td></tr>";
-
 
250
echo "<tr><td align='center' valign='middle'>";
-
 
251
echo "<table cellspacing=2 cellpadding=2 border=1>";
-
 
252
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
-
 
253
echo "<tr><th>$l_trusted_ip<th>$l_comment<th>$l_remove</tr>";
-
 
254
// Read the "ip alowed" file
-
 
255
$tab=file(IP_ALLOWED_LIST);
-
 
256
if ($tab)  # the file isn't empty
-
 
257
	{
-
 
258
	foreach ($tab as $line)
-
 
259
		{
-
 
260
		if (trim($line) != '') # the line isn't empty
-
 
261
			{
-
 
262
			$ip_allowed=explode("#", $line);
-
 
263
			$ip_a=trim($ip_allowed[0],"#");
-
 
264
			$ip=explode("\"", $ip_a);
-
 
265
			echo "<tr><td>$ip[1]";
-
 
266
			echo "<td>";
-
 
267
			if (isset($ip_allowed[1]))
-
 
268
				echo trim($ip_allowed[1]);
-
 
269
			else echo "&nbsp;";
-
 
270
			echo "<td><input type='checkbox' name='del-$ip[1]'>";
-
 
271
			echo "</tr>";
-
 
272
			}
-
 
273
		}
-
 
274
	}
-
 
275
echo "</table>";
-
 
276
if ($tab)
-
 
277
	{
-
 
278
	echo "<input type='hidden' name='choix' value='change_ip'>";
-
 
279
	echo "<input type='submit' value='$l_apply'>";
-
 
280
	}
-
 
281
?>
-
 
282
</form>
-
 
283
</td><td valign='middle' align='center'>
-
 
284
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
-
 
285
<table cellspacing=2 cellpadding=3 border=1>
-
 
286
<tr><th><?echo"$l_trusted_ip</th><th>$l_comment";?>
-
 
287
<td></td></tr>
-
 
288
<tr><td>exemple1 : 170.25.23.10 <br>exemple2 : 15.20.20.0/16</td>
-
 
289
<td>my_web_server <br>my_dmz</td>
-
 
290
<tr><td><input type='text' name='add_ip' size='20'></td>
-
 
291
<td><input type='text' name='add_ip_comment' size='15'></td>
-
 
292
<input type='hidden' name='choix' value='new_ip'>
-
 
293
<td><input type='submit' value='<?echo"$l_add_to_list";?>'></td>
-
 
294
</tr></table>
-
 
295
</form>
-
 
296
</td></tr>
-
 
297
</table>
138
</BODY>
298
</BODY>
139
</HTML>
299
</HTML>