当前位置: 首页>>代码示例>>PHP>>正文


PHP win_is_writable函数代码示例

本文整理汇总了PHP中win_is_writable函数的典型用法代码示例。如果您正苦于以下问题:PHP win_is_writable函数的具体用法?PHP win_is_writable怎么用?PHP win_is_writable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了win_is_writable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: aletheme_activation_is_config_writable

 function aletheme_activation_is_config_writable()
 {
     $home_path = get_home_path();
     $iis7_permalinks = iis7_supports_permalinks();
     if ($iis7_permalinks) {
         if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
             $config_writable = true;
         } else {
             $config_writable = false;
         }
     } else {
         if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
             $config_writable = true;
         } else {
             $config_writable = false;
         }
     }
     return $config_writable;
 }
开发者ID:BMNTeam,项目名称:myFirstThemeToTf,代码行数:19,代码来源:activation.php

示例2: modify_permalinks

function modify_permalinks($permalink_structure, $page_structure)
{
    require_once ABSPATH . 'wp-admin/includes/file.php';
    require_once ABSPATH . 'wp-admin/includes/misc.php';
    global $wp_rewrite;
    # set the structure
    $wp_rewrite->set_permalink_structure($permalink_structure);
    $wp_rewrite->page_structure = $page_structure;
    # get paths
    $home_path = get_home_path();
    $iis7_permalinks = iis7_supports_permalinks();
    # check if there is a file to rewrite
    if ($iis7_permalinks) {
        $writable = !file_exists($home_path . 'web.config') && win_is_writable($home_path);
        $writable = $writable || win_is_writable($home_path . 'web.config');
    } else {
        $writable = !file_exists($home_path . '.htaccess') && is_writable($home_path);
        $writable = $writable || is_writable($home_path . '.htaccess');
    }
    # flush the rules
    update_option('rewrite_rules', FALSE);
    $wp_rewrite->flush_rules($writable);
}
开发者ID:andresmatasuarez,项目名称:jedbangers-web,代码行数:23,代码来源:set_permalinks.php

示例3: cleanup

 /**
  * Clean up dead files older than given length of time.
  *
  * @param int $minutes Consider older files than this time as dead files
  * @return int|bool The number of removed files. Return false if error occurred.
  */
 function cleanup($minutes = 60)
 {
     $dir = trailingslashit($this->tmp_dir);
     if (!@is_dir($dir) || !@is_readable($dir)) {
         return false;
     }
     $is_win = 'WIN' === strtoupper(substr(PHP_OS, 0, 3));
     if (!($is_win ? win_is_writable($dir) : @is_writable($dir))) {
         return false;
     }
     $count = 0;
     if ($handle = @opendir($dir)) {
         while (false !== ($filename = readdir($handle))) {
             if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $filename)) {
                 continue;
             }
             $file = $dir . $filename;
             $stat = @stat($file);
             if ($stat['mtime'] + $minutes * 60 < time()) {
                 @unlink($file);
                 $count += 1;
             }
         }
         closedir($handle);
     }
     return $count;
 }
开发者ID:kristinakarnitskaya,项目名称:larkyonline,代码行数:33,代码来源:really-simple-captcha.php

示例4: win_is_writable

/**
 * Workaround for Windows bug in is_writable() function
 *
 * PHP has issues with Windows ACL's for determine if a
 * directory is writable or not, this works around them by
 * checking the ability to open files rather than relying
 * upon PHP to interprate the OS ACL.
 *
 * @since 2.8.0
 *
 * @see http://bugs.php.net/bug.php?id=27609
 * @see http://bugs.php.net/bug.php?id=30931
 *
 * @param string $path Windows path to check for write-ability.
 * @return bool Whether the path is writable.
 */
function win_is_writable($path)
{
    if ($path[strlen($path) - 1] == '/') {
        // if it looks like a directory, check a random file within the directory
        return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
    } elseif (is_dir($path)) {
        // If it's a directory (and not a file) check a random file within the directory
        return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp');
    }
    // check tmp file for read/write capabilities
    $should_delete_tmp_file = !file_exists($path);
    $f = @fopen($path, 'a');
    if ($f === false) {
        return false;
    }
    fclose($f);
    if ($should_delete_tmp_file) {
        unlink($path);
    }
    return true;
}
开发者ID:hpilevar,项目名称:WordPress,代码行数:37,代码来源:functions.php

