Subversion Repositories ALCASAR

Rev

Rev 2091 | Rev 2128 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><!-- written by Rexy -->
<head>
<META HTTP-EQUIV="Refresh" CONTENT="30">
<meta http-equiv="Content-Type" content="text/html; charset=$config[general_charset]">
<title>&Eacute;tat du r&eacute;seau</title>
<link rel="stylesheet" href="/css/style.css">
</head>
<body>
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<?
#retrieve IP_address of ALCASAR
$alcasar_conf_file="/usr/local/etc/alcasar.conf";
$ouvre=fopen("$alcasar_conf_file","r");
if ($ouvre){
        while (!feof ($ouvre))
        {
                $tampon = fgets($ouvre, 4096);
                if (strpos($tampon,"=")!==false){
                        $tmp = explode("=",$tampon);
                        $conf[$tmp[0]] = $tmp[1];
                }
        }
}else{
        exit("Erreur d'ouverture du fichier $alcasar_conf_file");
}
fclose($ouvre);
$tmp = explode("/",$conf["PRIVATE_IP"]);
$intif = $conf["INTIF"];
$private_ip=$tmp[0];
require('/etc/freeradius-web/config.php');
# Choice of language
$Language = 'en';
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
  $Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
  $Language = strtolower(substr(chop($Langue[0]),0,2)); }
if($Language == 'fr'){
  $l_activity = "Activité; sur le réseau de consultation";
  $l_ip_adr = "Adresse IP";
  $l_mac_adr = "Adresse MAC";
  $l_user = "Usager";
  $l_mac_allowed = "@MAC autorisée";
  $l_action = "Action";
  $l_dissociate = "Dissocier";
  $l_disconnect = "Déconnecter";
  $l_refresh = "Cette page est rafraichie toutes les 30 secondes";
  $l_edit_user = "Editer l'utilisateur"; 
  $l_mac_action = "Action temporaire";
  $l_connect = "Autoriser";
}
else {
  $l_activity = "Activity on the consultation LAN";
  $l_ip_adr = "IP Adress";
  $l_mac_adr = "MAC Adress";
  $l_user = "User";
  $l_mac_allowed = "@MAC allowed";
  $l_action = "Action";
  $l_dissociate = "Dissociate";
  $l_disconnect = "Disconnect";
  $l_refresh = "This frame is refreshed every 30'";
  $l_edit_user = "Edit user"; 
  $l_mac_action = "Temporarily Action";
  $l_connect = "Authorize";
}
echo "
<tr><th>$l_activity</th></tr>
<tr bgcolor=\"#FFCC66\"><td><img src=\"/images/pix.gif\" width=\"1\"
height=\"2\"></td></tr>
</TABLE>";
if (isset($_POST['action'])){
        switch ($_POST['action']){
                case "$l_disconnect" :
                        exec ("sudo /usr/sbin/chilli_query logout $_POST[mac_addr]");
                        unset ($_POST['mac_addr']);
                break;
                case "$l_dissociate" :
                        exec ("sudo /usr/sbin/chilli_query dhcp-release $_POST[mac_addr]");
                        unset ($_POST['mac_addr']);
                break;
                case "$l_connect" :
                        exec ("sudo /usr/sbin/chilli_query authorize mac $_POST[mac_addr]");
                        unset ($_POST['mac_addr']);
                break;
        }
}
?>
<TABLE width="100%" border=1 cellspacing=0 cellpadding=1>
        <tr><td valign="middle" align="left">
        <center>
<? echo "$l_refresh";?>
        <table border=1 width="80%" bordercolordark="#ffffe0" bordercolorlight="#000000" width="100%" cellpadding=2 cellspacing=0 bgcolor="#ffffe0" valign=top>
                <tr bgcolor="#d0ddb0">
<? echo "
                <th>#</th>
                <th>$l_ip_adr</th>
                <th>$l_mac_adr</th>
                <th>$l_user</th>
                <th>$l_action</th>
                </tr>";
                $output = array(); $detail = array(); $nb_ligne = 0;
                exec ("sudo /sbin/ip link show $intif", $output); // retrieve ALCASAR MAC address
                $detail = explode (" " , $output[1]);
                $intif_mac_addr=strtoupper(str_replace(":","-",$detail[5]));
                unset ($output);unset ($detail);
                exec ('sudo /usr/sbin/chilli_query list|sort -k5 -r', $output); 
                while (list(,$ligne) = each($output)){
                        $detail = explode (" ", $ligne);
                        $nb_ligne ++;
                        echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>";
                        echo "<TR>";
                        echo "<TD>".$nb_ligne."</TD>";
                        echo "<TD>".$detail[1]."</TD>";
                        if(file_exists('/usr/share/arp-scan/ieee-oui.txt')) // for each device on LAN, retrieve the MAC manufacturer
                        {
                                $oui_id = substr(str_replace("-","",$detail[0]),0,6);
                                exec ("grep $oui_id /usr/share/arp-scan/ieee-oui.txt | cut -f2", $mac_manufacturer);
                                if(empty($mac_manufacturer[0]))
                {
                        $mac_manufacturer[0] = "Unknown";
                }

                                echo "<TD>$detail[0] ($mac_manufacturer[0])</TD>";
                                unset($mac_manufacturer);
                        }
                        else
                        {
                                echo "<TD>$detail[0]</TD>";
                        }
                        echo "<TD>";
                        if ($detail[4] == "1"){ // authenticated equipment
                                $login = $detail[5];
                                unset ($found_users); $search = $login; $search_IN = 'username'; // is user in database ?
                                if (is_file("../lib/sql/find.php"))
                                        include("../lib/sql/find.php");
                                if (isset ($found_users)) // user is in database
                                {
                                        echo "OK - ";
                                        if (is_file("../lib/sql/user_info.php")) //retrieve user info
                                                include("../lib/sql/user_info.php");
                                }
                                # The user is an allowed MAC address
                                        if ($detail[5] == $detail[0]){
                                                if ($cn != '-') {echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed ($cn)</a>";}
                                                else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_allowed</a>";}
                                                echo "</TD>";
                                                echo "<TD>";
                                                # Disable temporarily @MAC access
                                                echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
                                                echo "<INPUT type=submit name='action' value='$l_disconnect'>";
                                                }
                                # The user is a humanoide ;-)
                                        else {
                                                if ($cn != '-') { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5] ($cn)</a>";}
                                                else { echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user $detail[5]\">$detail[5]</a>";}
                                                echo "</TD>";
                                                echo "<TD>";
                                                echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
                                                echo "<INPUT type=submit name='action' value='$l_disconnect'>";
                                                }
                                        }
                        # equipment without authenticated user
                        else if (($detail[0] == $intif_mac_addr) || ($detail[1] == $private_ip)){
                                echo "ALCASAR system";
                                echo "</TD>";
                                echo "<TD>";
                                echo "&nbsp;";
                                }       
                        else {  
                                echo "&nbsp;";
                                echo "</TD>";
                                echo "<TD>";

                                # Dissociate user (... or other) who is not connected yet
                                echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>";
                                echo "<INPUT type='submit' name='action' value='$l_dissociate'>";

                                # Enable temporarily @MAC access
                                echo "<INPUT type=submit name='action' value='$l_connect'>";

                        }

                        echo "</TR></FORM>";
                }
                ?>
                </td></tr>
        </table>
        </td></tr>
</table>
</html>