Ticket #19796: 19796-hack-day.9.diff
File 19796-hack-day.9.diff, 17.7 KB (added by , 12 years ago) |
---|
-
wp-signup.php
394 394 $proto = 'https://'; 395 395 else 396 396 $proto = 'http://'; 397 $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( $proto . $_SERVER['HTTP_HOST'] . '/wp-signup.php' ));397 $login_url = site_url( 'wp-login.php?redirect_to=' . urlencode( network_site_url( 'wp-signup.php' ) ) ); 398 398 echo sprintf( __( 'You must first <a href="%s">log in</a>, and then you can create a new site.' ), $login_url ); 399 399 } else { 400 400 $stage = isset( $_POST['stage'] ) ? $_POST['stage'] : 'default'; -
wp-login.php
509 509 case 'register' : 510 510 if ( is_multisite() ) { 511 511 // Multisite uses wp-signup.php 512 wp_redirect( apply_filters( 'wp_signup_location', site_url('wp-signup.php') ) );512 wp_redirect( apply_filters( 'wp_signup_location', network_site_url('wp-signup.php') ) ); 513 513 exit; 514 514 } 515 515 -
wp-includes/link-template.php
2129 2129 if ( 'relative' == $scheme ) 2130 2130 $url = $current_site->path; 2131 2131 else 2132 $url = $scheme . '://' . $current_site->domain . $current_site-> path;2132 $url = $scheme . '://' . $current_site->domain . $current_site->wp_siteurl_subdir; 2133 2133 2134 2134 if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) 2135 2135 $url .= ltrim($path, '/'); -
wp-includes/canonical.php
18 18 * one or the other. 19 19 * 20 20 * Prevents redirection for feeds, trackbacks, searches, comment popup, and 21 * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7, 21 * admin URLs. Does not redirect on non-pretty-permalink-supporting IIS 7, 22 22 * page/post previews, WP admin, Trackbacks, robots.txt, searches, or on POST 23 23 * requests. 24 24 * … … 282 282 283 283 if ( 'wp-register.php' == basename( $redirect['path'] ) ) { 284 284 if ( is_multisite() ) 285 $redirect_url = apply_filters( 'wp_signup_location', site_url( 'wp-signup.php' ) );285 $redirect_url = apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); 286 286 else 287 287 $redirect_url = site_url( 'wp-login.php?action=register' ); 288 288 wp_redirect( $redirect_url, 301 ); -
wp-includes/ms-load.php
142 142 $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1; 143 143 $current_site->domain = DOMAIN_CURRENT_SITE; 144 144 $current_site->path = $path = PATH_CURRENT_SITE; 145 146 if( defined( 'WP_SITEURL_SUBDIR' ) ) 147 $current_site->wp_siteurl_subdir = WP_SITEURL_SUBDIR; 148 else 149 $current_site->wp_siteurl_subdir = $current_site->path; 150 145 151 if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) 146 152 $current_site->blog_id = BLOG_ID_CURRENT_SITE; 147 153 elseif ( defined( 'BLOGID_CURRENT_SITE' ) ) // deprecated. -
wp-includes/ms-settings.php
86 86 if ( '%siteurl%' == $destination ) 87 87 $destination = "http://" . $current_site->domain . $current_site->path; 88 88 } else { 89 $destination = 'http://' . $current_site->domain . $current_site-> path. 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain );89 $destination = 'http://' . $current_site->domain . $current_site->wp_siteurl_subdir . 'wp-signup.php?new=' . str_replace( '.' . $current_site->domain, '', $domain ); 90 90 } 91 91 header( 'Location: ' . $destination ); 92 92 die(); -
wp-includes/ms-functions.php
595 595 $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain ); 596 596 $path = $base; 597 597 } else { 598 $mydomain = "$domain";599 $path = $base.$blogname.'/';598 $mydomain = $domain; 599 $path = '/' . join_wish_slashes( $base, $blogname ) . '/'; 600 600 } 601 601 if ( domain_exists($mydomain, $path) ) 602 602 $errors->add('blogname', __('Sorry, that site already exists!')); … … 1142 1142 1143 1143 $wpdb->suppress_errors(false); 1144 1144 1145 $ url = get_blogaddress_by_id($blog_id);1145 $homeurl = $siteurl = untrailingslashit( get_blogaddress_by_id( $blog_id ) ); 1146 1146 1147 1147 // Set everything up 1148 1148 make_db_current_silent( 'blog' ); … … 1150 1150 populate_roles(); 1151 1151 $wp_roles->_init(); 1152 1152 1153 $url = untrailingslashit( $url ); 1154 // fix url. 1155 update_option('siteurl', $url); 1156 update_option('home', $url); 1157 update_option('fileupload_url', $url . "/files" ); 1158 update_option('upload_path', UPLOADBLOGSDIR . "/$blog_id/files"); 1153 // Maybe fix url 1154 if ( defined( 'WP_SITEURL_SUBDIR' ) && WP_SITEURL_SUBDIR ) 1155 $siteurl = join_with_slashes( $siteurl, WP_SITEURL_SUBDIR ); 1156 1157 update_option('siteurl', $siteurl); 1158 update_option('home', $homeurl); 1159 update_option('fileupload_url', join_with_slashes( $homeurl, 'files' ) ); 1160 update_option('upload_path', join_with_slashes( UPLOADBLOGSDIR, $blog_id, 'files' ) ); 1159 1161 update_option('blogname', stripslashes( $blog_title ) ); 1160 1162 update_option('admin_email', ''); 1161 1163 $wpdb->update( $wpdb->options, array('option_value' => ''), array('option_name' => 'admin_email') ); 1162 1164 1163 1165 // remove all perms 1164 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'user_level' ) ); 1166 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix . 'user_level' ) ); 1167 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix . 'capabilities' ) ); 1165 1168 1166 $wpdb->delete( $wpdb->usermeta, array( 'meta_key' => $table_prefix.'capabilities' ) );1167 1168 1169 $wpdb->suppress_errors( false ); 1169 1170 } 1170 1171 -
wp-includes/functions.php
1434 1434 function wp_upload_dir( $time = null ) { 1435 1435 global $switched; 1436 1436 $siteurl = get_option( 'siteurl' ); 1437 $homeurl = get_option( 'home' ); 1438 $base_url = is_multisite() && defined( 'MULTISITE' ) ? $homeurl : $siteurl; 1437 1439 $upload_path = get_option( 'upload_path' ); 1438 1440 $upload_path = trim($upload_path); 1439 1441 $main_override = is_multisite() && defined( 'MULTISITE' ) && is_main_site(); … … 1453 1455 if ( empty($upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) 1454 1456 $url = WP_CONTENT_URL . '/uploads'; 1455 1457 else 1456 $url = trailingslashit( $ siteurl ) . $upload_path;1458 $url = trailingslashit( $baseurl ) . $upload_path; 1457 1459 } 1458 1460 1459 1461 if ( defined('UPLOADS') && !$main_override && ( !isset( $switched ) || $switched === false ) ) { 1460 1462 $dir = ABSPATH . UPLOADS; 1461 $url = trailingslashit( $ siteurl ) . UPLOADS;1463 $url = trailingslashit( $baseurl ) . UPLOADS; 1462 1464 } 1463 1465 1464 1466 if ( is_multisite() && !$main_override && ( !isset( $switched ) || $switched === false ) ) { -
wp-includes/formatting.php
1355 1355 } 1356 1356 1357 1357 /** 1358 * Removes trailing and leading slashes from elements (array or string args), then combines elements 1359 * with a slash in between each element. Leading and trailing slashes should be 1360 * manually concatenated. 1361 * 1362 * @since 3.5.0 1363 * @return string Concatenated string with slashes in between each element. 1364 */ 1365 function join_with_slashes() { 1366 $args = func_get_args(); 1367 $members = array(); 1368 foreach ( (array) $args as $arg ) { 1369 if ( is_array( $arg ) ) { 1370 foreach ( $arg as $member ) { 1371 $members[] = trim( $member, '/' ); 1372 } 1373 } else { 1374 $members[] = trim( $arg, '/' ); 1375 } 1376 } 1377 return implode( '/', $members ); 1378 } 1379 1380 1381 /** 1358 1382 * Adds slashes to escape strings. 1359 1383 * 1360 1384 * Slashes will first be removed if magic_quotes_gpc is set, see {@link -
wp-includes/ms-default-constants.php
47 47 * @since 1.5.0 48 48 */ 49 49 if ( !defined( 'SITECOOKIEPATH' ) ) 50 define( 'SITECOOKIEPATH', $current_site-> path);50 define( 'SITECOOKIEPATH', $current_site->wp_siteurl_subdir ); 51 51 52 52 /** 53 53 * @since 2.6.0 -
wp-admin/network.php
51 51 * @return bool Whether subdomain install is allowed 52 52 */ 53 53 function allow_subdomain_install() { 54 $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( ' siteurl' ) );55 if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) )54 $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'home' ) ); 55 if( parse_url( get_option( 'home' ), PHP_URL_PATH ) || 'localhost' == $domain || preg_match( '|^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$|', $domain ) ) 56 56 return false; 57 57 58 58 return true; … … 144 144 function network_step1( $errors = false ) { 145 145 global $is_apache; 146 146 147 if ( get_option( 'siteurl' ) != get_option( 'home' ) ) {148 echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . sprintf( __( 'Your <strong>WordPress address</strong> must match your <strong>Site address</strong> before creating a Network. See <a href="%s">General Settings</a>.' ), esc_url( admin_url( 'options-general.php' ) ) ) . '</p></div>';149 echo '</div>';150 include ( ABSPATH . 'wp-admin/admin-footer.php' );151 die();152 }153 154 147 if ( defined('DO_NOT_UPGRADE_GLOBAL_TABLES') ) { 155 148 echo '<div class="error"><p><strong>' . __('ERROR:') . '</strong> ' . __( 'The constant DO_NOT_UPGRADE_GLOBAL_TABLES cannot be defined when creating a network.' ) . '</p></div>'; 156 149 echo '</div>'; … … 314 307 * @since 3.0.0 315 308 */ 316 309 function network_step2( $errors = false ) { 317 global $base, $wpdb; 318 $hostname = get_clean_basedomain(); 310 global $wpdb; 319 311 320 if ( ! isset( $base ) ) 321 $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) ); 312 $hostname = get_clean_basedomain(); 313 $slashed_home = trailingslashit( get_option( 'home' ) ); 314 $slashed_siteurl = trailingslashit( get_option( 'siteurl' ) ); 315 $wp_siteurl_subdir = '/' . str_replace( $slashed_home, '', $slashed_siteurl ); 316 $rewrite_base = ! empty( $wp_siteurl_subdir ) ? ltrim( trailingslashit( $wp_siteurl_subdir ), '/' ) : ''; 317 $base = parse_url( $slashed_home, PHP_URL_PATH ); 322 318 323 319 // Wildcard DNS message. 324 320 if ( is_wp_error( $errors ) ) 325 321 echo '<div class="error">' . $errors->get_error_message() . '</div>'; 326 322 327 if ( $_POST) {328 if ( allow_subdomain_install() ) 323 if ( ! empty( $_POST ) ) { 324 if ( allow_subdomain_install() ) { 329 325 $subdomain_install = allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true; 330 else326 } else { 331 327 $subdomain_install = false; 328 } 332 329 } else { 333 330 if ( is_multisite() ) { 334 331 $subdomain_install = is_subdomain_install(); … … 344 341 } 345 342 } 346 343 347 if ( $_POST|| ! is_multisite() ) {344 if ( ! empty( $_POST ) || ! is_multisite() ) { 348 345 ?> 349 346 <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3> 350 347 <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p> … … 369 366 <textarea class="code" readonly="readonly" cols="100" rows="7"> 370 367 define('MULTISITE', true); 371 368 define('SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?>); 372 $base = '<?php echo $base; ?>';373 369 define('DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>'); 374 370 define('PATH_CURRENT_SITE', '<?php echo $base; ?>'); 375 371 define('SITE_ID_CURRENT_SITE', 1); 376 define('BLOG_ID_CURRENT_SITE', 1);</textarea> 372 define('BLOG_ID_CURRENT_SITE', 1); 373 define('WP_SITEURL_SUBDIR', '<?php echo $wp_siteurl_subdir; ?>');</textarea> 377 374 <?php 378 375 $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' ); 379 376 foreach ( $keys_salts as $c => $v ) { 380 if ( defined( $c ) ) 377 if ( defined( $c ) ) { 381 378 unset( $keys_salts[ $c ] ); 379 } 382 380 } 381 383 382 if ( ! empty( $keys_salts ) ) { 384 383 $keys_salts_str = ''; 385 $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );384 $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' ); 386 385 if ( is_wp_error( $from_api ) ) { 387 386 foreach ( $keys_salts as $c => $v ) { 388 387 $keys_salts_str .= "\ndefine( '$c', '" . wp_generate_password( 64, true, true ) . "' );"; … … 465 464 </rule> 466 465 <rule name="WordPress Rule 5" stopProcessing="true"> 467 466 <match url="^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*)" ignoreCase="false" /> 468 <action type="Rewrite" url=" {R:1}" />467 <action type="Rewrite" url="' . $rewrite_base . '{R:1}" /> 469 468 </rule> 470 469 <rule name="WordPress Rule 6" stopProcessing="true"> 471 470 <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" /> 472 <action type="Rewrite" url=" {R:2}" />471 <action type="Rewrite" url="' . $rewrite_base . '{R:2}" /> 473 472 </rule> 474 473 <rule name="WordPress Rule 7" stopProcessing="true"> 475 474 <match url="." ignoreCase="false" /> … … 494 493 RewriteRule ^index\.php$ - [L] 495 494 496 495 # uploaded files 497 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";496 RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) ' . $rewrite_base . 'wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n"; 498 497 499 498 if ( ! $subdomain_install ) 500 499 $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n"; … … 504 503 RewriteRule ^ - [L]'; 505 504 506 505 // @todo custom content dir. 507 if ( ! $subdomain_install ) 508 $htaccess_file .= "\nRewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $1 [L]\nRewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $1 [L]"; 506 if ( ! $subdomain_install ) { 507 $htaccess_file .= "\nRewriteRule ^[_0-9a-zA-Z-]+/(wp-(content|admin|includes).*) $rewrite_base$1 [L]\nRewriteRule ^[_0-9a-zA-Z-]+/(.*\.php)$ $rewrite_base$1 [L]"; 508 } 509 509 510 510 $htaccess_file .= "\nRewriteRule . index.php [L]"; 511 511 512 512 ?> 513 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH); ?></p>513 <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), trailingslashit( str_replace( trailingslashit( $wp_siteurl_subdir ), '', ABSPATH ) ) ); ?></p> 514 514 <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>"> 515 515 <?php echo esc_textarea( $htaccess_file ); ?></textarea></li> 516 516 </ol> … … 523 523 } 524 524 } 525 525 526 if ( $_POST) {526 if ( ! empty( $_POST ) ) { 527 527 528 $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );529 530 528 check_admin_referer( 'install-network-1' ); 531 529 532 530 require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); 531 533 532 // create network tables 534 533 install_network(); 535 $hostname = get_clean_basedomain(); 534 535 $base = parse_url( trailingslashit( get_option( 'home' ) ), PHP_URL_PATH ); 536 536 $subdomain_install = allow_subdomain_install() ? !empty( $_POST['subdomain_install'] ) : false; 537 537 538 if ( ! network_domain_check() ) { 538 539 $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install ); 539 540 if ( is_wp_error( $result ) ) { 540 if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() ) 541 if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() ) { 541 542 network_step2( $result ); 542 else543 } else { 543 544 network_step1( $result ); 545 } 544 546 } else { 545 547 network_step2(); 546 548 } -
wp-admin/includes/ms.php
657 657 <?php if ( in_array( get_site_option( 'registration' ), array( 'all', 'blog' ) ) ) : ?> 658 658 <tr> 659 659 <th scope="row" colspan="2" class="th-full"> 660 <a href="<?php echo apply_filters( 'wp_signup_location', network_ home_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a>660 <a href="<?php echo apply_filters( 'wp_signup_location', network_site_url( 'wp-signup.php' ) ); ?>"><?php _e( 'Create a New Site' ); ?></a> 661 661 </th> 662 662 </tr> 663 663 <?php endif; ?> -
wp-admin/network/site-new.php
62 62 63 63 if ( is_subdomain_install() ) { 64 64 $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', $current_site->domain ); 65 $path = $base;65 $path = $current_site->path; 66 66 } else { 67 67 $newdomain = $current_site->domain; 68 $path = $base. $domain . '/';68 $path = $current_site->path . $domain . '/'; 69 69 } 70 70 71 71 $password = 'N/A';