- Timestamp:
- 03/01/2018 09:13:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/api.wordpress.org/public_html/events/1.0/index.php
r6816 r6818 282 282 283 283 // Exact match 284 $ row = $wpdb->get_row( $wpdb->prepare("284 $query = " 285 285 SELECT name, latitude, longitude, country 286 286 FROM geoname_summary … … 290 290 FIELD( %s, timezone ) DESC, 291 291 population DESC 292 LIMIT 1", 293 $location_name, 294 $country, 295 $timezone 296 ) ); 292 LIMIT 1"; 293 294 $prepared_query = $wpdb->prepare( $query, $location_name, $country, $timezone ); 295 $db_handle = $wpdb->db_connect( $prepared_query ); 296 297 $wpdb->set_charset( $db_handle, 'utf8' ); // The content in this table requires a UTF8 connection. 298 $row = $wpdb->get_row( $prepared_query ); 299 $wpdb->set_charset( $db_handle, 'latin1' ); // Revert to the default charset to avoid affecting other queries. 297 300 298 301 // Wildcard match 299 302 if ( ! $row && $wildcard && 'ASCII' !== mb_detect_encoding( $location_name ) ) { 300 $ row = $wpdb->get_row( $wpdb->prepare("303 $query = " 301 304 SELECT name, latitude, longitude, country 302 305 FROM geoname_summary … … 306 309 FIELD( %s, timezone ) DESC, 307 310 population DESC 308 LIMIT 1", 309 $wpdb->esc_like( $location_name ) . '%', 310 $country, 311 $timezone 312 ) ); 311 LIMIT 1"; 312 313 $prepared_query = $wpdb->prepare( $query, $wpdb->esc_like( $location_name ) . '%', $country, $timezone ); 314 $db_handle = $wpdb->db_connect( $prepared_query ); 315 316 $wpdb->set_charset( $db_handle, 'utf8' ); // The content in this table requires a UTF8 connection. 317 $row = $wpdb->get_row( $prepared_query ); 318 $wpdb->set_charset( $db_handle, 'latin1' ); // Revert to the default charset to avoid affecting other queries. 313 319 } 314 320 … … 319 325 // $row->name .= ', ' . $row->state; 320 326 // } 327 328 // Strip off null bytes 329 // @todo Modify geoname script to to this instead? 330 if ( ! empty( $row->name ) ) { 331 $row->name = trim( $row->name ); 332 } 321 333 322 334 return $row;
Note: See TracChangeset
for help on using the changeset viewer.