Subversion Repositories ALCASAR

Rev

Rev 3135 | Rev 3173 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 3135 Rev 3137
1
<?php
1
<?php
2
/********************
2
/********************
3
* READ CONF FILES   *
3
* READ CONF FILES   *
4
*********************/
4
*********************/
5
define("CONF_FILE", "/usr/local/etc/alcasar.conf");
5
define("CONF_FILE", "/usr/local/etc/alcasar.conf");
6
define("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
6
define("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
7
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
7
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
8
foreach ($conf_files as $file) {
8
foreach ($conf_files as $file) {
9
	if (!file_exists($file)) {
9
	if (!file_exists($file)) {
10
		exit("Requested file ".$file." isn't present");
10
		exit("Requested file ".$file." isn't present");
11
	}
11
	}
12
	if (!is_readable($file)) {
12
	if (!is_readable($file)) {
13
		exit("Can't read the file ".$file);
13
		exit("Can't read the file ".$file);
14
	}
14
	}
15
}
15
}
16
 
16
 
17
$alcasar_conf_file = '/usr/local/etc/alcasar.conf';
17
$alcasar_conf_file = '/usr/local/etc/alcasar.conf';
18
$file_conf = fopen($alcasar_conf_file, 'r');
18
$file_conf = fopen($alcasar_conf_file, 'r');
19
if (!$file_conf) {
19
if (!$file_conf) {
20
	exit('Error opening the file '.$alcasar_conf_file);
20
	exit('Error opening the file '.$alcasar_conf_file);
21
}
21
}
22
while (!feof($file_conf)) {
22
while (!feof($file_conf)) {
23
	$buffer = fgets($file_conf, 4096);
23
	$buffer = fgets($file_conf, 4096);
24
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
24
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
25
		$tmp = explode('=', $buffer, 2);
25
		$tmp = explode('=', $buffer, 2);
26
		$conf[trim($tmp[0])] = trim($tmp[1]);
26
		$conf[trim($tmp[0])] = trim($tmp[1]);
27
	}
27
	}
28
}
28
}
29
fclose($file_conf);
29
fclose($file_conf);
30
 
30
 
