Subversion Repositories ALCASAR

Rev

Rev 3099 | 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>
2817 rexy 6
<link rel="stylesheet" href="/css/acc.css" type="text/css">
318 richard 7
</HEAD>
8
<body>
3028 rexy 9
<div id="ldoverlay" class="overlay">
10
	<div class="lds-spinner" id="spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
11
</div>
318 richard 12
<?
870 richard 13
/********************
14
*  TEST CONF FILES  *
15
*********************/
2138 richard 16
$domain_allowed_list="/usr/local/etc/alcasar-uamdomain";
17
$url_allowed_list="/usr/local/etc/alcasar-uamallowed";
18
define ("DOMAIN_ALLOWED_LIST", $domain_allowed_list);
19
define ("IP_ALLOWED_LIST", $url_allowed_list);
870 richard 20
$conf_files=array(DOMAIN_ALLOWED_LIST,IP_ALLOWED_LIST);
21
foreach ($conf_files as $file){
22
if (!file_exists($file)){
23
	exit("Requested file ".$file." isn't present");}
24
if (!is_readable($file)){
25
	exit("Can't read the file ".$file);}
26
}
318 richard 27
# Choice of language
28
$Language = 'en';
29
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
870 richard 30
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
31
	$Language = strtolower(substr(chop($Langue[0]),0,2)); }