示例5: preg_replace

    if (isset($_POST['tag_base'])) {
        $tag_base = $_POST['tag_base'];
        if (!empty($tag_base)) {
            $tag_base = $blog_prefix . preg_replace('#/+#', '/', '/' . str_replace('#', '', $tag_base));
        }
        $wp_rewrite->set_tag_base($tag_base);
    }
    wp_redirect(admin_url('options-permalink.php?settings-updated=true'));
    exit;
}
$permalink_structure = get_option('permalink_structure');
$category_base = get_option('category_base');
$tag_base = get_option('tag_base');
$update_required = false;
if ($iis7_permalinks) {
    if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
        $writable = true;
    } else {
        $writable = false;
    }
} elseif ($is_nginx) {
    $writable = false;
} else {
    if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
        $writable = true;
    } else {
        $writable = false;
        $existing_rules = array_filter(extract_from_markers($home_path . '.htaccess', 'WordPress'));
        $new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules()));
        $update_required = $new_rules !== $existing_rules;
    }
开发者ID:nmeiser,项目名称:WordPress,代码行数:31,代码来源:options-permalink.php

示例6: iis7_save_url_rewrite_rules

/**
 * Updates the IIS web.config file with the current rules if it is writable.
 * If the permalinks do not require rewrite rules then the rules are deleted from the web.config file.
 *
 * @since 2.8.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @return bool True if web.config was updated successfully
 */
function iis7_save_url_rewrite_rules()
{
    if (is_multisite()) {
        return;
    }
    global $wp_rewrite;
    $home_path = get_home_path();
    $web_config_file = $home_path . 'web.config';
    // Using win_is_writable() instead of is_writable() because of a bug in Windows PHP
    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))) {
        $rule = $wp_rewrite->iis7_url_rewrite_rules(false, '', '');
        if (!empty($rule)) {
            return iis7_add_rewrite_rule($web_config_file, $rule);
        } else {
            return iis7_delete_rewrite_rule($web_config_file);
        }
    }
    return false;
}
开发者ID:akalipetis,项目名称:WordPress,代码行数:29,代码来源:misc.php

示例7: wp_is_writable

 /**
  * Determine if a directory is writable.
  *
  * This function is used to work around certain ACL issues
  * in PHP primarily affecting Windows Servers.
  *
  * @see win_is_writable()
  *
  * @since 3.6.0
  *
  * @param string $path
  * @return bool
  */
 function wp_is_writable($path)
 {
     if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
         return win_is_writable($path);
     } else {
         return @is_writable($path);
     }
 }
开发者ID:Balamir,项目名称:Easy-Digital-Downloads,代码行数:21,代码来源:upload-functions.php

示例8: step_permalinks_save

    function step_permalinks_save()
    {
        global $nxt_rewrite, $current_site, $current_blog;
        // Prevent debug notices
        $iis7_permalinks = $usingpi = $writable = false;
        if (isset($_POST['submit'])) {
            check_admin_referer('bpwizard_permalinks');
            $home_path = get_home_path();
            $iis7_permalinks = iis7_supports_permalinks();
            if (isset($_POST['permalink_structure'])) {
                $permalink_structure = $_POST['permalink_structure'];
                if (!empty($permalink_structure)) {
                    $permalink_structure = preg_replace('#/+#', '/', '/' . $_POST['permalink_structure']);
                }
                if (defined('VHOST') && constant('VHOST') == 'no' && $permalink_structure != '' && $current_site->domain . $current_site->path == $current_blog->domain . $current_blog->path) {
                    $permalink_structure = '/blog' . $permalink_structure;
                }
                $nxt_rewrite->set_permalink_structure($permalink_structure);
            }
            if (!empty($iis7_permalinks)) {
                if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
                    $writable = true;
                }
            } else {
                if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
                    $writable = true;
                }
            }
            if ($nxt_rewrite->using_index_permalinks()) {
                $usingpi = true;
            }
            $nxt_rewrite->flush_rules();
            if (!empty($iis7_permalinks) || empty($usingpi) && empty($writable)) {
                function _bp_core_wizard_step_permalinks_message()
                {
                    global $nxt_rewrite;
                    ?>

					<div id="message" class="updated fade"><p>

						<?php 
                    _e('Oops, there was a problem creating a configuration file. ', 'buddypress');
                    if (!empty($iis7_permalinks)) {
                        if (!empty($permalink_structure) && empty($usingpi) && empty($writable)) {
                            _e('If your <code>web.config</code> file were <a href="http://codex.nxtclass.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;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>/&lt;configuration&gt;/&lt;system.webServer&gt;/&lt;rewrite&gt;/&lt;rules&gt;</code> element in <code>web.config</code> file.');
                            ?>

									<br /><br />

									<textarea rows="9" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php 
                            echo esc_html($nxt_rewrite->iis7_url_rewrite_rules());
                            ?>
</textarea>

								<?php 
                        } else {
                            if (!empty($permalink_structure) && empty($usingpi) && !empty($writable)) {
                            }
                        }
                        _e('Permalink structure updated. Remove write access on web.config file now!');
                    } else {
                        _e('If your <code>.htaccess</code> file were <a href="http://codex.nxtclass.org/Changing_File_Permissions">writable</a>, we could do this automatically, but it isn&#8217;t so these are the mod_rewrite rules you should have in your <code>.htaccess</code> file. Click in the field and press <kbd>CTRL + a</kbd> to select all.');
                        ?>

								<br /><br />

								<textarea rows="6" class="large-text readonly" style="background: #fff;" name="rules" id="rules" readonly="readonly"><?php 
                        echo esc_html($nxt_rewrite->mod_rewrite_rules());
                        ?>
</textarea>

							<?php 
                    }
                    ?>

						<br /><br />

						<?php 
                    if (empty($iis7_permalinks)) {
                        _e('Paste all these rules into a new <code>.htaccess</code> file in the root of your NXTClass installation and save the file. Once you\'re done, please hit the "Save and Next" button to continue.', 'buddypress');
                    }
                    ?>

					</p></div>

				<?php 
                }
                if ('post' == strtolower($_SERVER['REQUEST_METHOD']) && !empty($_POST['skip-htaccess'])) {
                    return true;
                } else {
                    add_action('bp_admin_notices', '_bp_core_wizard_step_permalinks_message');
                    return false;
                }
            }
            return true;
        }
        return false;
    }
