update check_occurence_name function to work with multiple aliases

This commit is contained in:
Nicolas Roman 2019-03-25 14:37:17 +01:00 committed by Ludovic Poujol
parent 2f25655038
commit 0bfe7a2aac
1 changed files with 9 additions and 4 deletions

View File

@ -27,10 +27,15 @@ function domain_add($name, $IP, $with_mxs, $gmail=false) {
return array($exec_cmd, $exec_return, $exec_output);
}
// Check if the name is present in vhosts already, returns 1 if no
function check_occurence_name($name) {
$check_occurence_cmd = 'web-add.sh check-occurence ' . $name;
sudoexec($check_occurence_cmd, $check_occurence_output, $check_occurence_return);
return $check_occurence_return;
$exploded_names = explode(',', $name);
foreach ($exploded_names as $current_name) {
$check_occurence_cmd = 'web-add.sh check-occurence ' . $current_name;
sudoexec($check_occurence_cmd, $check_occurence_output, $check_occurence_return);
if ($check_occurence_return == 0) return true;
}
return false;
}