You are here

static function MoAuthUtilities::get_client_ip in Google Authenticator / 2 Factor Authentication - 2FA 7

Return value

array|false|string Function to get the client IP address

1 call to MoAuthUtilities::get_client_ip()
MoAuthUtilities::check_white_IPs in classes/Utilities.php

File

classes/Utilities.php, line 447
This file is part of miniOrange 2FA module.

Class

MoAuthUtilities
@file This file is part of miniOrange 2FA module.

Code

static function get_client_ip() {
  $ipaddress = '';
  if (getenv('HTTP_CLIENT_IP')) {
    $ipaddress = getenv('HTTP_CLIENT_IP');
  }
  else {
    if (getenv('REMOTE_ADDR')) {
      $ipaddress = getenv('REMOTE_ADDR');
    }
    else {
      if (getenv('HTTP_X_FORWARDED_FOR')) {
        $ipaddress = getenv('HTTP_X_FORWARDED_FOR');
      }
      else {
        if (getenv('HTTP_X_FORWARDED')) {
          $ipaddress = getenv('HTTP_X_FORWARDED');
        }
        else {
          if (getenv('HTTP_FORWARDED_FOR')) {
            $ipaddress = getenv('HTTP_FORWARDED_FOR');
          }
          else {
            if (getenv('HTTP_FORWARDED')) {
              $ipaddress = getenv('HTTP_FORWARDED');
            }
            else {
              $ipaddress = 'UNKNOWN';
            }
          }
        }
      }
    }
  }
  return $ipaddress;
}