Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Namith Jawahar

    (@namithjawahar)

    On geoptargeting.php line 288

    $userIp = $_SERVER[“REMOTE_ADDR”];
    to
    $userIp = $_SERVER[“HTTP_CF_CONNECTING_IP”]

    Let e know if it works correctly…
    If yes I will push this with the next update making the plugin choose either one parameter automatically depending on the situation…

    Thread Starter hothbricks

    (@hothbricks)

    HI,

    So, did the modification, does not work.

    Tried to change $wpInsertGeoLocation = false; to $wpInsertGeoLocation = true; to be sure that it’s not a code issue, all ads display properly.

    It seems it cannot get the visitor IP at all.

    Plugin Author Namith Jawahar

    (@namithjawahar)

    Geo-targeting cant work unless the user IP reaches the plugin…
    Will try to find a workaround for cloudflare..

    Thread Starter hothbricks

    (@hothbricks)

    User IP is reaching other plugins (comments, anti-spam, contact forms, etc…) with no issues.

    Cloudflare offers many solutions to allow that (plugin, mod for server) ant it works.

    Old version of your plugin works too (modified to accomodate Cloudflare).

    Something is wrong with the new version.

    Thread Starter hothbricks

    (@hothbricks)

    I have done some more testing.

    $userIp = $_SERVER[“REMOTE_ADDR”]; works even with cloudflare. The detected IP is correct.

    something wrong happens later with the call to hostip.info, the api is not so effective as a lot of IPs are not located correctly at all, and the api send the XX code which is then useless.

    Any way to make the script send a default ad block if the XX code is detected by the hostip.info service ?

    Plugin Author Namith Jawahar

    (@namithjawahar)

    I was using a more accurate Maxmind GeoIp database earlier with the plugin but unfortunately WordPress removed the plugin from the repository as it was not GPL compatible. There are not many free services out there for Geo – Ip detection. The state of donations coming from the plugin (stuck in two digits for a whole year) does not give me any room to host such a service myself. Until either of the above situation changes we are stuck with a functional but less accurate HostIp database (Its pretty accurate for the most busy Ip ranges).

    Thread Starter hothbricks

    (@hothbricks)

    I understand, thanks for clarification.

    Thread Starter hothbricks

    (@hothbricks)

    Ok, a simple workaround to compensate the poor execution of the hostip.info service :

    Open the file wp-insert/includes/common/geotargeting.php

    add an array wherever you want before line 255 for the XX code which is sent back by hostip.info when it finds an IPv6 or cannot locate the country of an IP :

    array('value' => 'XX', 'text' => 'Various'),

    then replace line 298 by this :

    if(!is_wp_error($response) && isset($response['response']['code']) && ($response['response']['code'] == 200) && isset($response['body']) && ($response['body'] != '') ) {

    then you just need to add the “Various” country to your geolocated ad block.
    In case hostip.info does not locate properly the visitor IP it will serve the ad that was associated to the “Various” code.

    It works, at least you will serve some default content to the multiple IPs which are not geolocated properly.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Again, problem with Cloudflare with new version’ is closed to new replies.