|
@@ -262,6 +262,26 @@ class Request
|
|
|
$this->session = $session;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the client IP address.
|
|
|
+ *
|
|
|
+ * @param Boolean $proxy Whether the current request has been made behind a proxy or not
|
|
|
+ *
|
|
|
+ * @return string The client IP address
|
|
|
+ */
|
|
|
+ public function getClientIp($proxy = false)
|
|
|
+ {
|
|
|
+ if ($proxy) {
|
|
|
+ if ($this->server->has('HTTP_CLIENT_IP')) {
|
|
|
+ return $this->server->get('HTTP_CLIENT_IP');
|
|
|
+ } elseif ($this->server->has('HTTP_X_FORWARDED_FOR')) {
|
|
|
+ return $this->server->get('HTTP_X_FORWARDED_FOR');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->server->get('REMOTE_ADDR');
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Returns current script name.
|
|
|
*
|