mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 09:26:35 +02:00
MDL-55207 adminlib: Improve help and validation errors for configiplist
This commit is contained in:
parent
36a19ecc26
commit
685e5b002c
2 changed files with 8 additions and 4 deletions
|
@ -3526,21 +3526,24 @@ class admin_setting_configiplist extends admin_setting_configtextarea {
|
|||
return true;
|
||||
}
|
||||
$result = true;
|
||||
$badips = array();
|
||||
foreach($ips as $ip) {
|
||||
$ip = trim($ip);
|
||||
if (empty($ip)) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match('#^(\d{1,3})(\.\d{1,3}){0,3}$#', $ip, $match) ||
|
||||
preg_match('#^(\d{1,3})(\.\d{1,3}){0,3}(\/\d{1,2})$#', $ip, $match) ||
|
||||
preg_match('#^(\d{1,3})(\.\d{1,3}){3}(-\d{1,3})$#', $ip, $match)) {
|
||||
$result = true;
|
||||
} else {
|
||||
$result = false;
|
||||
break;
|
||||
$badips[] = $ip;
|
||||
}
|
||||
}
|
||||
if($result) {
|
||||
return true;
|
||||
} else {
|
||||
return get_string('validateerror', 'admin');
|
||||
return get_string('validateiperror', 'admin', join(', ', $badips));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue