1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2 |
<HTML><!-- written by Rexy -->
|
2 |
<HTML><!-- written by Rexy -->
|
3 |
<head>
|
3 |
<head>
|
4 |
<META HTTP-EQUIV="Refresh" CONTENT="30">
|
4 |
<META HTTP-EQUIV="Refresh" CONTENT="30">
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
|
6 |
<title>Activity</title>
|
6 |
<title>Activity</title>
|
7 |
<link rel="stylesheet" href="/css/style.css">
|
7 |
<link rel="stylesheet" href="/css/style.css">
|
8 |
</head>
|
8 |
</head>
|
9 |
<body>
|
9 |
<body>
|
10 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
10 |
<table width="100%" border="0" cellspacing="0" cellpadding="0">
|
11 |
<?
|
11 |
<?
|
12 |
/********************
|
12 |
/********************
|
13 |
* READ CONF FILES *
|
13 |
* READ CONF FILES *
|
14 |
*********************/
|
14 |
*********************/
|
15 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
15 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf");
|
16 |
define ("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
|
16 |
define ("ETHERS_INFO_FILE", "/usr/local/etc/alcasar-ethers-info");
|
17 |
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
|
17 |
$conf_files=array(CONF_FILE,ETHERS_INFO_FILE);
|
18 |
foreach ($conf_files as $file){
|
18 |
foreach ($conf_files as $file){
|
19 |
if (!file_exists($file)){
|
19 |
if (!file_exists($file)){
|
20 |
exit("Requested file ".$file." isn't present");}
|
20 |
exit("Requested file ".$file." isn't present");}
|
21 |
if (!is_readable($file)){
|
21 |
if (!is_readable($file)){
|
22 |
exit("Can't read the file ".$file);}
|
22 |
exit("Can't read the file ".$file);}
|
23 |
}
|
23 |
}
|
24 |
#retrieve IP_address of ALCASAR
|
24 |
#retrieve IP_address of ALCASAR
|
25 |
$alcasar_conf_file="/usr/local/etc/alcasar.conf";
|
25 |
$alcasar_conf_file="/usr/local/etc/alcasar.conf";
|
26 |
$ouvre=fopen("$alcasar_conf_file","r");
|
26 |
$ouvre=fopen("$alcasar_conf_file","r");
|
27 |
if ($ouvre){
|
27 |
if ($ouvre){
|
28 |
while (!feof ($ouvre))
|
28 |
while (!feof ($ouvre))
|
29 |
{
|
29 |
{
|
30 |
$tampon = fgets($ouvre, 4096);
|
30 |
$tampon = fgets($ouvre, 4096);
|
31 |
if (strpos($tampon,"=")!==false){
|
31 |
if (strpos($tampon,"=")!==false){
|
32 |
$tmp = explode("=",$tampon);
|
32 |
$tmp = explode("=",$tampon);
|
33 |
$conf[$tmp[0]] = $tmp[1];
|
33 |
$conf[$tmp[0]] = $tmp[1];
|
34 |
}
|
34 |
}
|
35 |
}
|
35 |
}
|
36 |
}
|
36 |
}
|
37 |
fclose($ouvre);
|
37 |
fclose($ouvre);
|
38 |
$tmp = explode("/",$conf["PRIVATE_IP"]);
|
38 |
$tmp = explode("/",$conf["PRIVATE_IP"]);
|
39 |
$intif = $conf["INTIF"];
|
39 |
$intif = $conf["INTIF"];
|
40 |
$private_ip=$tmp[0];
|
40 |
$private_ip=$tmp[0];
|
41 |
require('/etc/freeradius-web/config.php');
|
41 |
require('/etc/freeradius-web/config.php');
|
42 |
# Choice of language
|
42 |
# Choice of language
|
43 |
$Language = 'en';
|
43 |
$Language = 'en';
|
44 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
44 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
45 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
45 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
46 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
46 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
47 |
if($Language == 'fr'){
|
47 |
if($Language == 'fr'){
|
48 |
$l_activity = "Activité sur le réseau de consultation";
|
48 |
$l_activity = "Activité sur le réseau de consultation";
|
49 |
$l_ip_adr = "Adresse IP";
|
49 |
$l_ip_adr = "Adresse IP";
|
50 |
$l_mac_adr = "Adresse MAC";
|
50 |
$l_mac_adr = "Adresse MAC";
|
51 |
$l_user = "Usager";
|
51 |
$l_user = "Usager";
|
52 |
$l_mac_allowed = "@MAC autorisée";
|
52 |
$l_mac_allowed = "@MAC autorisée";
|
53 |
$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
|
53 |
$l_mac_temporarily_allowed = "@MAC autorisée temporairement";
|
54 |
$l_action = "Action";
|
54 |
$l_action = "Action";
|
55 |
$l_dissociate = "Dissocier @IP";
|
55 |
$l_dissociate = "Dissocier @IP";
|
56 |
$l_disconnect = "Déconnecter";
|
56 |
$l_disconnect = "Déconnecter";
|
57 |
$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
|
57 |
$l_refresh = "Cette page est rafraichie toutes les 30 secondes";
|
58 |
$l_edit_user = "Editer l'utilisateur";
|
58 |
$l_edit_user = "Editer l'utilisateur";
|
59 |
$l_connect = "Autoriser temporairement";
|
59 |
$l_connect = "Autoriser temporairement";
|
60 |
}
|
60 |
}
|
61 |
else {
|
61 |
else {
|
62 |
$l_activity = "Activity on the consultation LAN";
|
62 |
$l_activity = "Activity on the consultation LAN";
|
63 |
$l_ip_adr = "IP Adress";
|
63 |
$l_ip_adr = "IP Adress";
|
64 |
$l_mac_adr = "MAC Adress";
|
64 |
$l_mac_adr = "MAC Adress";
|
65 |
$l_user = "User";
|
65 |
$l_user = "User";
|
66 |
$l_mac_allowed = "@MAC allowed";
|
66 |
$l_mac_allowed = "@MAC allowed";
|
67 |
$l_mac_temporarily_allowed = "@MAC temporarily allowed";
|
67 |
$l_mac_temporarily_allowed = "@MAC temporarily allowed";
|
68 |
$l_action = "Action";
|
68 |
$l_action = "Action";
|
69 |
$l_dissociate = "Dissociate @IP";
|
69 |
$l_dissociate = "Dissociate @IP";
|
70 |
$l_disconnect = "Disconnect";
|
70 |
$l_disconnect = "Disconnect";
|
71 |
$l_refresh = "This frame is refreshed every 30'";
|
71 |
$l_refresh = "This frame is refreshed every 30'";
|
72 |
$l_edit_user = "Edit user";
|
72 |
$l_edit_user = "Edit user";
|
73 |
$l_connect = "Temporarily authorize";
|
73 |
$l_connect = "Temporarily authorize";
|
74 |
}
|
74 |
}
|
75 |
echo "<tr><th>$l_activity</th></tr>
|
75 |
echo "<tr><th>$l_activity</th></tr>
|
76 |
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td></tr>
|
76 |
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\" height=\"2\"></td></tr>
|
77 |
</table>";
|
77 |
</table>";
|
78 |
if (isset($_POST['action'])){
|
78 |
if (isset($_POST['action'])){
|
79 |
switch ($_POST['action']){
|
79 |
switch ($_POST['action']){
|
80 |
case "$l_disconnect" :
|
80 |
case "$l_disconnect" :
|
81 |
exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
|
81 |
exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
|
82 |
unset ($_POST['mac_addr']);
|
82 |
unset ($_POST['mac_addr']);
|
83 |
break;
|
83 |
break;
|
84 |
case "$l_dissociate" :
|
84 |
case "$l_dissociate" :
|
85 |
exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
|
85 |
exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
|
86 |
unset ($_POST['mac_addr']);
|
86 |
unset ($_POST['mac_addr']);
|
87 |
break;
|
87 |
break;
|
88 |
case "$l_connect" :
|
88 |
case "$l_connect" :
|
89 |
exec ("sudo /usr/sbin/chilli_query authorize mac $_POST[mac_addr]");
|
89 |
exec ("sudo /usr/sbin/chilli_query authorize mac $_POST[mac_addr]");
|
90 |
unset ($_POST['mac_addr']);
|
90 |
unset ($_POST['mac_addr']);
|
91 |
break;
|
91 |
break;
|
92 |
}
|
92 |
}
|
93 |
}
|
93 |
}
|
94 |
?>
|
94 |
?>
|
95 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
95 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
96 |
<tr><td valign="middle" align="center"><? echo "$l_refresh";?><br>
|
96 |
<tr><td valign="middle" align="center"><? echo "$l_refresh";?><br>
|
97 |
<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
|
97 |
<table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
|
98 |
<tr bgcolor="#d0ddb0">
|
98 |
<tr bgcolor="#d0ddb0">
|
99 |
<? echo " <th>#</th>
|
99 |
<? echo " <th>#</th>
|
100 |
<th>$l_ip_adr</th>
|
100 |
<th>$l_ip_adr</th>
|
101 |
<th>$l_mac_adr</th>
|
101 |
<th>$l_mac_adr</th>
|
102 |
<th>$l_user</th>
|
102 |
<th>$l_user</th>
|
103 |
<th>$l_action</th>
|
103 |
<th>$l_action</th>
|
104 |
</tr>";
|
104 |
</tr>";
|
105 |
$output = array(); $detail = array(); $nb_ligne = 0;
|
105 |
$output = array(); $detail = array(); $nb_ligne = 0;
|
106 |
exec ("sudo /sbin/ip link show $intif", $output); // retrieve ALCASAR MAC address
|
106 |
exec ("sudo /sbin/ip link show $intif", $output); // retrieve ALCASAR MAC address
|
107 |
$detail = explode (" " , $output[1]);
|
107 |
$detail = explode (" " , $output[1]);
|
108 |
$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
|
108 |
$intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
|
109 |
unset ($output);unset ($detail);
|
109 |
unset ($output);unset ($detail);
|
110 |
exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output);
|
110 |
exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output);
|
111 |
while (list(,$ligne) = each($output)){
|
111 |
while (list(,$ligne) = each($output)){
|
112 |
$detail = explode (" ", $ligne);
|
112 |
$detail = explode (" ", $ligne);
|
113 |
$nb_ligne ++;
|
113 |
$nb_ligne ++;
|
114 |
echo "<tr valign=\"middle\">";
|
114 |
echo "<tr valign=\"middle\">";
|
115 |
echo "<td>".$nb_ligne."</td>";
|
115 |
echo "<td>".$nb_ligne."</td>";
|
116 |
echo "<td>".$detail[1]."</td>";
|
116 |
echo "<td>".$detail[1]."</td>";
|
117 |
if(file_exists('/usr/share/arp-scan/ieee-oui.txt')) // for each device on LAN, retrieve the MAC manufacturer
|
117 |
if(file_exists('/usr/share/arp-scan/ieee-oui.txt')) // for each device on LAN, retrieve the MAC manufacturer
|
118 |
{
|
118 |
{
|
119 |
$oui_id = substr(str_replace("-","",$detail[0]),0,6);
|
119 |
$oui_id = substr(str_replace("-","",$detail[0]),0,6);
|
120 |
exec ("grep $oui_id /usr/share/arp-scan/ieee-oui.txt | cut -f2", $mac_manufacturer);
|
120 |
exec ("grep $oui_id /usr/share/arp-scan/ieee-oui.txt | cut -f2", $mac_manufacturer);
|
121 |
if(empty($mac_manufacturer[0]))
|
121 |
if(empty($mac_manufacturer[0]))
|
122 |
{
|
122 |
{
|
123 |
$mac_manufacturer[0] = "Unknown";
|
123 |
$mac_manufacturer[0] = "Unknown";
|
124 |
}
|
124 |
}
|
125 |
echo "<td>$detail[0] <font size=\"1\">($mac_manufacturer[0])</font>";
|
125 |
echo "<td>$detail[0] <font size=\"1\">($mac_manufacturer[0])</font>";
|
126 |
unset($mac_manufacturer);
|
126 |
unset($mac_manufacturer);
|
127 |
}
|
127 |
}
|
128 |
else
|
128 |
else
|
129 |
{
|
129 |
{
|
130 |
echo "<td>$detail[0]";
|
130 |
echo "<td>$detail[0]";
|
131 |
}
|
131 |
}
|
132 |
exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file);
|
132 |
exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info |cut -d' ' -f3", $mac_in_ether_file);
|
133 |
if (!empty($mac_in_ether_file[0]))
|
133 |
if (!empty($mac_in_ether_file[0]))
|
134 |
{
|
134 |
{
|
135 |
echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
|
135 |
echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>";
|
136 |
}
|
136 |
}
|
137 |
echo "</td><td>";
|
137 |
echo "</td><td>";
|
138 |
if ($detail[4] == "1"){ // authenticated equipment
|
138 |
if ($detail[4] == "1"){ // authenticated equipment
|
139 |
$login = $detail[5];
|
139 |
$login = $detail[5];
|
140 |
unset ($found_users); unset ($cn);
|
140 |
unset ($found_users); unset ($cn);
|
141 |
$search = $login; $search_IN = 'username'; // is user in database ?
|
141 |
$search = $login; $search_IN = 'username'; // is user in database ?
|
142 |
if (is_file("../lib/sql/find.php"))
|
142 |
if (is_file("../lib/sql/find.php"))
|
143 |
include("../lib/sql/find.php");
|
143 |
include("../lib/sql/find.php");
|
144 |
if (isset ($found_users)) // user is in database
|
144 |
if (isset ($found_users)) // user is in database
|
145 |
{
|
145 |
{
|
146 |
if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
|
146 |
if (is_file("../lib/sql/user_info.php")) //retrieve user info (especialy $cn)
|
147 |
include("../lib/sql/user_info.php");
|
147 |
include("../lib/sql/user_info.php");
|
148 |
}
|
148 |
}
|
149 |
if (! isset ($cn)){ $cn='-';}
|
149 |
if (! isset ($cn)){ $cn='-';}
|
150 |
# The user is an allowed MAC address
|
150 |
# The user is an allowed MAC address
|
151 |
if ($detail[5] == $detail[0]){
|
151 |
if ($detail[5] == $detail[0]){
|
152 |
if (isset ($found_users)) { #MAC is in database
|
152 |
if (isset ($found_users)) { #MAC is in database
|
153 |
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>";
|
153 |
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>";
|
154 |
echo "</td><td>";
|
154 |
echo "</td><td>";
|
155 |
}
|
155 |
}
|
156 |
else { #MAC is temporarily allowed
|
156 |
else { #MAC is temporarily allowed
|
157 |
echo "<b>$l_mac_temporarily_allowed</b>";
|
157 |
echo "<b>$l_mac_temporarily_allowed</b>";
|
158 |
echo "</td><td>";
|
158 |
echo "</td><td>";
|
159 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
159 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
160 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
160 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
161 |
echo "<INPUT type=submit name='action' value='$l_disconnect'>";
|
161 |
echo "<INPUT type=submit name='action' value='$l_disconnect'>";
|
162 |
echo "</FORM></TD>";
|
162 |
echo "</FORM></TD>";
|
163 |
}
|
163 |
}
|
164 |
# Disable temporarily @MAC access
|
164 |
# Disable temporarily @MAC access
|
165 |
}
|
165 |
}
|
166 |
# The user is a humanoide ;-)
|
166 |
# The user is a humanoide ;-)
|
167 |
else {
|
167 |
else {
|
168 |
if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
|
168 |
if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
|
169 |
else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
|
169 |
else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
|
170 |
echo "<TD>";
|
170 |
echo "<TD>";
|
171 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
171 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
172 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
172 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
173 |
echo "<INPUT type=submit name='action' value='$l_disconnect'>";
|
173 |
echo "<INPUT type=submit name='action' value='$l_disconnect'>";
|
174 |
echo "</FORM></TD>";
|
174 |
echo "</FORM></TD>";
|
175 |
}
|
175 |
}
|
176 |
}
|
176 |
}
|
177 |
# equipment without authenticated user
|
177 |
# equipment without authenticated user
|
178 |
else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
|
178 |
else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
|
179 |
echo "ALCASAR system";
|
179 |
echo "ALCASAR system";
|
180 |
echo "<TD>";
|
180 |
echo "<TD>";
|
181 |
echo " ";
|
181 |
echo " ";
|
182 |
echo "</TD>";
|
182 |
echo "</TD>";
|
183 |
}
|
183 |
}
|
184 |
else {
|
184 |
else {
|
185 |
echo " ";
|
185 |
echo " ";
|
186 |
echo "<TD>";
|
186 |
echo "<TD>";
|
187 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
187 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
|
188 |
# Dissociate user (... or other) who is not connected yet
|
188 |
# Dissociate user (... or other) who is not connected yet
|
189 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
189 |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
|
- |
|
190 |
exec ("grep $detail[0] /usr/local/etc/alcasar-ethers-info", $mac_in_ether_file);
|
190 |
if (empty($mac_in_ether_file[0]))
|
191 |
if (empty($mac_in_ether_file[1]))
|
191 |
{
|
192 |
{
|
192 |
echo "<INPUT type='submit' name='action' value='$l_dissociate'>"; // Dissociate only MAC not in ether file (dhcp)
|
193 |
echo "<INPUT type='submit' name='action' value='$l_dissociate'>"; // Dissociate only MAC not in ether file (dhcp)
|
193 |
}
|
194 |
}
|
194 |
echo "<INPUT type=submit name='action' value='$l_connect'>"; // Enable temporarily @MAC access
|
195 |
echo "<INPUT type=submit name='action' value='$l_connect'>"; // Enable temporarily @MAC access
|
195 |
echo "</FORM></TD>";
|
196 |
echo "</FORM></TD>";
|
196 |
}
|
197 |
}
|
197 |
unset ($mac_in_ether_file);
|
198 |
unset ($mac_in_ether_file);
|
198 |
echo "</tr>";
|
199 |
echo "</tr>";
|
199 |
}
|
200 |
}
|
200 |
?>
|
201 |
?>
|
201 |
</table>
|
202 |
</table>
|
202 |
</td></tr>
|
203 |
</td></tr>
|
203 |
</table>
|
204 |
</table>
|
204 |
</html>
|
205 |
</html>
|
205 |
|
206 |
|
206 |
|
207 |
|