开发者ID:nxtclass,项目名称:NXTClass-Plugin,代码行数:98,代码来源:bp-core-update.php

示例9: win_is_writable

/**
 * Workaround for Windows bug in is_writable() function
 *
 * @since 2.8.0
 *
 * @param object $path
 * @return bool
 */
function win_is_writable($path) {
	/* will work in despite of Windows ACLs bug
	 * NOTE: use a trailing slash for folders!!!
	 * see http://bugs.php.net/bug.php?id=27609
	 * see http://bugs.php.net/bug.php?id=30931
	 */

    if ( $path{strlen($path)-1} == '/' ) // recursively return a temporary file path
        return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
    else if ( is_dir($path) )
        return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp');
    // check tmp file for read/write capabilities
    $rm = file_exists($path);
    $f = @fopen($path, 'a');
    if ($f===false)
        return false;
    fclose($f);
    if ( ! $rm )
        unlink($path);
    return true;
}
开发者ID:staylor,项目名称:develop.svn.wordpress.org,代码行数:29,代码来源:misc.php

示例10: win_is_writable

/**
 * Workaround for Windows bug in is_writable() function
 *
 * @since 2.8.0
 *
 * @param string $path
 * @return bool
 */
function win_is_writable($path)
{
    /* will work in despite of Windows ACLs bug
     * NOTE: use a trailing slash for folders!!!
     * see http://bugs.php.net/bug.php?id=27609
     * see http://bugs.php.net/bug.php?id=30931
     */
    if ($path[strlen($path) - 1] == '/') {
        // recursively return a temporary file path
        return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
    } else {
        if (is_dir($path)) {
            return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp');
        }
    }
    // check tmp file for read/write capabilities
    $should_delete_tmp_file = !file_exists($path);
    $f = @fopen($path, 'a');
    if ($f === false) {
        return false;
    }
    fclose($f);
    if ($should_delete_tmp_file) {
        unlink($path);
    }
    return true;
}
开发者ID:liangwei1988,项目名称:wordpress,代码行数:35,代码来源:functions.php

示例11: _disable_wincache_ocache

 /**
  * Disable wincache's opcode cache
  * @return void
  */
 protected function _disable_wincache_ocache()
 {
     global $is_iis7;
     if (version_compare(PHP_VERSION, '5.3.0') >= 0 && $is_iis7 && function_exists('wincache_ucache_add')) {
         $file = trailingslashit(ABSPATH) . 'php5.ini';
         if (!file_exists($file) || win_is_writable($file)) {
             $directives = array();
             if (file_exists($file)) {
                 $directives = parse_ini_file($file);
             }
             unset($directives['wincache.ocenabled']);
             $this->_write_ini_file($file, $directives);
         }
     }
 }
开发者ID:uniquegel,项目名称:Feminnova,代码行数:19,代码来源:welcome-to-wordpress.php

