在windows中运行ionize的FileManager插件,会提示缺少fnmatch()函数的定义,我们可以在/application/libraries/FileManager/Tooling.php文件的顶部加上fnmatch()在windows平台的实现代码:
- <?php
-
-
if (!function_exists('fnmatch')) {
-
define('FNM_PATHNAME', 1);
-
define('FNM_NOESCAPE', 2);
-
define('FNM_PERIOD', 4);
-
define('FNM_CASEFOLD', 16);
-
-
function fnmatch($pattern, $string, $flags = 0) {
-
return pcre_fnmatch($pattern, $string, $flags);
-
}
-
}
-
-
function pcre_fnmatch($pattern, $string, $flags = 0) {
-
$modifiers = null;
-
$transforms = array(
-
'\*' => '.*',
-
'\?' => '.',
-
'\[\!' => '[^',
-
'\[' => '[',
-
'\]' => ']',
-
'\.' => '\.',
-
'\\' => '\\\\'
-
);
-
-
// Forward slash in string must be in pattern:
-
if ($flags & FNM_PATHNAME) {
-
$transforms['\*'] = '[^/]*';
-
}
-
-
// Back slash should not be escaped:
-
if ($flags & FNM_NOESCAPE) {
-
unset($transforms['\\']);
-
}
-
-
// Perform case insensitive match:
-
if ($flags & FNM_CASEFOLD) {
-
$modifiers .= 'i';
-
}
-
-
// Period at start must be the same as pattern:
-
if ($flags & FNM_PERIOD) {
-
if (strpos($string, '.') === 0 && strpos($pattern, '.') !== 0) return false;
-
}
-
-
$pattern = '#^'
-
. strtr(preg_quote($pattern, '#'), $transforms)
-
. '$#'
-
. $modifiers;
-
-
return (boolean)preg_match($pattern, $string);
-
}
阅读(1163) | 评论(0) | 转发(0) |