Changeset 4869
- Timestamp:
- 02/03/2017 05:22:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r4865 r4869 58 58 } 59 59 60 function guess_location_from_ip( $dotted_ip, $timezone, $country ) { 61 global $wpdb; 62 63 $long_ip = ip2long( $dotted_ip ); 64 if ( $long_ip === false ) 65 return; 66 67 $row = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM ip2location WHERE ip_to >= %d ORDER BY ip_to ASC LIMIT 1", $long_ip ) ); 68 return $row; 69 } 60 70 61 71 function get_location( $args = array() ) { … … 90 100 'latitude' => $guess->latitude, 91 101 'longitude' => $guess->longitude, 102 'country' => $guess->country, 92 103 ); 104 } 105 106 // IP: 107 if ( isset( $args['location_data']['ip'] ) ) { 108 $guess = guess_location_from_ip( $args['location_data']['ip'], $args['location_data']['timezone'] ?? '', $country_code ); 109 if ( $guess ) { 110 return array( 111 'description' => $guess->ip_city, 112 'latitude' => $guess->ip_latitude, 113 'longitude' => $guess->ip_longitude, 114 'country' => $guess->country_short, 115 ); 116 } 93 117 } 94 118
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)