本文整理汇总了PHP中MOXMAN_Util_PathUtils::toUnixPath方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN_Util_PathUtils::toUnixPath方法的具体用法?PHP MOXMAN_Util_PathUtils::toUnixPath怎么用?PHP MOXMAN_Util_PathUtils::toUnixPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOXMAN_Util_PathUtils
的用法示例。
在下文中一共展示了MOXMAN_Util_PathUtils::toUnixPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verifyPath
/**
* Verifies the input path against various exploits and throws exceptions if one is found.
*
* @param String $path Path to verify.
* @param String $fileType File type to verify path against. Values: dir or file.
*/
public function verifyPath($path, $fileType = null)
{
// Verfiy that the path doesn't have any abnormalities
if (preg_match('/\\\\|\\.\\.\\/|[\\x00-\\x19]/', $path)) {
throw new MOXMAN_Exception("Specified path has invalid characters.");
}
$path = MOXMAN_Util_PathUtils::toUnixPath($path);
if (preg_match('~IIS/(\\d+\\.\\d+)~', $_SERVER['SERVER_SOFTWARE'], $matches)) {
$version = floatval($matches[1]);
if ($version < 7) {
if (strpos($path, ';') !== false) {
if ($this->getConfig()->get("filesystem.local.warn_semicolon", true)) {
throw new MOXMAN_Exception("IIS 6 doesn't support semicolon in paths for security reasons.", MOXMAN_Exception::INVALID_FILE_NAME);
}
}
if (preg_match('/\\.[^\\/]+\\//', $path) || $fileType == "dir" && strpos($path, '.') !== false) {
if ($this->getConfig()->get("filesystem.local.warn_dot_dirs", true)) {
throw new MOXMAN_Exception("IIS 6 don't support dots in directory names for security reasons.", MOXMAN_Exception::INVALID_FILE_NAME);
}
}
}
} else {
if (preg_match('/.(php|inc|php\\d+|phtml|php[st])\\.[^\\/]+/', $path)) {
if ($this->getConfig()->get("filesystem.local.warn_double_exts", true)) {
throw new MOXMAN_Exception("Double extensions is not allowed for security reasons.", MOXMAN_Exception::INVALID_FILE_NAME);
}
}
}
}
示例2: childPath
/**
* Sanitize a child path
*
* @param String $path String to check against.
* @return String Sanitized path according to rules.
*/
public static function childPath($path)
{
$path = MOXMAN_Util_PathUtils::toUnixPath($path);
$path = preg_replace('/[\\x00-\\x19?"|><];|:/', '', $path);
$pathExp = explode("/", $path);
$pathOut = array();
foreach ($pathExp as $exp) {
$exp = trim($exp);
if ($exp != "." && $exp != "..") {
$pathOut[] = $exp;
}
}
$path = implode("/", $pathOut);
$path = preg_replace("/\\/+/", '/', $path);
return $path;
}