You are here

public static function Helper::ip_get in Anti Spam by CleanTalk 8.3

Same name in this branch
  1. 8.3 src/lib/Cleantalk/Common/Helper.php \Drupal\cleantalk\lib\Cleantalk\Common\Helper::ip_get()
  2. 8.3 src/lib/Cleantalk/ApbctDrupal/Helper.php \Drupal\cleantalk\lib\Cleantalk\ApbctDrupal\Helper::ip_get()

Overrides Helper::ip_get

2 calls to Helper::ip_get()
CleantalkFuncs::_apbct_alt_session__id__get in src/CleantalkFuncs.php
Get hash session ID
CleantalkFuncs::_cleantalk_check_spam in src/CleantalkFuncs.php
Cleantalk inner function - performs antispam checking.

File

src/lib/Cleantalk/ApbctDrupal/Helper.php, line 15

Class

Helper

Namespace

Drupal\cleantalk\lib\Cleantalk\ApbctDrupal

Code

public static function ip_get($ips_input = array(
  'real',
  'remote_addr',
  'x_forwarded_for',
  'x_real_ip',
  'cloud_flare',
), $v4_only = true) {

  // If we need only REAL ip
  if (count($ips_input) == 1 && in_array('real', $ips_input) && \Drupal::request() !== null) {
    return \Drupal::request()
      ->getClientIp();
  }
  else {
    return parent::ip_get($ips_input, $v4_only) ? parent::ip_get($ips_input, $v4_only) : '::1';
  }
}