31
$csrf_key = "";
31
$csrf_key = "";
32
$csrf_token = hash('sha256', $_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'].$_SERVER['REQUEST_URI'].$csrf_key);
32
$csrf_token = hash('sha256', $_SERVER['REMOTE_ADDR'].$_SERVER['HTTP_USER_AGENT'].$_SERVER['REQUEST_URI'].$csrf_key);
33
$tmp = explode("/",$conf["PRIVATE_IP"]);
33
$tmp = explode("/",$conf["PRIVATE_IP"]);
34
$private_ip=$tmp[0];
34
$private_ip=$tmp[0];
35
$intif = $conf["INTIF"];
35
$intif = $conf["INTIF"];
36
if ($conf['MULTIWAN'] !== 'off') {
36
if ($conf['MULTIWAN'] !== 'off') {
37
	exec ('sudo /usr/local/bin/alcasar-list-ip_gw.sh', $list_ip_gw); 
37
	exec ('sudo /usr/local/bin/alcasar-list-ip_gw.sh', $list_ip_gw); 
38
}
38
}
39
require('/etc/freeradius-web/config.php');
39
require('/etc/freeradius-web/config.php');
40
# Choice of language
40
# Choice of language
41
$Language = 'en';
41
$Language = 'en';
42
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
42
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
43
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
43
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
44
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
44
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
45
}
45
}
46
if ($Language === 'fr') {
46
if ($Language === 'fr') {
47
	$l_activity = "Activité sur le réseau de consultation";
47
	$l_activity = "Activité sur le réseau de consultation";
48
	$l_ip_adr = "Adresse IP";
48
	$l_ip_adr = "Adresse IP";
49
	$l_mac_adr = "Adresse MAC";
49
	$l_mac_adr = "Adresse MAC";
50
	$l_unknown = "manufacturer unknown";
50
	$l_unknown = "manufacturer unknown";
51
	$l_user = "Usager";
51
	$l_user = "Usager";
52
	$l_mac_allowed = "@MAC autorisée";
52
	$l_mac_allowed = "@MAC autorisée";
53
	$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
53
	$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
54
	$l_action = "Action";
54
	$l_action = "Action";
55
	$l_dissociate = "Dissocier @IP";
55
	$l_dissociate = "Dissocier @IP";
56
	$l_disconnect = "Déconnecter";
56
	$l_disconnect = "Déconnecter";
57
	$l_stop_capture_disconnect = "Arrêter la capture et déconnecter";
57
	$l_stop_capture_disconnect = "Arrêter la capture et déconnecter";
58
	$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
58
	$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
59
	$l_edit_user = "Editer l'utilisateur";
59
	$l_edit_user = "Editer l'utilisateur";
60
	$l_connect = "Autoriser temporairement";
60
	$l_connect = "Autoriser temporairement";
61
	$l_captureon = "Autoriser et capturer";
61
	$l_captureon = "Autoriser et capturer";
62
	$l_captureoff = "Arrêter la capture";
62
	$l_captureoff = "Arrêter la capture";
63
	$l_captureonly_on = "Capturer";
63
	$l_captureonly_on = "Capturer";
64
	$l_gw = "Routeur";
64
	$l_gw = "Routeur";
65
} else if ($Language === 'es') {
65
} else if ($Language === 'es') {
66
	$l_activity = "Actividad en la LAN";
66
	$l_activity = "Actividad en la LAN";
67
	$l_ip_adr = "Dirección IP";
67
	$l_ip_adr = "Dirección IP";
68
	$l_mac_adr = "Dirección MAC";
68
	$l_mac_adr = "Dirección MAC";
69
	$l_unknown = "fabricante desconocido";
69
	$l_unknown = "fabricante desconocido";
70
	$l_user = "Usuario";
70
	$l_user = "Usuario";
71
	$l_mac_allowed = "@MAC autorizada";
71
	$l_mac_allowed = "@MAC autorizada";
72
	$l_mac_temporarily_allowed = "@MAC temporalmente autorizada";
72
	$l_mac_temporarily_allowed = "@MAC temporalmente autorizada";
73
	$l_action = "Acción";
73
	$l_action = "Acción";
74
	$l_dissociate = "Liberar @IP";
74
	$l_dissociate = "Liberar @IP";
75
	$l_disconnect = "Desconectar";
75
	$l_disconnect = "Desconectar";
76
	$l_stop_capture_disconnect = "Deje de capturar y desconecte";
76
	$l_stop_capture_disconnect = "Deje de capturar y desconecte";
77
	$l_refresh = "Esta información es actualizada cada 30''";
77
	$l_refresh = "Esta información es actualizada cada 30''";
78
	$l_edit_user = "usuario de edición"; 
78
	$l_edit_user = "usuario de edición"; 
79
	$l_connect = "Permitir temporalmente";
79
	$l_connect = "Permitir temporalmente";
80
	$l_captureon = "Autorizar y capturar";
80
	$l_captureon = "Autorizar y capturar";
81
	$l_captureoff = "Detener la captura";
81
	$l_captureoff = "Detener la captura";
82
	$l_captureonly_on = "Captura";
82
	$l_captureonly_on = "Captura";
83
	$l_gw = "Router";
83
	$l_gw = "Router";
84
} else {
84
} else {
85
	$l_activity = "Activity on the consultation LAN";
85
	$l_activity = "Activity on the consultation LAN";
86
	$l_ip_adr = "IP Address";
86
	$l_ip_adr = "IP Address";
87
	$l_mac_adr = "MAC Address";
87
	$l_mac_adr = "MAC Address";
88
	$l_unknown = "fabricant inconnu";
88
	$l_unknown = "fabricant inconnu";
89
	$l_user = "User";
89
	$l_user = "User";
90
	$l_mac_allowed = "@MAC allowed";
90
	$l_mac_allowed = "@MAC allowed";
91
	$l_mac_temporarily_allowed = "@MAC temporarily allowed";
91
	$l_mac_temporarily_allowed = "@MAC temporarily allowed";
92
	$l_action = "Action";
92
	$l_action = "Action";
93
	$l_dissociate = "Dissociate @IP";
93
	$l_dissociate = "Dissociate @IP";
94
	$l_disconnect = "Disconnect";
94
	$l_disconnect = "Disconnect";
95
	$l_stop_capture_disconnect = "Stop capture and disconnect";
95
	$l_stop_capture_disconnect = "Stop capture and disconnect";
96
	$l_refresh = "This frame is refreshed every 30'";
96
	$l_refresh = "This frame is refreshed every 30'";
97
	$l_edit_user = "Edit user";
97
	$l_edit_user = "Edit user";
98
	$l_connect = "Temporarily authorize";
98
	$l_connect = "Temporarily authorize";
99
	$l_captureon = "Authorize and capture";
99
	$l_captureon = "Authorize and capture";
100
	$l_captureoff = "Stop capture";
100
	$l_captureoff = "Stop capture";
101
	$l_captureonly_on = "Capture";
101
	$l_captureonly_on = "Capture";
102
	$l_gw = "Router";
102
	$l_gw = "Router";
103
}
103
}
104
function taille_fichier($fichier)
104
function taille_fichier($fichier)
105
{
105
{
106
	$taille_fichier = filesize($fichier);
106
	$taille_fichier = filesize($fichier);
107
	if ($taille_fichier >= 1073741824){
107
	if ($taille_fichier >= 1073741824){
108
		$taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go";}
108
		$taille_fichier = round($taille_fichier / 1073741824 * 100) / 100 . " Go";}
109
	elseif ($taille_fichier >= 1048576){
109
	elseif ($taille_fichier >= 1048576){
110
		$taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo";}
110
		$taille_fichier = round($taille_fichier / 1048576 * 100) / 100 . " Mo";}
111
	elseif ($taille_fichier >= 1024){
111
	elseif ($taille_fichier >= 1024){
112
		$taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko";}
112
		$taille_fichier = round($taille_fichier / 1024 * 100) / 100 . " Ko";}
113
	else {$taille_fichier = $taille_fichier . " o";}
113
	else {$taille_fichier = $taille_fichier . " o";}
114
	return $taille_fichier;
114
	return $taille_fichier;
115
}
115
}
116
 
116
 
117
if (isset($_POST['action'])){
117
if (isset($_POST['action'])){
118
	$mac= trim($_POST['mac_addr']);
118
	$mac= trim($_POST['mac_addr']);
119
	if ((filter_var($mac, FILTER_VALIDATE_MAC) !== false) && (trim($_POST['post_csrf_token']) == $csrf_token)){
119
	if ((filter_var($mac, FILTER_VALIDATE_MAC) !== false) && (trim($_POST['post_csrf_token']) == $csrf_token)){
120
		switch ($_POST['action']){
120
		switch ($_POST['action']){
121
			case "$l_disconnect" :
121
			case "$l_disconnect" :
122
				exec("sudo /usr/sbin/chilli_query logout ".$mac);
122
				exec("sudo /usr/sbin/chilli_query logout ".$mac);
123
			break;
123
			break;
124
			case "$l_stop_capture_disconnect" :
124
			case "$l_stop_capture_disconnect" :
125
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
125
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
126
				exec("sudo /usr/sbin/chilli_query logout ".$mac);
126
				exec("sudo /usr/sbin/chilli_query logout ".$mac);
127
			break;
127
			break;
128
			case "$l_dissociate" :
128
			case "$l_dissociate" :
129
				exec("sudo /usr/sbin/chilli_query dhcp-release ".$mac);
129
				exec("sudo /usr/sbin/chilli_query dhcp-release ".$mac);
130
			break;
130
			break;
131
			case "$l_connect" :
131
			case "$l_connect" :
132
				exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
132
				exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
133
			break;
133
			break;
134
			case "$l_captureon" :
134
			case "$l_captureon" :
135
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
135
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
136
				exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
136
				exec("sudo /usr/sbin/chilli_query authorize mac ".$mac);
137
			break;
137
			break;
138
			case "$l_captureonly_on" :
138
			case "$l_captureonly_on" :
139
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
139
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -l '.$mac.' &>/dev/null &');
140
			break;	
140
			break;	
141
			case "$l_captureoff" :
141
			case "$l_captureoff" :
142
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
142
				exec('sudo /usr/local/bin/alcasar-iot_capture.sh -k '.$mac.' &>/dev/null &');
143
			break;
143
			break;
144
		}
144
		}
145
 
-
 
146
	}
145
	}
147
	unset($_POST['mac_addr']);
146
	unset($_POST['mac_addr']);
148
}
147
}
149
?>
148
?>
150
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
149
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
151
<html><!-- written by Rexy -->
150
<html><!-- written by Rexy -->
152
<head>
151
<head>
153
<meta HTTP-EQUIV="Refresh" CONTENT="30">
152
<meta HTTP-EQUIV="Refresh" CONTENT="30">
154
<meta http-equiv="Content-Type" content="text/html; charset=<?= $config['general_charset'] ?>">
153
<meta http-equiv="Content-Type" content="text/html; charset=<?= $config['general_charset'] ?>">
155
<title>Activity</title>
154
<title>Activity</title>
156
<link rel="stylesheet" type="text/css" href="/css/acc.css">
155
<link rel="stylesheet" type="text/css" href="/css/acc.css">
157
</head>
156
</head>
158
<body>
157
<body>
159
<div id="ldoverlay" class="overlay">
158
<div id="ldoverlay" class="overlay">
160
	<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>
159
	<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>
161
</div>
160
</div>
162
<table width="100%" border="0" cellspacing="0" cellpadding="0">
161
<table width="100%" border="0" cellspacing="0" cellpadding="0">
163
<tr><th><?= $l_activity ?></th></tr>
162
<tr><th><?= $l_activity ?></th></tr>
164
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
163
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr>
165
</table>
164
</table>
166
<table width="100%" border=1 cellspacing=0 cellpadding=1>
165
<table width="100%" border=1 cellspacing=0 cellpadding=1>
167
	<tr><td valign="middle" align="center"><?= $l_refresh ?><br>
166
	<tr><td valign="middle" align="center"><?= $l_refresh ?><br>
168
	<table border=1 width="80%" cellpadding=2 cellspacing=0>
167
	<table border=1 width="80%" cellpadding=2 cellspacing=0>
169
		<tr>
168
		<tr>
170
			<th>#</th>
169
			<th>#</th>
171
			<th><?= $l_ip_adr ?></th>
170
			<th><?= $l_ip_adr ?></th>
172
			<th><?= $l_mac_adr ?></th>
171
			<th><?= $l_mac_adr ?></th>
173
			<th><?= $l_user ?></th>
172
			<th><?= $l_user ?></th>
174
			<th><?= $l_action ?></th>
173
			<th><?= $l_action ?></th>
175
			<?php
174
			<?php
176
			if ($conf['MULTIWAN'] !== 'off') {
175
			if ($conf['MULTIWAN'] !== 'off') {
177
				echo "<th>$l_gw</th>";
176
				echo "<th>$l_gw</th>";
178
			}
177
			}
179
		echo "</tr>";
178
		echo "</tr>";
180
		$IoT_capture = $conf["IOT_CAPTURE"];
179
		$IoT_capture = $conf["IOT_CAPTURE"];
181
		$output = array(); $detail = array(); $nb_ligne = 0;
180
		$output = array(); $detail = array(); $nb_ligne = 0;
182
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR @MAC
181
		exec("sudo /sbin/ip link show ".escapeshellarg($intif), $output); // retrieve ALCASAR @MAC
183
		$detail = explode (" " , $output[1]);
182
		$detail = explode (" " , $output[1]);
184
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
183
		$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
185
		unset ($output);unset ($detail);
184
		unset ($output);unset ($detail);
186
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
185
		exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
187
		foreach($output as $ligne){
186
		foreach($output as $ligne){
188
			$detail = explode (" ", $ligne);
187
			$detail = explode (" ", $ligne);
189
			$nb_ligne ++;
188
			$nb_ligne ++;
190
			echo "<tr valign=\"middle\">";
189
			echo "<tr valign=\"middle\">";
191
			echo "<td>".$nb_ligne."</td>";
190
			echo "<td>".$nb_ligne."</td>";
192
			echo "<td>".$detail[1]."</td>"; // @IP
191
			echo "<td>".$detail[1]."</td>"; // @IP
193
			echo "<td>$detail[0]"; // @MAC
192
			echo "<td>$detail[0]"; // @MAC
194
			if(file_exists('/usr/local/share/nmap-mac-prefixes')){ // retrieve @MAC manufacturer
193
			if(file_exists('/usr/local/share/nmap-mac-prefixes')){ // retrieve @MAC manufacturer
195
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
194
				$oui_id = substr(str_replace("-","",$detail[0]),0,6);
196
				exec ("grep $oui_id /usr/local/share/nmap-mac-prefixes | cut -f2", $mac_manufacturer);
195
				exec ("grep $oui_id /usr/local/share/nmap-mac-prefixes | cut -f2", $mac_manufacturer);
197
				if(! empty($mac_manufacturer[0])) echo " <font size=\"1\">($mac_manufacturer[0])</font>";
196
				if(! empty($mac_manufacturer[0])) echo " <font size=\"1\">($mac_manufacturer[0])</font>";
198
					else echo " <font size=\"1\">($l_unknown)</font>";
197
					else echo " <font size=\"1\">($l_unknown)</font>";
199
				unset($mac_manufacturer);
198
				unset($mac_manufacturer);
200
			}
199
			}
201
			exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file); // retrieve @MAC info
200
			exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file); // retrieve @MAC info
202
			if (!empty($mac_in_ether_file[0])){
201
			if (!empty($mac_in_ether_file[0])){
203
				$mac_info= ltrim($mac_in_ether_file[0],'#');
202
				$mac_info= ltrim($mac_in_ether_file[0],'#');
204
				if (!empty($mac_info)) echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
203
				if (!empty($mac_info)) echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
205
			}
204
			}
206
			echo "</td><td>";
205
			echo "</td><td>";
207
			if ($detail[4] == "1"){ // is user authenticated ?
206
			if ($detail[4] == "1"){ // is user authenticated ?
208
				$login = $detail[5];
207
				$login = $detail[5];
209
				unset ($found_users); unset ($cn);
208
				unset ($found_users); unset ($cn);
210
				$search = $login; $search_IN = 'username'; // search user in database
209
				$search = $login; $search_IN = 'username'; // search user in database
211
				if (is_file("../lib/sql/find.php"))
210
				if (is_file("../lib/sql/find.php"))
212
				include("../lib/sql/find.php");
211
				include("../lib/sql/find.php");
213
				if (isset ($found_users)){ // is user in database ? 
212
				if (isset ($found_users)){ // is user in database ? 
214
					if (is_file("../lib/sql/user_info.php")) // retrieve user info (especialy $cn)
213
					if (is_file("../lib/sql/user_info.php")) // retrieve user info (especialy $cn)
215
						include("../lib/sql/user_info.php");
214
						include("../lib/sql/user_info.php");
216
				}
215
				}
217
				if (! isset ($cn)){ $cn='-';}
216
				if (! isset ($cn)){ $cn='-';}
218
				if ($detail[5] == $detail[0]){ // is user an @MAC ?
217
				if ($detail[5] == $detail[0]){ // is user an @MAC ?
219
					if (isset ($found_users)){ // is @MAC allowed ?
218
					if (isset ($found_users)){ // is @MAC allowed ?
220
						echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
219
						echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed";if ($cn != '-'){ echo " ($cn)";};echo "</a>";
221
						echo "</td>";
220
						echo "</td>";
222
						echo "<td>&nbsp;</td>"; // no 'disconnect' button for allowed @MAC
221
						echo "<td>&nbsp;</td>"; // no 'disconnect' button for allowed @MAC
223
					}
222
					}
224
					else {
223
					else {
225
						echo "<b>$l_mac_temporarily_allowed</b>";
224
						echo "<b>$l_mac_temporarily_allowed</b>";
226
						echo "</td><td>";
225
						echo "</td><td>";
227
						echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
226
						echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
228
						echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
227
						echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
229
						echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
228
						echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
230
						if($IoT_capture == "on"){
229
						if($IoT_capture == "on"){
231
							if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
230
							if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
232
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_stop_capture_disconnect\">";
231
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_stop_capture_disconnect\">";
233
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureoff\">";
232
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureoff\">";
234
							}
233
							}
235
 							else {
234
 							else {
236
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
235
								echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
237
								echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureonly_on\">";
236
								echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureonly_on\">";
238
								$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
237
								$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
239
								if (file_exists($file))	{
238
								if (file_exists($file))	{
240
									echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
239
									echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
241
								}
240
								}
242
							}	
241
							}	
243
						}
242
						}
244
						else echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
243
						else echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
245
						echo "</form></td>";
244
						echo "</form></td>";
246
					}
245
					}
247
				}
246
				}
248
				else { // The user is a humanoide ;-)
247
				else { // The user is a humanoide ;-)
249
					if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
248
					if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
250
					else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
249
					else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
251
					echo "<td>";
250
					echo "<td>";
252
					echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
251
					echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
253
					echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
252
					echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
254
					echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
253
					echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
255
					echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
254
					echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_disconnect\">";
256
					echo "</form></td>";
255
					echo "</form></td>";
257
				}
256
				}
258
			}
257
			}
259
			// equipment without authenticated user
258
			// equipment without authenticated user
260
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){ 
259
			else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){ 
261
				echo "ALCASAR system";
260
				echo "ALCASAR system";
262
				echo "<td>";
261
				echo "<td>";
263
				echo "&nbsp;";
262
				echo "&nbsp;";
264
				echo "</td>";
263
				echo "</td>";
265
			}	
