예제 #1
0
 /**
  * 打包全部的hook文件
  *
  */
 public static function hooks()
 {
     $modules = zotop::data('module');
     foreach ($modules as $module) {
         if ((int) $module['status'] >= 0 && dir::exists($module['path'])) {
             //只加载相应的hook文件
             runtime::$hooks[] = $module['path'] . DS . 'hooks' . DS . ZOTOP_APP_NAME . '.php';
         }
     }
 }
예제 #2
0
파일: module.php 프로젝트: dalinhuang/zotop
 public function actionLicense($path)
 {
     $module = zotop::model('zotop.module');
     $modules = $module->getUnInstalled();
     if (empty($path) || !dir::exists($path)) {
         msg::error(array('content' => zotop::t('模块不存在,请确认是否已经上传该模块?'), 'description' => zotop::t("路径:{$path}")));
     }
     $licenseFile = $path . DS . 'license.txt';
     if (!file::exists($licenseFile)) {
         zotop::redirect('zotop/module/install', array('path' => url::encode($path)));
         exit;
     }
     $license = file::read($licenseFile);
     $page = new dialog();
     $page->set('title', '许可协议');
     $page->set('license', html::decode($license));
     $page->set('next', zotop::url('zotop/module/install', array('path' => url::encode($path))));
     $page->display();
 }
예제 #3
0
파일: file.php 프로젝트: dalinhuang/zotop
 /**
  * 上传文件
  *
  * @param string $name  FILE字段名称
  * @param string $path  上传的路径
  * @param string $ext   扩展名
  * @param boolean $rename 是否重新命名
  * @return array
  */
 public static function upload($name, $path, $ext, $rename = true)
 {
     if (!dir::exists(dirname($path))) {
         dir::create(dirname($path));
     }
     $ext = explode(',', $ext);
     $files = $_FILES[$name];
     $attachments = array();
     //转换数组
     if (is_array($files['name'])) {
         foreach ($files as $key => $var) {
             foreach ($var as $id => $val) {
                 $attachments[$id][$key] = $val;
             }
         }
     } else {
         $attachments[] = $files;
     }
     //上传
     $return = array();
     foreach ($attachments as $k => $file) {
         if (in_array(self::ext($file['name']), $ext)) {
             $tmp = $path;
             if ($rename) {
                 $tmp .= DS . rand::string(10) . self::ext($file['name']);
             } else {
                 $tmp .= DS . $file['name'];
             }
             @move_uploaded_file($file['name'], $tmp);
             $return[] = $tmp;
             @unlink($file['tmp_name']);
         } else {
             $return[] = false;
         }
     }
     return $return;
 }
예제 #4
0
파일: admin.php 프로젝트: dalinhuang/zotop
 /**
  * 写入文件
  *
  * @param string $file
  * @param string $content
  * @param boolean $overwrite
  * @return boolean
  */
 public static function write($file, $content = '', $overwrite = TRUE)
 {
     $file = path::decode($file);
     //当目录不存在的情况下先创建目录
     if (!dir::exists(dirname($file))) {
         dir::create(dirname($file));
     }
     if (!file::exists($file) || $overwrite) {
         return @file_put_contents($file, $content);
     }
     return false;
 }