Subversion Repositories ALCASAR

Rev

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

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