Subversion Repositories ALCASAR

Rev

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

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