本文整理汇总了PHP中create_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP create_dir函数的具体用法?PHP create_dir怎么用?PHP create_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_image
public function save_image($page_id, $image)
{
$dir = DOCROOT . 'public' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'page_preview' . DIRECTORY_SEPARATOR;
create_dir($dir);
$file = $dir . $page_id . '.jpg';
$this->base64_to_jpeg($image, $file);
}
示例2: upload_image
public function upload_image($dir = 'images')
{
$options = array('upload_dir' => FCPATH . config_item('site_attachments_dir') . $dir . '/', 'upload_url' => '/' . config_item('site_attachments_dir') . $dir . '/', 'script_url' => '/admin/upload/index/upload_image/' . $dir);
$this->load->library('UploadHandler', $options);
create_dir($this->uploadhandler->get_option('upload_dir'));
$this->uploadhandler->initialize();
}
示例3: copy_dir
/**
* 拷贝目录及下面所有文件
*
* @param string $from 原路径
* @param string $to 目标路径
*
* @return bool true拷贝成功,否则false
*/
function copy_dir($from, $to)
{
$from = dir_path($from);
$to = dir_path($to);
if (!is_dir($from)) {
return false;
}
if ($from == $to) {
return true;
}
!is_dir($to) && create_dir($to);
$list = glob($from . '*');
if (!empty($list)) {
foreach ($list as $v) {
$path = $to . basename($v);
if (is_dir($v)) {
copy_dir($v, $path);
} else {
copy($v, $path);
chmod($path, 0755);
}
}
}
return true;
}
示例4: __construct
public function __construct()
{
parent::__construct();
$this->_curruid = (int) $this->auth->user('uid');
$this->_attach_dir = config_item('site_attach_dir') . DIRECTORY_SEPARATOR;
if (@is_dir($this->_attach_dir) === FALSE) {
create_dir($this->_attach_dir);
}
}
示例5: create_dirs
function create_dirs($dirs)
{
$rtn = 1;
foreach ($dirs as $dir) {
if (!create_dir($dir)) {
$rtn = 0;
}
}
return $rtn;
}
示例6: install
function install()
{
global $_plugin;
global $success;
global $error;
global $errors;
!plugin_is_installed($_plugin['name']) or $error = $errors['installed'];
create_dir($_plugin['dir']['definitions']) or $error = $errors['create_dir'];
copy_example('example', $_plugin['dir']['definitions']) or $error = $errors['example'];
set_as_installed() or $error = $errors['installing'];
$success = $_plugin['name'] . ' was successfully installed';
}
示例7: create_dirs_recursively
function create_dirs_recursively($dirs)
{
$dirs = str_replace('\\', '', $dirs);
$dirs_array = explode('/', $dirs);
$dir = $dirs_array[0];
unset($dirs_array[0]);
create_dir($dir);
foreach ($dirs_array as $d) {
$dir .= '/' . $d;
create_dir($dir);
}
}
示例8: register_uploaded_file
function register_uploaded_file($file, $to_folder, $creator_id, $type, $access_policy = 'public')
{
$md5_hash = md5_file($file['tmp_name']);
if ($md5_hash === false) {
return false;
}
create_dir(DATA_PATH . $to_folder);
$newName = getAvailableName(DATA_PATH . $to_folder, $file['name']);
if (move_uploaded_file($file['tmp_name'], DATA_PATH . $to_folder . $newName) === false) {
return false;
}
$file_record = array('creator' => $creator_id, 'creation_date' => now(), 'filepath' => $to_folder . $newName, 'filesize' => filesize(DATA_PATH . $to_folder . $newName), 'filename_original' => $file['name'], 'extension' => pathinfo($file['name'], PATHINFO_EXTENSION), 'mime_type' => $file['type'], 'md5_hash' => $md5_hash, 'type' => $type, 'access_policy' => $access_policy);
$file_id = $this->insert($file_record);
return $file_id;
}
示例9: create_html
/**
* 创建html生成文件
* @param string $html
* @param string $content
* @return boolean
*/
function create_html($html, $content)
{
//分析dir
$dirname = dirname($html);
$path = str_replace('\\', '/', FCPATH) . 'html/';
if (!create_dir('html/' . $dirname)) {
return false;
}
$fp = fopen($path . $html, 'w');
if (!$fp) {
return false;
}
fwrite($fp, $content);
fclose($fp);
return true;
}
示例10: action_upload_files
public function action_upload_files()
{
$files = array();
if (isset($_FILES)) {
foreach ($_FILES as $name => $file) {
if (Upload::not_empty($file)) {
$filename = uniqid() . '_' . $file['name'];
$filename = preg_replace('/\\s+/u', '_', $filename);
$dir = 'public' . DIRECTORY_SEPARATOR . 'upload' . DIRECTORY_SEPARATOR . 'page_media';
create_dir($dir);
Upload::save($file, $filename, DOCROOT . $dir);
$files[] = array('url' => URL::site($dir . '/' . $filename), 'file' => $file, 'dir' => $dir, 'filename' => $filename);
}
}
}
$this->response->json(array('files' => $files));
}
示例11: createAction
/**
* 生成语言包js
*
* @author mrmsl <msl-138@163.com>
* @date 2012-07-04 08:35:38
* @lastmodify 2013-01-27 14:14:23 by mrmsl
*
* @return void 无返回值
*/
public function createAction()
{
require CORE_PATH . 'functions/dir.php';
create_dir(WEB_JS_LANG_PATH);
$loop_arr = array('admin' => LANG_PATH, str_replace('modules/admin/', 'modules/' . FRONT_MODULE_NAME . '/', LANG_PATH));
foreach ($loop_arr as $key => $item) {
$lang_arr = scand_dir($item);
//语言包
foreach ($lang_arr as $k => $v) {
$lang = is_file($filename = SYS_LANG_PATH . $k . '.php') ? include $filename : array();
foreach ($v as $file) {
$lang = array_merge($lang, array_change_key_case(include $file, CASE_UPPER));
}
array2js($lang, 'L', WEB_JS_LANG_PATH . (is_string($key) ? $key . '.' : '') . $k . '.js');
}
}
}
示例12: getDirctoriesState
/**
* 检查目录可读、可写权限
* @param array $directories
* @return array
*/
private function getDirctoriesState(array $directories)
{
$dirStates = array();
foreach ($directories as $key => $dir) {
$fullDirPath = WEB_ROOT . $dir;
create_dir($fullDirPath);
$dirStates[$key]['dir_name'] = $dir;
// 测试可写
if (is_writable($fullDirPath)) {
$dirStates[$key]['writable'] = current_state_support('可写');
} else {
$dirStates[$key]['writable'] = current_state_unsupport('不可写');
}
// 测试可读
if (is_readable($fullDirPath)) {
$dirStates[$key]['readable'] = current_state_support('可读');
} else {
$dirStates[$key]['readable'] = current_state_unsupport('不可读');
}
}
return $dirStates;
}
示例13: ob_end_flush
echo '<font color="blue">正在进行代码预处理CODE_ADV2..</font><br>';
include GAME_ROOT . './include/modulemng.codeadv2.func.php';
for ($i = 1; $i <= $n; $i++) {
/*
if (strtoupper($modn[$i])=='INPUT')
{
echo '跳过模块input。<br>';
continue;
}
*/
echo '开始处理模块' . $modn[$i] . '...<br>';
ob_end_flush();
flush();
$srcdir = GAME_ROOT . './include/modules/' . $modp[$i];
$tpldir = GAME_ROOT . './gamedata/run/' . $modp[$i];
create_dir($tpldir);
clear_dir($tpldir);
copy_dir($srcdir, $tpldir);
foreach ($codelist[$i] as $key) {
echo ' 正在处理代码' . $key . '.. ';
ob_end_flush();
flush();
$src = GAME_ROOT . './include/modules/' . $modp[$i] . $key;
$objfile = GAME_ROOT . './gamedata/run/' . $modp[$i] . $key;
$objfile = substr($objfile, 0, -4) . '.adv' . substr($objfile, strlen($objfile) - 4);
$delfile = GAME_ROOT . './gamedata/run/' . $modp[$i] . $key;
preparse($modn[$i], $i, $src);
parse($modn[$i], $src, $objfile);
unlink($delfile);
echo '完成。<br>';
ob_end_flush();
示例14: form
public static function form($appid, $list)
{
global $_G;
$sql = "SELECT * FROM `mod:form_form` WHERE appid='" . $appid . "' ";
//读取表单信息
$list && ($sql .= " and id in(" . $list . ")");
//创建子文件夹
$folder = create_dir(self::direct($appid));
$result = System::$db->getAll($sql);
foreach ($result as $form) {
$file = $folder . "/form." . $form['id'] . ".php";
$part = array('form' => array(), 'group' => array(), 'option' => array());
//表单主体
foreach ($form as $key => $val) {
if ($key == 'config') {
$form[$key] = fix_json($val);
}
}
$part['form'] = $form;
////////////////
//选项组
$sql = "SELECT * FROM `mod:form_group` WHERE fid=" . $form['id'] . " and `state`>0 order BY sort ASC,id ASC";
$res = System::$db->getAll($sql, 'id');
foreach ($res as $gid => $group) {
foreach ($group as $key => $val) {
if ($key == 'config') {
$group[$key] = fix_json($val);
}
if ($key == 'selected') {
$group[$key] = explode(',', $val);
}
}
$part['group'][$gid] = $group;
}
////////////////
//子选项
$sql = "SELECT * FROM `mod:form_option` WHERE fid=" . $form['id'] . " and `state`>0 order BY sort ASC,id ASC";
$res = System::$db->getAll($sql, 'id');
foreach ($res as $oid => $option) {
foreach ($option as $key => $val) {
if ($key == 'config') {
$option[$key] = fix_json($val);
}
}
$part['option'][$option['gid']][$oid] = $option;
}
////////////////
//写入缓存
create_file($file, '<?php /*' . date("Y-m-d H:i:s") . '*/ $_CACHE[\'' . $appid . '\'] = ' . var_export($part, true) . ';');
}
}
示例15: moved_file
public static function moved_file($tmpdir, $newdir, $pack)
{
//return rename( $tmpdir, $newdir );
$list = rglob($tmpdir . '*', GLOB_BRACE);
//var_dump( $list );
//exit;
//批量迁移文件
foreach ($list as $file) {
$newd = str_replace($tmpdir, $newdir, $file);
//var_dump( $file );
//var_dump( $newd );
//echo '<hr />';
if (file_exists($file) && is_writable($file) == FALSE) {
//记录在案
self::$lastfile = str_replace($tmpdir, '', $file);
return -10007;
}
////////////////////////////
if (file_exists($newd) && is_writable($newd) == FALSE) {
//记录在案
self::$lastfile = str_replace($newdir, '', $newd);
return -10007;
}
////////////////////////////
//创建文件夹
if (is_dir($file)) {
create_dir($newd, TRUE, 0777);
} else {
//删除旧文件(winodws 环境需要)
if (file_exists($newd)) {
unlink($newd);
}
//生成新文件
$test = @rename($file, $newd);
//记录在案
self::$lastfile = str_replace($tmpdir, '', $file);
}
////////////////////////////
//移动文件出错
if ($test === FALSE) {
return -10005;
}
}
//删除临时目录
delete_dir($tmpdir);
//删除文件包
unlink(self::get_pack_file($pack));
return count($list);
}