/web/acc/admin/network.php |
---|
7,7 → 7,7 |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf"); |
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers"); |
define ("DNS_LOCAL_FILE", "/usr/local/etc/alcasar-dns-name"); |
$conf_files=array(CONF_FILE,ETHERS_FILE); |
$conf_files=array(CONF_FILE,ETHERS_FILE,DNS_LOCAL_FILE); |
$reg_ip = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/'; |
$reg_ip_cidr = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\/([0-9]|[1-2][0-9]|3[0-2]))$/'; |
$network_modification=0; |
53,7 → 53,6 |
$l_import = "Importer"; |
$l_current_certificate = "Certificat actuel"; |
$l_validated = "Validé par :"; |
} else { |
$l_network_title = "Network configuration"; |
$l_extif_legend = " (Internet connected interface)"; |
85,7 → 84,6 |
$l_import = "Import"; |
$l_current_certificate = "Current certificate"; |
$l_validated = "Validated by :"; |
} |
if (isset($_POST['choix'])){$choix=$_POST['choix'];} else {$choix="";} |
switch ($choix) |
103,16 → 101,18 |
if ($tab) # the file isn't empty |
{ |
$insert="True"; |
$new_mac_addr=trim($_POST['add_mac'],"\x00..\x20"); |
$new_ip_addr=trim($_POST['add_ip'],"\x00..\x20"); |
foreach ($tab as $line) # verify that MAC or IP address doesn't exist |
{ |
$field=explode(" ", $line); |
$mac_addr=trim($field[0]);$ip_addr=trim($field[1]); |
if (strcasecmp(trim($_POST['add_mac']),trim($mac_addr)) == 0) |
if (strcasecmp($new_mac_addr, $mac_addr) == 0) |
{ |
$insert="False"; |
break; |
} |
if (strcasecmp(trim($_POST['add_ip']), trim($ip_addr)) == 0) |
if (strcasecmp($new_ip_addr, $ip_addr) == 0) |
{ |
$insert="False"; |
break; |
120,7 → 120,7 |
} |
if ($insert == "True") |
{ |
$line = trim($_POST['add_mac']) . " " . trim($_POST['add_ip']) . "\n"; |
$line = $new_mac_addr . " " . $new_ip_addr . " #" . trim($_POST['info'],"\x00..\x20") . "\n"; |
$pointeur=fopen(ETHERS_FILE,"a"); |
fwrite ($pointeur, $line); |
fclose ($pointeur); |
415,7 → 415,7 |
echo "<tr><th>$l_host_name<th>$l_ip_address"; |
?> |
<td></td></tr> |
<tr><td>exemple : my_nas</td><td>exemple : 192.168.182.10</td><td></td></tr> |
<tr><td>Ex. : my_nas</td><td>Ex. : 192.168.182.10</td><td></td></tr> |
<tr><td><input type='text' name='add_host' size='17'></td> |
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_host'></td> |
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\">"?></td> |
/web/acc/admin/network2.php |
---|
4,7 → 4,7 |
echo "<tr><td align='center' valign='middle'>"; |
echo "<FORM action='network.php' method='POST'>"; |
echo "<table cellspacing=2 cellpadding=3 border=1>"; |
echo "<tr><th>$l_mac_address<th>$l_ip_address<th>$l_del</tr>"; |
echo "<tr><th>$l_mac_address<th>$l_ip_address<th>Info<th>$l_del</tr>"; |
// Read the "ether" file |
$intif = $conf["INTIF"]; |
exec ("sudo /sbin/ip link show $intif", $output); |
14,38 → 14,46 |
$line_exist=False; |
$tab=file(ETHERS_FILE); |
if ($tab) # le fichier n'est pas vide |
{ |
foreach ($tab as $line) |
{ |
foreach ($tab as $line) |
{ |
$field=explode(" ", $line); |
$mac_addr=$field[0]; |
$ip_addr=$field[1]; |
if (isset($field[2])) $info=$field[2]; |
else $info=" "; |
echo "<tr><td>$mac_addr"; |
echo "<td>$ip_addr"; |
if ($mac_addr != $intif_mac_addr) |
{ |
{ |
echo "<td>" . ltrim($info,'#'); |
echo "<td><input type='checkbox' name='$mac_addr'>"; |
$line_exist=True; |
} |
else echo "<td>"; |
} |
else |
{ |
echo "<td>ALCASAR"; |
echo "<td>"; |
} |
echo "</tr>"; |
} |
} |
} |
echo "</table>"; |
if ($line_exist) |
{ |
{ |
echo "<input type='hidden' name='choix' value='del_mac'>"; |
echo "<input type='submit' value='$l_apply'>"; |
} |
} |
echo "</form></td><td valign='middle' align='center'>"; |
echo "<FORM name='new_mac' action='network.php' method='POST'>"; |
echo "<table cellspacing=2 cellpadding=3 border=1>"; |
echo "<tr><th>$l_mac_address<th>$l_ip_address"; |
echo "<tr><th>$l_mac_address<th>$l_ip_address<th>Info"; |
?> |
<td></td></tr> |
<tr><td>exemple : 12-2F-36-A4-DF-43</td><td>exemple : 192.168.182.10</td><td></td></tr> |
<tr><td>Ex. : 12-2F-36-A4-DF-43</td><td>Ex. : 192.168.182.10</td><td>Ex. : Switch<td></td></tr> |
<tr><td><input type='text' name='add_mac' size='17'></td> |
<td><input type='text' name='add_ip' size='10'><input type='hidden' name='choix' value='new_mac'></td> |
<td><input type='text' name='info' size='10'></td> |
<td><? echo "<input type=submit class=button value=\"$l_add_to_list\" OnClick=\"return MAC_Control('new_mac');\">"?></td> |
</tr></table> |
</form> |
/web/acc/manager/htdocs/activity.php |
---|
9,6 → 9,18 |
<body> |
<table width="100%" border="0" cellspacing="0" cellpadding="0"> |
<? |
/******************** |
* READ CONF FILES * |
*********************/ |
define ("CONF_FILE", "/usr/local/etc/alcasar.conf"); |
define ("ETHERS_FILE", "/usr/local/etc/alcasar-ethers"); |
$conf_files=array(CONF_FILE,ETHERS_FILE); |
foreach ($conf_files as $file){ |
if (!file_exists($file)){ |
exit("Requested file ".$file." isn't present");} |
if (!is_readable($file)){ |
exit("Can't read the file ".$file);} |
} |
#retrieve IP_address of ALCASAR |
$alcasar_conf_file="/usr/local/etc/alcasar.conf"; |
$ouvre=fopen("$alcasar_conf_file","r"); |
21,8 → 33,6 |
$conf[$tmp[0]] = $tmp[1]; |
} |
} |
}else{ |
exit("Erreur d'ouverture du fichier $alcasar_conf_file"); |
} |
fclose($ouvre); |
$tmp = explode("/",$conf["PRIVATE_IP"]); |
109,18 → 119,22 |
$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>"; |
{ |
$mac_manufacturer[0] = "Unknown"; |
} |
echo "<td>$detail[0] <font size=\"1\">($mac_manufacturer[0])</font>"; |
unset($mac_manufacturer); |
} |
else |
{ |
echo "<td>$detail[0]</td>"; |
echo "<td>$detail[0]"; |
} |
echo "<td>"; |
exec ("grep $detail[0] /usr/local/etc/alcasar-ethers |cut -d' ' -f3", $mac_in_ether_file); |
if (!empty($mac_in_ether_file[0])) |
{ |
echo " - <b>" . ltrim($mac_in_ether_file[0],'#') . "</b>"; |
} |
echo "</td><td>"; |
if ($detail[4] == "1"){ // authenticated equipment |
$login = $detail[5]; |
unset ($found_users); unset ($cn); |
140,7 → 154,7 |
echo "</td><td>"; |
} |
else { #MAC is temporarily allowed |
echo "<a href=\"/acc/manager/htdocs/user_admin.php?login=$detail[5]\" title=\"$l_edit_user\">$l_mac_temporarily_allowed</a>"; |
echo "<b>$l_mac_temporarily_allowed</b>"; |
echo "</td><td>"; |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>"; |
echo "<INPUT type='hidden' name='mac_addr' value='$detail[0]'>"; |
173,11 → 187,14 |
echo "<FORM action='".$_SERVER['PHP_SELF']."' method=POST>"; |
# 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'>"; |
if (empty($mac_in_ether_file[0])) |
{ |
echo "<INPUT type='submit' name='action' value='$l_dissociate'>"; // Dissociate only MAC not in ether file (dhcp) |
} |
echo "<INPUT type=submit name='action' value='$l_connect'>"; // Enable temporarily @MAC access |
echo "</FORM></TD>"; |
} |
unset ($mac_in_ether_file); |
echo "</tr>"; |
} |
?> |