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
<?
870 richard 10
/********************
11
*  TEST CONF FILES  *
12
*********************/
13
define ("DOMAIN_ALLOWED_LIST", "/usr/local/etc/alcasar-uamdomain");
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
}
606 richard 22
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
23
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
318 richard 24
# Choice of language
25
$Language = 'en';
26
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
870 richard 27
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
28
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
318 richard 29
if($Language == 'fr'){
1886 raphael.pi 30
	$l_load="Chargement...";
870 richard 31
	$l_error_open_file	= "Erreur d'ouverture du fichier";
32
	$l_trusted_domain	= "Noms de domaine Internet de confiance";
33
	$l_domain		= "Noms de domaine";
871 richard 34
	$l_comment_explain	= "Lien affiché dans la page d'interception";
870 richard 35
	$l_comment_explain2	= "Laissez vide si non affiché";
36
	$l_remove		= "Retirer de la liste";
37
	$l_trusted_ip		= "adresses IP de confiance";
885 richard 38
	$l_trusted_equipments	= "Equipements de consultation de confiance";
870 richard 39
	$l_comment		= "Commentaires";
40
	$l_trusted_domain_explain = "Gérez ici les noms de domaine Internet pouvant &ecirc;tre joints sans authentification";
1559 richard 41
	$l_trusted_equipments_explain	= "Pour qu'un équipement du réseau de consultation puisse accéder à Internet sans être interceptés : créer un utilisateur dont le nom de login est l'@MAC de l'équipement et le mot de passe est 'password'" ;
870 richard 42
	$l_trusted_ip_explain	= "Gérez ici les adresses IP de systèmes ou de réseaux pouvant être joints sans authentification";
43
	$l_submit		= "Enregistrer";
44
	$l_add_to_list		= "Ajouter à la liste";
45
	$l_apply		= "Appliquer les changements";
318 richard 46
}
47
else {
1886 raphael.pi 48
 	$l_load="Loading...";
870 richard 49
	$l_error_open_file	= "File open error";
50
	$l_trusted_domain	= "Trusted Internet domain names";
51
	$l_domain		= "Domain names";
871 richard 52
	$l_comment_explain	= "Link displayed in intercept page";
53
	$l_comment_explain2	= "Let empty to not display link";
870 richard 54
	$l_remove		= "Remove from list";
1240 richard 55
	$l_trusted_ip		= "Trusted IP addresses";
885 richard 56
	$l_trusted_equipments	= "Trusted consultation equipements";
870 richard 57
	$l_comment		= "Comments";
58
	$l_trusted_domain_explain = "Manage Internet domain names that can be joined without authentication";
1559 richard 59
	$l_trusted_equipments_explain	= "To allow a consultation equipment to connect to Internet without interception, create a user whose name is the MAC address of the device and the password is 'password'";
1240 richard 60
	$l_trusted_ip_explain	= "Manage systems addresses or networks IP addresses that can be joined without authentication";
870 richard 61
	$l_submit		= "Submit";
62
	$l_add_to_list		= "Add to list";
63
	$l_apply		= "Apply changes";
318 richard 64
}
65
if (isset($_POST['choix'])){ 
66
	switch ($_POST['choix'])
67
	{
870 richard 68
	case 'new_uamdomain' :
69
	if (trim($_POST['add_uamdomain']) != "") 
70
		{
71
		$tab=file(DOMAIN_ALLOWED_LIST);
72
		$insert = true;
73
		if ($tab) // file isn't empty
74
			{
75
			foreach ($tab as $line) // test if domain address doesn't already exist
76
				{
77
				$domain=explode("\"", $line);
78
				if (strcmp(trim($_POST['add_uamdomain']),$domain[1]) == 0)
79
			       		{
80
					$insert = false;
81
					break;
82
					}
83
				}
318 richard 84
			}
870 richard 85
		if ($insert == true) 
86
			{
87
			$line ="\nuamdomain=\"" . trim($_POST['add_uamdomain']) . "\" #" . trim($_POST['add_domain_comment']);
88
			$pointeur=fopen(DOMAIN_ALLOWED_LIST,"a");
89
			fwrite ($pointeur, $line);
90
			fclose ($pointeur);
91
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
1578 richard 92
			exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 93
			}
94
		}
95
	break;
96
	case 'change_uamdomain' :
97
	$tab=file(DOMAIN_ALLOWED_LIST);
98
	if ($tab)
99
		{
100
		$pointeur=fopen(DOMAIN_ALLOWED_LIST,"w+");
101
		foreach ($tab as $ligne)
102
			{
103
			$uamdomain1=explode("\"", $ligne);
104
			$remove_line = false;
105
			foreach ($_POST as $key => $value)
106
				{
107
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
108
				if (strstr($key,'del-'))
109
					{
110
					$uamdomain2 = str_replace('del-','',$key);
111
					if (strcmp($uamdomain1[1],$uamdomain2) == 0)
112
				       		{
113
						$remove_line = True;
114
						break;
115
						}
116
					}
117
				}
118
			if (! $remove_line)
119
				{
120
				fwrite($pointeur,$ligne);
121
				}
122
			}
123
		fclose($pointeur);
124
		}
1578 richard 125
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 126
	break;
127
	case 'new_ip' :
128
	if (trim($_POST['add_ip']) != "") 
129
		{
130
		$tab=file(IP_ALLOWED_LIST);
131
		$insert = true;
132
		if ($tab) // file isn't empty
133
			{
134
			foreach ($tab as $line) // test if domain address doesn't already exist
135
				{
136
				$ip=explode("\"", $line);
137
				if (strcmp(trim($_POST['add_ip']),$ip[1]) == 0)
138
			       		{
139
					$insert = false;
140
					break;
141
					}
142
				}
143
			}
144
		if ($insert == true) 
145
			{
146
			$line ="\nuamallowed=\"" . trim($_POST['add_ip']) ."\" #" . trim($_POST['add_ip_comment']);
147
			$pointeur=fopen(IP_ALLOWED_LIST,"a");
148
			fwrite ($pointeur, $line);
149
			fclose ($pointeur);
150
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh");
1578 richard 151
			exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 152
			}
153
		}
154
	break;
155
	case 'change_ip' :
156
	$tab=file(IP_ALLOWED_LIST);
157
	if ($tab)
158
		{
159
		$pointeur=fopen(IP_ALLOWED_LIST,"w+");
160
		foreach ($tab as $ligne)
161
			{
162
			$ip1=explode("\"", $ligne);
163
			$remove_line = false;
164
			foreach ($_POST as $key => $value)
165
				{
166
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
167
				if (strstr($key,'del-'))
168
					{
169
					$ip2 = str_replace('del-','',$key);
170
					if (strcmp($ip1[1],$ip2) == 0)
171
				       		{
172
						$remove_line = True;
173
						break;
174
						}
175
					}
176
				}
177
			if (! $remove_line)
178
				{
179
				fwrite($pointeur,$ligne);
180
				}
181
			}
182
		fclose($pointeur);
183
		}
1578 richard 184
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 185
	break;
186
	}
318 richard 187
}
188
?>
870 richard 189
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
190
<tr><th><?echo "$l_trusted_domain";?></th></tr>
191
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
192
</table>
193
<table width="100%" border=1 cellspacing=0 cellpadding=1>
194
<tr><td colspan=2 align="center">
195
<?
196
echo "$l_trusted_domain_explain</td></tr>";
197
echo "<tr><td align='center' valign='middle'>";
198
echo "<table cellspacing=2 cellpadding=2 border=1>";
199
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
912 richard 200
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_domain<td>$l_comment_explain<td>$l_remove</tr>";
870 richard 201
// Read the "Domain alowed" file
202
$tab=file(DOMAIN_ALLOWED_LIST);
203
if ($tab)  # the file isn't empty
204
	{
205
	foreach ($tab as $line)
206
		{
207
		if (trim($line) != '') # the line isn't empty
208
			{
209
			$domain_allowed=explode("#", $line);
210
			$uamdomain=trim($domain_allowed[0],"#");
211
			$domain=explode("\"", $uamdomain);
212
			echo "<tr><td>$domain[1]";
213
			echo "<td>";
214
			if (isset ($domain_allowed[1])) {
215
				echo trim($domain_allowed[1]);}
216
			else echo "&nbsp";
217
			echo "<td>";
218
			echo "<input type='checkbox' name='del-$domain[1]'>";
219
			echo "</tr>";
220
			}
221
		}
222
	}
