Subversion Repositories ALCASAR

Rev

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

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