209,8 → 209,8 |
if ($value == 'on') { |
$ether_file = ETHERS_FILE; |
$ether_file_info = ETHERS_INFO_FILE; |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file"); |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info"); |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file"); |
exec("/bin/sed -i ".escapeshellarg("/^$key/d")." $ether_file_info"); |
exec('sudo /usr/bin/systemctl reload chilli'); |
} |
} |
223,27 → 223,23 |
$tab = file(DNS_LOCAL_FILE); |
if ($tab) { // the file isn't empty |
$insert = true; |
foreach ($tab as $line) { // verify that host or IP address doesn't already exist |
$field = explode('\t', $line); |
$host_name = trim($field[1]); |
$ip_addr = trim($field[2]); |
if (strcasecmp($add_host, $host_name) === 0) { |
$insert = false; |
break; |
foreach ($tab as $line) { // verify that host or IP address doesn't exist |
if (preg_match('/^\d+/', $line)) { |
$field = preg_split("/\s+/",$line); |
$ip_addr = $field[0]; |
$host_name = trim($field[1]); |
if (strcmp($add_ip, $ip_addr) === 0) { |
$insert = false; |
break; |
} |
if (strcasecmp($add_host, $host_name) === 0) { |
$insert = false; |
break; |
} |
} |
if (strcmp($add_ip, $ip_addr) === 0) { |
$insert = false; |
break; |
} |
} |
} |
if ($insert) { |
$line1 = $add_ip.'\t'.$add_host."\n"; |
$pointeur=fopen(DNS_LOCAL_FILE, 'a'); |
fwrite($pointeur, $line1); |
fclose($pointeur); |
exec('sudo /usr/bin/systemctl restart dnsmasq'); |
exec('sudo /usr/bin/systemctl restart dnsmasq-blacklist'); |
exec('sudo /usr/bin/systemctl restart dnsmasq-whitelist'); |
exec("sudo /usr/local/bin/alcasar-dns-local.sh -add $add_ip $add_host"); |
} |
} |
} |
251,10 → 247,9 |
case 'del_host': |
foreach ($_POST as $key => $value) { |
if ($value == 'on') { |
exec('/bin/sed -i '.escapeshellarg("\\@^address=/$key/@d;\\@^ptr-record=.*,$key\$@d").' '.DNS_LOCAL_FILE); |
exec('sudo /usr/bin/systemctl restart dnsmasq'); |
exec('sudo /usr/bin/systemctl restart dnsmasq-blacklist'); |
exec('sudo /usr/bin/systemctl restart dnsmasq-whitelist'); |
$del_host = explode ("|", $key); |
$del_ip = str_replace("_",".",$del_host[0]); |
exec("sudo /usr/local/bin/alcasar-dns-local.sh --del $del_ip $del_host[1]"); |
} |
} |
break; |
707,7 → 702,7 |
<td width="50%" align="center"> |
<form action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> |
<table cellspacing="2" cellpadding="3" border="1"> |
<tr><th><?= $l_host_name ?></th><th><?= $l_ip_address ?></th><th><?= $l_del ?></th></tr> |
<tr><th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><th><?= $l_del ?></th></tr> |
<?php |
// Read the "dns_local" file |
$line_exist = false; |
714,15 → 709,19 |
$tab = file(DNS_LOCAL_FILE); |
if ($tab) { // not empty |
foreach ($tab as $line) { |
if (preg_match ('/^address/', $line)) { |
if (preg_match ('/^\d+/', $line)) { # begin with one or several digit |
$line_exist = true; |
$field = explode('/', $line); |
$field = preg_split("/\s+/",$line); # split with one or several whitespace (or tab) |
$ip_addr = $field[0]; |
$host_name = $field[1]; |
$ip_addr = $field[2]; |
echo "<tr><td>$host_name</td>"; |
echo "<td>$ip_addr</td>"; |
echo "<td><input type=\"checkbox\" name=\"$host_name\"></td>"; |
echo "</tr>"; |
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 "</td></tr>"; |
} |
} |
} |
741,14 → 740,14 |
<form name="new_host" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>" method="POST"> |
<table cellspacing="2" cellpadding="3" border="1"> |
<tr> |
<th><?= $l_host_name ?></th><th><?= $l_ip_address ?></th><td></td> |
<th><?= $l_ip_address ?></th><th><?= $l_host_name ?></th><td></td> |
</tr> |
<tr> |
<td>Ex. : my_nas</td><td>Ex. : 192.168.182.10</td><td></td> |
<td>Ex. : 192.168.182.10</td><td>Ex. : my_nas</td><td></td> |
</tr> |
<tr> |
<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="text" name="add_ip" size="10"><input type="hidden" name="choix" value="new_host"></td> |
<td><input type=submit class=button value="<?= $l_add_to_list ?>"></td> |
</tr> |
</table> |