223
echo "</table>";
224
if ($tab)
225
	{
226
	echo "<input type='hidden' name='choix' value='change_uamdomain'>";
1886 raphael.pi 227
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_apply'>";
870 richard 228
	}
229
?>
230
</form>
231
</td><td valign='middle' align='center'>
232
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
233
<table cellspacing=2 cellpadding=3 border=1>
912 richard 234
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_domain<td bgcolor='#d0ddb0'>$l_comment_explain";?>
235
<td></tr>
236
<tr><td>exemple1 : www.mydomain.com <br>exemple2 : .yourdomain.net
925 richard 237
<td>exemple1 : mydomain<br><?echo "$l_comment_explain2";?><td></tr>
912 richard 238
<tr><td><input type='text' name='add_uamdomain' size='20'>
239
<td><input type='text' name='add_domain_comment' size='15'>
870 richard 240
<input type='hidden' name='choix' value='new_uamdomain'>
1886 raphael.pi 241
<td><input type='submit' onClick="this.disabled=true; this.value='<?echo $l_load;?>';" value='<?echo "$l_add_to_list";?>'>
870 richard 242
</tr></table>
243
</form>
912 richard 244
</tr>
870 richard 245
</table>
885 richard 246
<table width="100%" border="0" cellspacing="0" cellpadding="0">
247
	<tr><th><?php echo "$l_trusted_ip" ;?></th></tr>
