本文整理汇总了PHP中Sanitize::filepath方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitize::filepath方法的具体用法?PHP Sanitize::filepath怎么用?PHP Sanitize::filepath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitize
的用法示例。
在下文中一共展示了Sanitize::filepath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public static function get($downloadURL, $savePath = "", $baseDir = false)
{
$fileContents = file_get_contents($downloadURL);
// Return false if the download was unsuccessful
if ($fileContents === false) {
return false;
}
// If you are attempting to save the file locally, run the save function
if ($savePath != "") {
$basePath = $baseDir == false ? SITE_PATH : dirname(SYS_PATH);
$savePath = Sanitize::filepath($savePath);
$savePath = ltrim($savePath, "/");
File::write($basePath . '/' . $savePath, $fileContents);
}
// Return the downloaded content
return $fileContents;
}
示例2: getConfig
public static function getConfig($class, $dir = "")
{
// Prepare Values
$class = Sanitize::variable($class);
$slashClass = str_replace("_", "/", $class);
$classConfig = $class . "_config";
// If a directory is provided, ONLY look through that directory for plugins
if ($dir !== "") {
$dir = rtrim(Sanitize::filepath($dir), "/");
$fullDir = $dir . "/" . $slashClass . "/" . $class . ".config.php";
if (is_file($fullDir)) {
// TODO: Eventually this needs to be resolved - all configs should use the new format.
if (!class_exists($classConfig)) {
$config = (require $fullDir);
if (is_array($config)) {
return $config;
}
}
$classConfig = new $classConfig();
$classConfig->data['path'] = $dir . "/" . $slashClass;
$classConfig->data['type'] = "???";
return $classConfig;
}
return false;
}
// Attempt to load an application class
$dir = APP_PATH . "/classes/" . $slashClass . "/" . $class . ".config.php";
if (is_file($dir)) {
if (!class_exists($classConfig)) {
$config = (require $dir);
if (is_array($config)) {
return $config;
}
}
$classConfig = new $classConfig();
$classConfig->data['path'] = APP_PATH . "/classes/" . $slashClass;
$classConfig->data['type'] = "app";
return $classConfig;
}
// Attempt to load a core class
$dir = SYS_PATH . "/core-classes/" . $slashClass . "/" . $class . ".config.php";
if (is_file($dir)) {
if (!class_exists($classConfig)) {
$config = (require $dir);
if (is_array($config)) {
return $config;
}
}
$classConfig = new $classConfig();
$classConfig->data['path'] = SYS_PATH . "/core-classes/" . $slashClass;
$classConfig->data['type'] = "core";
return $classConfig;
}
// Attempt to load a plugin class
$dir = SYS_PATH . "/plugin-classes/" . $slashClass . "/" . $class . ".config.php";
if (is_file($dir)) {
if (!class_exists($classConfig)) {
$config = (require $dir);
if (is_array($config)) {
return $config;
}
}
$classConfig = new $classConfig();
$classConfig->data['path'] = SYS_PATH . "/plugin-classes/" . $slashClass;
$classConfig->data['type'] = "addon";
return $classConfig;
}
return false;
}