57,10 → 57,6 |
$l_DHCP_off = "inactif"; |
$l_DHCP_off_explain = "/!\\ Avant d'arrêter le serveur DHCP, vous devez renseigner les paramètres d'un serveur externe (cf. documentation)."; |
$l_static_dhcp_title = "Réservation d'adresses IP statiques"; |
$l_dhcp_relay = "Relais DHCP"; |
$l_dhcp_relay_local_ip = "Adresse IP locale"; |
$l_dhcp_relay_ip = "Adresse IP DHCP"; |
$l_dhcp_relay_port = "Port DHCP"; |
$l_mac_address = "Adresse MAC"; |
$l_ip_address = "Adresse IP"; |
$l_host_name = "Nom d'hôte"; |
115,13 → 111,8 |
$l_DHCP_off = "disabled"; |
$l_DHCP_off_explain = "/!\\ Before disabling the DHCP server, you must write the extern DHCP parameters in the config file (see Documentation)"; |
$l_static_dhcp_title = "Static IP addresses reservation"; |
$l_dhcp_relay = "DHCP relay"; |
$l_dhcp_relay_local_ip = "Locale IP address"; |
$l_dhcp_relay_ip = "DHCP IP address"; |
$l_dhcp_relay_port = "DHCP port"; |
$l_mac_address = "MAC address"; |
$l_ip_address = "IP address"; |
$l_port = "Port"; |
$l_mac_address = "MAC Address"; |
$l_ip_address = "IP Address"; |
$l_host_name = "Host name"; |
$l_del = "Delete from list"; |
$l_add_to_list = "Add"; |
172,12 → 163,10 |
switch ($choix) { |
case 'DHCP_On': |
exec('sudo /usr/local/bin/alcasar-dhcp.sh -on'); |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
case 'DHCP_Off': |
exec('sudo /usr/local/bin/alcasar-dhcp.sh -off'); |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
|
case 'new_mac': |
$new_mac_addr = trim($_POST['add_mac']); |
212,8 → 201,7 |
} |
} |
} |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
case 'del_mac': |
foreach ($_POST as $key => $value) { |
if ($value == 'on') { |
224,17 → 212,8 |
exec('sudo /usr/bin/systemctl reload chilli'); |
} |
} |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
|
case 'dhcp_relay': // DHCP relay |
// TODO : check DHCP relay before apply? |
file_put_contents(CONF_FILE, str_replace('EXT_DHCP_IP='.$conf['EXT_DHCP_IP'], 'EXT_DHCP_IP='.trim($_POST['dhcp_relay_ext_ip']), file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('RELAY_DHCP_IP='.$conf['RELAY_DHCP_IP'], 'RELAY_DHCP_IP='.trim($_POST['dhcp_relay_ip']), file_get_contents(CONF_FILE))); |
file_put_contents(CONF_FILE, str_replace('RELAY_DHCP_PORT='.$conf['RELAY_DHCP_PORT'], 'RELAY_DHCP_PORT='.trim($_POST['dhcp_relay_port']), file_get_contents(CONF_FILE))); |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
|
case 'new_host': |
$add_host = trim($_POST['add_host']); |
$add_ip = trim($_POST['add_ip']); |
258,8 → 237,7 |
} |
} |
} |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
case 'del_host': |
foreach ($_POST as $key => $value) { |
if ($value == 'on') { |
268,8 → 246,7 |
exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]"); |
} |
} |
header('Location: '.$_SERVER['PHP_SELF']); |
exit(); |
break; |
|
case 'default_cert': // Restore default certificate |
exec('sudo alcasar-importcert.sh -d'); |
702,85 → 679,75 |
</form> |
</td></tr> |
|
<?php if ($conf['DHCP'] === 'on'): ?> |
<tr><td colspan="2" align="center"><?= $l_static_dhcp_title ?></td></tr> |
<tr><td width="50%" align="center" valign="middle"> |
<form action="network.php" method="POST"> |
<?php |
if ($conf['DHCP'] === 'on') { |
require('network2.php'); |
} |
?> |
</table> |
<br> |
|
<table width="100%" cellspacing="0" cellpadding="0" border="0"> |
<tr><th><?= $l_local_dns?></th></tr> |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width="1" height="2"></td></tr> |
</table> |
<table width="100%" cellspacing="0" cellpadding="5" border="1"> |
<tr> |
<td width="50%" align="center"> |
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> |
<table cellspacing="2" cellpadding="3" border="1"> |
<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info<th><?= $l_del ?></th></tr> |
<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr> |
<?php |
// Read the "ether" file |
exec('sudo /sbin/ip link show '.escapeshellarg($conf["INTIF"]), $output); |
$detail = explode(' ', $output[1]); |
$intif_mac_addr = strtoupper(str_replace(':', '-', $detail[5])); |
unset($output); unset($detail); |
// Read the "dns_local" file |
$line_exist = false; |
$tab = file(ETHERS_INFO_FILE); |
if ($tab) { // le fichier n'est pas vide |
$tab = file(DNS_LOCAL_FILE); |
if ($tab) { // not empty |
foreach ($tab as $line) { |
$fields = explode(' ', $line); |
$mac_addr = $fields[0]; |
$ip_addr = $fields[1]; |
$info = (isset($fields[2])) ? $fields[2] : ' '; |
|
echo '<tr>'; |
echo "<td>$mac_addr</td>"; |
echo "<td>$ip_addr</td>"; |
if ($mac_addr !== $intif_mac_addr) { |
echo '<td>'.ltrim($info, '#').'</td>'; |
echo "<td><input type=\"checkbox\" name=\"$mac_addr\"></td>"; |
$line_exist=True; |
} else { |
echo '<td>ALCASAR</td>'; |
echo '<td></td>'; |
if (preg_match ('/^\d+/', $line)) { # begin with one or several digit |
$line_exist = true; |
$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab) |
$ip_addr = $field[0]; |
$host_name = $field[1]; |
echo "<tr><td>$ip_addr</td>"; |
echo "<td>$host_name</td>"; |
if (($ip_addr == "127.0.0.1")|($host_name == "alcasar")) { |
echo "<td>";} |
else { |
echo "<td><input type=\"checkbox\" name=\"$ip_addr|$host_name\">"; |
} |
echo '</tr>'; |
echo "</td></tr>"; |
} |
} |
} |
if (!$line_exist) { |
echo '<tr><td colspan="3" style="text-align: center;font-style: italic;">'.$l_empty.'</td></tr>'; |
} |
?> |
</table> |
<?php if ($line_exist): ?> |
<input type="hidden" name="choix" value="del_mac"> |
<input type="hidden" name="choix" value="del_host"> |
<input type="submit" value="<?= $l_apply ?>"> |
<?php endif; ?> |
</form> |
</td><td width="50%" valign="middle" align="center"> |
<form name="new_mac" action="network.php" method="POST"> |
<table cellspacing="2" cellpadding="3" border="1"> |
<tr><th><?= $l_mac_address ?></th><th><?= $l_ip_address ?></th><th>Info</th><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"></td> |
<td><input type="text" name="info" size="10"></td> |
<td> |
<input type="hidden" name="choix" value="new_mac"> |
<input type="submit" class="button" value="<?= $l_add_to_list ?>" onclick="return MAC_Control('new_mac');"> |
</td> |
</tr></table> |
</form> |
</td></tr> |
<?php else: ?> |
<tr><td colspan="2" align="center"><?= $l_dhcp_relay ?></td></tr> |
<tr> |
<td colspan="2" align="center"> |
<td width="50%" valign="middle" align="center"> |
<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> |
<table cellspacing="2" cellpadding="3" border="1"> |
<tr> |
<th><label for="dhcp_relay_ip"><?= $l_dhcp_relay_local_ip ?></label></th><td><input type="text" name="dhcp_relay_ip" id="dhcp_relay_ip" value="<?= $conf['RELAY_DHCP_IP'] ?>" size="32"></td> |
<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td> |
</tr> |
<tr> |
<th><label for="dhcp_relay_ext_ip"><?= $l_dhcp_relay_ip ?></label></th><td><input type="text" name="dhcp_relay_ext_ip" id="dhcp_relay_ext_ip" value="<?= $conf['EXT_DHCP_IP'] ?>" size="32"></td> |
<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td> |
</tr> |
<tr> |
<th><label for="dhcp_relay_port"><?= $l_dhcp_relay_port ?></label></th><td><input type="text" name="dhcp_relay_port" id="dhcp_relay_port" value="<?= $conf['RELAY_DHCP_PORT'] ?>" size="32"></td> |
<td><input type="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td> |
<td><input type="text" name="add_host" size="17"></td> |
<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td> |
</tr> |
</table> |
<input type="hidden" name="choix" value="dhcp_relay"> |
<input type="submit" value="<?= $l_apply ?>"> |
</form> |
</td> |
</tr> |
<?php endif; ?> |
</table> |
<br> |
|