本文整理汇总了PHP中dir::isWritable方法的典型用法代码示例。如果您正苦于以下问题:PHP dir::isWritable方法的具体用法?PHP dir::isWritable怎么用?PHP dir::isWritable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dir
的用法示例。
在下文中一共展示了dir::isWritable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: minify
public function minify($cacheFile = null, $dir = null)
{
if ($dir === null) {
$dir = dirname($_SERVER['SCRIPT_FILENAME']);
}
// MODIFICATION TIME FILES
$mtFiles = array(__FILE__, $_SERVER['SCRIPT_FILENAME'], "conf/config.php");
// GET SOURCE CODE FILES
$files = dir::content($dir, array('types' => "file", 'pattern' => '/^.*\\.' . $this->type . '$/'));
// GET NEWEST MODIFICATION TIME
$mtime = 0;
foreach (array_merge($mtFiles, $files) as $file) {
$fmtime = filemtime($file);
if ($fmtime > $mtime) {
$mtime = $fmtime;
}
}
$header = "Content-Type: {$this->mime[$this->type]}";
// GET SOURCE CODE FROM CLIENT HTTP CACHE IF EXISTS
httpCache::checkMTime($mtime, $header);
// OUTPUT SOURCE CODE
header($header);
// GET SOURCE CODE FROM SERVER-SIDE CACHE
if ($cacheFile !== null && file_exists($cacheFile) && (filemtime($cacheFile) >= $mtime || !is_writable($cacheFile))) {
// with its distribution content
readfile($cacheFile);
die;
}
// MINIFY AND JOIN SOURCE CODE
$source = "";
foreach ($files as $file) {
if (strlen($this->minCmd) && substr($file, 4, 1) != "_") {
$cmd = str_replace("{file}", $file, $this->minCmd);
$source .= `{$cmd}`;
} else {
$source .= file_get_contents($file);
}
}
// UPDATE SERVER-SIDE CACHE
if ($cacheFile !== null && (is_writable($cacheFile) || !file_exists($cacheFile) && dir::isWritable(dirname($cacheFile)))) {
file_put_contents($cacheFile, $source);
touch($cacheFile, $mtime);
}
// OUTPUT SOURCE CODE
echo $source;
}
示例2: getDirInfo
protected function getDirInfo($dir, $removable = false)
{
if (substr(basename($dir), 0, 1) == "." || !is_dir($dir) || !is_readable($dir)) {
return false;
}
$dirs = dir::content($dir, array('types' => "dir"));
if (is_array($dirs)) {
foreach ($dirs as $key => $cdir) {
if (substr(basename($cdir), 0, 1) == ".") {
unset($dirs[$key]);
}
}
$hasDirs = count($dirs) ? true : false;
} else {
$hasDirs = false;
}
$writable = dir::isWritable($dir);
$info = array('name' => stripslashes(basename($dir)), 'readable' => is_readable($dir), 'writable' => $writable, 'removable' => $removable && $writable && dir::isWritable(dirname($dir)), 'hasDirs' => $hasDirs);
if ($dir == "{$this->config['uploadDir']}/{$this->session['dir']}") {
$info['current'] = true;
}
return $info;
}
示例3: act_mv_cbd
protected function act_mv_cbd()
{
$dir = $this->postDir();
if (!$this->config['access']['files']['move'] || !isset($_POST['dir']) || !is_dir($dir) || !is_readable($dir) || !dir::isWritable($dir) || !isset($_POST['files']) || !is_array($_POST['files']) || !count($_POST['files'])) {
$this->errorMsg("Unknown error.");
}
$error = array();
foreach ($_POST['files'] as $file) {
$file = path::normalize($file);
if (substr($file, 0, 1) == ".") {
continue;
}
$type = explode("/", $file);
$type = $type[0];
if ($type != $this->type) {
continue;
}
$path = "{$this->config['uploadDir']}/{$file}";
if (!$this->checkFilePath($path)) {
continue;
}
$base = basename($file);
$replace = array('file' => $this->htmlData($base));
$ext = file::getExtension($base);
if (!file_exists($path)) {
$error[] = $this->label("The file '{file}' does not exist.", $replace);
} elseif (substr($base, 0, 1) == ".") {
$error[] = $this->htmlData($base) . ": " . $this->label("File name shouldn't begins with '.'");
} elseif (!$this->validateExtension($ext, $type)) {
$error[] = $this->htmlData($base) . ": " . $this->label("Denied file extension.");
} elseif (file_exists("{$dir}/{$base}")) {
$error[] = $this->htmlData($base) . ": " . $this->label("A file or folder with that name already exists.");
} elseif (!is_readable($path) || !is_file($path)) {
$error[] = $this->label("Cannot read '{file}'.", $replace);
} elseif (!file::isWritable($path) || !@rename($path, "{$dir}/{$base}")) {
$error[] = $this->label("Cannot move '{file}'.", $replace);
} else {
if (function_exists("chmod")) {
@chmod("{$dir}/{$base}", $this->config['filePerms']);
}
$fromThumb = "{$this->thumbsDir}/{$file}";
if (is_file($fromThumb) && is_readable($fromThumb)) {
$toThumb = "{$this->thumbsTypeDir}/{$_POST['dir']}";
if (!is_dir($toThumb)) {
@mkdir($toThumb, $this->config['dirPerms'], true);
}
$toThumb .= "/{$base}";
@rename($fromThumb, $toThumb);
}
}
}
if (count($error)) {
return json_encode(array('error' => $error));
}
return true;
}