Пример #1
0
 /**
  * Get the list of client IP addresses.
  *
  * @return string
  */
 public static function getClientIps()
 {
     // Get the list of client IP addresses by first setting the
     // list of trusted proxies.
     // Request::setTrustedProxies(['reverse.proxies.go.here']);
     $clientIps = Request::getClientIps();
     $clientIp = implode(', ', $clientIps);
     // Also get any addresses in _SERVER["HTTP_X_FORWARDED_FOR"]
     $forwardAddress = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : '';
     if (empty($clientIp)) {
         $clientIp = $forwardAddress;
     } elseif (!empty($forwardAddress)) {
         $clientIp = $clientIp . ',' . $forwardAddress;
     }
     return $clientIp;
 }