/** * Return the address of the remote host. * @return string the remote host address (or null) */ public static function getRemoteHostAddress() { $addr = null; if (isset($_SERVER['REMOTE_ADDR'])) { $addr = $_SERVER['REMOTE_ADDR']; if (MyOOS_Utilities::isTrustedProxy($addr)) { foreach (array('HTTP_X_FORWARDED_FOR', 'HTTP_CLIENT_IP') as $key) { if (isset($_SERVER[$key]) && preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/', $_SERVER[$key])) { $addr = $_SERVER[$key]; break; } } } } return $addr; }