PageRenderTime 47ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-admin/network.php

https://gitlab.com/endomorphosis/reservationtelco
PHP | 520 lines | 420 code | 46 blank | 54 comment | 70 complexity | 4a83c2eab28d47ef6e5487bddec491b2 MD5 | raw file
  1. <?php
  2. /**
  3. * Network installation administration panel.
  4. *
  5. * A multi-step process allowing the user to enable a network of WordPress sites.
  6. *
  7. * @since 3.0.0
  8. *
  9. * @package WordPress
  10. * @subpackage Administration
  11. */
  12. define( 'WP_NETWORK_ADMIN_PAGE', true );
  13. /** WordPress Administration Bootstrap */
  14. require_once( './admin.php' );
  15. if ( ! is_super_admin() )
  16. wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
  17. if ( is_multisite() && ! defined( 'MULTISITE' ) )
  18. wp_die( __( 'The Network creation panel is not for WordPress MU networks.' ) );
  19. // We need to create references to ms global tables to enable Network.
  20. foreach ( $wpdb->tables( 'ms_global' ) as $table => $prefixed_table )
  21. $wpdb->$table = $prefixed_table;
  22. /**
  23. * Check for an existing network.
  24. *
  25. * @since 3.0.0
  26. * @return Whether a network exists.
  27. */
  28. function network_domain_check() {
  29. global $wpdb;
  30. if ( $wpdb->get_var( "SHOW TABLES LIKE '$wpdb->site'" ) )
  31. return $wpdb->get_var( "SELECT domain FROM $wpdb->site ORDER BY id ASC LIMIT 1" );
  32. return false;
  33. }
  34. /**
  35. * Allow subdomain install
  36. *
  37. * @since 3.0.0
  38. * @return bool Whether subdomain install is allowed
  39. */
  40. function allow_subdomain_install() {
  41. $domain = preg_replace( '|https?://([^/]+)|', '$1', get_option( 'siteurl' ) );
  42. if( false !== strpos( $domain, '/' ) || 'localhost' == $domain || preg_match( '|[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+|', $domain ) )
  43. return false;
  44. return true;
  45. }
  46. /**
  47. * Allow subdirectory install
  48. *
  49. * @since 3.0.0
  50. * @return bool Whether subdirectory install is allowed
  51. */
  52. function allow_subdirectory_install() {
  53. global $wpdb;
  54. if ( apply_filters( 'allow_subdirectory_install', false ) )
  55. return true;
  56. $post = $wpdb->get_row( "SELECT ID FROM $wpdb->posts WHERE post_date < DATE_SUB(NOW(), INTERVAL 1 MONTH) AND post_status = 'publish'" );
  57. if ( empty( $post ) )
  58. return true;
  59. return false;
  60. }
  61. /**
  62. * Get base domain of network.
  63. *
  64. * @since 3.0.0
  65. * @return string Base domain.
  66. */
  67. function get_clean_basedomain() {
  68. if ( $existing_domain = network_domain_check() )
  69. return $existing_domain;
  70. $domain = preg_replace( '|https?://|', '', get_option( 'siteurl' ) );
  71. if ( $slash = strpos( $domain, '/' ) )
  72. $domain = substr( $domain, 0, $slash );
  73. return $domain;
  74. }
  75. if ( ! network_domain_check() && ( ! defined( 'WP_ALLOW_MULTISITE' ) || ! WP_ALLOW_MULTISITE ) )
  76. wp_die( __( 'You must define the <code>WP_ALLOW_MULTISITE</code> constant as true in your wp-config.php file to allow creation of a Network.' ) );
  77. $title = __( 'Create a Network of WordPress Sites' );
  78. $parent_file = 'tools.php';
  79. add_contextual_help($current_screen,
  80. '<p>' . __('This screen allows you to configure a network as having subdomains (site1.example.com) or subdirectories (example.com/site1). Subdomains require wildcard subdomains to be enabled in Apache and DNS records, if your host allows it.') . '</p>' .
  81. '<p>' . __('Choose subdomains or subdirectories; this can only be switched afterwards by reconfiguring your install. Fill out the network details, and click install. If this does not work, you may have to add a wildcard DNS record (for subdomains) or change to another setting in Permalinks (for subdirectories).') . '</p>' .
  82. '<p>' . __('The next screen for Network will give you individually-generated lines of code to add to your wp-config.php and .htaccess files. Make sure the settings of your FTP client make files starting with a dot visible, so that you can find .htaccess; you may have to create this file if it really is not there. Make backup copies of those two files.') . '</p>' .
  83. '<p>' . __('Add a blogs.dir directory under /wp-content/ and add the designated lines of code to wp-config.php (just before /*...stop editing...*/) and .htaccess (replacing the existing WordPress rules).') . '</p>' .
  84. '<p>' . __('Refreshing your browser will take you to a screen with an archive of those added lines of code. A set of six links under Super Admin will appear at the top of the main left navigation menu. The multisite network is now enabled.') . '</p>' .
  85. '<p>' . __('The choice of subdirectory sites is disabled if this setup is more than a month old because of permalink problems with &#8220;/blog/&#8221; from the main site. This disabling will be addressed soon in a future version.') . '</p>' .
  86. '<p><strong>' . __('For more information:') . '</strong></p>' .
  87. '<p>' . __('<a href="http://codex.wordpress.org/Create_A_Network">General Network Creation Documentation</a>') . '</p>' .
  88. '<p>' . __('<a href="http://codex.wordpress.org/Tools_Network_SubPanel">Tools > Network Documentation</a>') . '</p>' .
  89. '<p>' . __('<a href="http://wordpress.org/support/">Support Forums</a>') . '</p>'
  90. );
  91. include( './admin-header.php' );
  92. ?>
  93. <div class="wrap">
  94. <?php screen_icon(); ?>
  95. <h2><?php echo esc_html( $title ); ?></h2>
  96. <?php
  97. /**
  98. * Prints step 1 for Network installation process.
  99. *
  100. * @todo Realistically, step 1 should be a welcome screen explaining what a Network is and such. Navigating to Tools > Network
  101. * should not be a sudden "Welcome to a new install process! Fill this out and click here." See also contextual help todo.
  102. *
  103. * @since 3.0.0
  104. */
  105. function network_step1( $errors = false ) {
  106. global $is_apache;
  107. if ( get_option( 'siteurl' ) != get_option( 'home' ) ) {
  108. 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>';
  109. echo '</div>';
  110. include ('./admin-footer.php' );
  111. die();
  112. }
  113. $active_plugins = get_option( 'active_plugins' );
  114. if ( ! empty( $active_plugins ) ) {
  115. echo '<div class="updated"><p><strong>' . __('Warning:') . '</strong> ' . sprintf( __( 'Please <a href="%s">deactivate your plugins</a> before enabling the Network feature.' ), admin_url( 'plugins.php?plugin_status=active' ) ) . '</p></div><p>' . __( 'Once the network is created, you may reactivate your plugins.' ) . '</p>';
  116. echo '</div>';
  117. include( './admin-footer.php' );
  118. die();
  119. }
  120. $hostname = get_clean_basedomain();
  121. $has_ports = strstr( $hostname, ':' );
  122. if ( ( false !== $has_ports && ! in_array( $has_ports, array( ':80', ':443' ) ) ) ) {
  123. echo '<div class="error"><p><strong>' . __( 'Error:') . '</strong> ' . __( 'You cannot install a network of sites with your server address.' ) . '</p></div>';
  124. echo '<p>' . sprintf( __( 'You cannot use port numbers such as <code>%s</code>.' ), $has_ports ) . '</p>';
  125. echo '<a href="' . esc_url( admin_url() ) . '">' . __( 'Return to Dashboard' ) . '</a>';
  126. echo '</div>';
  127. include( './admin-footer.php' );
  128. die();
  129. }
  130. echo '<form method="post" action="">';
  131. wp_nonce_field( 'install-network-1' );
  132. $error_codes = array();
  133. if ( is_wp_error( $errors ) ) {
  134. echo '<div class="error"><p><strong>' . __( 'ERROR: The network could not be created.' ) . '</strong></p>';
  135. foreach ( $errors->get_error_messages() as $error )
  136. echo "<p>$error</p>";
  137. echo '</div>';
  138. $error_codes = $errors->get_error_codes();
  139. }
  140. if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
  141. echo '<div class="error"><p><strong>' . __('Warning!') . '</strong> ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</p></div>';
  142. $site_name = ( ! empty( $_POST['sitename'] ) && ! in_array( 'empty_sitename', $error_codes ) ) ? $_POST['sitename'] : sprintf( _x('%s Sites', 'Default network name' ), get_option( 'blogname' ) );
  143. $admin_email = ( ! empty( $_POST['email'] ) && ! in_array( 'invalid_email', $error_codes ) ) ? $_POST['email'] : get_option( 'admin_email' );
  144. ?>
  145. <p><?php _e( 'Welcome to the Network installation process!' ); ?></p>
  146. <p><?php _e( 'Fill in the information below and you&#8217;ll be on your way to creating a network of WordPress sites. We will create configuration files in the next step.' ); ?></p>
  147. <?php
  148. if ( isset( $_POST['subdomain_install'] ) ) {
  149. $subdomain_install = (bool) $_POST['subdomain_install'];
  150. } elseif ( apache_mod_loaded('mod_rewrite') ) { // assume nothing
  151. $subdomain_install = true;
  152. } elseif ( !allow_subdirectory_install() ) {
  153. $subdomain_install = true;
  154. } else {
  155. $subdomain_install = false;
  156. if ( $got_mod_rewrite = got_mod_rewrite() ) // dangerous assumptions
  157. echo '<div class="updated inline"><p><strong>' . __( 'Note:' ) . '</strong> ' . __( 'Please make sure the Apache <code>mod_rewrite</code> module is installed as it will be used at the end of this installation.' ) . '</p>';
  158. elseif ( $is_apache )
  159. echo '<div class="error inline"><p><strong>' . __( 'Warning!' ) . '</strong> ' . __( 'It looks like the Apache <code>mod_rewrite</code> module is not installed.' ) . '</p>';
  160. if ( $got_mod_rewrite || $is_apache ) // Protect against mod_rewrite mimicry (but ! Apache)
  161. echo '<p>' . __( 'If <code>mod_rewrite</code> is disabled, ask your administrator to enable that module, or look at the <a href="http://httpd.apache.org/docs/mod/mod_rewrite.html">Apache documentation</a> or <a href="http://www.google.com/search?q=apache+mod_rewrite">elsewhere</a> for help setting it up.' ) . '</p></div>';
  162. }
  163. if ( allow_subdomain_install() && allow_subdirectory_install() ) : ?>
  164. <h3><?php esc_html_e( 'Addresses of Sites in your Network' ); ?></h3>
  165. <p><?php _e( 'Please choose whether you would like sites in your WordPress network to use sub-domains or sub-directories. <strong>You cannot change this later.</strong>' ); ?></p>
  166. <p><?php _e( 'You will need a wildcard DNS record if you are going to use the virtual host (sub-domain) functionality.' ); ?></p>
  167. <?php // @todo: Link to an MS readme? ?>
  168. <table class="form-table">
  169. <tr>
  170. <th><label><input type='radio' name='subdomain_install' value='1'<?php checked( $subdomain_install ); ?> /> <?php _e( 'Sub-domains' ); ?></label></th>
  171. <td><?php printf( _x( 'like <code>site1.%1$s</code> and <code>site2.%1$s</code>', 'subdomain examples' ), $hostname ); ?></td>
  172. </tr>
  173. <tr>
  174. <th><label><input type='radio' name='subdomain_install' value='0'<?php checked( ! $subdomain_install ); ?> /> <?php _e( 'Sub-directories' ); ?></label></th>
  175. <td><?php printf( _x( 'like <code>%1$s/site1</code> and <code>%1$s/site2</code>', 'subdirectory examples' ), $hostname ); ?></td>
  176. </tr>
  177. </table>
  178. <?php
  179. endif;
  180. $is_www = ( 0 === strpos( $hostname, 'www.' ) );
  181. if ( $is_www ) :
  182. ?>
  183. <h3><?php esc_html_e( 'Server Address' ); ?></h3>
  184. <p><?php printf( __( 'We recommend you change your siteurl to <code>%1$s</code> before enabling the network feature. It will still be possible to visit your site using the <code>www</code> prefix with an address like <code>%2$s</code> but any links will not have the <code>www</code> prefix.' ), substr( $hostname, 4 ), $hostname ); ?></h3>
  185. <table class="form-table">
  186. <tr>
  187. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
  188. <td>
  189. <?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
  190. </td>
  191. </tr>
  192. </table>
  193. <?php endif; ?>
  194. <h3><?php esc_html_e( 'Network Details' ); ?></h3>
  195. <table class="form-table">
  196. <?php if ( 'localhost' == $hostname ) : ?>
  197. <tr>
  198. <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
  199. <td><?php
  200. _e( 'Because you are using <code>localhost</code>, the sites in your WordPress network must use sub-directories. Consider using <code>localhost.localdomain</code> if you wish to use sub-domains.' );
  201. // Uh oh:
  202. if ( !allow_subdirectory_install() )
  203. echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  204. ?></td>
  205. </tr>
  206. <?php elseif ( !allow_subdomain_install() ) : ?>
  207. <tr>
  208. <th scope="row"><?php esc_html_e( 'Sub-directory Install' ); ?></th>
  209. <td><?php
  210. _e( 'Because your install is in a directory, the sites in your WordPress network must use sub-directories.' );
  211. // Uh oh:
  212. if ( !allow_subdirectory_install() )
  213. echo ' <strong>' . __( 'Warning!' ) . ' ' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  214. ?></td>
  215. </tr>
  216. <?php elseif ( !allow_subdirectory_install() ) : ?>
  217. <tr>
  218. <th scope="row"><?php esc_html_e( 'Sub-domain Install' ); ?></th>
  219. <td><?php _e( 'Because your install is not new, the sites in your WordPress network must use sub-domains.' );
  220. echo ' <strong>' . __( 'The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links.' ) . '</strong>';
  221. ?></td>
  222. </tr>
  223. <?php endif; ?>
  224. <?php if ( ! $is_www ) : ?>
  225. <tr>
  226. <th scope='row'><?php esc_html_e( 'Server Address' ); ?></th>
  227. <td>
  228. <?php printf( __( 'The internet address of your network will be <code>%s</code>.' ), $hostname ); ?>
  229. </td>
  230. </tr>
  231. <?php endif; ?>
  232. <tr>
  233. <th scope='row'><?php esc_html_e( 'Network Title' ); ?></th>
  234. <td>
  235. <input name='sitename' type='text' size='45' value='<?php echo esc_attr( $site_name ); ?>' />
  236. <br /><?php _e( 'What would you like to call your network?' ); ?>
  237. </td>
  238. </tr>
  239. <tr>
  240. <th scope='row'><?php esc_html_e( 'Admin E-mail Address' ); ?></th>
  241. <td>
  242. <input name='email' type='text' size='45' value='<?php echo esc_attr( $admin_email ); ?>' />
  243. <br /><?php _e( 'Your email address.' ); ?>
  244. </td>
  245. </tr>
  246. </table>
  247. <p class='submit'><input class="button-primary" name='submit' type='submit' value='<?php esc_attr_e( 'Install' ); ?>' /></p>
  248. </form>
  249. <?php
  250. }
  251. /**
  252. * Prints step 2 for Network installation process.
  253. *
  254. * @since 3.0.0
  255. */
  256. function network_step2( $errors = false ) {
  257. global $base, $wpdb;
  258. $hostname = get_clean_basedomain();
  259. // Wildcard DNS message.
  260. if ( is_wp_error( $errors ) )
  261. echo '<div class="error">' . $errors->get_error_message() . '</div>';
  262. if ( $_POST ) {
  263. $subdomain_install = allow_subdomain_install() ? ( allow_subdirectory_install() ? ! empty( $_POST['subdomain_install'] ) : true ) : false;
  264. } else {
  265. if ( is_multisite() ) {
  266. $subdomain_install = is_subdomain_install();
  267. ?>
  268. <div class="updated"><p><strong><?php _e( 'Notice: The Network feature is already enabled.' ); ?></strong> <?php _e( 'The original configuration steps are shown here for reference.' ); ?></p></div>
  269. <?php } else {
  270. $subdomain_install = (bool) $wpdb->get_var( "SELECT meta_value FROM $wpdb->sitemeta WHERE site_id = 1 AND meta_key = 'subdomain_install'" );
  271. ?>
  272. <div class="error"><p><strong><?php _e('Warning:'); ?></strong> <?php _e( 'An existing WordPress network was detected.' ); ?></p></div>
  273. <p><?php _e( 'Please complete the configuration steps. To create a new network, you will need to empty or remove the network database tables.' ); ?></p>
  274. <?php
  275. }
  276. }
  277. if ( $_POST || ! is_multisite() ) {
  278. ?>
  279. <h3><?php esc_html_e( 'Enabling the Network' ); ?></h3>
  280. <p><?php _e( 'Complete the following steps to enable the features for creating a network of sites.' ); ?></p>
  281. <div class="updated inline"><p><?php
  282. if ( iis7_supports_permalinks() )
  283. _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> file.' );
  284. else
  285. _e( '<strong>Caution:</strong> We recommend you back up your existing <code>wp-config.php</code> and <code>.htaccess</code> files.' );
  286. ?></p></div>
  287. <?php
  288. }
  289. ?>
  290. <ol>
  291. <li><p><?php
  292. printf( __( 'Create a <code>blogs.dir</code> directory in <code>%s</code>. This directory is used to stored uploaded media for your additional sites and must be writeable by the web server.' ), WP_CONTENT_DIR );
  293. if ( WP_CONTENT_DIR != ABSPATH . 'wp-content' )
  294. echo ' <strong>' . __('Warning:') . ' ' . __( 'Networks may not be fully compatible with custom wp-content directories.' ) . '</strong';
  295. ?></p></li>
  296. <li><p><?php printf( __( 'Add the following to your <code>wp-config.php</code> file in <code>%s</code> <strong>above</strong> the line reading <code>/* That&#8217;s all, stop editing! Happy blogging. */</code>:' ), ABSPATH ); ?></p>
  297. <textarea class="code" readonly="readonly" cols="100" rows="7">
  298. define( 'MULTISITE', true );
  299. define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
  300. $base = '<?php echo $base; ?>';
  301. define( 'DOMAIN_CURRENT_SITE', '<?php echo $hostname; ?>' );
  302. define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
  303. define( 'SITE_ID_CURRENT_SITE', 1 );
  304. define( 'BLOG_ID_CURRENT_SITE', 1 );</textarea>
  305. <?php
  306. $keys_salts = array( 'AUTH_KEY' => '', 'SECURE_AUTH_KEY' => '', 'LOGGED_IN_KEY' => '', 'NONCE_KEY' => '', 'AUTH_SALT' => '', 'SECURE_AUTH_SALT' => '', 'LOGGED_IN_SALT' => '', 'NONCE_SALT' => '' );
  307. foreach ( $keys_salts as $c => $v ) {
  308. if ( defined( $c ) )
  309. unset( $keys_salts[ $c ] );
  310. }
  311. if ( ! empty( $keys_salts ) ) {
  312. $from_api = wp_remote_get( 'https://api.wordpress.org/secret-key/1.1/salt/' );
  313. if ( is_wp_error( $from_api ) ) {
  314. foreach ( $keys_salts as $c => $v ) {
  315. $keys_salts[ $c ] = wp_generate_password( 64, true, true );
  316. }
  317. } else {
  318. $from_api = explode( "\n", wp_remote_retrieve_body( $from_api ) );
  319. foreach ( $keys_salts as $c => $v ) {
  320. $keys_salts[ $c ] = substr( array_shift( $from_api ), 28, 64 );
  321. }
  322. }
  323. $num_keys_salts = count( $keys_salts );
  324. ?>
  325. <p><?php
  326. echo _n( 'This unique authentication key is also missing from your <code>wp-config.php</code> file.', 'These unique authentication keys are also missing from your <code>wp-config.php</code> file.', $num_keys_salts ); ?> <?php _e( 'To make your installation more secure, you should also add:' ) ?></p>
  327. <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $num_keys_salts; ?>"><?php
  328. foreach ( $keys_salts as $c => $v ) {
  329. echo "\ndefine( '$c', '$v' );";
  330. }
  331. ?></textarea>
  332. <?php
  333. }
  334. ?>
  335. </li>
  336. <?php
  337. if ( iis7_supports_permalinks() ) :
  338. if ( $subdomain_install ) {
  339. $web_config_file =
  340. '<?xml version="1.0" encoding="UTF-8"?>
  341. <configuration>
  342. <system.webServer>
  343. <rewrite>
  344. <rules>
  345. <rule name="WordPress Rule 1" stopProcessing="true">
  346. <match url="^index\.php$" ignoreCase="false" />
  347. <action type="None" />
  348. </rule>
  349. <rule name="WordPress Rule 2" stopProcessing="true">
  350. <match url="^files/(.+)" ignoreCase="false" />
  351. <action type="Rewrite" url="wp-includes/ms-files.php?file={R:1}" appendQueryString="false" />
  352. </rule>
  353. <rule name="WordPress Rule 3" stopProcessing="true">
  354. <match url="^" ignoreCase="false" />
  355. <conditions logicalGrouping="MatchAny">
  356. <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
  357. <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
  358. </conditions>
  359. <action type="None" />
  360. </rule>
  361. <rule name="WordPress Rule 4" stopProcessing="true">
  362. <match url="." ignoreCase="false" />
  363. <action type="Rewrite" url="index.php" />
  364. </rule>
  365. </rules>
  366. </rewrite>
  367. </system.webServer>
  368. </configuration>';
  369. } else {
  370. $web_config_file =
  371. '<?xml version="1.0" encoding="UTF-8"?>
  372. <configuration>
  373. <system.webServer>
  374. <rewrite>
  375. <rules>
  376. <rule name="WordPress Rule 1" stopProcessing="true">
  377. <match url="^index\.php$" ignoreCase="false" />
  378. <action type="None" />
  379. </rule>
  380. <rule name="WordPress Rule 2" stopProcessing="true">
  381. <match url="^([_0-9a-zA-Z-]+/)?files/(.+)" ignoreCase="false" />
  382. <action type="Rewrite" url="wp-includes/ms-files.php?file={R:2}" appendQueryString="false" />
  383. </rule>
  384. <rule name="WordPress Rule 3" stopProcessing="true">
  385. <match url="^([_0-9a-zA-Z-]+/)?wp-admin$" ignoreCase="false" />
  386. <action type="Redirect" url="{R:1}wp-admin/" redirectType="Permanent" />
  387. </rule>
  388. <rule name="WordPress Rule 4" stopProcessing="true">
  389. <match url="^" ignoreCase="false" />
  390. <conditions logicalGrouping="MatchAny">
  391. <add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
  392. <add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" />
  393. </conditions>
  394. <action type="None" />
  395. </rule>
  396. <rule name="WordPress Rule 5" stopProcessing="true">
  397. <match url="^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*)" ignoreCase="false" />
  398. <action type="Rewrite" url="{R:2}" />
  399. </rule>
  400. <rule name="WordPress Rule 6" stopProcessing="true">
  401. <match url="^([_0-9a-zA-Z-]+/)?(.*\.php)$" ignoreCase="false" />
  402. <action type="Rewrite" url="{R:2}" />
  403. </rule>
  404. <rule name="WordPress Rule 7" stopProcessing="true">
  405. <match url="." ignoreCase="false" />
  406. <action type="Rewrite" url="index.php" />
  407. </rule>
  408. </rules>
  409. </rewrite>
  410. </system.webServer>
  411. </configuration>';
  412. }
  413. ?>
  414. <li><p><?php printf( __( 'Add the following to your <code>web.config</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
  415. <textarea class="code" readonly="readonly" cols="100" rows="20">
  416. <?php echo wp_htmledit_pre( $web_config_file ); ?>
  417. </textarea></li>
  418. </ol>
  419. <?php else : // end iis7_supports_permalinks(). construct an htaccess file instead:
  420. $htaccess_file = 'RewriteEngine On
  421. RewriteBase ' . $base . '
  422. RewriteRule ^index\.php$ - [L]
  423. # uploaded files
  424. RewriteRule ^' . ( $subdomain_install ? '' : '([_0-9a-zA-Z-]+/)?' ) . 'files/(.+) wp-includes/ms-files.php?file=$' . ( $subdomain_install ? 1 : 2 ) . ' [L]' . "\n";
  425. if ( ! $subdomain_install )
  426. $htaccess_file .= "\n# add a trailing slash to /wp-admin\n" . 'RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]' . "\n";
  427. $htaccess_file .= "\n" . 'RewriteCond %{REQUEST_FILENAME} -f [OR]
  428. RewriteCond %{REQUEST_FILENAME} -d
  429. RewriteRule ^ - [L]';
  430. // @todo custom content dir.
  431. if ( ! $subdomain_install )
  432. $htaccess_file .= "\nRewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]\nRewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]";
  433. $htaccess_file .= "\nRewriteRule . index.php [L]";
  434. ?>
  435. <li><p><?php printf( __( 'Add the following to your <code>.htaccess</code> file in <code>%s</code>, replacing other WordPress rules:' ), ABSPATH ); ?></p>
  436. <textarea class="code" readonly="readonly" cols="100" rows="<?php echo $subdomain_install ? 11 : 16; ?>">
  437. <?php echo wp_htmledit_pre( $htaccess_file ); ?></textarea></li>
  438. </ol>
  439. <?php endif; // end IIS/Apache code branches.
  440. if ( !is_multisite() ) { ?>
  441. <p><?php printf( __( 'Once you complete these steps, your network is enabled and configured. You will have to log in again.') ); ?> <a href="<?php echo esc_url( site_url( 'wp-login.php' ) ); ?>"><?php _e( 'Log In' ); ?></a></p>
  442. <?php
  443. }
  444. }
  445. $base = trailingslashit( stripslashes( dirname( dirname( $_SERVER['SCRIPT_NAME'] ) ) ) );
  446. if ( $_POST ) {
  447. check_admin_referer( 'install-network-1' );
  448. require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
  449. // create network tables
  450. install_network();
  451. $hostname = get_clean_basedomain();
  452. $subdomain_install = !allow_subdomain_install() ? false : (bool) $_POST['subdomain_install'];
  453. if ( ! network_domain_check() ) {
  454. $result = populate_network( 1, get_clean_basedomain(), sanitize_email( $_POST['email'] ), stripslashes( $_POST['sitename'] ), $base, $subdomain_install );
  455. if ( is_wp_error( $result ) ) {
  456. if ( 1 == count( $result->get_error_codes() ) && 'no_wildcard_dns' == $result->get_error_code() )
  457. network_step2( $result );
  458. else
  459. network_step1( $result );
  460. } else {
  461. network_step2();
  462. }
  463. } else {
  464. network_step2();
  465. }
  466. } elseif ( is_multisite() || network_domain_check() ) {
  467. network_step2();
  468. } else {
  469. network_step1();
  470. }
  471. ?>
  472. </div>
  473. <?php include( './admin-footer.php' ); ?>