Plugin Directory

Changeset 3383142


Ignore:
Timestamp:
10/23/2025 07:59:28 AM (5 months ago)
Author:
hatul
Message:

v1.8.3 - Set location to Israel for invalid IPs

Location:
shamor
Files:
136 added
3 edited

Legend:

Unmodified
Added
Removed
  • shamor/trunk/README.md

    r3317528 r3383142  
    1010**Requires PHP:** 5.3
    1111
    12 **Stable tag:** 1.8.2
     12**Stable tag:** 1.8.3
    1313
    1414**License:** GPL
     
    2828
    2929## Changelog ##
     30### 1.8.3 ###
     31* Set location to Israel for invalid IPs
    3032### 1.8.2 ###
    3133* Fix some small bugs
  • shamor/trunk/readme.txt

    r3317528 r3383142  
    55Tested up to: 6.4.2
    66Requires PHP: 5.3
    7 Stable tag: 1.8.2
     7Stable tag: 1.8.3
    88License: GPL
    99
     
    2626
    2727== Changelog ==
     28= 1.8.3 =
     29* Set location to Israel for invalid IPs
    2830= 1.8.2 =
    2931* Fix some small bugs
  • shamor/trunk/wp-shamor.php

    r3317528 r3383142  
    44   Plugin URI: https://wpshamor.com/
    55   description: A plugin to redirect user out of your site on Shabbat and Holiday.
    6    Version: 1.8.2
     6   Version: 1.8.3
    77   Author: wpshamor.com
    88   Author URI: https://wpshamor.com/
     
    5454        }
    5555
    56         $reader = new Reader(__DIR__ . '/db/GeoLite2-City.mmdb');
    57         $record = $reader->city($ip);
    58 
    59         $this->country = $record->country->isoCode;
    60 
    61         return apply_filters('shamor_location_data_from_ip', $record->location);
     56        try {
     57            $reader = new Reader(__DIR__ . '/db/GeoLite2-City.mmdb');
     58            $record = $reader->city($ip);
     59            $this->country = $record->country->isoCode;
     60            $location = $record->location;
     61        } catch (Exception $e) {
     62            // invalid ip
     63            error_log("Shamor: invalid ip: $ip");
     64
     65            $this->country = 'IL';
     66            $location = (object) [
     67                'latitude'  => 31.5,
     68                'longitude' => 34.75,
     69                'timeZone' => 'Asia/Jerusalem',
     70            ];
     71        }
     72
     73        return apply_filters('shamor_location_data_from_ip', $location);
    6274    }
    6375
Note: See TracChangeset for help on using the changeset viewer.