示例12: regenerate_htaccess_file

 public static function regenerate_htaccess_file()
 {
     if (!function_exists('save_mod_rewrite_rules')) {
         if (!function_exists('mysql2date')) {
             require ABSPATH . '/wp-includes/functions.php';
         }
         if (!function_exists('get_home_path')) {
             require ABSPATH . '/wp-admin/includes/file.php';
         }
         require ABSPATH . '/wp-admin/includes/misc.php';
     }
     global $is_nginx, $wp_rewrite;
     $home_path = get_home_path();
     $htaccess_file = $home_path . '.htaccess';
     if (file_exists($htaccess_file)) {
         unlink($htaccess_file);
     }
     $home_path = get_home_path();
     $iis7_permalinks = iis7_supports_permalinks();
     $prefix = $blog_prefix = '';
     if (!got_url_rewrite()) {
         $prefix = '/index.php';
     }
     if (is_multisite() && !is_subdomain_install() && is_main_site()) {
         $blog_prefix = '/blog';
     }
     $permalink_structure = get_option('permalink_structure');
     $category_base = get_option('category_base');
     $tag_base = get_option('tag_base');
     $update_required = false;
     if ($iis7_permalinks) {
         if (!file_exists($home_path . 'web.config') && win_is_writable($home_path) || win_is_writable($home_path . 'web.config')) {
             $writable = true;
         } else {
             $writable = false;
         }
     } elseif ($is_nginx) {
         $writable = false;
     } else {
         if (!file_exists($home_path . '.htaccess') && is_writable($home_path) || is_writable($home_path . '.htaccess')) {
             $writable = true;
         } else {
             $writable = false;
             $existing_rules = array_filter(extract_from_markers($home_path . '.htaccess', 'WordPress'));
             $new_rules = array_filter(explode("\n", $wp_rewrite->mod_rewrite_rules()));
             $update_required = $new_rules !== $existing_rules;
         }
     }
     if ($wp_rewrite->using_index_permalinks()) {
         $usingpi = true;
     } else {
         $usingpi = false;
     }
     flush_rewrite_rules();
     save_mod_rewrite_rules();
 }
开发者ID:sb-xs,项目名称:que-pour-elle,代码行数:56,代码来源:class-sb-core.php

示例13: cleanup_expired

 public function cleanup_expired($minutes = 60)
 {
     $dir = trailingslashit($this->get_save_path());
     $dir = wp_normalize_path($dir);
     if (!@is_dir($dir) || !@is_readable($dir)) {
         return false;
     }
     $is_win = 'WIN' === strtoupper(substr(PHP_OS, 0, 3));
     if (!($is_win ? win_is_writable($dir) : @is_writable($dir))) {
         return false;
     }
     hocwp_delete_old_file($dir, $minutes * MINUTE_IN_SECONDS);
     $count = 0;
     if ($handle = @opendir($dir)) {
         while (false !== ($filename = readdir($handle))) {
             if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $filename)) {
                 continue;
             }
             $file = wp_normalize_path($dir . $filename);
             $stat = @stat($file);
             if ($stat['mtime'] + $minutes * MINUTE_IN_SECONDS < time()) {
                 @unlink($file);
                 $count += 1;
             }
         }
         closedir($handle);
     }
     return $count;
 }
开发者ID:skylarkcob,项目名称:hocwp-projects,代码行数:29,代码来源:class-hocwp-captcha.php

示例14: cleanup

 /**
  * Clean up dead files older than given length of time.
  *
  * @param int $minutes Consider older files than this time as dead files
  * @return int|bool The number of removed files. Return false if error occurred.
  */
 public function cleanup($minutes = 60)
 {
     $dir = trailingslashit($this->tmp_dir);
     $dir = wp_normalize_path($dir);
     if (!@is_dir($dir) || !@is_readable($dir)) {
         return false;
     }
     if (!($this->is_win() ? win_is_writable($dir) : @is_writable($dir))) {
         return false;
     }
     $count = 0;
     if ($handle = @opendir($dir)) {
         while (false !== ($filename = readdir($handle))) {
             if (!preg_match('/^[0-9]+\\.(php|txt|png|gif|jpeg)$/', $filename)) {
                 continue;
             }
             $file = wp_normalize_path($dir . $filename);
             $stat = @stat($file);
             if ($stat['mtime'] + $minutes * 60 < time()) {
                 @unlink($file);
                 $count += 1;
             }
         }
         closedir($handle);
     }
     return $count;
 }
开发者ID:interfisch,项目名称:lm,代码行数:33,代码来源:swifty-captcha.php

示例15: win_is_writable

 /**
  * win_is_writable function lifted from WordPress
  * @param $path
  * @return bool
  */
 private function win_is_writable($path)
 {
     if ($path[strlen($path) - 1] == '/') {
         return win_is_writable($path . uniqid(mt_rand()) . '.tmp');
     } else {
         if (is_dir($path)) {
             return win_is_writable($path . '/' . uniqid(mt_rand()) . '.tmp');
         }
     }
     $should_delete_tmp_file = !file_exists($path);
     $f = @fopen($path, 'a');
     if ($f === false) {
         return false;
     }
     fclose($f);
     if ($should_delete_tmp_file) {
         unlink($path);
     }
     return true;
 }
开发者ID:bself,项目名称:nuimage-wp,代码行数:25,代码来源:SmackCSVLogger.php


注:本文中的win_is_writable函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。