Ticket #10384: 10384-whale.patch
File 10384-whale.patch, 13.4 KB (added by , 14 years ago) |
---|
-
wp-admin/includes/misc.php
141 141 * Updates the IIS web.config file with the current rules if it is writable. 142 142 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. 143 143 * 144 * @since 2. 8.0144 * @since 2.9.0 145 145 * 146 146 * @return bool True if web.config was updated successfully 147 147 */ 148 function iis 7_save_url_rewrite_rules(){148 function iis_save_url_rewrite_rules() { 149 149 global $wp_rewrite; 150 150 151 151 $home_path = get_home_path(); … … 153 153 154 154 // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP 155 155 if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) { 156 if ( iis 7_supports_permalinks() ) {157 $rule = $wp_rewrite->iis 7_url_rewrite_rules();156 if ( iis_supports_permalinks() ) { 157 $rule = $wp_rewrite->iis_url_rewrite_rules(); 158 158 if ( ! empty($rule) ) { 159 return iis 7_add_rewrite_rule($web_config_file, $rule);159 return iis_add_rewrite_rule($web_config_file, $rule); 160 160 } else { 161 return iis 7_delete_rewrite_rule($web_config_file);161 return iis_delete_rewrite_rule($web_config_file); 162 162 } 163 163 } 164 164 } … … 429 429 } 430 430 431 431 /** 432 * Check if IIS 7 supports pretty permalinks432 * Check if IIS supports pretty permalinks via URL Rewrite Module 433 433 * 434 * @since 2. 8.0434 * @since 2.9.0 435 435 * 436 436 * @return bool 437 437 */ 438 function iis 7_supports_permalinks() {439 global $is_ iis7;438 function iis_supports_permalinks() { 439 global $is_IIS; 440 440 441 $supports_permalinks = false; 442 if ( $is_iis7 ) { 443 /* First we check if the DOMDocument class exists. If it does not exist, 444 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, 445 * hence we just bail out and tell user that pretty permalinks cannot be used. 446 * This is not a big issue because PHP 4.X is going to be depricated and for IIS it 447 * is recommended to use PHP 5.X NTS. 448 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When 449 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. 450 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 451 * via ISAPI then pretty permalinks will not work. 452 */ 453 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 454 } 455 456 return apply_filters('iis7_supports_permalinks', $supports_permalinks); 441 /* First we check if the DOMDocument class exists. If it does not exist, 442 * which is the case for PHP 4.X, then we cannot easily update the xml configuration file, 443 * hence we just bail out and tell user that pretty permalinks cannot be used. 444 * This is not a big issue because PHP 4.X is going to be depricated and for IIS it 445 * is recommended to use PHP 5.X NTS. 446 * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When 447 * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'. 448 * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs 449 * via ISAPI then pretty permalinks will not work. 450 */ 451 $supports_permalinks = $is_IIS && class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); 452 453 $supports_permalinks = apply_filters('iis7_supports_permalinks', $supports_permalinks); 454 455 return apply_filters('iis_supports_permalinks', $supports_permalinks); 457 456 } 458 457 459 458 /** 460 * Check if rewrite rule for WordPress already exists in the IIS 7configuration file459 * Check if rewrite rule for WordPress already exists in the IIS configuration file 461 460 * 462 * @since 2. 8.0461 * @since 2.9.0 463 462 * 464 463 * @return bool 465 464 * @param string $filename The file path to the configuration file 466 465 */ 467 function iis 7_rewrite_rule_exists($filename) {466 function iis_rewrite_rule_exists($filename) { 468 467 if ( ! file_exists($filename) ) 469 468 return false; 470 469 if ( ! class_exists('DOMDocument') ) … … 484 483 /** 485 484 * Delete WordPress rewrite rule from web.config file if it exists there 486 485 * 487 * @since 2. 8.0486 * @since 2.9.0 488 487 * 489 488 * @param string $filename Name of the configuration file 490 489 * @return bool 491 490 */ 492 function iis 7_delete_rewrite_rule($filename) {491 function iis_delete_rewrite_rule($filename) { 493 492 // If configuration file does not exist then rules also do not exist so there is nothing to delete 494 493 if ( ! file_exists($filename) ) 495 494 return true; … … 515 514 } 516 515 517 516 /** 518 * Add WordPress rewrite rule to the IIS 7configuration file.517 * Add WordPress rewrite rule to the IIS configuration file. 519 518 * 520 * @since 2. 8.0519 * @since 2.9.0 521 520 * 522 521 * @param string $filename The file path to the configuration file 523 522 * @param string $rewrite_rule The XML fragment with URL Rewrite rule 524 523 * @return bool 525 524 */ 526 function iis 7_add_rewrite_rule($filename, $rewrite_rule) {525 function iis_add_rewrite_rule($filename, $rewrite_rule) { 527 526 if ( ! class_exists('DOMDocument') ) 528 527 return false; 529 528 -
wp-admin/options-permalink.php
70 70 include('admin-header.php'); 71 71 72 72 $home_path = get_home_path(); 73 $iis 7_permalinks = iis7_supports_permalinks();73 $iis_permalinks = iis_supports_permalinks(); 74 74 75 75 if ( isset($_POST['permalink_structure']) || isset($_POST['category_base']) ) { 76 76 check_admin_referer('update-permalink'); … … 101 101 $category_base = get_option('category_base'); 102 102 $tag_base = get_option( 'tag_base' ); 103 103 104 if ( $iis 7_permalinks ) {104 if ( $iis_permalinks ) { 105 105 if ( ( ! file_exists($home_path . 'web.config') && win_is_writable($home_path) ) || win_is_writable($home_path . 'web.config') ) 106 106 $writable = true; 107 107 else … … 123 123 124 124 <?php if (isset($_POST['submit'])) : ?> 125 125 <div id="message" class="updated fade"><p><?php 126 if ( $iis 7_permalinks ) {126 if ( $iis_permalinks ) { 127 127 if ( $permalink_structure && ! $usingpi && ! $writable ) 128 128 _e('You should update your web.config now'); 129 129 else if ( $permalink_structure && ! $usingpi && $writable) … … 152 152 <?php 153 153 $prefix = ''; 154 154 155 if ( ! got_mod_rewrite() && ! $iis 7_permalinks )155 if ( ! got_mod_rewrite() && ! $iis_permalinks ) 156 156 $prefix = '/index.php'; 157 157 158 158 $structures = array( … … 197 197 </table> 198 198 199 199 <h3><?php _e('Optional'); ?></h3> 200 <?php if ( $is_apache || $iis 7_permalinks ) : ?>200 <?php if ( $is_apache || $iis_permalinks ) : ?> 201 201 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <kbd>topics</kbd> as your category base would make your category links like <code>http://example.org/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> 202 202 <?php else : ?> 203 203 <p><?php _e('If you like, you may enter custom structures for your category and tag <abbr title="Universal Resource Locator">URL</abbr>s here. For example, using <code>topics</code> as your category base would make your category links like <code>http://example.org/index.php/topics/uncategorized/</code>. If you leave these blank the defaults will be used.') ?></p> … … 221 221 <input type="submit" name="submit" class="button-primary" value="<?php esc_attr_e('Save Changes') ?>" /> 222 222 </p> 223 223 </form> 224 <?php if ($iis 7_permalinks) :224 <?php if ($iis_permalinks) : 225 225 if ( isset($_POST['submit']) && $permalink_structure && ! $usingpi && ! $writable ) : ?> 226 226 <p><?php _e('If your <code>web.config</code> file were <a href="http://codex.wordpress.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn’t so this is the url rewrite rule you should have in your <code>web.config</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all. Then insert this rule inside of the <code>/<configuration>/<system.webServer>/<rewrite>/<rules></code> element in <code>web.config</code> file.') ?></p> 227 227 <form action="options-permalink.php" method="post"> 228 228 <?php wp_nonce_field('update-permalink') ?> 229 <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis 7_url_rewrite_rules()); ?></textarea></p>229 <p><textarea rows="10" class="large-text readonly" name="rules" id="rules" readonly="readonly"><?php echo esc_html($wp_rewrite->iis_url_rewrite_rules()); ?></textarea></p> 230 230 </form> 231 231 <p><?php _e('If you temporarily make your <code>web.config</code> file writable for us to generate rewrite rules automatically, do not forget to revert the permissions after rule has been saved.') ?></p> 232 232 <?php endif; ?> -
wp-includes/deprecated.php
74 74 */ 75 75 $tablepostmeta = $wpdb->postmeta; 76 76 77 /** 78 * Whether the server software is IIS 7.X 79 * @global bool $is_iis7 80 * @deprecated Detect IIS version using local code 81 */ 82 $is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false); 83 77 84 /* 78 85 * Deprecated functions come here to die. 79 86 */ … … 1690 1697 the_author_meta('ID'); 1691 1698 } 1692 1699 1700 /** 1701 * Updates the IIS web.config file with the current rules if it is writable. 1702 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file. 1703 * 1704 * @since 2.8.0 1705 * @deprecated 2.9.0 1706 * @uses iis_save_url_rewrite_rules() 1707 */ 1708 function iis7_save_url_rewrite_rules() { 1709 _deprecated_function(__FUNCTION__, '2.9', 'iis_save_url_rewrite_rules()'); 1710 return iis_save_url_rewrite_rules(); 1711 } 1712 1713 /** 1714 * Check if IIS 7 supports pretty permalinks 1715 * 1716 * @since 2.8.0 1717 * @deprecated 2.9.0 1718 * @uses iis_supports_permalinks() 1719 */ 1720 function iis7_supports_permalinks() { 1721 _deprecated_function(__FUNCTION__, '2.9', 'iis_supports_permalinks()'); 1722 return iis_supports_permalinks(); 1723 } 1724 1725 /** 1726 * Check if rewrite rule for WordPress already exists in the IIS 7 configuration file 1727 * 1728 * @since 2.8.0 1729 * @deprecated 2.9.0 1730 * @uses iis_supports_permalinks($filename) 1731 */ 1732 function iis7_rewrite_rule_exists($filename) { 1733 _deprecated_function(__FUNCTION__, '2.9', 'iis_rewrite_rule_exists($filename)'); 1734 return iis_rewrite_rule_exists($filename); 1735 } 1736 1737 /** 1738 * Delete WordPress rewrite rule from web.config file if it exists there 1739 * 1740 * @since 2.8.0 1741 * @deprecated 2.9.0 1742 * @uses iis_delete_rewrite_rule($filename) 1743 */ 1744 function iis7_delete_rewrite_rule($filename) { 1745 _deprecated_function(__FUNCTION__, '2.9', 'iis_delete_rewrite_rule($filename)'); 1746 return iis_delete_rewrite_rule($filename); 1747 } 1748 1749 /** 1750 * Add WordPress rewrite rule to the IIS 7 configuration file. 1751 * 1752 * @since 2.8.0 1753 * @deprecated 2.9.0 1754 * @uses iis_add_rewrite_rule($filename, $rewrite_rule) 1755 */ 1756 function iis7_add_rewrite_rule($filename, $rewrite_rule) { 1757 _deprecated_function(__FUNCTION__, '2.9', 'iis_add_rewrite_rule($filename, $rewrite_rule)'); 1758 return iis_add_rewrite_rule($filename, $rewrite_rule); 1759 } 1760 1761 1762 /** 1763 * Retrieve IIS 7 URL Rewrite formatted rewrite rules to write to web.config file. 1764 * 1765 * Does not actually write to the web.config file, but creates the rules for 1766 * the process that will. 1767 * 1768 * @since 2.8.0 1769 * @deprecated 2.9.0 1770 * @uses iis_url_rewrite_rules() 1771 */ 1772 function iis7_url_rewrite_rules() { 1773 _deprecated_function(__FUNCTION__, '2.9', 'iis_url_rewrite_rules()'); 1774 return iis_url_rewrite_rules(); 1775 } 1693 1776 ?> 1777 No newline at end of file -
wp-includes/rewrite.php
1705 1705 } 1706 1706 1707 1707 /** 1708 * Retrieve IIS 7URL Rewrite formatted rewrite rules to write to web.config file.1708 * Retrieve IIS URL Rewrite formatted rewrite rules to write to web.config file. 1709 1709 * 1710 1710 * Does not actually write to the web.config file, but creates the rules for 1711 1711 * the process that will. 1712 1712 * 1713 * @since 2. 8.01713 * @since 2.9.0 1714 1714 * @access public 1715 1715 * 1716 1716 * @return string 1717 1717 */ 1718 function iis 7_url_rewrite_rules(){1718 function iis_url_rewrite_rules() { 1719 1719 1720 1720 if ( ! $this->using_permalinks()) { 1721 1721 return ''; … … 1730 1730 $rules .= "</rule>"; 1731 1731 1732 1732 $rules = apply_filters('iis7_url_rewrite_rules', $rules); 1733 $rules = apply_filters('iis_url_rewrite_rules', $rules); 1733 1734 1734 1735 return $rules; 1735 1736 } … … 1829 1830 $this->wp_rewrite_rules(); 1830 1831 if ( $hard && function_exists('save_mod_rewrite_rules') ) 1831 1832 save_mod_rewrite_rules(); 1832 if ( $hard && function_exists('iis 7_save_url_rewrite_rules') )1833 iis 7_save_url_rewrite_rules();1833 if ( $hard && function_exists('iis_save_url_rewrite_rules') ) 1834 iis_save_url_rewrite_rules(); 1834 1835 } 1835 1836 1836 1837 /** -
wp-includes/vars.php
73 73 */ 74 74 $is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false || strpos($_SERVER['SERVER_SOFTWARE'], 'ExpressionDevServer') !== false); 75 75 76 /**77 * Whether the server software is IIS 7.X78 * @global bool $is_iis779 */80 $is_iis7 = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS/7.') !== false);81 82 83 76 ?> 84 No newline at end of file