本文整理汇总了PHP中MOXMAN_Util_PathUtils::isChildOf方法的典型用法代码示例。如果您正苦于以下问题:PHP MOXMAN_Util_PathUtils::isChildOf方法的具体用法?PHP MOXMAN_Util_PathUtils::isChildOf怎么用?PHP MOXMAN_Util_PathUtils::isChildOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MOXMAN_Util_PathUtils
的用法示例。
在下文中一共展示了MOXMAN_Util_PathUtils::isChildOf方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFile
/**
* Returns a file object out of the specified URL.
*
* @param string Absolute URL for the specified file.
* @return MOXMAN_Vfs_IFile File that got resolved or null if it wasn't found.
*/
public function getFile($url)
{
$prefix = "http://memory";
$file = null;
if (strpos($url, $prefix) === 0) {
$filePath = substr($url, strlen($prefix));
if (MOXMAN_Util_PathUtils::isChildOf($filePath, $this->fileSystem->getRootPath())) {
return $this->fileSystem->getFile($filePath);
}
}
return $file;
}
示例2: getFile
/**
* Returns a MOXMAN_Vfs_IFile instance based on the specified path.
*
* @param string $path Path of the file to retrive.
* @return MOXMAN_Vfs_IFile File instance for the specified path.
*/
public function getFile($path)
{
// Never give access to the mc_access file
if ($this->getConfig()->get("filesystem.local.access_file_name") === basename($path)) {
throw new MOXMAN_Exception("Can't access the access_file_name.");
}
$this->verifyPath($path);
// Force the path to an absolute path
$path = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $path);
// If the path is out side the root then return null
if (!MOXMAN_Util_PathUtils::isChildOf($path, $this->rootPath)) {
$null = null;
return $null;
}
return new MOXMAN_Vfs_Local_File($this, $path);
}
示例3: getFile
/**
* Returns a file object out of the specified URL.
*
* @param string Absolute URL for the specified file.
* @return MOXMAN_Vfs_IFile File that got resolved or null if it wasn't found.
*/
public function getFile($url)
{
$file = null;
$prefix = $this->fileSystem->getBucketOption("urlprefix");
$prefix = preg_replace('/^https?:\\/\\//', '//', $prefix);
$url = preg_replace('/^https?:\\/\\//', '//', $url);
if (strpos($url, $prefix) === 0) {
$bucketKey = $this->fileSystem->getBucketOption("key");
$path = urldecode(substr($url, strlen($prefix)));
$filePath = MOXMAN_Util_PathUtils::combine("s3://" . $bucketKey, $path);
if (MOXMAN_Util_PathUtils::isChildOf($filePath, $this->fileSystem->getRootPath())) {
return $this->fileSystem->getFile($filePath);
}
}
return $file;
}
示例4: getFile
/**
* Returns a file object out of the specified URL.
*
* @param string Absolute URL for the specified file.
* @return MOXMAN_Vfs_IFile File that got resolved or null if it wasn't found.
*/
public function getFile($url)
{
$config = $this->fileSystem->getConfig();
$file = null;
// Get config items
$wwwroot = $config->get("filesystem.local.wwwroot");
$prefix = $config->get("filesystem.local.urlprefix");
$paths = MOXMAN_Util_PathUtils::getSitePaths();
// No wwwroot specified try to figure out a wwwroot
if (!$wwwroot) {
$wwwroot = $paths["wwwroot"];
} else {
// Force the www root to an absolute file system path
$wwwroot = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $wwwroot);
}
// Add prefix to URL
if ($prefix == "") {
$prefix = MOXMAN_Util_PathUtils::combine("{proto}://{host}", $paths["prefix"]);
}
// Replace protocol
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
$prefix = str_replace("{proto}", "https", $prefix);
} else {
$prefix = str_replace("{proto}", "http", $prefix);
}
// Replace host/port
$prefix = str_replace("{host}", $_SERVER['HTTP_HOST'], $prefix);
$prefix = str_replace("{port}", $_SERVER['SERVER_PORT'], $prefix);
// Remove prefix from url
if ($prefix && strpos($url, $prefix) === 0) {
$url = substr($url, strlen($prefix));
}
// Parse url and check if path part of the URL is within the root of the file system
$url = parse_url($url);
if (isset($url["path"])) {
$path = MOXMAN_Util_PathUtils::combine($wwwroot, $url["path"]);
if (MOXMAN_Util_PathUtils::isChildOf($path, $this->fileSystem->getRootPath())) {
// Crop away root path part and glue it back on again since the case might be different
// For example: c:/inetpub/wwwroot and C:/InetPub/WWWRoot this will force it into the
// valid fileSystem root path prefix
$path = substr($path, strlen($this->fileSystem->getRootPath()));
$path = MOXMAN_Util_PathUtils::combine($this->fileSystem->getRootPath(), $path);
$file = $this->fileSystem->getFile($path);
}
}
return $file;
}
示例5: getFile
/**
* Returns a MOXMAN_Vfs_IFile instance based on the specified path.
*
* @param string $path Path of the file to retrive.
* @return MOXMAN_Vfs_IFile File instance for the specified path.
*/
public function getFile($path)
{
// Get file from cache
if ($this->cache->has($path)) {
return $this->cache->get($path);
}
// Never give access to the mc_access file
if ($this->getConfig()->get("filesystem.local.access_file_name") === basename($path)) {
throw new MOXMAN_Exception("Can't access the access_file_name.");
}
MOXMAN_Util_PathUtils::verifyPath($path, true);
// Force the path to an absolute path
$path = MOXMAN_Util_PathUtils::toAbsolute(MOXMAN_ROOT, $path);
// If the path is out side the root then return null
if (!MOXMAN_Util_PathUtils::isChildOf($path, $this->rootPath)) {
$null = null;
return $null;
}
// Create the file and put it in the cache
$file = new MOXMAN_Vfs_Local_File($this, $path);
$this->cache->put($path, $file);
return $file;
}
示例6: getUrl
public function getUrl()
{
$url = "";
$fileSystem = $this->getFileSystem();
$wwwroot = $fileSystem->getAccountItem("wwwroot");
$path = $this->getInternalPath();
// Resolve ftp path to url
if ($wwwroot) {
if (MOXMAN_Util_PathUtils::isChildOf($path, $wwwroot)) {
// Get config items
$prefix = $fileSystem->getAccountItem("prefix", "{proto}://{host}");
$suffix = $fileSystem->getAccountItem("urlsuffix");
// Replace protocol
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == "on") {
$prefix = str_replace("{proto}", "https", $prefix);
} else {
$prefix = str_replace("{proto}", "http", $prefix);
}
// Replace host/port
$prefix = str_replace("{host}", $fileSystem->getAccountItem("host"), $prefix);
$prefix = str_replace("{port}", $_SERVER['SERVER_PORT'], $prefix);
// Insert path into URL
$url = substr($path, strlen($wwwroot));
// Add prefix to URL
if ($prefix) {
$url = MOXMAN_Util_PathUtils::combine($prefix, $url);
}
// Add suffix to URL
if ($suffix) {
$url .= $suffix;
}
} else {
throw new MOXMAN_Exception("Ftp path is not within wwwroot path.");
}
}
return $url;
}
示例7: getParent
/**
* Returns the parent files absolute path or an empty string if there is no parent.
*
* @return String parent files absolute path.
*/
public function getParent()
{
$path = MOXMAN_Util_PathUtils::getParent($this->getPath());
// If path is out side the file systems root path
if (!MOXMAN_Util_PathUtils::isChildOf($path, $this->fileSystem->getRootPath())) {
return "";
}
return $path;
}
示例8: copyTo
/**
* Copies this file to the specified file instance.
*
* @param MOXMAN_Vfs_IFile $dest File to copy to.
*/
public function copyTo(MOXMAN_Vfs_IFile $dest)
{
if (!$this->exists()) {
throw new Exception("Source file doesn't exist: " . $dest->getPublicPath());
}
if (MOXMAN_Util_PathUtils::isChildOf($dest->getPath(), $this->getPath())) {
throw new Exception("You can't copy the file into it self.");
}
// File copy or dir copy
if ($this->isFile()) {
if ($dest instanceof MOXMAN_Vfs_Local_File) {
copy($this->internalPath, $this->fromUtf($dest->getPath()));
} else {
// Copy between file systems
$in = $this->open(MOXMAN_Vfs_IFileStream::READ);
$out = $dest->open(MOXMAN_Vfs_IFileStream::WRITE);
// Stream in file to out file
while (($data = $in->read()) !== "") {
$out->write($data);
}
$in->close();
$out->close();
}
} else {
// Copy dir to dir
$this->copyDir($this, $dest);
}
}
示例9: execute
/**
* Executes the command logic with the specified RPC parameters.
*
* @param Object $params Command parameters sent from client.
* @return Object Result object to be passed back to client.
*/
public function execute($params)
{
$url = isset($params->url) ? $params->url : "";
$path = isset($params->path) ? $params->path : "{default}";
$rootPath = isset($params->rootpath) ? $params->rootpath : "";
$lastPath = isset($params->lastPath) ? $params->lastPath : "";
$offset = isset($params->offset) ? $params->offset : 0;
$length = isset($params->length) ? $params->length : null;
$orderBy = isset($params->orderBy) ? $params->orderBy : "name";
$desc = isset($params->desc) ? $params->desc : false;
// Result URL to closest file
$file = null;
if ($url) {
try {
$file = MOXMAN::getFile($url);
if ($file && !MOXMAN_Util_PathUtils::isChildOf($file->getPublicPath(), $rootPath)) {
$file = null;
}
} catch (MOXMAN_Exception $e) {
// Might throw exception ignore it
$file = null;
}
if ($file) {
if ($file->exists()) {
$urlFile = $file;
}
while (!$file->exists() || !$file->isDirectory()) {
$file = $file->getParentFile();
}
}
}
if ($rootPath) {
if (!MOXMAN_Util_PathUtils::isChildOf($path, $rootPath)) {
$path = $rootPath;
}
if (!MOXMAN_Util_PathUtils::isChildOf($lastPath, $rootPath)) {
$lastPath = null;
}
}
// Resolve lastPath input
if ($lastPath && !$file) {
try {
$file = MOXMAN::getFile($lastPath);
} catch (MOXMAN_Exception $e) {
// Might throw exception ignore it
$file = null;
}
if ($file) {
while (!$file->exists() || !$file->isDirectory()) {
$file = $file->getParentFile();
}
}
}
$file = $file ? $file : MOXMAN::getFile($path);
// Force update on cached file info
if (isset($params->force) && $params->force) {
MOXMAN_Vfs_Cache_FileInfoStorage::getInstance()->updateFileList($file);
}
if (!$file->isDirectory()) {
throw new MOXMAN_Exception("Path isn't a directory: " . $file->getPublicPath(), MOXMAN_Exception::INVALID_FILE_TYPE);
}
$config = $file->getConfig();
// Setup input file filter
$paramsFileFilter = new MOXMAN_Vfs_BasicFileFilter();
if (isset($params->include_directory_pattern) && $params->include_directory_pattern) {
$paramsFileFilter->setIncludeDirectoryPattern($params->include_directory_pattern);
}
if (isset($params->exclude_directory_pattern) && $params->exclude_directory_pattern) {
$paramsFileFilter->setExcludeDirectoryPattern($params->exclude_directory_pattern);
}
if (isset($params->include_file_pattern) && $params->include_file_pattern) {
$paramsFileFilter->setIncludeFilePattern($params->include_file_pattern);
}
if (isset($params->exclude_file_pattern) && $params->exclude_file_pattern) {
$paramsFileFilter->setExcludeFilePattern($params->exclude_file_pattern);
}
if (isset($params->extensions) && $params->extensions) {
$paramsFileFilter->setIncludeExtensions($params->extensions);
}
if (isset($params->filter) && $params->filter != null) {
$paramsFileFilter->setIncludeWildcardPattern($params->filter);
}
if (isset($params->only_dirs) && $params->only_dirs === true) {
$paramsFileFilter->setOnlyDirs(true);
}
if (isset($params->only_files) && $params->only_files === true) {
$paramsFileFilter->setOnlyFiles(true);
}
// Setup file filter
$configuredFilter = new MOXMAN_Vfs_BasicFileFilter();
$configuredFilter->setIncludeDirectoryPattern($config->get('filesystem.include_directory_pattern'));
$configuredFilter->setExcludeDirectoryPattern($config->get('filesystem.exclude_directory_pattern'));
$configuredFilter->setIncludeFilePattern($config->get('filesystem.include_file_pattern'));
$configuredFilter->setExcludeFilePattern($config->get('filesystem.exclude_file_pattern'));
//.........这里部分代码省略.........