318 richard 32
if($Language == 'fr'){
1886 raphael.pi 33
	$l_load="Chargement...";
870 richard 34
	$l_error_open_file	= "Erreur d'ouverture du fichier";
35
	$l_trusted_domain	= "Noms de domaine Internet de confiance";
36
	$l_domain		= "Noms de domaine";
871 richard 37
	$l_comment_explain	= "Lien affiché dans la page d'interception";
870 richard 38
	$l_comment_explain2	= "Laissez vide si non affiché";
39
	$l_remove		= "Retirer de la liste";
40
	$l_trusted_ip		= "adresses IP de confiance";
3212 rexy 41
	$l_trusted_dest_ip		= "adresses IP destination de confiance";
885 richard 42
	$l_trusted_equipments	= "Equipements de consultation de confiance";
870 richard 43
	$l_comment		= "Commentaires";
2138 richard 44
	$l_trusted_domain_explain = "Gérez ici les noms de domaine Internet pouvant être joints sans authentification";
1559 richard 45
	$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 46
	$l_trusted_ip_explain	= "Gérez ici les adresses IP de systèmes ou de réseaux pouvant être joints sans authentification";
47
	$l_submit		= "Enregistrer";
48
	$l_add_to_list		= "Ajouter à la liste";
49
	$l_apply		= "Appliquer les changements";
2857 rexy 50
	$l_invalid_ip	= "Format d'adresse IP invalide";
2853 rexy 51
} else if($Language == 'es') {
52
    $l_load="Cargando...";
53
	$l_error_open_file	= "Error en la lectura del archivo";
54
	$l_trusted_domain	= "Sitios de Internet confiables";
55
	$l_domain		= "Nombres de Dominio";
56
	$l_comment_explain	= "Enlace mostrado en la página de interceptación";
57
	$l_comment_explain2	= "Dejar vacío para ocultar el enlace";
58
	$l_remove		= "Borrar de la lista";
59
	$l_trusted_ip		= "Direcciones IP confiables";
3212 rexy 60
	$l_trusted_dest_ip		= "direcciones IP de destino aprobadas";
2853 rexy 61
	$l_trusted_equipments	= "Equipos Autorizados (confiables)";
62
	$l_comment		= "Comentarios";
63
	$l_trusted_domain_explain = "Administra los sitios de Internet a los que se acceder sin iniciar sesión";
64
	$l_trusted_equipments_explain	= "Para permitir que un equipo se conecte a Internet sin interceptarlo, cree un usuario cuyo nombre sea la dirección MAC del dispositivo y la contraseña sea 'password'";
65
	$l_trusted_ip_explain	= "Administre direcciones IP de sistemas o direcciones IP de redes que pueden unirse sin autenticación";
66
	$l_submit		= "Enviar";
67
	$l_add_to_list		= "Agregar a la lista";
68
	$l_apply		= "Aplicar cambios";
2857 rexy 69
	$l_invalid_ip	= "Formato de dirección IP inválido";
2853 rexy 70
} else {
1886 raphael.pi 71
 	$l_load="Loading...";
870 richard 72
	$l_error_open_file	= "File open error";
73
	$l_trusted_domain	= "Trusted Internet domain names";
74
	$l_domain		= "Domain names";
871 richard 75
	$l_comment_explain	= "Link displayed in intercept page";
76
	$l_comment_explain2	= "Let empty to not display link";
870 richard 77
	$l_remove		= "Remove from list";
1240 richard 78
	$l_trusted_ip		= "Trusted IP addresses";
3212 rexy 79
	$l_trusted_dest_ip		= "Trusted destination IP addresses";
885 richard 80
	$l_trusted_equipments	= "Trusted consultation equipements";
870 richard 81
	$l_comment		= "Comments";
82
	$l_trusted_domain_explain = "Manage Internet domain names that can be joined without authentication";
1559 richard 83
	$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'";
2853 rexy 84
	$l_trusted_ip_explain	= "Manage systems IP addresses or networks IP addresses that can be joined without authentication";
870 richard 85
	$l_submit		= "Submit";
86
	$l_add_to_list		= "Add to list";
87
	$l_apply		= "Apply changes";
2857 rexy 88
	$l_invalid_ip	= "Invalid IP address format";
318 richard 89
}
90
if (isset($_POST['choix'])){ 
91
	switch ($_POST['choix'])
92
	{
870 richard 93
	case 'new_uamdomain' :
94
	if (trim($_POST['add_uamdomain']) != "") 
95
		{
96
		$tab=file(DOMAIN_ALLOWED_LIST);
97
		$insert = true;
98
		if ($tab) // file isn't empty
99
			{
100
			foreach ($tab as $line) // test if domain address doesn't already exist
101
				{
102
				$domain=explode("\"", $line);
103
				if (strcmp(trim($_POST['add_uamdomain']),$domain[1]) == 0)
104
			       		{
105
					$insert = false;
106
					break;
107
					}
108
				}
318 richard 109
			}
870 richard 110
		if ($insert == true) 
111
			{
2952 rexy 112
			if (trim($_POST['add_domain_comment']))
113
			{			
114
				$line ="\nuamdomain=\"" . trim($_POST['add_uamdomain']) . "\" #" . trim($_POST['add_domain_comment']);
115
			}
116
			else
117
			{
118
				$line ="\nuamdomain=\"" . trim($_POST['add_uamdomain']) . "\"";
119
			}
870 richard 120
			$pointeur=fopen(DOMAIN_ALLOWED_LIST,"a");
121
			fwrite ($pointeur, $line);
122
			fclose ($pointeur);
2175 richard 123
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh"); # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
3099 rexy 124
			sleep (1); # be sure that unbound-blackhole is restarted before killing tun0 ! 
1578 richard 125
			exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 126
			}
127
		}
128
	break;
129
	case 'change_uamdomain' :
130
	$tab=file(DOMAIN_ALLOWED_LIST);
131
	if ($tab)
132
		{
133
		$pointeur=fopen(DOMAIN_ALLOWED_LIST,"w+");
134
		foreach ($tab as $ligne)
135
			{
136
			$uamdomain1=explode("\"", $ligne);
137
			$remove_line = false;
138
			foreach ($_POST as $key => $value)
139
				{
140
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
141
				if (strstr($key,'del-'))
142
					{
143
					$uamdomain2 = str_replace('del-','',$key);
144
					if (strcmp($uamdomain1[1],$uamdomain2) == 0)
145
				       		{
146
						$remove_line = True;
147
						break;
148
						}
149
					}
150
				}
151
			if (! $remove_line)
152
				{
153
				fwrite($pointeur,$ligne);
154
				}
155
			}
156
		fclose($pointeur);
157
		}
2178 richard 158
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
3099 rexy 159
	sleep (1); # be sure that unbound-blackhole is restarted before killing tun0 ! 
1578 richard 160
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 161
	break;
162
	case 'new_ip' :
2463 tom.houday 163
		$ipAddr = trim($_POST['add_ip']);
2857 rexy 164
		if (!preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}(\/([0-9]|[1-2][0-9]|3[0-2]))?$/', $ipAddr)) {
165
			echo '<span style="color: red;">'. $l_invalid_ip .'</span>';
2463 tom.houday 166
		} else if (!empty($ipAddr)) {
167
			$tab=file(IP_ALLOWED_LIST);
168
			$insert = true;
169
			if ($tab) { // file isn't empty
170
				foreach ($tab as $line) { // test if domain address doesn't already exist
171
					$ip = explode('"', $line);
172
					if (strcmp($ipAddr, $ip[1]) === 0) {
173
						$insert = false;
174
						break;
870 richard 175
					}
176
				}
177
			}
2463 tom.houday 178
			if ($insert === true)  {
179
				$line = "\nuamallowed=\"" . $ipAddr .'" #' . trim($_POST['add_ip_comment']);
180
				$pointeur = fopen(IP_ALLOWED_LIST, 'a');
181
				fwrite($pointeur, $line);
182
				fclose($pointeur);
183
				exec('sudo /usr/local/bin/alcasar-file-clean.sh');  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
184
				exec('sudo /usr/bin/systemctl restart chilli');
870 richard 185
			}
186
		}
187
	break;
188
	case 'change_ip' :
189
	$tab=file(IP_ALLOWED_LIST);
190
	if ($tab)
191
		{
192
		$pointeur=fopen(IP_ALLOWED_LIST,"w+");
193
		foreach ($tab as $ligne)
194
			{
195
			$ip1=explode("\"", $ligne);
196
			$remove_line = false;
197
			foreach ($_POST as $key => $value)
198
				{
199
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
200
				if (strstr($key,'del-'))
201
					{
202
					$ip2 = str_replace('del-','',$key);
203
					if (strcmp($ip1[1],$ip2) == 0)
204
				       		{
205
						$remove_line = True;
206
						break;
207
						}
208
					}
209
				}
210
			if (! $remove_line)
211
				{
212
				fwrite($pointeur,$ligne);
213
				}
214
			}
215
		fclose($pointeur);
216
		}
2178 richard 217
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
1578 richard 218
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 219
	break;
220
	}
