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