public function RestrictIpService::cleanIpAddressInput in Restrict IP 8
Same name and namespace in other branches
- 8.2 src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::cleanIpAddressInput()
- 3.x src/Service/RestrictIpService.php \Drupal\restrict_ip\Service\RestrictIpService::cleanIpAddressInput()
*
Overrides RestrictIpServiceInterface::cleanIpAddressInput
File
- src/
Service/ RestrictIpService.php, line 151
Class
Namespace
Drupal\restrict_ip\ServiceCode
public function cleanIpAddressInput($input) {
$ip_addresses = trim($input);
$ip_addresses = preg_replace('/(\\/\\/|#).+/', '', $ip_addresses);
$ip_addresses = preg_replace('~/\\*([^*]|[\\r\\n]|(\\*+([^*/]|[\\r\\n])))*\\*+/~', '', $ip_addresses);
$addresses = explode(PHP_EOL, $ip_addresses);
$return = [];
foreach ($addresses as $ip_address) {
$trimmed = trim($ip_address);
if (strlen($trimmed)) {
$return[] = $trimmed;
}
}
return $return;
}