Plugin Directory

Changeset 3166044


Ignore:
Timestamp:
10/09/2024 05:21:20 PM (14 months ago)
Author:
rickcurran
Message:

Added support for OpenLiteSpeed web server’s local Geolocation functionality

Location:
rc-geo-access
Files:
3 added
4 edited

Legend:

Unmodified
Added
Removed
  • rc-geo-access/trunk/changelog.txt

    r2844071 r3166044  
    11# Changelog
     2
     3## 1.49
     4
     5- Added support for OpenLiteSpeed web server’s local Geolocation functionality, this removes the need for an external third-party geolocation API if you are serving websites using OLS. See more details about how to configure this in OLS here: https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation
    26
    37## 1.48
  • rc-geo-access/trunk/rc-geo-access.php

    r2844071 r3166044  
    44Plugin URI: https://qreate.co.uk/projects/#rcgeoaccess
    55Description: This plugin restricts access to the login page of your WordPress Admin based on the location of the user trying to access it.
    6 Version: 1.48
     6Version: 1.49
    77Author: Rick Curran
    88Author URI: https://qreate.co.uk
     
    3030    $options = get_option( 'rc_geo_access_settings' );
    3131
    32     if ( ( !isset( $options[ 'rc_geo_access_status' ] ) && !isset( $options[ 'rc_geo_access_ipstack_api_key' ] ) ) || ( $options[ 'rc_geo_access_status' ] !== 'enabled' && $options[ 'rc_geo_access_ipstack_api_key' ] === '' ) ) {
     32    if (
     33        ( !isset( $options[ 'rc_geo_access_status' ] ) && !isset( $options[ 'rc_geo_access_ipstack_api_key' ] ) ) || ( $options[ 'rc_geo_access_status' ] !== 'enabled' && $options[ 'rc_geo_access_ipstack_api_key' ] === '' ) ||
     34        ( !isset( $options[ 'rc_geo_access_status' ] ) && !isset( $options[ 'rc_geo_access_ipgeolocation_api_key' ] ) ) || ( $options[ 'rc_geo_access_status' ] !== 'enabled' && $options[ 'rc_geo_access_ipgeolocation_api_key' ] === '' ) ||
     35        ( !isset( $options[ 'rc_geo_access_status' ] ) && !isset( $options[ 'rc_geo_access_openlitespeed_local_geoip' ] ) ) || ( $options[ 'rc_geo_access_status' ] !== 'enabled' && $options[ 'rc_geo_access_openlitespeed_local_geoip' ] === '' )
     36    ) {
    3337       
    3438        if ( is_admin() ) {
     
    6973    add_settings_field( 'rc_geo_access_ipgeolocation_api_key', __( 'IPGeolocation API Key:', 'rc_geo_access_plugin' ), 'rc_geo_access_ipgeolocation_api_key_render', 'rc_geo_access_admin_page', 'rc_geo_access_admin_page_section' );
    7074
     75    add_settings_field( 'rc_geo_access_openlitespeed_local_geoip', __( 'OpenLiteSpeed GeoIP:', 'rc_geo_access_plugin' ), 'rc_geo_access_openlitespeed_local_geoip_render', 'rc_geo_access_admin_page', 'rc_geo_access_admin_page_section' );
     76
    7177    add_settings_field( 'rc_geo_access_restricted_countries', __( 'Country Whitelist:', 'rc_geo_access_plugin' ), 'rc_geo_access_restricted_countries_render', 'rc_geo_access_admin_page', 'rc_geo_access_admin_page_section' );
    7278           
     
    96102    if ( $options[ 'rc_geo_access_email_recipient' ] === '' ) {
    97103       
    98         echo '<p style="color:darkorange;font-weight:bold;">&uarr; ' . __( 'Please enter a valid email address to receive notifications.', 'rc_geo_access_plugin' ) . '</p>';
     104        echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Please enter a valid email address to receive notifications.', 'rc_geo_access_plugin' ) . '</p>';
    99105       
    100106    }
     
    104110        if ( ! is_email( $options[ 'rc_geo_access_email_recipient' ] ) ) {
    105111       
    106             echo '<p style="color:darkorange;font-weight:bold;">&uarr; ' . __( 'Sorry, that doesn\'t appear to be a valid email address, please check your typing and try again.', 'rc_geo_access_plugin' ) . ' -' . $options[ 'rc_geo_access_email_recipient' ] . '-</p>';
     112            echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Sorry, that doesn\'t appear to be a valid email address, please check your typing and try again.', 'rc_geo_access_plugin' ) . ' -' . $options[ 'rc_geo_access_email_recipient' ] . '-</p>';
    107113           
    108114        }
     
    134140    <select name='rc_geo_access_settings[rc_geo_access_api_provider]'>
    135141        <option value="">Select...</option>
    136         <option value='ipgeolocation' <?php selected( $options[ 'rc_geo_access_api_provider' ], 'ipgeolocation' ); ?>>ipgeolocation</option>
    137         <option value='ipstack' <?php selected( $options[ 'rc_geo_access_api_provider' ], 'ipstack' ); ?>>ipstack</option>
     142        <option value='ipgeolocation' <?php selected( $options[ 'rc_geo_access_api_provider' ], 'ipgeolocation' ); ?>>ipgeolocation.io</option>
     143        <option value='ipstack' <?php selected( $options[ 'rc_geo_access_api_provider' ], 'ipstack' ); ?>>ipstack.com</option>
     144        <option value='openlitespeed' <?php selected( $options[ 'rc_geo_access_api_provider' ], 'openlitespeed' ); ?>>OpenLiteSpeed’s local GeoIP variable</option>
    138145    </select>
    139146
    140147<?php
    141148    if ( $options[ 'rc_geo_access_api_provider' ] == '' ) {
    142         echo '<p style="color:darkorange;font-weight:bold;">&uarr; ' . __( 'Please select an API provider from the menu above.', 'rc_geo_access_plugin' ) . '</p>';
     149        echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Please select an API provider from the menu above.', 'rc_geo_access_plugin' ) . '</p>';
    143150    }
    144151}
     
    157164    if ( $options[ 'rc_geo_access_status' ] === 'disabled' ) {
    158165       
    159         echo '<p style="color:darkorange;font-weight:bold;">&uarr; ' . __( 'Change this to "Enabled" to turn on access restriction', 'rc_geo_access_plugin' ) . '</p>';
     166        echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Change this to "Enabled" to turn on access restriction', 'rc_geo_access_plugin' ) . '</p>';
    160167       
    161168    }
     
    180187        if ( $options[ 'rc_geo_access_ipstack_api_key' ] === '' && $options[ 'rc_geo_access_api_provider' ] === 'ipstack' ) {
    181188           
    182             echo '<p style="color:darkorange;font-weight:bold;">&uarr;' . __( 'Please enter an API Key. This is required for access restriction to function', 'rc_geo_access_plugin' ) . '</p>';
     189            echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Please enter an API Key. This is required for access restriction to function', 'rc_geo_access_plugin' ) . '</p>';
    183190           
    184191        }
     
    195202
    196203            if ( $rc_geo_access_error_status !== '' && $rc_geo_access_provider == 'ipstack' ) { // If errors then display message...
    197                 echo '<p style="color:darkorange;font-weight:bold;">&uarr;' . $rc_geo_access_error_status . '</p>';
     204                echo '<p style="color:#fff;font-weight:bold;padding:10px;border-radius:8px;background-color:red;">&uarr;&nbsp;' . $rc_geo_access_error_status . '</p>';
    198205            }
    199206           
     
    221228        if ( $options[ 'rc_geo_access_ipgeolocation_api_key' ] === '' && $options[ 'rc_geo_access_api_provider' ] === 'ipgeolocation' ) {
    222229           
    223             echo '<p style="color:darkorange;font-weight:bold;">&uarr;' . __( 'Please enter an API Key. This is required for access restriction to function', 'rc_geo_access_plugin' ) . '</p>';
     230            echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Please enter an API Key. This is required for access restriction to function', 'rc_geo_access_plugin' ) . '</p>';
    224231           
    225232        }
     
    236243
    237244            if ( $rc_geo_access_error_status !== '' && $rc_geo_access_provider == 'ipgeolocation' ) { // If errors then display message...
    238                 echo '<p style="color:darkorange;font-weight:bold;">&uarr;' . $rc_geo_access_error_status . '</p>';
     245                echo '<p style="color:#fff;font-weight:bold;padding:10px;border-radius:8px;background-color:red;">&uarr;&nbsp;' . $rc_geo_access_error_status . '</p>';
     246            }
     247           
     248        }
     249   
     250}
     251
     252function rc_geo_access_openlitespeed_local_geoip_render() {
     253
     254    $options = get_option( 'rc_geo_access_settings' );
     255    $rc_geo_access_provider = $options[ 'rc_geo_access_api_provider' ];
     256   
     257    $rc_geo_access_ipstack_api_key = $options[ 'rc_geo_access_ipstack_api_key' ];
     258    $rc_geo_access_ipgeolocation_api_key = $options[ 'rc_geo_access_ipgeolocation_api_key' ];
     259    $rc_geo_access_openlitespeed_local_geoip = $options[ 'rc_geo_access_openlitespeed_local_geoip' ];
     260   
     261    $rc_geo_access_api_warn = '';
     262    if ( $rc_geo_access_provider == 'openlitespeed' && ( $rc_geo_access_ipgeolocation_api_key != '' || $rc_geo_access_ipstack_api_key != '' ) ) {
     263        $rc_geo_access_api_warn = '<p style="color:darkorange;font-weight:normal;">You have selected <strong>OpenLiteSpeed\'s local GeoIP variable</strong> as your geolocation API provider, only enter an API key in the <strong>ipgeolocation.io</strong> or <strong>ipstack.com</strong> API Key fields if using those APIs.</p>';
     264    }
     265   
     266    ?>
     267    <input type='text' name='rc_geo_access_settings[rc_geo_access_openlitespeed_local_geoip]' value='NO API KEY REQUIRED' size="50" readonly>
     268    <?php
     269        if ( $options[ 'rc_geo_access_openlitespeed_local_geoip' ] === '' && $options[ 'rc_geo_access_api_provider' ] === 'openlitespeed' ) {
     270           
     271            echo '<p style="color:darkorange;font-weight:bold;">&uarr;&nbsp;' . __( 'Please ensure a Geolocation database is configured on your OpenLiteSpeed server. This is required for access restriction to function', 'rc_geo_access_plugin' ) . '</p>';
     272           
     273        }
     274   
     275        echo $rc_geo_access_api_warn;
     276   
     277        // Check if API Key has any errors...
     278        if ( $options[ 'rc_geo_access_status' ] === 'enabled' && $options[ 'rc_geo_access_openlitespeed_local_geoip' ] !== '' ) {
     279           
     280            // Lookup current admin user's location...
     281            $rc_geo_access_api_result = rc_geo_access_lookup_ip( $_SERVER[ 'REMOTE_ADDR' ], $options[ 'rc_geo_access_openlitespeed_local_geoip' ], $options[ 'rc_geo_access_api_provider' ] );
     282            // ...and then check response for any errors relating to the API key...
     283            $rc_geo_access_error_status = rc_geo_access_error_handling( $rc_geo_access_api_result, $rc_geo_access_provider );
     284
     285            if ( $rc_geo_access_error_status !== '' && $rc_geo_access_provider == 'openlitespeed' ) { // If errors then display message...
     286                echo '<p style="color:#fff;font-weight:bold;padding:10px;border-radius:8px;background-color:red;">&uarr;&nbsp;' . $rc_geo_access_error_status . '</p>';
    239287            }
    240288           
     
    253301    } else if ( $rc_geo_access_provider == 'ipgeolocation' ) {
    254302        $rc_geo_access_api_key = $options[ 'rc_geo_access_ipgeolocation_api_key' ];
     303       
     304    } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     305        $rc_geo_access_api_key = $options[ 'rc_geo_access_openlitespeed_local_geoip' ];
    255306    }
    256307   
     
    265316    $rc_geo_access_no_countries_forced_country_code = '';
    266317   
    267     if ( $options[ 'rc_geo_access_status' ] === 'enabled' && $rc_geo_access_provider !== '' && ( $options[ 'rc_geo_access_ipstack_api_key' ] !== '' || $options[ 'rc_geo_access_ipgeolocation_api_key' ] !== '' ) ) {
     318    if ( $options[ 'rc_geo_access_status' ] === 'enabled' && $rc_geo_access_provider !== '' && ( $options[ 'rc_geo_access_ipstack_api_key' ] !== '' || $options[ 'rc_geo_access_ipgeolocation_api_key' ] !== '' || $options[ 'rc_geo_access_openlitespeed_local_geoip' ] !== '' ) ) {
    268319        $rga_countries_whitelist_style = 'style="display:block;"';
    269320       
     
    290341        } else if ( $rc_geo_access_provider == 'ipgeolocation' ) {
    291342             $rc_geo_access_country_code = $rc_geo_access_api_result[ 'country_code2' ];
     343           
     344        } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     345             $rc_geo_access_country_code = $rc_geo_access_api_result[ 'geoip_country_code' ];
    292346        }
    293347       
     
    315369
    316370            $checked = '';
     371            $il_style = 'padding:5px 10px 5px 8px;display:block;';
    317372            if ( is_array($rc_geo_access_restricted_countries) && in_array( $v, $rc_geo_access_restricted_countries ) ) {
    318373                $checked = ' checked';
     374                $il_style = 'padding:5px 10px 5px 8px;display:block;background-color:#C1E1C1;border-radius:6px;';
    319375            }
    320376
     
    322378            if ( $rc_geo_access_no_countries_forced_country_code === $v ) {
    323379                $checked = ' checked';
    324             }
    325 
    326             echo '<li><label style="padding:0 10px 0 8px;display:block;"><input type="checkbox" name="rc_geo_access_settings[rc_geo_access_restricted_countries][]" value="' . $v . '"' . $checked . '> <span>' . $k . ' - ' . $v . '</span></label></li>';
     380                $il_style = 'padding:5px 10px 5px 8px;display:block;background-color:#C1E1C1;border-radius:6px;';
     381            }
     382
     383            echo '<li><label style="' . $il_style . '"><input type="checkbox" name="rc_geo_access_settings[rc_geo_access_restricted_countries][]" value="' . $v . '"' . $checked . '> <span>' . $k . ' - ' . $v . '</span></label></li>';
    327384
    328385
     
    341398    echo __( '
    342399    <p>This plugin restricts access to the login page of your WordPress Admin based on the location of the user trying to access it. Restricting access in this way can be a useful way of reducing unwanted login attempts.</p>
    343     <p>To get the location of the user the plugin gets the IP address of the user attempting to access the login page and geo-locates their location by using a geolocation API, currently there are two services available to use:</p>
    344     <ul>
    345         <li><strong>ipstack:</strong> <a href="http://ipstack.com?utm_source=FirstPromoter&utm_medium=Affiliate&fpr=rick54" target="_blank">ipstack.com</a>.</li>
    346         <li><strong>ipgeolocation:</strong> <a href="https://ipgeolocation.io/" target="_blank">ipgeolocation.io</a>.</li>
     400    <p>The plugin gets the IP address of the user attempting to access the login page and geo-locates their location by using a geolocation API, currently there are three options available to use:</p>
     401    <ul style="list-style:decimal;margin-left: 1.75rem;">
     402        <li><strong>ipstack.com:</strong> <a href="http://ipstack.com?utm_source=FirstPromoter&utm_medium=Affiliate&fpr=rick54" target="_blank">ipstack.com</a>.</li>
     403        <li><strong>ipgeolocation.io:</strong> <a href="https://ipgeolocation.io/" target="_blank">ipgeolocation.io</a>.</li>
     404        <li><strong>OpenLiteSpeed’s local GeoIP variables:</strong> <a href="https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation" target="_blank">View OLS Enabling GeoLocation instructions</a>.</li>
    347405    </ul>
    348     <p><strong>Please note: an active API Key is required for either of these this services for the plugin to function correctly.</strong> You can register a free account at either of the website addresses above. Please note they offer varying amounts of location API requests for their free and paid plans, it may be necessary to upgrade to a paid plan to provide an increased amount of requests if your site gets a huge amount of login attempts.</p>', 'rc_geo_access_plugin' );
     406    <p><strong>Please note: an active API Key or a specifically configured OpenLiteSpeed webserver is required for the plugin to function correctly.</strong> You can register a free account at either of the website addresses above. Please note they offer varying amounts of location API requests for their free and paid plans, it may be necessary to upgrade to a paid plan to provide an increased amount of requests if your site gets a huge amount of login attempts. The “OpenLiteSpeed" option requires a configured IPGeolocation database as per the linked instructions.</p>', 'rc_geo_access_plugin' );
    349407   
    350408    submit_button();
     
    430488    } else if ( $rc_geo_access_provider == 'ipgeolocation' ) {
    431489        $rc_geo_access_api_key = $options[ 'rc_geo_access_ipgeolocation_api_key' ];
     490       
     491    } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     492        //wp_die( 'HI openlitespeed' );
     493        $rc_geo_access_api_key = $options[ 'rc_geo_access_openlitespeed_local_geoip' ];
     494       
    432495    }
    433496   
     
    445508            // Output the 2 letter "country_code" and other details...
    446509            if ( $rc_geo_access_provider == 'ipstack' ) {
    447                  $rc_geo_access_country_code = $rc_geo_access_api_result[ 'country_code' ];
     510                $rc_geo_access_country_code = $rc_geo_access_api_result[ 'country_code' ];
     511                $rc_geo_access_country_name = $rc_geo_access_api_result[ 'country_name' ];
     512                $rc_geo_access_longitude = $rc_geo_access_api_result[ 'longitude' ];
     513                $rc_geo_access_latitude = $rc_geo_access_api_result[ 'latitude' ];
    448514
    449515            } else if ( $rc_geo_access_provider == 'ipgeolocation' ) {
    450                  $rc_geo_access_country_code = $rc_geo_access_api_result[ 'country_code2' ];
    451             }
    452             $rc_geo_access_country_name = $rc_geo_access_api_result[ 'country_name' ];
    453             $rc_geo_access_longitude = $rc_geo_access_api_result[ 'longitude' ];
    454             $rc_geo_access_latitude = $rc_geo_access_api_result[ 'latitude' ];
     516                $rc_geo_access_country_code = $rc_geo_access_api_result[ 'country_code2' ];
     517                $rc_geo_access_country_name = $rc_geo_access_api_result[ 'country_name' ];
     518                $rc_geo_access_longitude = $rc_geo_access_api_result[ 'longitude' ];
     519                $rc_geo_access_latitude = $rc_geo_access_api_result[ 'latitude' ];
     520               
     521            } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     522                $rc_geo_access_country_code = $rc_geo_access_api_result[ 'geoip_country_code' ];
     523                $rc_geo_access_country_name = $rc_geo_access_api_result[ 'country_name' ];
     524                $rc_geo_access_longitude = 'N/A';
     525                $rc_geo_access_latitude = 'N/A';
     526            }
    455527
    456528            // Get list of enabled countries...
     
    526598        }
    527599
     600    } else {
     601        error_log( 'RC GEO ACCESS - NO API KEY FOUND' );
    528602    }
    529603   
     
    581655        }
    582656
     657    } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     658        // Check if `GEOIP_COUNTRY_CODE` and `GEOIP_COUNTRY_NAME` server variables exist...       
     659        if ( !isset( $_SERVER[ 'GEOIP_COUNTRY_CODE' ] ) || !isset( $_SERVER[ 'GEOIP_COUNTRY_NAME' ] ) ) {
     660            $rga_error_status = __( 'Sorry, the OpenLiteSpeed GeoIP variables could not be read. This could be due to the IP address not being found in the Geolocation database. Please also check that you have configured the OLS geolocation lookup function correctly.', 'rc_geo_access_plugin' );
     661        }
     662
    583663    }
    584664   
     
    597677        $ch = curl_init( 'http://api.ipstack.com/' . $ip . '?access_key=' . $rc_geo_access_key . '&fields=country_code,country_name,longitude,latitude' );
    598678        curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
     679       
     680        $json = curl_exec( $ch );
     681        curl_close( $ch );
     682        // For PHP 8+ curl_close no longer has any effect, so `unset` should be used instead
     683        unset( $ch );
     684
     685        $rc_geo_access_api_result = json_decode( $json, true );
    599686       
    600687    } else if ( $rc_geo_access_provider == 'ipgeolocation' ) {
     
    609696        ));
    610697       
    611     }
    612 
    613     $json = curl_exec( $ch );
    614     curl_close( $ch );
    615     // For PHP 8+ curl_close no longer has any effect, so `unset` should be used instead
    616     unset( $ch );
    617 
    618     $rc_geo_access_api_result = json_decode( $json, true );
    619    
     698        $json = curl_exec( $ch );
     699        curl_close( $ch );
     700        // For PHP 8+ curl_close no longer has any effect, so `unset` should be used instead
     701        unset( $ch );
     702
     703        $rc_geo_access_api_result = json_decode( $json, true );
     704       
     705    } else if ( $rc_geo_access_provider == 'openlitespeed' ) {
     706       
     707       
     708        $rc_geo_access_api_result_json = '{ "geoip_country_code": "' . $_SERVER[ 'GEOIP_COUNTRY_CODE' ] . '", "country_name": "' . $_SERVER[ 'GEOIP_COUNTRY_NAME' ] . '", "latitude": 0, "longitude": 0 }';
     709       
     710        $rc_geo_access_api_result = json_decode( $rc_geo_access_api_result_json, true );
     711           
     712        /*$geoip_country_code = $_SERVER[ 'GEOIP_COUNTRY_CODE' ]
     713        $rc_geo_access_country_name = $_SERVER[ 'GEOIP_COUNTRY_NAME' ];
     714        $rc_geo_access_longitude = 'na';
     715        $rc_geo_access_latitude = 'na';*/
     716       
     717        //wp_die( print_r( $rc_geo_access_api_result ) );
     718        //wp_die( print_r( $rc_geo_access_api_result_json ) );
     719       
     720    }
     721
    620722    return $rc_geo_access_api_result;
    621723}
  • rc-geo-access/trunk/readme.txt

    r3008230 r3166044  
    33Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QZEXMAMCYDS3G
    44Tags: security, geolocation, login
    5 Requires at least: 4.6
    6 Tested up to: 6.4
    7 Stable tag: 1.48
    8 Requires PHP: 7.3
     5Requires at least: 5
     6Tested up to: 6.6
     7Stable tag: 1.49
     8Requires PHP: 7.4
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717This plugin restricts access to the login page of your WordPress Admin based on the location of the user trying to access it. Restricting access in this way can be a useful way of reducing unwanted login attempts.
    18 To get the location of the user the plugin gets the IP address of the user attempting to access the login page and geo-locates their location by using a geolocation API, currently there are two services available to use:
     18To get the location of the user the plugin gets the IP address of the user attempting to access the login page and geo-locates their location by using a geolocation API, currently there are three options available to use:
    1919
    2020 - IPStack: http://ipstack.com
    2121 - IPGeolocation: https://ipgeolocation.io
     22 - OpenLiteSpeed’s local GeoIP variables
    2223
    23 Please note: an active API Key is required for either of these this services for the plugin to function correctly. You can register a free account at either of the website addresses above. Please note they offer varying amounts of location API requests for their free and paid plans, it may be necessary to upgrade to a paid plan to provide an increased amount of requests if your site gets a huge amount of login attempts.
     24Please note: an active API Key is required for `IPStack` and `IPGeolocation` for the plugin to function correctly. You can register a free account at either of the website addresses above. Please note they offer varying amounts of location API requests for their free and paid plans, it may be necessary to upgrade to a paid plan to provide an increased amount of requests if your site gets a huge amount of login attempts. The `OpenLiteSpeed’s local GeoIP variables` option can be used if you are using OpenLiteSpeed server and have a properly configured geolocation database, more information about configuring that is available here: https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation
    2425
    2526
    2627== Example usage: ==
    2728
    28 Enable the plugin and access the "RC Geo Access" page in the Settings menu in your WordPress Admin to configure the required settings. Note: an active API Key is required for this plugin to function, currently there are two services available to use, you can choose from either 'IPStack' - http://ipstack.com and 'IPGeolocation' - https://ipgeolocation.io as the geolocation providers.
     29Enable the plugin and access the "RC Geo Access" page in the Settings menu in your WordPress Admin to configure the required settings. Note: an active API Key is required for this plugin to function, currently there are two external Geolocation services available to use, you can choose from either 'IPStack' - http://ipstack.com and 'IPGeolocation' - https://ipgeolocation.io as the geolocation providers. The `OpenLiteSpeed’s local GeoIP variables` option can be used if you are using OpenLiteSpeed server and have a properly configured geolocation database, more information about configuring that is available here: https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation
    2930
    3031
     
    4849= How does this plugin get the user's location? =
    4950
    50 The plugin uses a geolocation API to look up the user's location based on their IP address. Note: an active API Key is required for this plugin to function, currently there are two services available to use, you can choose from either 'IPStack' - http://ipstack.com and 'IPGeolocation' - https://ipgeolocation.io as the geolocation providers.
     51The plugin uses a geolocation API to look up the user's location based on their IP address. Note: an active API Key may be required for this plugin to function, currently there are two external services available to use, you can choose from either 'IPStack' - http://ipstack.com and 'IPGeolocation' - https://ipgeolocation.io as the geolocation providers. There is also a third `OpenLiteSpeed’s local GeoIP variables` option which can be used if you are using OpenLiteSpeed server and have a properly configured geolocation database, more information about configuring that is available here: https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation
    5152
    5253= Can I use other geolocation APIs? =
    5354
    54 No, at this time it is only possible to use either the IPStack.com API or the IPGeolocation.io API.
     55No, at this time it is only possible to use either the external providers of IPStack.com or the IPGeolocation.io, or the locally configured OpenLiteSpeed Geolocation functionality.
    5556
    5657= How do I configure the plugin settings? =
     
    6061= How can I tell if it is working? =
    6162
    62 If you're not seeing any error messages when you are in the plugin settings page then it should hopefully be working correctly. If you've enabled email notifications then at some point you should receive an email when your login page is restricted. There is a way to test it yourself  but you need to be very careful! Uncheck your country from the list and save the changes (do not close the browser window or logout from WordPress or you will be locked out of your site - see below for help if that happens!), using another browser or browser tab attempt to access your login page
     63If you're not seeing any error messages when you are in the plugin settings page then it should hopefully be working correctly. If you've enabled email notifications then at some point you should receive an email when your login page is restricted. There is a way to test it yourself  but you need to be very careful! Uncheck your country from the list and save the changes (do not close the browser window or logout from WordPress or you will be locked out of your site - see below for help if that happens!), using another browser or browser tab attempt to access your login page.
    6364
    6465= Help! I've enabled this plugin and now I'm locked out of my site! =
     
    6667Yikes, sorry! There is a potential danger of this happening if you have enabled the restriction (including the required API key) but you did not set your own country location to be accessible. If this happens then I'm afraid the only option here is to connect to your site directly via SFTP / FTP and remove the plugin files from your site. Once removed you will then be able to login, you can then re-install the plugin, you should then immediately ensure that your current country location is given access in the "RC Geo Access" page in the Settings menu in your WordPress Admin.
    6768
     69= I am using the OpenLiteSpeed Geolocation option but it isn't blocking login access =
     70
     71If you are using the OpenLiteSpeed option the IP address of users to your site must be found in the configured Geolocation database in order to establish the user’s country. If the IP address isn't found it will trigger an error message email to be sent which begins with "Sorry, the OpenLiteSpeed GeoIP variables could not be read...". If you receive this error email then you should check that the Geolocation database is configured correctly and also that the database is up to date.
    6872
    6973== Changelog ==
     74
     75= 1.49 =
     76
     77- Added support for OpenLiteSpeed web server’s local Geolocation functionality, this removes the need for an external third-party geolocation API if you are serving websites using OLS. See more details about how to configure this in OLS here: https://docs.openlitespeed.org/config/advanced/geolocation/#enabling-geolocation
    7078
    7179= 1.48 =
Note: See TracChangeset for help on using the changeset viewer.