Subversion Repositories ALCASAR

Rev

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