当前位置: 首页>>代码示例>>PHP>>正文


PHP Folder::mk方法代码示例

本文整理汇总了PHP中Folder::mk方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::mk方法的具体用法?PHP Folder::mk怎么用?PHP Folder::mk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Folder的用法示例。


在下文中一共展示了Folder::mk方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: upload

 /**
  * 上传头像
  */
 public function upload()
 {
     if (isset($_GET['userid']) && isset($GLOBALS['HTTP_RAW_POST_DATA'])) {
         // 根据用户id创建文件夹
         $userid = intval($_GET['userid']);
         $avatardata = $GLOBALS['HTTP_RAW_POST_DATA'];
     } else {
         exit('0');
     }
     $dir1 = ceil($userid / 10000);
     $dir2 = ceil($userid % 10000 / 1000);
     // 创建图片存储文件夹
     $avatarfile = DATA_PATH . 'avatar/';
     $dir = $avatarfile . $dir1 . '/' . $dir2 . '/' . $userid . '/';
     if (!file_exists($dir)) {
         Folder::mk($dir);
     }
     $filename = $dir . $userid . '.zip';
     File::write($filename, $avatardata);
     $archive = new PclZip($filename);
     if ($archive->extract(PCLZIP_OPT_PATH, $dir) == 0) {
         die("Error : " . $archive->errorInfo(true));
     }
     // 判断文件安全,删除压缩包和非jpg图片
     $avatararr = array('180x180.jpg', '30x30.jpg', '45x45.jpg', '90x90.jpg');
     if ($handle = opendir($dir)) {
         while (false !== ($file = readdir($handle))) {
             if ($file !== '.' && $file !== '..') {
                 if (!in_array($file, $avatararr)) {
                     File::delete($dir . $file);
                 } else {
                     $info = @getimagesize($dir . $file);
                     if (!$info || $info[2] != 2) {
                         File::del($dir . $file);
                     }
                 }
             }
         }
         closedir($handle);
     }
     $this->db->where(array('userid' => $userid))->update(array('avatar' => 1));
     exit('1');
 }
开发者ID:hubs,项目名称:yuncms,代码行数:46,代码来源:AvatarController.php

示例2: compile

 /**
  * 缓存重写分析
  *
  * @param string $template
  * @param string $application
  * @param string $style
  */
 public function compile($template, $application = null, $style = 'default')
 {
     $application = is_null($application) ? APP : $application;
     $this->style = $style;
     // 定义模版路径
     $tplfile = $this->view_dir . $style . DIRECTORY_SEPARATOR . $application . DIRECTORY_SEPARATOR . $template . $this->_ext;
     if (!file_exists($tplfile)) {
         throw new Base_Exception('Unable to load the file ' . $tplfile . ' , file is not exist.');
     }
     $filepath = $this->compile_dir . $style . DIRECTORY_SEPARATOR . $application . DIRECTORY_SEPARATOR;
     if (!is_dir($filepath)) {
         Folder::mk($filepath);
     }
     $this->compilefile = $filepath . $template . '.php';
     if (!file_exists($this->compilefile) || $this->_referesh && @filemtime($tplfile) > @filemtime($this->compilefile)) {
         $this->refresh($tplfile);
     }
     return $this->compilefile;
 }
开发者ID:hubs,项目名称:yuncms,代码行数:26,代码来源:View.php

