Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/misc.php

    r15263 r17328  
    1010 * {@internal Missing Short Description}}
    1111 *
    12  * @since unknown
     12 * @since 2.0.0
    1313 *
    1414 * @return unknown
    … …  
    2222 * {@internal Missing Short Description}}
    2323 *
    24  * @since unknown
     24 * @since 1.5.0
    2525 *
    2626 * @param unknown_type $filename
    … …  
    5858 * data. Creates file if none exists.
    5959 *
    60  * @since unknown
     60 * @since 1.5.0
    6161 *
    6262 * @param unknown_type $filename
    … …  
    118118 * blank out old rules.
    119119 *
    120  * @since unknown
     120 * @since 1.5.0
    121121 */
    122122function save_mod_rewrite_rules() {
    … …  
    150150 */
    151151function iis7_save_url_rewrite_rules(){
     152        if ( is_multisite() )
     153                return;
     154
    152155        global $wp_rewrite;
    153156
    … …  
    156159
    157160        // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
    158         if ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) {
    159                 if ( iis7_supports_permalinks() ) {
    160                         $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
    161                         if ( ! empty($rule) ) {
    162                                 return iis7_add_rewrite_rule($web_config_file, $rule);
    163                         } else {
    164                                 return iis7_delete_rewrite_rule($web_config_file);
    165                         }
     161        if ( iis7_supports_permalinks() && ( ( ! file_exists($web_config_file) && win_is_writable($home_path) && $wp_rewrite->using_mod_rewrite_permalinks() ) || win_is_writable($web_config_file) ) ) {
     162                $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
     163                if ( ! empty($rule) ) {
     164                        return iis7_add_rewrite_rule($web_config_file, $rule);
     165                } else {
     166                        return iis7_delete_rewrite_rule($web_config_file);
    166167                }
    167168        }
    … …  
    172173 * {@internal Missing Short Description}}
    173174 *
    174  * @since unknown
     175 * @since 1.5.0
    175176 *
    176177 * @param unknown_type $file
    … …  
    194195 * If siteurl or home changed, flush rewrite rules.
    195196 *
    196  * @since unknown
     197 * @since 2.1.0
    197198 *
    198199 * @param unknown_type $old_value
    … …  
    213214
    214215/**
    215  * {@internal Missing Short Description}}
    216  *
    217  * @since unknown
    218  *
    219  * @param unknown_type $url
    220  * @return unknown
     216 * Shorten an URL, to be used as link text
     217 *
     218 * @since 1.2.1
     219 *
     220 * @param string $url
     221 * @return string
    221222 */
    222223function url_shorten( $url ) {
    … …  
    237238 * if neither is defined.
    238239 *
    239  * @since unknown
     240 * @since 2.0.0
    240241 *
    241242 * @param array $vars An array of globals to reset.
    … …  
    260261 * {@internal Missing Short Description}}
    261262 *
    262  * @since unknown
     263 * @since 2.1.0
    263264 *
    264265 * @param unknown_type $message
    … …  
    344345                switch ( $map_option ) {
    345346                        case 'edit_per_page':
    346                         case 'ms_sites_per_page':
    347                         case 'ms_users_per_page':
     347                        case 'users_per_page':
    348348                        case 'edit_comments_per_page':
    349349                        case 'upload_per_page':
    350350                        case 'edit_tags_per_page':
    351351                        case 'plugins_per_page':
     352                        // Network admin
     353                        case 'sites_network_per_page':
     354                        case 'users_network_per_page':
     355                        case 'site_users_network_per_page':
     356                        case 'plugins_network_per_page':
     357                        case 'themes_network_per_page':
     358                        case 'site_themes_network_per_page':
    352359                                $value = (int) $value;
    353360                                if ( $value < 1 || $value > 999 )
    … …  
    373380                exit;
    374381        }
    375 }
    376 
    377 /**
    378  * Check if IIS 7 supports pretty permalinks
    379  *
    380  * @since 2.8.0
    381  *
    382  * @return bool
    383  */
    384 function iis7_supports_permalinks() {
    385         global $is_iis7;
    386 
    387         $supports_permalinks = false;
    388         if ( $is_iis7 ) {
    389                 /* First we check if the DOMDocument class exists. If it does not exist,
    390                  * which is the case for PHP 4.X, then we cannot easily update the xml configuration file,
    391                  * hence we just bail out and tell user that pretty permalinks cannot be used.
    392                  * This is not a big issue because PHP 4.X is going to be depricated and for IIS it
    393                  * is recommended to use PHP 5.X NTS.
    394                  * Next we check if the URL Rewrite Module 1.1 is loaded and enabled for the web site. When
    395                  * URL Rewrite 1.1 is loaded it always sets a server variable called 'IIS_UrlRewriteModule'.
    396                  * Lastly we make sure that PHP is running via FastCGI. This is important because if it runs
    397                  * via ISAPI then pretty permalinks will not work.
    398                  */
    399                 $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' );
    400         }
    401 
    402         return apply_filters('iis7_supports_permalinks', $supports_permalinks);
    403382}
    404383
    … …  
    562541 * @since 2.8.0
    563542 *
    564  * @param object $path
     543 * @param string $path
    565544 * @return bool
    566545 */
    567 function win_is_writable($path) {
     546function win_is_writable( $path ) {
    568547        /* will work in despite of Windows ACLs bug
    569548         * NOTE: use a trailing slash for folders!!!
    … …  
    572551         */
    573552
    574     if ( $path{strlen($path)-1} == '/' ) // recursively return a temporary file path
    575         return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
    576     else if ( is_dir($path) )
    577         return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp');
    578     // check tmp file for read/write capabilities
    579     $rm = file_exists($path);
    580     $f = @fopen($path, 'a');
    581     if ($f===false)
    582         return false;
    583     fclose($f);
    584     if ( ! $rm )
    585         unlink($path);
    586     return true;
     553        if ( $path[strlen( $path ) - 1] == '/' ) // recursively return a temporary file path
     554                return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp');
     555        else if ( is_dir( $path ) )
     556                return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' );
     557        // check tmp file for read/write capabilities
     558        $should_delete_tmp_file = !file_exists( $path );
     559        $f = @fopen( $path, 'a' );
     560        if ( $f === false )
     561                return false;
     562        fclose( $f );
     563        if ( $should_delete_tmp_file )
     564                unlink( $path );
     565        return true;
    587566}
    588567
Note: See TracChangeset for help on using the changeset viewer.