Update Request.php

This commit is contained in:
Yağızhan committed 2021-10-27 19:37:46 +03:00
1 parent b549df10f0
commit acf7d3185d
1 file changed
+6 -6
+6 -6
View File
@@ -250,15 +250,15 @@ class Box_Request implements \Box\InjectionAwareInterface
/**
* Gets most possible client IPv4 Address. This method search in $_SERVER[‘REMOTE_ADDR’] and optionally in $_SERVER[‘HTTP_X_FORWARDED_FOR’] or $_SERVER['HTTP_CF_CONNECTING_IP']
* @param bool $trustForwardedHeader - No by default because this can be changed to anything extremely easy, making it unreliable for tracking and adding a potential source for external data to be executed.
* Please see: https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php
* return string
* @see https://stackoverflow.com/questions/3003145/how-to-get-the-client-ip-address-in-php
* @return string
*/
public function getClientAddress($trustForwardedHeader = false)
{
$address = null;
if($trustForwardedHeader) {
if ($trustForwardedHeader) {
// Check to see if the CF-Connecting-IP (Cloudflare) header exists.
if($this->getServer("HTTP_CF_CONNECTING_IP") !== null){
if ($this->getServer("HTTP_CF_CONNECTING_IP") !== null) {
// If it does, assume that BoxBilling is behind Cloudflare.
$address = $this->getServer("HTTP_CF_CONNECTING_IP");
} else {
@@ -266,11 +266,11 @@ class Box_Request implements \Box\InjectionAwareInterface
}
}
if(is_null($address)) {
if (is_null($address)) {
$address = $this->getServer('REMOTE_ADDR');
}
if(is_string($address)) {
if (is_string($address)) {
if(strpos($address, ',') !== false) {
list($address) = explode(',', $address);
}