예제 #1
0
 public static function hook()
 {
     //打包全部hook
     $hooks = array();
     $modules = zotop::data('module');
     foreach ($modules as $module) {
         $path = $module['path'] . DS . 'hook';
         $path = path::decode($path);
         $hook = (array) dir::files($path, '', true, true);
         $hooks = array_merge($hooks, $hook);
     }
     $content = runtime::compile($hooks);
     if (!empty($content)) {
         file::write(ZPATH_RUNTIME . DS . 'hook.php', $content, true);
     }
 }
예제 #2
0
파일: index.php 프로젝트: dalinhuang/zotop
 public function actionIndex($dir = '')
 {
     $dir = url::clean($dir);
     $path = ZOTOP_PATH_ROOT . DS . trim($dir, DS);
     $path = path::clean($path);
     //获取当前目录的子目录及子文件
     $folders = (array) dir::folders($path);
     $files = (array) dir::files($path);
     $position = '<a href="' . zotop::url('webftp/index/index') . '">wwwroot</a>';
     $dirs = arr::dirpath($dir, '/');
     foreach ($dirs as $d) {
         $position .= ' / <a href="' . zotop::url('webftp/index/index', array('dir' => rawurlencode($d[1]))) . '">' . $d[0] . '</a>';
     }
     $page = new page();
     $page->title = '文件管理器';
     $page->set('position', $position);
     $page->set('navbar', $this->navbar($dir));
     $page->set('folders', $folders);
     $page->set('files', $files);
     $page->set('path', $path);
     $page->set('dir', $dir);
     $page->display();
 }
예제 #3
0
파일: dir.php 프로젝트: dalinhuang/zotop
 /**
  * 返回目录下的全部文件的数组
  * @param string $path 路径
  * @param array $ext 特定的文件格式,如只获取jpg,png格式
  * @param bool|int $recurse 子目录,或者子目录级数
  * @param bool $fullpath 全路径或者仅仅获取文件名称
  * @param array $ignore 忽略的文件夹名称
  * @return array
  */
 public static function files($path, $ext = '', $recurse = false, $fullpath = false, $ignore = array('.svn', 'CVS', '.DS_Store', '__MACOSX'))
 {
     $files = array();
     $path = path::clean($path);
     if (!is_dir($path)) {
         return false;
     }
     $handle = opendir($path);
     while (($file = readdir($handle)) !== false) {
         if ($file != '.' && $file != '..' && !in_array($file, $ignore)) {
             $f = $path . DS . $file;
             if (is_dir($f)) {
                 if ($recurse) {
                     if (is_bool($recurse)) {
                         $subfiles = dir::files($f, $ext, $recurse, $fullpath);
                     } else {
                         $subfiles = dir::files($f, $ext, $recurse - 1, $fullpath);
                     }
                     if (is_array($subfiles)) {
                         $files = array_merge($files, $subfiles);
                     }
                 }
             } else {
                 if (!empty($ext)) {
                     if (is_array($ext) && in_array(file::ext($file), $ext)) {
                         $files[] = $fullpath ? $f : $file;
                     }
                 } else {
                     $files[] = $fullpath ? $f : $file;
                 }
             }
         }
     }
     closedir($handle);
     return $files;
 }
예제 #4
0
파일: file.php 프로젝트: dalinhuang/zotop
 /**
  * 返回目录下的全部文件的数组,当level为0时候返回全部子文件夹目录
  * @param string $path 路径
  * @param array $ext 特定的文件格式,如只获取jpg,png格式
  * @param bool|int $recurse 子目录,或者子目录级数
  * @param bool $fullpath 全路径或者仅仅获取文件名称
  * @param array $ignore 忽略的文件夹名称
  * @return array
  */
 public static function brower($path, $ext = '', $recurse = false, $fullpath = false, $ignore = array('.svn', 'CVS', '.DS_Store', '__MACOSX'))
 {
     return dir::files($path, $ext, $recurse, $fullpath, $ignore);
 }
