Skip to content

Commit

Permalink
Helper::getClientIp() function
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Jul 16, 2023
1 parent 9266e5c commit 2b9f56b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions app/Misc/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1890,4 +1890,17 @@ public static function setPcreBacktrackLimit()
ini_set('pcre.backtrack_limit', 1000000000);
}
}

/**
* Get client IP address.
*/
public static function getClientIp()
{
// Fix for CloudFlare: https://laracasts.com/discuss/channels/laravel/cloudflare-and-user-ip
// But if CloudFlare is not used any value can be set to "Cf-Connecting-Ip" header.
// if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
// $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"];
// }
return request()->ip();
}
}

0 comments on commit 2b9f56b

Please sign in to comment.