示例3: crop_upload

 /**
  * 图片裁切
  *
  * @return boolean
  */
 public function crop_upload()
 {
     if (isset($GLOBALS["HTTP_RAW_POST_DATA"])) {
         $pic = $GLOBALS["HTTP_RAW_POST_DATA"];
         if (isset($_GET['width']) && !empty($_GET['width'])) {
             $width = intval($_GET['width']);
         }
         if (isset($_GET['height']) && !empty($_GET['height'])) {
             $height = intval($_GET['height']);
         }
         if (isset($_GET['file']) && !empty($_GET['file'])) {
             if (is_image($_GET['file']) == false) {
                 exit;
             }
             if (strpos($_GET['file'], C('attachment', 'upload_url')) !== false) {
                 $file = $_GET['file'];
                 $basename = basename($file);
                 $filepath = str_replace(SITE_URL, '', dirname($file)) . '/';
                 if (strpos($basename, 'thumb_') !== false) {
                     $file_arr = explode('_', $basename);
                     $basename = array_pop($file_arr);
                 }
                 $new_file = 'thumb_' . $width . '_' . $height . '_' . $basename;
             } else {
                 $application = trim($_GET['application']);
                 $catid = intval($_GET['catid']);
                 $attachment = new Attachment($application, $catid);
                 $uploadedfile['filename'] = basename($_GET['file']);
                 $uploadedfile['fileext'] = File::get_suffix($_GET['file']);
                 if (in_array($uploadedfile['fileext'], array('jpg', 'gif', 'jpeg', 'png', 'bmp'))) {
                     $uploadedfile['isimage'] = 1;
                 }
                 $file_path = C('attachment', 'upload_path') . date('Y/md/');
                 Folder::mk($file_path);
                 $new_file = date('Ymdhis') . rand(100, 999) . '.' . $uploadedfile['fileext'];
                 $uploadedfile['filepath'] = date('Y/md/') . $new_file;
                 $aid = $attachment->add($uploadedfile);
                 $filepath = str_replace(SITE_URL, '', C('attachment', 'upload_url')) . date('Y/md/');
             }
             file_put_contents(BASE_PATH . $filepath . $new_file, $pic);
         } else {
             return false;
         }
         echo SITE_URL . $filepath . $new_file;
         exit;
     }
 }
开发者ID:hubs,项目名称:yuncms,代码行数:52,代码来源:AttachmentsController.php

