Subversion Repositories ALCASAR

Rev

Rev 2178 | Rev 2817 | 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>
6
<link rel="stylesheet" href="/css/style.css" type="text/css">
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";
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'";
2083 richard 60
	  $l_trusted_ip_explain	= "Manage systems IP 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);
2175 richard 91
			exec ("sudo /usr/local/bin/alcasar-file-clean.sh"); # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
2177 richard 92
			sleep (1); # be sure that dnsmasq-blackhole is restarted before killing tun0 ! 
1578 richard 93
			exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 94
			}
95
		}
96
	break;
97
	case 'change_uamdomain' :
98
	$tab=file(DOMAIN_ALLOWED_LIST);
99
	if ($tab)
100
		{
101
		$pointeur=fopen(DOMAIN_ALLOWED_LIST,"w+");
102
		foreach ($tab as $ligne)
103
			{
104
			$uamdomain1=explode("\"", $ligne);
105
			$remove_line = false;
106
			foreach ($_POST as $key => $value)
107
				{
108
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
109
				if (strstr($key,'del-'))
110
					{
111
					$uamdomain2 = str_replace('del-','',$key);
112
					if (strcmp($uamdomain1[1],$uamdomain2) == 0)
113
				       		{
114
						$remove_line = True;
115
						break;
116
						}
117
					}
118
				}
119
			if (! $remove_line)
120
				{
121
				fwrite($pointeur,$ligne);
122
				}
123
			}
124
		fclose($pointeur);
125
		}
2178 richard 126
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
2177 richard 127
	sleep (1); # be sure that dnsmasq-blackhole is restarted before killing tun0 ! 
1578 richard 128
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 129
	break;
130
	case 'new_ip' :
2463 tom.houday 131
		$ipAddr = trim($_POST['add_ip']);
132
		if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ipAddr)) {
133
			echo '<span style="color: red;">'.'Invalid IP address'.'</span>'; // TODO : need to translate
134
		} else if (!empty($ipAddr)) {
135
			$tab=file(IP_ALLOWED_LIST);
136
			$insert = true;
137
			if ($tab) { // file isn't empty
138
				foreach ($tab as $line) { // test if domain address doesn't already exist
139
					$ip = explode('"', $line);
140
					if (strcmp($ipAddr, $ip[1]) === 0) {
141
						$insert = false;
142
						break;
870 richard 143
					}
144
				}
145
			}
2463 tom.houday 146
			if ($insert === true)  {
147
				$line = "\nuamallowed=\"" . $ipAddr .'" #' . trim($_POST['add_ip_comment']);
148
				$pointeur = fopen(IP_ALLOWED_LIST, 'a');
149
				fwrite($pointeur, $line);
150
				fclose($pointeur);
151
				exec('sudo /usr/local/bin/alcasar-file-clean.sh');  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
152
				exec('sudo /usr/bin/systemctl restart chilli');
870 richard 153
			}
154
		}
155
	break;
156
	case 'change_ip' :
157
	$tab=file(IP_ALLOWED_LIST);
158
	if ($tab)
159
		{
160
		$pointeur=fopen(IP_ALLOWED_LIST,"w+");
161
		foreach ($tab as $ligne)
162
			{
163
			$ip1=explode("\"", $ligne);
164
			$remove_line = false;
165
			foreach ($_POST as $key => $value)
166
				{
167
				$key = str_replace ("_",".",$key); // dot are replace by '_' in post request
168
				if (strstr($key,'del-'))
169
					{
170
					$ip2 = str_replace('del-','',$key);
171
					if (strcmp($ip1[1],$ip2) == 0)
172
				       		{
173
						$remove_line = True;
174
						break;
175
						}
176
					}
177
				}
178
			if (! $remove_line)
179
				{
180
				fwrite($pointeur,$ligne);
181
				}
182
			}
183
		fclose($pointeur);
184
		}
2178 richard 185
	exec ("sudo /usr/local/bin/alcasar-file-clean.sh");  # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf
1578 richard 186
	exec ("sudo /usr/bin/systemctl restart chilli");
870 richard 187
	break;
188
	}
318 richard 189
}
190
?>
870 richard 191
<TABLE width="100%" border=0 cellspacing=0 cellpadding=0>
192
<tr><th><?echo "$l_trusted_domain";?></th></tr>
193
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
194
</table>
195
<table width="100%" border=1 cellspacing=0 cellpadding=1>
196
<tr><td colspan=2 align="center">
197
<?
2138 richard 198
echo "$l_trusted_domain_explain</td></tr>\n";
199
echo "<tr><td align='center' valign='middle'>\n";
200
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>\n";
870 richard 201
echo "<table cellspacing=2 cellpadding=2 border=1>";
2138 richard 202
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_domain<td>$l_comment_explain<td>$l_remove</tr>\n";
870 richard 203
// Read the "Domain alowed" file
204
$tab=file(DOMAIN_ALLOWED_LIST);
205
if ($tab)  # the file isn't empty
206
	{
207
	foreach ($tab as $line)
208
		{
209
		if (trim($line) != '') # the line isn't empty
210
			{
211
			$domain_allowed=explode("#", $line);
212
			$uamdomain=trim($domain_allowed[0],"#");
213
			$domain=explode("\"", $uamdomain);
214
			echo "<tr><td>$domain[1]";
215
			echo "<td>";
216
			if (isset ($domain_allowed[1])) {
217
				echo trim($domain_allowed[1]);}
218
			else echo "&nbsp";
219
			echo "<td>";
220
			echo "<input type='checkbox' name='del-$domain[1]'>";
2138 richard 221
			echo "</tr>\n";
870 richard 222
			}
223
		}
224
	}
