128,30 → 128,28 |
exec ("sudo /usr/bin/systemctl restart chilli"); |
break; |
case 'new_ip' : |
if (trim($_POST['add_ip']) != "") |
{ |
$ipAddr = trim($_POST['add_ip']); |
if (!preg_match('/^([0-9]{1,3}\.){3}([0-9]{1,3})$/', $ipAddr)) { |
echo '<span style="color: red;">'.'Invalid IP address'.'</span>'; // TODO : need to translate |
} else if (!empty($ipAddr)) { |
$tab=file(IP_ALLOWED_LIST); |
$insert = true; |
if ($tab) // file isn't empty |
{ |
foreach ($tab as $line) // test if domain address doesn't already exist |
{ |
$ip=explode("\"", $line); |
if (strcmp(trim($_POST['add_ip']),$ip[1]) == 0) |
{ |
if ($tab) { // file isn't empty |
foreach ($tab as $line) { // test if domain address doesn't already exist |
$ip = explode('"', $line); |
if (strcmp($ipAddr, $ip[1]) === 0) { |
$insert = false; |
break; |
} |
} |
} |
if ($insert == true) |
{ |
$line ="\nuamallowed=\"" . trim($_POST['add_ip']) ."\" #" . trim($_POST['add_ip_comment']); |
$pointeur=fopen(IP_ALLOWED_LIST,"a"); |
if ($insert === true) { |
$line = "\nuamallowed=\"" . $ipAddr .'" #' . trim($_POST['add_ip_comment']); |
$pointeur = fopen(IP_ALLOWED_LIST, 'a'); |
fwrite ($pointeur, $line); |
fclose ($pointeur); |
exec ("sudo /usr/local/bin/alcasar-file-clean.sh"); # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf |
exec ("sudo /usr/bin/systemctl restart chilli"); |
exec('sudo /usr/local/bin/alcasar-file-clean.sh'); # Clean & sort conf files. Add uamallowed domains to the dns-blackhole conf |
exec('sudo /usr/bin/systemctl restart chilli'); |
} |
} |
break; |