318 richard 248
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
885 richard 249
</table>
870 richard 250
<table width="100%" border=1 cellspacing=0 cellpadding=1>
251
<tr><td colspan=2 align="center">
252
<?
253
echo "$l_trusted_ip_explain</td></tr>";
254
echo "<tr><td align='center' valign='middle'>";
255
echo "<table cellspacing=2 cellpadding=2 border=1>";
256
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>";
912 richard 257
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_trusted_ip<td>$l_comment<td>$l_remove</tr>";
870 richard 258
// Read the "ip alowed" file
259
$tab=file(IP_ALLOWED_LIST);
260
if ($tab)  # the file isn't empty
261
	{
262
	foreach ($tab as $line)
263
		{
264
		if (trim($line) != '') # the line isn't empty
265
			{
266
			$ip_allowed=explode("#", $line);
267
			$ip_a=trim($ip_allowed[0],"#");
268
			$ip=explode("\"", $ip_a);
269
			echo "<tr><td>$ip[1]";
270
			echo "<td>";
271
			if (isset($ip_allowed[1]))
272
				echo trim($ip_allowed[1]);
273
			else echo "&nbsp;";
274
			echo "<td><input type='checkbox' name='del-$ip[1]'>";
275
			echo "</tr>";
276
			}
277
		}
278
	}
279
echo "</table>";
280
if ($tab)
281
	{
282
	echo "<input type='hidden' name='choix' value='change_ip'>";
1886 raphael.pi 283
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';\" value='$l_apply'>";
870 richard 284
	}
285
?>
286
</form>
287
</td><td valign='middle' align='center'>
885 richard 288
<form action='<?echo "$_SERVER[PHP_SELF]"?>' method='POST'>
870 richard 289
<table cellspacing=2 cellpadding=3 border=1>
912 richard 290
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_trusted_ip<td bgcolor='#d0ddb0'>$l_comment";?>
291
<td></tr>
870 richard 292
<tr><td>exemple1 : 170.25.23.10 <br>exemple2 : 15.20.20.0/16</td>
912 richard 293
<td>my_web_server <br>my_dmz<td></tr>
870 richard 294
<tr><td><input type='text' name='add_ip' size='20'></td>
295
<td><input type='text' name='add_ip_comment' size='15'></td>
296
<input type='hidden' name='choix' value='new_ip'>
1886 raphael.pi 297
<td><input type='submit' onClick="this.disabled=true; this.value='<?echo $l_load;?>';" value='<?echo "$l_add_to_list";?>'></td>
870 richard 298
</tr></table>
299
</td></tr>
300
</table>
912 richard 301
</form>
885 richard 302
<table width="100%" border="0" cellspacing="0" cellpadding="0">
303
	<tr><th><?php echo "$l_trusted_equipments";?></th></tr>
304
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
305
</table>
306
<table width="100%" border=1 cellspacing=0 cellpadding=1>
307
<tr><td colspan=2 align="center">
308
<?echo "$l_trusted_equipments_explain";?>
309
</td></tr>
310
</table>
318 richard 311
</BODY>
312
</HTML>