示例4: check

 /**
  * 检查安装目录
  *
  * @param string $application
  */
 public function check($application = '')
 {
     defined('INSTALL') or define('INSTALL', true);
     if ($application) {
         $this->application = $application;
     }
     if (!$this->application) {
         $this->error_msg = L('no_application');
         return false;
     }
     if (!defined('INSTALL_APPLICATION')) {
         if (Folder::mk(WEKIT_PATH . 'languages' . DIRECTORY_SEPARATOR . C('config', 'lang') . DIRECTORY_SEPARATOR . 'test_create_dir')) {
             sleep(1);
             Folder::rm(WEKIT_PATH . 'languages' . DIRECTORY_SEPARATOR . C('config', 'lang') . DIRECTORY_SEPARATOR . 'test_create_dir');
         } else {
             $this->error_msg = L('lang_dir_no_write');
             return false;
         }
     }
     $r = $this->db->where(array('application' => $this->application))->find();
     if ($r) {
         $this->error_msg = L('this_application_installed');
         return false;
     }
     if (!$this->installdir) {
         $this->installdir = APPS_PATH . $this->application . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR;
     }
     if (!is_dir($this->installdir)) {
         $this->error_msg = L('install_dir_no_exist');
         return false;
     }
     if (!file_exists($this->installdir . 'application.sql')) {
         $this->error_msg = L('application_sql_no_exist');
         return false;
     }
     $models = @(require $this->installdir . 'model.php');
     if (is_array($models) && !empty($models)) {
         foreach ($models as $app) {
             if (!file_exists(WEKIT_PATH . 'model' . DIRECTORY_SEPARATOR . $app . '_model.php')) {
                 copy($this->installdir . 'model' . DIRECTORY_SEPARATOR . $app . '_model.php', WEKIT_PATH . 'model' . DIRECTORY_SEPARATOR . $app . '_model.php');
             }
             if (!file_exists($this->installdir . $app . '.sql')) {
                 $this->error_msg = $app . L('sql_no_exist');
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:hubs,项目名称:yuncms,代码行数:54,代码来源:application_api.php

示例5: create_html

 /**
  * 生成静态文件
  *
  * @param string $file
  *        	文件路径
  * @return boolen/intval 成功返回生成文件的大小
  */
 private function create_html($file)
 {
     $data = ob_get_contents();
     ob_end_clean();
     Folder::mk(dirname($file));
     $strlen = File::write($file, $data);
     return $strlen;
 }
开发者ID:hubs,项目名称:yuncms,代码行数:15,代码来源:html.php

示例6: upload_tmp

 /**
  * 上传无记录的临时文件
  *
  * @param unknown_type $field
  */
 public function upload_tmp($field)
 {
     $tmpPath = $this->upload_root . "tmp/";
     if (!isset($_FILES[$field])) {
         // 判断附件上传字段是否为空
         $this->error = UPLOAD_ERR_OK;
         return false;
     }
     // 判断限制的类型
     $this->alowexts = C('attachment', 'allowext');
     $this->savepath = $tmpPath;
     $this->maxsize = C('attachment', 'maxsize') * 1024;
     $this->uploads = 1;
     if (!Folder::mk($this->savepath) && !is_dir($this->savepath)) {
         $this->error = '8';
         return false;
     }
     @chmod($this->savepath, 0755);
     if (!is_writeable($this->savepath)) {
         $this->error = '9';
         return false;
     }
     $file = $_FILES[$field];
     if (is_array($file['error'])) {
         $this->error = '5';
         return false;
     } else {
         $this->uploads = 1;
     }
     $fileext = File::get_suffix($file['name']);
     if ($file['error'] != 0) {
         $this->error = $file['error'];
         return false;
     }
     if (!preg_match("/^(" . $this->alowexts . ")\$/", $fileext)) {
         $this->error = '10';
         return false;
     }
     if ($this->maxsize && $file['size'] > $this->maxsize) {
         $this->error = '11';
         return false;
     }
     if (!$this->isuploadedfile($file['tmp_name'])) {
         $this->error = '12';
         return false;
     }
     $filename = $this->getname("png");
     $savefile = $this->savepath . $filename;
     $filepath = preg_replace(String::addslashes("|^" . $this->upload_root . "|"), "", $savefile);
     $upload_func = $this->upload_func;
     if (@$upload_func($file['tmp_name'], $savefile)) {
         @chmod($savefile, 0755);
         @unlink($file['tmp_name']);
         return $filepath;
     } else {
         return false;
     }
 }
开发者ID:hubs,项目名称:yuncms,代码行数:63,代码来源:Attachment.php

示例7: export_database

 /**
  * 数据库导出方法
  *
  * @param unknown_type $tables 数据表数据组
  * @param unknown_type $sqlcompat 数据库兼容类型
  * @param unknown_type $sqlcharset 数据库字符
  * @param unknown_type $sizelimit 卷大小
  * @param unknown_type $action 操作
  * @param unknown_type $fileid 卷标
  * @param unknown_type $random 随机字段
  * @param unknown_type $tableid
  * @param unknown_type $startfrom
  * @param unknown_type $tabletype 备份数据库类型 (非yuncms数据与yuncms数据)
  */
 private function export_database($tables, $sqlcompat, $sqlcharset, $sizelimit, $action, $fileid, $random, $tableid, $startfrom, $tabletype)
 {
     $dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', CHARSET);
     $fileid = $fileid != '' ? $fileid : 1;
     if ($fileid == 1 && $tables) {
         if (!isset($tables) || !is_array($tables)) {
             showmessage(L('select_tbl'));
         }
         $random = mt_rand(1000, 9999);
         S('common/bakup_table', $tables);
     } else {
         if (!($tables = S('common/bakup_table'))) {
             showmessage(L('select_tbl'));
         }
     }
     if ($this->db->version() > '4.1') {
         if ($sqlcharset) {
             $this->db->query("SET NAMES '" . $sqlcharset . "';\n\n");
         }
         if ($sqlcompat == 'MYSQL40') {
             $this->db->query("SET SQL_MODE='MYSQL40'");
         } elseif ($sqlcompat == 'MYSQL41') {
             $this->db->query("SET SQL_MODE=''");
         }
     }
     $tabledump = '';
     $tableid = $tableid != '' ? $tableid - 1 : 0;
     $startfrom = $startfrom != '' ? intval($startfrom) : 0;
     for ($i = $tableid; $i < count($tables) && strlen($tabledump) < $sizelimit * 1000; $i++) {
         global $startrow;
         $offset = 100;
         if (!$startfrom) {
             if ($tables[$i] != $this->db->get_prefix() . 'session') {
                 $tabledump .= "DROP TABLE IF EXISTS `{$tables[$i]}`;\n";
             }
             $create = $this->db->query("SHOW CREATE TABLE `{$tables[$i]}` ");
             $tabledump .= $create[0]['Create Table'] . ";\n\n";
             if ($sqlcompat == 'MYSQL41' && $this->db->version() < '4.1') {
                 $tabledump = preg_replace("/TYPE\\=([a-zA-Z0-9]+)/", "ENGINE=\\1 DEFAULT CHARSET=" . $dumpcharset, $tabledump);
             }
             if ($this->db->version() > '4.1' && $sqlcharset) {
                 $tabledump = preg_replace("/(DEFAULT)*\\s*CHARSET=[a-zA-Z0-9]+/", "DEFAULT CHARSET=" . $sqlcharset, $tabledump);
             }
             if ($tables[$i] == $this->db->get_prefix() . 'session') {
                 $tabledump = str_replace("CREATE TABLE `" . $this->db->get_prefix() . "session`", "CREATE TABLE IF NOT EXISTS `" . $this->db->get_prefix() . "session`", $tabledump);
             }
         }
         $numrows = $offset;
         while (strlen($tabledump) < $sizelimit * 1000 && $numrows == $offset) {
             if ($tables[$i] == $this->db->get_prefix() . 'session') {
                 break;
             }
             $sql = "SELECT * FROM `{$tables[$i]}` LIMIT {$startfrom}, {$offset}";
             //获取字段
             $fields_name = $this->db->get_fields($tables[$i]);
             //字段总数
             $numfields = count($fields_name);
             //返回结果集中行的数目
             $numrows = $this->db->num_rows;
             $rows = $this->db->query($sql);
             $name = array_keys($fields_name);
             $r = array();
             foreach ($rows as $row) {
                 $r[] = $row;
                 $comma = "";
                 $tabledump .= "INSERT INTO `{$tables[$i]}` VALUES(";
                 for ($j = 0; $j < $numfields; $j++) {
                     $tabledump .= $comma . "'" . mysql_escape_string($row[$name[$j]]) . "'";
                     $comma = ",";
                 }
                 $tabledump .= ");\n";
             }
             $startfrom += $offset;
         }
         $tabledump .= "\n";
         $startrow = $startfrom;
         $startfrom = 0;
     }
     if (trim($tabledump)) {
         $tabledump = "# YUNCMS bakfile\n# version:YUNCMS " . C('version', 'version') . "\n# time:" . date('Y-m-d H:i:s') . "\n# type:YUNCMS\n# TINTSOFT:http://www.tintsoft.com\n# --------------------------------------------------------\n\n\n" . $tabledump;
         $tableid = $i;
         $filename = $tabletype . '_' . date('Ymd') . '_' . $random . '_' . $fileid . '.sql';
         $altid = $fileid;
         $fileid++;
         $bakfile_path = DATA_PATH . 'bakup' . DIRECTORY_SEPARATOR . $this->pdo_name;
         if (!Folder::mk($bakfile_path)) {
//.........这里部分代码省略.........
开发者ID:hubs,项目名称:yuncms,代码行数:101,代码来源:DatabaseController.php

示例8: _path

 /**
  * 获取文本缓存要存放的路径
  *
  * @param string $key
  *            缓存数据的唯一key
  */
 private function _path($key)
 {
     if (strpos($key, '/') !== false) {
         $path = CACHE_PATH . dirname($key) . DIRECTORY_SEPARATOR . basename($key) . $this->suffix;
     } else {
         $path = CACHE_PATH . $key . $this->suffix;
     }
     $dir = dirname($path);
     if (!is_dir($dir)) {
         Folder::mk($dir, 0777);
     }
     return $path;
 }
开发者ID:hubs,项目名称:yuncms,代码行数:19,代码来源:File.php


注:本文中的Folder::mk方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。