Ticket #20835: 20835.diff
| File 20835.diff, 7.8 KB (added by , 14 years ago) |
|---|
-
wp-admin/includes/class-wp-ms-sites-list-table.php
29 29 $pagenum = $this->get_pagenum(); 30 30 31 31 $s = isset( $_REQUEST['s'] ) ? stripslashes( trim( $_REQUEST[ 's' ] ) ) : ''; 32 $wild = '';33 if ( false !== strpos($s, '*') ) {34 $wild = '%';35 $s = trim($s, '*');36 }37 32 38 $like_s = esc_sql( like_escape( $s ) );39 40 33 // If the network is large and a search is not being performed, show only the latest blogs with no paging in order 41 34 // to avoid expensive count queries. 42 35 if ( !$s && wp_is_large_network() ) { … … 46 39 $_GET['order'] = $_REQUEST['order'] = 'DESC'; 47 40 } 48 41 49 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 42 if ( $s ) 43 $query = self::get_search_sql( $s ); 44 else 45 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 50 46 51 if ( empty($s) ) {52 // Nothing to do.53 } elseif ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) ||54 preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||55 preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) ||56 preg_match( '/^[0-9]{1,3}\.$/', $s ) ) {57 // IPv4 address58 $reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" );59 60 if ( !$reg_blog_ids )61 $reg_blog_ids = array( 0 );62 63 $query = "SELECT *64 FROM {$wpdb->blogs}65 WHERE site_id = '{$wpdb->siteid}'66 AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")";67 } else {68 if ( is_numeric($s) && empty( $wild ) ) {69 $query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )";70 } elseif ( is_subdomain_install() ) {71 $blog_s = str_replace( '.' . $current_site->domain, '', $like_s );72 $blog_s .= $wild . '.' . $current_site->domain;73 $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) ";74 } else {75 if ( $like_s != trim('/', $current_site->path) )76 $blog_s = $current_site->path . $like_s . $wild . '/';77 else78 $blog_s = $like_s;79 $query .= " AND ( {$wpdb->blogs}.path LIKE '$blog_s' )";80 }81 }82 83 47 $order_by = isset( $_REQUEST['orderby'] ) ? $_REQUEST['orderby'] : ''; 84 48 if ( $order_by == 'registered' ) { 85 49 $query .= ' ORDER BY registered '; … … 201 165 } 202 166 echo "<tr class='$class'>"; 203 167 204 $blogname = ( is_subdomain_install() ) ? str_replace( '.'.$current_site->domain, '', $blog['domain'] ) : $blog['path'];168 $blogname = is_subdomain_install() ? str_replace( '.' . $current_site->domain, '', $blog['domain'] ) : $blog['path']; 205 169 206 170 list( $columns, $hidden ) = $this->get_column_info(); 207 171 … … 336 300 <?php 337 301 } 338 302 } 303 304 static function get_search_sql( $s ) { 305 global $wpdb, $current_site; 306 307 $wild = ''; 308 if ( false !== strpos($s, '*') ) { 309 $wild = '%'; 310 $s = trim($s, '*'); 311 } 312 313 $like_s = esc_sql( like_escape( $s ) ); 314 315 if ( preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $s ) || 316 preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || 317 preg_match( '/^[0-9]{1,3}\.[0-9]{1,3}\.?$/', $s ) || 318 preg_match( '/^[0-9]{1,3}\.$/', $s ) ) { 319 // IPv4 address 320 $reg_blog_ids = $wpdb->get_col( "SELECT blog_id FROM {$wpdb->registration_log} WHERE {$wpdb->registration_log}.IP LIKE ( '{$like_s}$wild' )" ); 321 322 if ( !$reg_blog_ids ) 323 $reg_blog_ids = array( 0 ); 324 325 return "SELECT * 326 FROM {$wpdb->blogs} 327 WHERE site_id = '{$wpdb->siteid}' 328 AND {$wpdb->blogs}.blog_id IN (" . implode( ', ', $reg_blog_ids ) . ")"; 329 } 330 331 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 332 333 if ( is_numeric($s) && empty( $wild ) ) { 334 $query .= " AND ( {$wpdb->blogs}.blog_id = '{$like_s}' )"; 335 } elseif ( is_subdomain_install() ) { 336 $blog_s = str_replace( '.' . $current_site->domain, '', $like_s ); 337 $blog_s .= $wild . '.' . $current_site->domain; 338 $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ) "; 339 } else { 340 // In a subdirectory install, trim off http://example.com and example.com from the start. 341 if ( 0 === strpos( $like_s, 'http://' ) || 0 === strpos( $like_s, 'https://' ) ) 342 $like_s = str_replace( array( 'http://' . $current_site->domain, 'https://' . $current_site->domain ), '', $like_s ); 343 elseif ( 0 === strpos( $like_s, $current_site->domain ) ) 344 $like_s = substr( $like_s, strlen( $current_site->domain ) ); 345 346 // If we're missing the network's path, we'll need to add it. 347 if ( 0 !== strpos( ltrim( $like_s . '/', '/' ), ltrim( $current_site->path, '/' ) ) ) 348 $blog_s = $current_site->path . $like_s . $wild; 349 // And this allows for search strings that already include the network path. 350 else 351 $blog_s = $like_s . $wild; 352 $query .= " AND ( {$wpdb->blogs}.path LIKE '$blog_s' )"; 353 } 354 355 return $query; 356 } 339 357 } -
wp-admin/includes/ajax-actions.php
213 213 } 214 214 215 215 function wp_ajax_autocomplete_site() { 216 global $wp_list_table, $current_site, $wpdb; 217 216 218 if ( ! is_multisite() || ! current_user_can( 'manage_sites' ) || wp_is_large_network( 'sites' ) ) 217 219 wp_die( -1 ); 218 220 219 $return = array();221 require ABSPATH . '/wp-admin/includes/class-wp-ms-sites-list-table.php'; 220 222 221 global $wpdb;222 $like_escaped_term = '%' . like_escape( stripslashes( $_REQUEST['term'] ) ) . '%';223 $sites = $wpdb->get_results( $ wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE ( domain LIKE %s OR path LIKE %s ) AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $like_escaped_term, $like_escaped_term ), ARRAY_A);223 $query = WP_MS_Sites_List_Table::get_search_sql( trim( $_REQUEST['term'] ) . '*' ); 224 error_log( $query ); 225 $sites = $wpdb->get_results( $query ); 224 226 225 227 if ( empty( $sites ) ) 226 228 wp_die( -1 ); 227 229 228 foreach ( (array) $sites as $details ) { 229 $blogname = get_blog_option( $details['blog_id'], 'blogname' ); 230 $return = array(); 231 232 foreach ( $sites as $site ) { 233 $value = is_subdomain_install() ? str_replace( '.' . $current_site->domain, '', $site->domain ) : $site->path; 230 234 $return[] = array( 231 'label' => sprintf( '%1$s (%2$s)', $blogname, $details['domain'] . $details['path'] ),232 'value' => $ details['domain']235 'label' => $value, 236 'value' => $value, 233 237 ); 234 238 } 235 239 -
wp-admin/includes/dashboard.php
442 442 <p class="youhave"><?php echo $sentence; ?></p> 443 443 <?php do_action( 'wpmuadminresult', '' ); ?> 444 444 445 <form name="searchform"action="<?php echo network_admin_url('users.php'); ?>" method="get">445 <form action="<?php echo network_admin_url('users.php'); ?>" method="get"> 446 446 <p> 447 <input type="search" name="s" value="" size="30" id="all-user-search-input" />447 <input type="search" name="s" value="" size="30" id="all-user-search-input" autocomplete="off" /> 448 448 <?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?> 449 449 </p> 450 450 </form> 451 451 452 <form name="searchform"action="<?php echo network_admin_url('sites.php'); ?>" method="get">452 <form action="<?php echo network_admin_url('sites.php'); ?>" method="get"> 453 453 <p> 454 <input type="search" name="s" value="" size="30" id="site-search-input" />454 <input type="search" name="s" value="" size="30" id="site-search-input" autocomplete="off" /> 455 455 <?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?> 456 456 </p> 457 457 </form>
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)