264
			}	
266
			else {  
265
			else {  
267
				echo "&nbsp;";
266
				echo "&nbsp;";
268
				echo "<td>";		
267
				echo "<td>";		
269
				echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
268
				echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"POST\">";
270
				# Dissociate user (... or other) who is not connected yet
269
				# Dissociate user (... or other) who is not connected yet
271
				echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
270
				echo "<input type=\"hidden\" name=\"mac_addr\" value=\"$detail[0]\">";
272
				echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
271
				echo "<input type=\"hidden\" name=\"post_csrf_token\" value=\"$csrf_token\">";
273
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
272
				exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
274
				if (empty($mac_in_ether_file[1])){
273
				if (empty($mac_in_ether_file[1])){
275
					echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
274
					echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_dissociate\">"; // Dissociate only MAC not in ether file (dhcp)
276
				}
275
				}
277
				echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
276
				echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_connect\">"; // Enable temporarily @MAC access
278
				if($IoT_capture == "on"){
277
				if($IoT_capture == "on"){
279
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
278
					if(exec('sudo /usr/local/bin/alcasar-iot_capture.sh -i '.$detail[0]) == "CaptureON"){
280
						echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureoff\">";
279
						echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureoff\">";
281
					}
280
					}
282
					else {
281
					else {
283
						echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureon\">";
282
						echo "<br><input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureon\">";
284
						echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureonly_on\">";
283
						echo "<input type=\"submit\" onClick=\"document.getElementById('ldoverlay').style.display='block';\" name=\"action\" value=\"$l_captureonly_on\">";
285
						$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
284
						$file = '/var/Save/iot_captures/'.$detail[0].'.pcap';
286
						if (file_exists($file)) {
285
						if (file_exists($file)) {
287
							echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
286
							echo "<br><center><a href=\"/save/iot_captures/$detail[0].pcap\">$detail[0].pcap</a> (";echo taille_fichier("/var/Save/iot_captures/".$detail[0].".pcap");echo ")</center>";
288
						}
287
						}
289
					}
288
					}
290
				}
289
				}
291
				echo "</form></td>";
290
				echo "</form></td>";
292
			}
