本文整理汇总了PHP中FileSystem::putDir方法的典型用法代码示例。如果您正苦于以下问题:PHP FileSystem::putDir方法的具体用法?PHP FileSystem::putDir怎么用?PHP FileSystem::putDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileSystem
的用法示例。
在下文中一共展示了FileSystem::putDir方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
public function write($path, $data, $mode)
{
import('ORG.Net.FileSystem');
$paths = new FileSystem();
$paths->root = ITEM;
$paths->charset = C('CFG_CHARSET');
//main
if ($mode == 'conf') {
if (!is_writeable(ROOT . '/Conf')) {
return -1;
}
$fp = fopen($path, 'wb');
flock($fp, 3);
fwrite($fp, "<" . "?php\r\n");
fwrite($fp, "return array(\r\n");
//dump($data);
foreach ($data as $fval) {
$fval['vals'] = htmlspecialchars_decode($fval['vals']);
if ($fval['types'] == 'int' || $fval['types'] == 'bool') {
if ($fval['vals'] == "") {
$fval['vals'] = 0;
}
fwrite($fp, "\t'" . $fval['keyword'] . "' => " . addslashes($fval['vals']) . ",\r\n");
} elseif ($fval['types'] == 'select' || $fval['types'] == 'more') {
list($key, $val) = explode('>>', $fval['vals']);
if ($key == 'none') {
fwrite($fp, "\t'" . $fval['keyword'] . "' => '',\r\n");
} else {
fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($key) . "',\r\n");
}
} else {
fwrite($fp, "\t'" . $fval['keyword'] . "' => '" . addslashes($fval['vals']) . "',\r\n");
}
}
fwrite($fp, ");");
fclose($fp);
return 1;
} elseif ($mode && $mode != 'conf') {
if (!file_exists($path)) {
$paths->putDir($path);
}
if (!is_writeable($path)) {
return -1;
}
$put = $paths->putFile($path . '/' . $mode . '.json', $data);
return $put;
} else {
$this->error('未知操作模式,请检查!');
}
}
示例2: downzip
/**
* 打包下载备份包
*@param $file 文件路劲
*@examlpe
*/
public function downzip($file)
{
import('ORG.Util.phpzip');
$addzip = new phpzip();
import('ORG.Net.FileSystem');
$path = new FileSystem();
$path->root = ITEM;
$path->charset = C('CFG_CHARSET');
load("@.download");
//main
$file = strval($file);
$realpath = CONF_PATH . 'Backup/' . $file;
$bakfile = RUNTIME_PATH . 'Temp/Zip/';
if (!file_exists($bakfile)) {
$path->putDir($bakfile);
}
$zipname = 'Backup_' . $file . '.zip';
$zippath = $bakfile . $zipname;
$addzip->zip($realpath, $zippath);
if (file_exists($zippath)) {
download($zippath);
$path->delFile($zippath);
}
unset($addzip, $path);
}