You are here

public static function CleantalkHelper::ip_v6_reduce in Anti Spam by CleanTalk 7.4

Same name and namespace in other branches
  1. 7.5 src/CleantalkHelper.php \CleantalkHelper::ip_v6_reduce()

* Reduce IPv6 * param (string) $ip * returns (string) IPv6

1 call to CleantalkHelper::ip_v6_reduce()
CleantalkHelper::ip_validate in src/CleantalkHelper.php

File

src/CleantalkHelper.php, line 235

Class

CleantalkHelper
Cleantalk's hepler class

Code

public static function ip_v6_reduce($ip) {
  if (strpos($ip, ':') !== false) {
    $ip = preg_replace('/:0{1,4}/', ':', $ip);
    $ip = preg_replace('/:{2,}/', '::', $ip);
    $ip = strpos($ip, '0') === 0 ? substr($ip, 1) : $ip;
  }
  return $ip;
}