318 richard 221
}
222
?>
870 richard 223
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
224
<tr><th><?echo "$l_trusted_domain";?></th></tr>
225
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
226
</table>
227
<table width="100%" border=1 cellspacing=0 cellpadding=1>
228
<tr><td colspan=2 align="center">
229
<?
2138 richard 230
echo "$l_trusted_domain_explain</td></tr>\n";
231
echo "<tr><td align='center' valign='middle'>\n";
232
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>\n";
870 richard 233
echo "<table cellspacing=2 cellpadding=2 border=1>";
2138 richard 234
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_domain<td>$l_comment_explain<td>$l_remove</tr>\n";
870 richard 235
// Read the "Domain alowed" file
236
$tab=file(DOMAIN_ALLOWED_LIST);
237
if ($tab)  # the file isn't empty
238
	{
239
	foreach ($tab as $line)
240
		{
241
		if (trim($line) != '') # the line isn't empty
242
			{
243
			$domain_allowed=explode("#", $line);
244
			$uamdomain=trim($domain_allowed[0],"#");
245
			$domain=explode("\"", $uamdomain);
246
			echo "<tr><td>$domain[1]";
247
			echo "<td>";
248
			if (isset ($domain_allowed[1])) {
249
				echo trim($domain_allowed[1]);}
250
			else echo "&nbsp";
251
			echo "<td>";
252
			echo "<input type='checkbox' name='del-$domain[1]'>";
2138 richard 253
			echo "</tr>\n";
870 richard 254
			}
255
		}
256
	}
257
echo "</table>";
258
if ($tab)
259
	{
260
	echo "<input type='hidden' name='choix' value='change_uamdomain'>";
3028 rexy 261
	echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_apply'>";
870 richard 262
	}
