Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map location is not working #507

Open
Amar69 opened this issue Feb 27, 2019 · 2 comments
Open

Map location is not working #507

Amar69 opened this issue Feb 27, 2019 · 2 comments

Comments

@Amar69
Copy link

Amar69 commented Feb 27, 2019

I am not getting my Click Location in map and rest is working like a charm.

I am using php-fpm-7.0, Cloudlfare and Nginx web server. As I found out that Nginx hides native origin source IP. So I followed below links:

https://support.cloudflare.com/hc/en-us/articles/200170706-How-do-I-restore-original-visitor-IP-with-Nginx-)

https://github.com/cydrobolt/polr/issues/491

I have modified /app/Helpers/ClickHelper.php file as suggested by above links

`<?php
namespace App\Helpers;
use App\Models\Click;
use App\Models\Link;
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
    // not found.
    return parse_url($url, PHP_URL_HOST);
}

static public function recordClick(Link $link, Request $request) {
    /**
     * Given a Link model instance and Request object, process post click operations.
     * @param Link model instance $link
     * @return boolean
     */

    $ip = $request->server('HTTP_X_FORWARDED_FOR');
    $referer = $request->server('HTTP_REFERER');

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

    return true;
}

}`

please help me to resolve this issue. Thanks:)

@jsbrain
Copy link

jsbrain commented Mar 6, 2019

+1

@Tchekda
Copy link

Tchekda commented Oct 20, 2020

Hi, I know the topic is old but can you try with #569 ? It's made for Cloudflare but should work here too.
Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants