Subversion Repositories ALCASAR

Rev

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