Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions app/Helpers/ClickHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
use Illuminate\Http\Request;

class ClickHelper {
static private function getCountry($ip) {
$country_iso = geoip()->getLocation($ip)->iso_code;
return $country_iso;
}

static private function getHost($url) {
// Return host given URL; NULL if host is
Expand All @@ -23,13 +19,13 @@ static public function recordClick(Link $link, Request $request) {
* @return boolean
*/

$ip = $request->ip();
$location = geoip()->getLocation(); // Without the IP specified, it will be detected automatically and use the real user IP if website is behind CloudFlare or other Proxy (Nginx, ...)
$referer = $request->server('HTTP_REFERER');

$click = new Click;
$click->link_id = $link->id;
$click->ip = $ip;
$click->country = self::getCountry($ip);
$click->ip = $location->ip;
$click->country = $location->iso_code;
$click->referer = $referer;
$click->referer_host = ClickHelper::getHost($referer);
$click->user_agent = $request->server('HTTP_USER_AGENT');
Expand Down