Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r17328 r15263  
    1010 * {@internal Missing Short Description}}
    1111 *
    12  * @since 2.0.0
     12 * @since unknown
    1313 *
    1414 * @return unknown
     
    2222 * {@internal Missing Short Description}}
    2323 *
    24  * @since 1.5.0
     24 * @since unknown
    2525 *
    2626 * @param unknown_type $filename
     
    5858 * data. Creates file if none exists.
    5959 *
    60  * @since 1.5.0
     60 * @since unknown
    6161 *
    6262 * @param unknown_type $filename
     
    118118 * blank out old rules.
    119119 *
    120  * @since 1.5.0
     120 * @since unknown
    121121 */
    122122function save_mod_rewrite_rules() {
     
    150150 */
    151151function iis7_save_url_rewrite_rules(){
    152     if ( is_multisite() )
    153         return;
    154 
    155152    global $wp_rewrite;
    156153
     
    159156
    160157    // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
    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);
     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            }
    167166        }
    168167    }
     
    173172 * {@internal Missing Short Description}}
    174173 *
    175  * @since 1.5.0
     174 * @since unknown
    176175 *
    177176 * @param unknown_type $file
     
    195194 * If siteurl or home changed, flush rewrite rules.
    196195 *
    197  * @since 2.1.0
     196 * @since unknown
    198197 *
    199198 * @param unknown_type $old_value
     
    214213
    215214/**
    216  * Shorten an URL, to be used as link text
    217  *
    218  * @since 1.2.1
    219  *
    220  * @param string $url
    221  * @return string
     215 * {@internal Missing Short Description}}
     216 *
     217 * @since unknown
     218 *
     219 * @param unknown_type $url
     220 * @return unknown
    222221 */
    223222function url_shorten( $url ) {
     
    238237 * if neither is defined.
    239238 *
    240  * @since 2.0.0
     239 * @since unknown
    241240 *
    242241 * @param array $vars An array of globals to reset.
     
    261260 * {@internal Missing Short Description}}
    262261 *
    263  * @since 2.1.0
     262 * @since unknown
    264263 *
    265264 * @param unknown_type $message
     
    345344        switch ( $map_option ) {
    346345            case 'edit_per_page':
    347             case 'users_per_page':
     346            case 'ms_sites_per_page':
     347            case 'ms_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':
    359352                $value = (int) $value;
    360353                if ( $value < 1 || $value > 999 )
     
    380373        exit;
    381374    }
     375}
     376
     377/**
     378 * Check if IIS 7 supports pretty permalinks
     379 *
     380 * @since 2.8.0
     381 *
     382 * @return bool
     383 */
     384function 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);
    382403}
    383404
     
    541562 * @since 2.8.0
    542563 *
    543  * @param string $path
     564 * @param object $path
    544565 * @return bool
    545566 */
    546 function win_is_writable( $path ) {
     567function win_is_writable($path) {
    547568    /* will work in despite of Windows ACLs bug
    548569     * NOTE: use a trailing slash for folders!!!
     
    551572     */
    552573
    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;
     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;
    566587}
    567588
Note: See TracChangeset for help on using the changeset viewer.