Subversion Repositories ALCASAR

Rev

Rev 3132 | Rev 3137 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

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