263
?>
264
</form>
265
</td><td valign='middle' align='center'>
266
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
267
<table cellspacing=2 cellpadding=3 border=1>
912 richard 268
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_domain<td bgcolor='#d0ddb0'>$l_comment_explain";?>
269
<td></tr>
270
<tr><td>exemple1 : www.mydomain.com <br>exemple2 : .yourdomain.net
925 richard 271
<td>exemple1 : mydomain<br><?echo "$l_comment_explain2";?><td></tr>
912 richard 272
<tr><td><input type='text' name='add_uamdomain' size='20'>
273
<td><input type='text' name='add_domain_comment' size='15'>
2138 richard 274
<input type='hidden' name='choix' value='new_uamdomain'></td>
3028 rexy 275
<td><input type='submit' onClick="this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='<?echo $l_load;?>';submit();" value='<?echo "$l_add_to_list";?>'>
870 richard 276
</tr></table>
277
</form>
912 richard 278
</tr>
870 richard 279
</table>
885 richard 280
<table width="100%" border="0" cellspacing="0" cellpadding="0">
3212 rexy 281
	<tr><th><?php echo "$l_trusted_dest_ip" ;?></th></tr>
318 richard 282
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
885 richard 283
</table>
870 richard 284
<table width="100%" border=1 cellspacing=0 cellpadding=1>
285
<tr><td colspan=2 align="center">
286
<?
2138 richard 287
echo "$l_trusted_ip_explain</td></tr>\n";
288
echo "<tr><td align='center' valign='middle'>\n";
289
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>\n";
870 richard 290
echo "<table cellspacing=2 cellpadding=2 border=1>";
2138 richard 291
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_trusted_ip<td>$l_comment<td>$l_remove</tr>\n";
870 richard 292
// Read the "ip alowed" file
293
$tab=file(IP_ALLOWED_LIST);
294
if ($tab)  # the file isn't empty
295
	{
296
	foreach ($tab as $line)
297
		{
298
		if (trim($line) != '') # the line isn't empty
299
			{
300
			$ip_allowed=explode("#", $line);
301
			$ip_a=trim($ip_allowed[0],"#");
302
			$ip=explode("\"", $ip_a);
303
			echo "<tr><td>$ip[1]";
304
			echo "<td>";
305
			if (isset($ip_allowed[1]))
306
				echo trim($ip_allowed[1]);
307
			else echo "&nbsp;";
308
			echo "<td><input type='checkbox' name='del-$ip[1]'>";
2138 richard 309
			echo "</tr>\n";
870 richard 310
			}
311
		}
312
	}
313
echo "</table>";
314
if ($tab)
315
	{
316
	echo "<input type='hidden' name='choix' value='change_ip'>";
3028 rexy 317
	echo "<input type='submit' onClick=\"this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='$l_load';submit();\" value='$l_apply'>";
870 richard 318
	}
319
?>
320
</form>
321
</td><td valign='middle' align='center'>
885 richard 322
<form action='<?echo "$_SERVER[PHP_SELF]"?>' method='POST'>
870 richard 323
<table cellspacing=2 cellpadding=3 border=1>
912 richard 324
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_trusted_ip<td bgcolor='#d0ddb0'>$l_comment";?>
325
<td></tr>
870 richard 326
<tr><td>exemple1 : 170.25.23.10 <br>exemple2 : 15.20.20.0/16</td>
912 richard 327
<td>my_web_server <br>my_dmz<td></tr>
870 richard 328
<tr><td><input type='text' name='add_ip' size='20'></td>
2138 richard 329
<td><input type='text' name='add_ip_comment' size='15'>
330
<input type='hidden' name='choix' value='new_ip'></td>
3028 rexy 331
<td><input type='submit' onClick="this.disabled=true; document.getElementById('ldoverlay').style.display='block'; this.value='<?echo $l_load;?>';submit();" value='<?echo "$l_add_to_list";?>'></td>
870 richard 332
</tr></table>
2138 richard 333
</form>
870 richard 334
</table>
885 richard 335
<table width="100%" border="0" cellspacing="0" cellpadding="0">
336
	<tr><th><?php echo "$l_trusted_equipments";?></th></tr>
337
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
338
</table>
339
<table width="100%" border=1 cellspacing=0 cellpadding=1>
340
<tr><td colspan=2 align="center">
341
<?echo "$l_trusted_equipments_explain";?>
342
</td></tr>
343
</table>
318 richard 344
</BODY>
345
</HTML>