Simple yet powerful tool to allow access from your country only 1.1

now you can restrict acceessto your webidsite except only your country

  1. kslakhani
    WeBid Version:
    • 1.1.1/1.1.2
    in common.php find abt line 19
    PHP:
    session_start();
    $error_reporting E_ALL^E_NOTICE;
    // $error_reporting = E_ALL; // use this for debugging
    define('InWeBid'1);
    define('TrackUserIPs'1);
    add after
    PHP:
    function getUserCountry() {
    $xml simplexml_load_file("http://www.geoplugin.net/xml.gp?ip=".getRealIpAddr());
    return 
    $xml->geoplugin_countryCode;
    }

    function 
    getRealIpAddr()
    {
        if (!empty(
    $_SERVER['HTTP_CLIENT_IP']))   //check ip from share internet
        
    {
          
    $ip=$_SERVER['HTTP_CLIENT_IP'];
        }
        elseif (!empty(
    $_SERVER['HTTP_X_FORWARDED_FOR']))   //to check ip is pass from proxy
        
    {
          
    $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
        }
        else
        {
          
    $ip=$_SERVER['REMOTE_ADDR'];
        }
        return 
    $ip;
    }

    if (
    getUserCountry() != "IN") { // just change your country code like US, UK, NZ, IN for complete list visit https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
    echo "<p>only country from India can access this website</P><p> for more info contact to care@mywebidsite.com</p>";
    exit;
    }
    dont forget to change your country name in echo and code on function(getUserCountry()
    thats it folks:D
    sdzd73 likes this.

Recent Updates

  1. just avoid extra lookup to save recource

Recent Reviews

  1. Cash Crusaders NZ
    Cash Crusaders NZ
    5/5,
    Version: 1.1
    I have added this to version 1.2.2 and used mutltiple "IF" commands to allow only 3 countries. This really worked fine and helped to disallow spamming, which in my case is mostly from outside these 3 countries.
  2. Flint
    Flint
    4/5,
    Version: 1.1
    It works on 1.2
    Place after:
    [code] session_start();
    date_default_timezone_set('UTC'); // to make times more consistent
    define('WeBidDebug', false); // use this for debugging
    define('InWeBid', true);
    define('TrackUserIPs', true);

    [/code]