MDL-57404 admin_settings: Allow comments in ip block

This adds the ability to to add comments to ip lists in moodle.

Currently, the configiplist textentry box does not allow the user to annotate
the IP addresses defined.  For example, I'd like to be able to define:
 192.168.1.1     # London office
 10.1.1.1        # New york office
 118.209.246.240 # My home IP

This would allow me to revisit this list after a few months, and remove
IP addresses that are no longer required - without having to manually confirm
each IP address
This commit is contained in:
Evan Giles
2018-06-16 21:08:46 +10:00
parent 9e7c397889
commit 53007faad1
3 changed files with 9 additions and 7 deletions
+4 -3
View File
@@ -3614,14 +3614,15 @@ class admin_setting_configiplist extends admin_setting_configtextarea {
*/
public function validate($data) {
if(!empty($data)) {
$ips = explode("\n", $data);
$lines = explode("\n", $data);
} else {
return true;
}
$result = true;
$badips = array();
foreach($ips as $ip) {
$ip = trim($ip);
foreach ($lines as $line) {
$tokens = explode('#', $line);
$ip = trim($tokens[0]);
if (empty($ip)) {
continue;
}