Subversion Repositories ALCASAR

Rev

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