Ticket #31240: 31240.diff
File 31240.diff, 4.1 KB (added by , 9 years ago) |
---|
-
wp-admin/network/site-new.php
40 40 wp_die( __( 'Can’t create an empty site.' ) ); 41 41 42 42 $blog = $_POST['blog']; 43 $domain = ''; 44 if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) ) 45 $domain = strtolower( $blog['domain'] ); 43 $parsed_url = parse_url( 'http://' . trim( $blog['url'] ) ); 44 45 if ( empty( $parsed_url ) ) 46 wp_die( __( 'Missing or invalid site address.' ) ); 47 48 $newdomain = strtolower( $parsed_url['domain'] ); 49 $path = trailingslashit( $parsed_url['path'] ); 46 50 47 // If not a subdomain install, make sure the domainisn't a reserved word48 if ( ! is_subdomain_install() ) {49 /** This filter is documented in wp-includes/ms-functions.php */50 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed', 'wp-admin', 'wp-content', 'wp-includes' ) );51 if ( in_array( $domain, $subdirectory_reserved_names ) )51 // Make sure the path isn't a reserved word 52 /** This filter is documented in wp-includes/ms-functions.php */ 53 $subdirectory_reserved_names = apply_filters( 'subdirectory_reserved_names', array( 'page', 'comments', 'blog', 'files', 'feed', 'wp-admin', 'wp-content', 'wp-includes' ) ); 54 foreach( $subdirectory_reserved_names as $reserved_name ) { 55 if ( strpos( $path, '/' . $reserved_name . '/' ) !== false ) 52 56 wp_die( sprintf( __('The following words are reserved for use by WordPress functions and cannot be used as blog names: <code>%s</code>' ), implode( '</code>, <code>', $subdirectory_reserved_names ) ) ); 53 57 } 54 58 55 59 $title = $blog['title']; 56 60 57 61 $meta = array( … … 66 70 } 67 71 } 68 72 69 if ( empty( $domain ) )70 wp_die( __( 'Missing or invalid site address.' ) );71 72 73 if ( isset( $blog['email'] ) && '' === trim( $blog['email'] ) ) { 73 74 wp_die( __( 'Missing email address.' ) ); 74 75 } … … 78 79 wp_die( __( 'Invalid email address.' ) ); 79 80 } 80 81 81 if ( is_subdomain_install() ) {82 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain );83 $path = $current_site->path;84 } else {85 $newdomain = $current_site->domain;86 $path = $current_site->path . $domain . '/';87 }88 89 82 $password = 'N/A'; 90 83 $user_id = email_exists($email); 91 84 if ( !$user_id ) { // Create a new user with a random password 85 if ( is_subdomain_install() ) { 86 $subdomain = explode( $newdomain, '.', 1 ); 87 $username = $subdomain[0]; 88 } else { 89 $pathsegments = explode( trim( $path, '/' ), '/' ); 90 $username = array_pop( $pathsegments ); 91 } 92 92 $password = wp_generate_password( 12, false ); 93 $user_id = wpmu_create_user( $ domain, $password, $email );93 $user_id = wpmu_create_user( $username, $password, $email ); 94 94 if ( false === $user_id ) 95 95 wp_die( __( 'There was an error creating the user.' ) ); 96 96 else … … 156 156 <table class="form-table"> 157 157 <tr class="form-field form-required"> 158 158 <th scope="row"><label for="site-address"><?php _e( 'Site Address' ) ?></label></th> 159 <td> 160 <?php if ( is_subdomain_install() ) { ?> 161 <input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo preg_replace( '|^www\.|', '', $current_site->domain ); ?></span> 162 <?php } else { 163 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off" /> 164 <?php } 165 echo '<p id="site-address-desc">' . __( 'Only lowercase letters (a-z) and numbers are allowed.' ) . '</p>'; 166 ?> 159 <td>http:// 160 <input name="blog[url]" type="text" class="regular-text" id="site-address" aria-describedby="site-address-desc" autocapitalize="none" autocorrect="off"/><span class="no-break">.<?php echo $current_site->domain . $current_site->path; ?></span> 167 161 </td> 168 162 </tr> 169 163 <tr class="form-field form-required">