public static function whitelistIP($IP) { //IP as a string in dotted quad notation e.g. '10.11.12.13' $IP = trim($IP); $user_range = new wfUserIPRange($IP); if (!$user_range->isValidRange()) { throw new Exception("The IP you provided must be in dotted quad notation or use ranges with square brackets. e.g. 10.11.12.13 or 10.11.12.[1-50]"); } $whites = wfConfig::get('whitelisted', ''); $arr = explode(',', $whites); $arr2 = array(); foreach ($arr as $e) { if ($e == $IP) { return false; } $arr2[] = trim($e); } $arr2[] = $IP; wfConfig::set('whitelisted', implode(',', $arr2)); return true; }