本文整理汇总了PHP中dir_create函数的典型用法代码示例。如果您正苦于以下问题:PHP dir_create函数的具体用法?PHP dir_create怎么用?PHP dir_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dir_create函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* 生成静态页面
* <code>
* array(控制器名,方法名,表态数据,保存表态文件路径)
* array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
* </code>
* @param $control
* @param $method
* @param $data
* @return bool
*/
public static function create($control, $method, $data)
{
//创建控制器对象
if (is_null(self::$obj)) {
$obj = control($control);
if (!method_exists($obj, $method)) {
error("方法{$method}不存在,请查看HD手册", false);
}
}
foreach ($data as $d) {
//************创建GET数据****************
$_GET = array_merge($_GET, $d);
$htmlPath = dirname($d['html_file']);
//生成静态目录
if (!dir_create($htmlPath)) {
//创建生成静态的目录
throw_exception(L("html_create_error2"));
return false;
}
ob_start();
$obj->{$method}();
//执行控制器方法
$content = ob_get_clean();
file_put_contents($d['html_file'], $content);
}
return true;
}
示例2: emailTpl
function emailTpl()
{
$db = M('mail_tpl');
$type = $_GET['type'];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($db->where("type='{$type}'")->update($_POST) >= 0) {
$filename = PATH_ROOT . '/caches/email';
if (!file_exists($filename)) {
dir_create($filename);
}
$filename .= '/' . $type . '.php';
file_put_contents($filename, '<?php return ' . var_export(array('subject' => $_POST['subject'], 'content' => $_POST['content']), true) . '?>');
$this->success('更新成功', __CONTROL__ . '/emailConfig/action/3');
}
}
$placeholder = array('web_name' => '网站名称', 'web_host' => '网站域名');
switch ($type) {
case 'register_active':
$placeholder = array_merge($placeholder, array('username' => '用户名', 'email' => '邮箱', 'password' => '密码', 'activate_url' => '激活地址', 'expire' => '有效时间(小时)'));
break;
case 'register_info':
$placeholder = array_merge($placeholder, array('username' => '用户名', 'email' => '邮箱', 'password' => '密码'));
break;
default:
break;
}
$tpl = $db->where("type='{$type}'")->find();
$this->assign('tpl', $tpl);
$this->assign('placeholder', $placeholder);
$this->display();
}
示例3: make
/**
* 生成静态页面
* <code>
* array(控制器名,方法名,表态数据,保存表态文件路径)
* array(news,show,1,'h/b/Hd.html');表示生成news控制器中的show方法生成ID为1的文章
* </code>
* @param $control 控制器,需要事先加载
* @param $method 方法
* @param $field 数据array("aid"=>1,"_html"=>"html/2013/2/22/1.html")
* @return bool
*/
public static function make($control, $method, $field)
{
if (!class_exists($control) or !method_exists($control, $method)) {
DEBUG && halt("静态生成需要的控制器{$control}或方法{$method}不存在");
}
if (!isset($field['_html'])) {
DEBUG && halt("请指定静态文件参数'_html',请参考后盾HD框架手册");
}
$obj = NULL;
if (!$obj) {
$obj = new $control();
}
//************创建GET数据****************
$html = $field['_html'];
unset($field['_html']);
$_GET = array_merge($_GET, $field);
if (!dir_create(dirname($html))) {
//创建生成静态的目录
DEBUG && halt("创建目录失败,请检查目录权限");
return false;
}
ob_start();
$obj->{$method}();
//执行控制器方法
$content = ob_get_clean();
file_put_contents($html, $content);
return true;
}
示例4: F
/**
* 快速缓存 以文件形式缓存
* @param String $name 缓存KEY
* @param bool $value 删除缓存
* @param string $path 缓存目录
* @return bool
*/
function F($name, $value = false, $path = APP_CACHE_PATH)
{
$_cache = array();
$cacheFile = rtrim($path, '/') . '/' . $name . '.php';
if (is_null($value)) {
if (is_file($cacheFile)) {
unlink($cacheFile);
unset($_cache[$name]);
}
return true;
}
if ($value === false) {
if (isset($_cache[$name])) {
return $_cache[$name];
}
return is_file($cacheFile) ? include $cacheFile : null;
}
$data = "<?php if(!defined('HDPHP_PATH'))exit;\nreturn " . compress(var_export($value, true)) . ";\n?>";
is_dir($path) || dir_create($path);
if (!file_put_contents($cacheFile, $data)) {
return false;
}
$_cache[$name] = $data;
return true;
}
示例5: display
/**
* 模板显示
* @param string $tplFile 模板文件
* @param string $cachePath 缓存目录
* @param null $cacheTime 缓存时间
* @param string $contentType 文件类型
* @param string $charset 字符集
* @param bool $show 是否显示
* @return bool|string
*/
public function display($tplFile = null, $cacheTime = null, $cachePath = null, $contentType = "text/html", $charset = "", $show = true)
{
//缓存文件名
$cacheName = md5($_SERVER['REQUEST_URI']);
//内容
$content = null;
if ($cacheTime >= 0) {
$content = S($cacheName, false, $cacheTime, array("dir" => $cachePath, 'zip' => false, "Driver" => "File"));
}
//缓存失效
if (!$content) {
//获得模板文件
$this->tplFile = $this->getTemplateFile($tplFile);
//模板文件不存在
if (!$this->tplFile) {
return;
}
//编译文件
$this->compileFile = COMPILE_PATH . basename($this->tplFile, C("TPL_FIX")) . '_' . substr(md5(APP . CONTROL . METHOD), 0, 5) . '.php';
//记录模板编译文件
if (DEBUG) {
Debug::$tpl[] = array(basename($this->tplFile), $this->compileFile);
}
//缓存时间
$cacheTime = is_int($cacheTime) ? $cacheTime : intval(C("CACHE_TPL_TIME"));
//缓存路径
$cachePath = $cachePath ? $cachePath : CACHE_PATH;
//编译文件失效(不存在或过期)
if ($this->compileInvalid($tplFile)) {
//执行编译
$this->compile();
}
$_CONFIG = C();
$_LANGUAGE = L();
//加载全局变量
if (!empty($this->vars)) {
extract($this->vars);
}
ob_start();
include $this->compileFile;
$content = ob_get_clean();
//创建缓存
if ($cacheTime >= 0) {
//创建缓存目录
is_dir(CACHE_PATH) || dir_create(CACHE_PATH);
//写入缓存
S($cacheName, $content, $cacheTime, array("dir" => $cachePath, 'zip' => false, "Driver" => "File"));
}
}
if ($show) {
$charset = strtoupper(C("CHARSET")) == 'UTF8' ? "UTF-8" : strtoupper(C("CHARSET"));
if (!headers_sent()) {
header("Content-type:" . $contentType . ';charset=' . $charset);
}
echo $content;
} else {
return $content;
}
}
示例6: display
/**
* 模板显示
* @param string $tplFile 模板文件
* @param string $cachePath 缓存目录
* @param null $cacheTime 缓存时间
* @param string $contentType 文件类型
* @param string $charset 字符集
* @param bool $show 是否显示
* @return bool|string
*/
public function display($tplFile = null, $cacheTime = null, $cachePath = null, $contentType = "text/html", $charset = "", $show = true)
{
$this->tplFile = $this->getTemplateFile($tplFile);
$this->compileFile = COMPILE_PATH . md5_d($this->tplFile) . '.php';
if (DEBUG) {
Debug::$tpl[] = array(basename($this->tplFile), $this->compileFile);
//记录模板编译文件
}
//缓存时间设置
$cacheTime = is_int($cacheTime) ? $cacheTime : intval(C("CACHE_TPL_TIME"));
$content = false;
$cachePath = $cachePath ? $cachePath : CACHE_PATH;
if ($cacheTime >= 0) {
$content = S($_SERVER['REQUEST_URI'], false, $cacheTime, array("dir" => $cachePath, "Driver" => "File"));
}
//缓存失效
if (!$content) {
if ($this->compileInvalid($tplFile)) {
//编译文件失效
$this->compile();
}
$_CONFIG = C();
$_LANGUAGE = L();
if (!empty($this->vars)) {
//加载全局变量
extract($this->vars);
}
ob_start();
include $this->compileFile;
$content = ob_get_clean();
if ($cacheTime >= 0) {
is_dir(CACHE_PATH) || dir_create(CACHE_PATH);
//创建缓存目录
S($_SERVER['REQUEST_URI'], $content, $cacheTime, array("dir" => $cachePath, "Driver" => "File"));
//写入缓存
}
}
if ($show) {
$charset = strtoupper(C("CHARSET")) == 'UTF8' ? "UTF-8" : strtoupper(C("CHARSET"));
if (!headers_sent()) {
header("Content-type:" . $contentType . ';charset=' . $charset);
}
echo $content;
} else {
return $content;
}
}
示例7: dsession
function dsession()
{
if (DT_DOMAIN) {
@ini_set('session.cookie_domain', '.' . DT_DOMAIN);
}
@ini_set('session.gc_maxlifetime', 1800);
if (is_dir(DT_ROOT . '/file/session/')) {
$dir = DT_ROOT . '/file/session/' . substr(DT_KEY, 2, 6) . '/';
if (is_dir($dir)) {
session_save_path($dir);
} else {
dir_create($dir);
}
}
session_cache_limiter('private, must-revalidate');
@session_start();
header("cache-control: private");
}
示例8: display
public function display($resource_name, $cacheTime = null)
{
$resource_name = $this->getTemplateFile($resource_name);
//缓存时间设置
$_cacheTime = is_null($cacheTime) ? C("CACHE_TPL_TIME") : $cacheTime;
$cacheTime = is_int($_cacheTime) ? $_cacheTime : Null;
$content = false;
if ($cacheTime) {
$content = S($_SERVER['REQUEST_URI'], false, null, array("dir" => PATH_TEMP_TPL_CACHE, "Driver" => "File"));
}
if (!$content) {
$content = $this->smarty->fetch($resource_name);
//创建缓存
if ($cacheTime) {
is_dir(PATH_TEMP_TPL_CACHE) || dir_create(PATH_TEMP_CACHE);
//创建缓存目录
S($_SERVER['REQUEST_URI'], $content, $cacheTime, array("dir" => PATH_TEMP_TPL_CACHE, "Driver" => "File"));
//写入缓存
}
}
}
示例9: dir_copy
/**
* 拷贝目录及下面所有文件
*
* @param string $fromdir 原路径
* @param string $todir 目标路径
* @return string 如果目标路径不存在则返回false,否则为true
*/
function dir_copy($fromdir, $todir)
{
$fromdir = dir_path($fromdir);
$todir = dir_path($todir);
if (!is_dir($fromdir)) {
return FALSE;
}
if (!is_dir($todir)) {
dir_create($todir);
}
$list = glob($fromdir . '*');
if (!empty($list)) {
foreach ($list as $v) {
$path = $todir . basename($v);
if (is_dir($v)) {
dir_copy($v, $path);
} else {
copy($v, $path);
@chmod($path, 0777);
}
}
}
return TRUE;
}
示例10: generate_arc_html
/**
* 生成文章静态HTML
* @param int $id 文章ID
* @param string $path 文章生成路径
* @param string $tpl 文章内容页的模板
*/
public function generate_arc_html($id, $path, $tpl)
{
$path = PATH_ROOT . $path;
$arc = $this->arc->arc('id=' . $id);
$this->assign('arc', $arc);
$content = $this->display($tpl, 0, 'text/html', 'utf-8', false);
if (!file_exists($path)) {
dir_create($path);
}
$path .= "/arc_{$id}.html";
file_put_contents($path, $content);
}
示例11: create_html
/**
* 生成静态文件
* @param string $file 文件路径
* @return boolen/intval 成功返回生成文件的大小
*/
private function create_html($file)
{
$data = ob_get_contents();
ob_end_clean();
pc_base::load_sys_func('dir');
dir_create(dirname($file));
$strlen = file_put_contents($file, $data);
@chmod($file, 0777);
return $strlen;
}
示例12: design
public function design() {
if(isset($_POST['dosubmit'])) {
$data['identification'] = $_POST['info']['identification'];
$data['realease'] = date('YMd',SYS_TIME);
$data['dir'] = $_POST['info']['identification'];
$data['appid'] = '';
$data['plugin'] = array(
'version' => '0.0.2',
'name' => $_POST['info']['name'],
'copyright' => $_POST['info']['copyright'],
'description' => "",
'installfile' => 'install.php',
'uninstallfile' => 'uninstall.php',
);
$filepath = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$data['identification'].DIRECTORY_SEPARATOR.'plugin_'.$data['identification'].'.cfg.php';
pc_base::load_sys_func('dir');
dir_create(dirname($filepath));
$data = "<?php\nreturn ".var_export($data, true).";\n?>";
if(pc_base::load_config('system', 'lock_ex')) {
$file_size = file_put_contents($filepath, $data, LOCK_EX);
} else {
$file_size = file_put_contents($filepath, $data);
}
echo 'success';
} else {
include $this->admin_tpl('plugin_design');
}
}
示例13: index
function index()
{
$status = true;
if (!file_exists(INTALL_UPLOAD_TEMP_PATH)) {
$status = dir_create(INTALL_UPLOAD_TEMP_PATH);
}
$install_uploaded_chomd = $status ? octal_permissions(fileperms(INTALL_UPLOAD_TEMP_PATH)) : 0;
$install_config_chomd = $status ? @octal_permissions(fileperms(APPPATH . 'config' . DIRECTORY_SEPARATOR . 'aci.php')) : 0;
$error = array('uploadChomd' => $install_uploaded_chomd, 'configChomd' => $install_config_chomd, 'supportZip' => class_exists('ZipArchive'));
$this->view('index', $error);
}
示例14: save
function save($file)
{
dir_create(dirname($file));
return file_put_contents($file, $this->data);
}
示例15: qrCode
function qrCode($data, $fileName, $pathMy = '', $level = 'L', $size = 4)
{
$path = './Public/qr/';
if ($pathMy) {
$path .= $pathMy . '/';
$pathMy = $pathMy . '/';
}
dir_create($path);
vendor('phpqrcode', '', '.php');
$path .= $fileName . '.png';
\QRcode::png($data, $path, $level, $size, 2);
if ($fileName) {
return C('APP_URL') . '/Public/qr/' . $pathMy . $fileName . '.png';
}
}