225
echo "</table>";
226
if ($tab)
227
	{
228
	echo "<input type='hidden' name='choix' value='change_uamdomain'>";
2054 raphael.pi 229
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_apply'>";
870 richard 230
	}
231
?>
232
</form>
233
</td><td valign='middle' align='center'>
234
<form action='<?echo"$_SERVER[PHP_SELF]"?>' method='POST'>
235
<table cellspacing=2 cellpadding=3 border=1>
912 richard 236
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_domain<td bgcolor='#d0ddb0'>$l_comment_explain";?>
237
<td></tr>
238
<tr><td>exemple1 : www.mydomain.com <br>exemple2 : .yourdomain.net
925 richard 239
<td>exemple1 : mydomain<br><?echo "$l_comment_explain2";?><td></tr>
912 richard 240
<tr><td><input type='text' name='add_uamdomain' size='20'>
241
<td><input type='text' name='add_domain_comment' size='15'>
2138 richard 242
<input type='hidden' name='choix' value='new_uamdomain'></td>
2054 raphael.pi 243
<td><input type='submit' onClick="this.disabled=true; this.value='<?echo $l_load;?>';submit();" value='<?echo "$l_add_to_list";?>'>
870 richard 244
</tr></table>
245
</form>
912 richard 246
</tr>
870 richard 247
</table>
885 richard 248
<table width="100%" border="0" cellspacing="0" cellpadding="0">
249
	<tr><th><?php echo "$l_trusted_ip" ;?></th></tr>
318 richard 250
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
885 richard 251
</table>
870 richard 252
<table width="100%" border=1 cellspacing=0 cellpadding=1>
253
<tr><td colspan=2 align="center">
254
<?
2138 richard 255
echo "$l_trusted_ip_explain</td></tr>\n";
256
echo "<tr><td align='center' valign='middle'>\n";
257
echo "<FORM action='$_SERVER[PHP_SELF]' method='POST'>\n";
870 richard 258
echo "<table cellspacing=2 cellpadding=2 border=1>";
2138 richard 259
echo "<tr align='center' bgcolor='#d0ddb0'><td>$l_trusted_ip<td>$l_comment<td>$l_remove</tr>\n";
870 richard 260
// Read the "ip alowed" file
261
$tab=file(IP_ALLOWED_LIST);
262
if ($tab)  # the file isn't empty
263
	{
264
	foreach ($tab as $line)
265
		{
266
		if (trim($line) != '') # the line isn't empty
267
			{
268
			$ip_allowed=explode("#", $line);
269
			$ip_a=trim($ip_allowed[0],"#");
270
			$ip=explode("\"", $ip_a);
271
			echo "<tr><td>$ip[1]";
272
			echo "<td>";
273
			if (isset($ip_allowed[1]))
274
				echo trim($ip_allowed[1]);
275
			else echo "&nbsp;";
276
			echo "<td><input type='checkbox' name='del-$ip[1]'>";
2138 richard 277
			echo "</tr>\n";
870 richard 278
			}
279
		}
280
	}
281
echo "</table>";
282
if ($tab)
283
	{
284
	echo "<input type='hidden' name='choix' value='change_ip'>";
2054 raphael.pi 285
	echo "<input type='submit' onClick=\"this.disabled=true; this.value='$l_load';submit();\" value='$l_apply'>";
870 richard 286
	}
287
?>
288
</form>
289
</td><td valign='middle' align='center'>
885 richard 290
<form action='<?echo "$_SERVER[PHP_SELF]"?>' method='POST'>
870 richard 291
<table cellspacing=2 cellpadding=3 border=1>
912 richard 292
<tr align='center'><td bgcolor='#d0ddb0'><?echo "$l_trusted_ip<td bgcolor='#d0ddb0'>$l_comment";?>
293
<td></tr>
870 richard 294
<tr><td>exemple1 : 170.25.23.10 <br>exemple2 : 15.20.20.0/16</td>
912 richard 295
<td>my_web_server <br>my_dmz<td></tr>
870 richard 296
<tr><td><input type='text' name='add_ip' size='20'></td>
2138 richard 297
<td><input type='text' name='add_ip_comment' size='15'>
298
<input type='hidden' name='choix' value='new_ip'></td>
2054 raphael.pi 299
<td><input type='submit' onClick="this.disabled=true; this.value='<?echo $l_load;?>';submit();" value='<?echo "$l_add_to_list";?>'></td>
870 richard 300
</tr></table>
2138 richard 301
</form>
870 richard 302
</table>
885 richard 303
<table width="100%" border="0" cellspacing="0" cellpadding="0">
304
	<tr><th><?php echo "$l_trusted_equipments";?></th></tr>
305
	<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
306
</table>
307
<table width="100%" border=1 cellspacing=0 cellpadding=1>
308
<tr><td colspan=2 align="center">
309
<?echo "$l_trusted_equipments_explain";?>
310
</td></tr>
311
</table>
318 richard 312
</BODY>
313
</HTML>