예제 #5
0
파일: index.php 프로젝트: dalinhuang/zotop
 public function onDefault($dir = '')
 {
     $path = ROOT . DS . trim($dir, DS);
     $path = path::clean($path);
     $folders = dir::folders($path);
     $files = dir::files($path);
     $fileext = array('php', 'css', 'js', 'jpg', 'jpeg', 'gif', 'png', 'bmp', 'psd', 'html', 'htm', 'tpl', 'rar', 'zip', 'mp3');
     $page['title'] = '文件管理器';
     page::header($page);
     page::add('<div id="page" class="clearfix">');
     page::add('<div id="main">');
     page::add('<div id="main-inner">');
     page::top();
     page::navbar($this->navbar(), 'default');
     $column = array();
     $column['select'] = '';
     $column['name'] = '名称';
     $column['type'] = '类型';
     $column['size w60'] = '大小';
     $column['atime w120'] = '创建时间';
     $column['mtime w120'] = '修改时间';
     $column['manage rename w80'] = '重命名';
     $column['manage edit w80'] = '编辑';
     $column['manage delete'] = '删除';
     table::header('list', $column);
     foreach ($folders as $folder) {
         $column = array();
         $column['select w20 center'] = html::image(url::theme() . '/image/fileext/folder.gif');
         $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $folder)) . '"><b>' . $folder . '</b></a>';
         $column['type w60'] = '文件夹';
         $column['size w60'] = '--';
         $column['atime w120'] = time::format(@fileatime($path . DS . $folder));
         $column['mtime w120'] = time::format(@filemtime($path . DS . $folder));
         $column['manage rename w80'] = '<a>重命名</a>';
         $column['manage edit w80'] = '<a class="disabled">编辑</a>';
         $column['manage delete'] = '<a>删除</a>';
         table::row($column);
     }
     foreach ($files as $file) {
         $column = array();
         $column['select w20 center'] = in_array(file::ext($file), $fileext) ? html::image(url::theme() . '/image/fileext/' . file::ext($file) . '.gif') : html::image(url::theme() . '/image/fileext/unknown.gif');
         $column['name'] = '<a href="' . zotop::url('filemanager/index/default', array('dir' => $dir . DS . $file)) . '"><b>' . $file . '</b></a>';
         $column['type w60'] = '文件';
         $column['size w60'] = format::byte(@filesize($path . DS . $file));
         $column['atime w120'] = time::format(@fileatime($path . DS . $file));
         $column['mtime w120'] = time::format(@filemtime($path . DS . $file));
         $column['manage rename w80'] = '<a>重命名</a>';
         $column['manage edit w80'] = '<a href="' . zotop::url('filemanager/file/edit', array('filename' => $dir . DS . $file, 'dir' => '***')) . '">编辑</a>';
         $column['manage delete'] = '<a>删除</a>';
         table::row($column);
     }
     table::footer();
     page::bottom();
     page::add('</div>');
     page::add('</div>');
     page::add('<div id="side">');
     block::header('快捷操作');
     echo '<ul class="list">';
     echo '<li class="file"><a href="' . zotop::url('zotop/file/newfile') . '" class="dialog">新建文件</a></li>';
     echo '<li class="folder"><a href="' . zotop::url('zotop/file/newfolder') . '" class="dialog">新建文件夹</a></li>';
     echo '<li class="folder"><a href="' . zotop::url('zotop/file/upload') . '" class="dialog">文件上传</a></li>';
     echo '</ul>';
     block::footer();
     block::header('其他位置');
     echo '<ul class="list">';
     echo '<li class="root"><a>根目录</a></li>';
     echo '<li class="root"><a>模板目录</a></li>';
     echo '<li class="root"><a>模块目录</a></li>';
     echo '<li class="root"><a>缓存目录</a></li>';
     echo '</ul>';
     block::footer();
     page::add('</div>');
     page::add('</div>');
     page::footer();
 }