Making WordPress.org


Ignore:
Timestamp:
02/22/2017 12:47:27 AM (9 years ago)
Author:
dd32
Message:

Events API: In the event that the IP address does not have any location for it, it may have a DB entry consisting of only -.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/api.wordpress.org/public_html/events/1.0/index.php

    r4884 r4978  
    8080}
    8181
    82 function guess_location_from_ip( $dotted_ip, $timezone, $country ) {
     82function guess_location_from_ip( $dotted_ip ) {
    8383    global $wpdb;
    8484
     
    8888
    8989    $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ip2location WHERE ip_to >= %d ORDER BY ip_to ASC LIMIT 1", $long_ip ) );
     90    // Unknown location:
     91    if ( ! $row || '-' == $row->country_short ) {
     92        return;
     93    }
     94
    9095    return $row;
    9196}
     
    120125    // IP:
    121126    if ( isset( $args['ip'] ) ) {
    122         $guess = guess_location_from_ip( $args['ip'], $args['timezone'] ?? '', $country_code );
     127        $guess = guess_location_from_ip( $args['ip'] );
    123128        if ( $guess ) {
    124129            return array(
Note: See TracChangeset for help on using the changeset viewer.