291
			}
293
			if ($conf['MULTIWAN'] !== 'off') {
292
			if ($conf['MULTIWAN'] !== 'off') {
294
				if ($detail[4] == "1"){ // authenticated user
293
				if ($detail[4] == "1"){ // authenticated user
295
					foreach ($list_ip_gw as $ligne2){
294
					foreach ($list_ip_gw as $ligne2){
296
						$detail2 = explode (" ", $ligne2);
295
						$detail2 = explode (" ", $ligne2);
297
						if ($detail2[0] == $detail[1]){
296
						if ($detail2[0] == $detail[1]){
298
							echo "<td>$detail2[1]</td>";
297
							echo "<td>$detail2[1]</td>";
299
							reset ($list_ip_gw);
298
							reset ($list_ip_gw);
300
							break;
299
							break;
301
						}
300
						}
302
					}
301
					}
303
				}
302
				}
304
			else echo "<td>&nbsp;</td>"; 
303
			else echo "<td>&nbsp;</td>"; 
305
			}
304
			}
306
			unset ($mac_in_ether_file);
305
			unset ($mac_in_ether_file);
307
			echo "</tr>";
306
			echo "</tr>";
308
		}
307
		}
309
		?>
308
		?>
310
	</table>
309
	</table>
311
	</td></tr>
310
	</td></tr>
312
</table>
311
</table>
313
</html>
312
</html>
314
 
313