示例#1
0
 public function indexAction()
 {
     $dir = $this->get('dir') ? base64_decode($this->get('dir')) : '';
     $iframe = $this->get('iframe') ? 1 : 0;
     if ($this->checkFileName($dir)) {
         $this->adminMsg(lang('m-con-20'));
     }
     $dir = substr($dir, 0, 1) == DIRECTORY_SEPARATOR ? substr($dir, 1) : $dir;
     $dir = str_replace(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, $dir);
     $data = file_list::get_file_list(VIEW_DIR . $dir);
     $dlist = $flist = array();
     if ($data) {
         foreach ($data as $t) {
             if (!$dir && $t == 'header.html') {
                 continue;
             }
             $path = $dir . $t . DIRECTORY_SEPARATOR;
             if (@is_dir(VIEW_DIR . $path) && !in_array($t, array('admin', 'install'))) {
                 //目录
                 $ext = 'dir';
                 $dlist[] = array('name' => $t, 'dir' => base64_encode($path), 'ico' => ADMIN_THEME . 'images/ext/dir.gif', 'isdir' => 1, 'url' => url('admin/theme/index', array('dir' => base64_encode($path), 'iframe' => $iframe)));
             } else {
                 //文件
                 $ext = strtolower(trim(substr(strrchr($t, '.'), 1, 10)));
                 if (in_array($ext, array('html', 'js', 'css'))) {
                     $ico = ADMIN_THEME . 'images/ext/' . $ext . '.gif';
                     $flist[] = array('name' => $t, 'dir' => base64_encode($path), 'ico' => $ico);
                 }
             }
         }
     }
     sort($flist);
     $this->view->assign(array('dir' => VIEW_DIR . $dir, 'pdir' => url('admin/theme/index', array('dir' => base64_encode(str_replace(basename($dir), '', $dir)), 'iframe' => $iframe)), 'istop' => $dir ? 1 : 0, 'dlist' => $dlist, 'flist' => $flist, 'cpath' => base64_encode($dir), 'iframe' => $iframe, 'iswrite' => is_writable(VIEW_DIR)));
     $this->view->display('admin/theme_list');
 }
示例#2
0
 /**
  * 管理
  */
 public function indexAction()
 {
     $iframe = $this->get('iframe') ? 1 : 0;
     $dir = $this->get('dir') ? base64_decode($this->get('dir')) : '';
     $dir = substr($dir, 0, 1) == '/' ? substr($dir, 1) : $dir;
     $dir = str_replace('//', '/', $dir);
     if ($this->checkFileName($dir)) {
         $this->adminMsg(lang('m-con-20'));
     }
     $list = array();
     if ($this->isPostForm()) {
         $name = $this->post('kw');
         if (empty($name)) {
             $this->adminMsg(lang('a-att-31'));
         }
         if ($this->checkFileName($name)) {
             $this->adminMsg(lang('m-con-20'));
         }
         $dir = '';
         $data = $this->getfiles($this->dir, $name);
     } else {
         $data = file_list::get_file_list($this->dir . $dir);
     }
     if ($data) {
         foreach ($data as $t) {
             if ($t == 'index.html') {
                 continue;
             }
             $path = $dir . $t . '/';
             $ext = is_dir($this->dir . $path) ? 'dir' : strtolower(trim(substr(strrchr($t, '.'), 1, 10)));
             $ico = file_exists(basename(VIEW_DIR) . '/admin/images/ext/' . $ext . '.gif') ? $ext . '.gif' : $ext . '.png';
             $fileinfo = array();
             if (is_file($this->dir . $dir . $t)) {
                 $file = $this->dir . $dir . $t;
                 $fileinfo = array('path' => $file, 'time' => date(TIME_FORMAT, filemtime($file)), 'size' => formatFileSize(filesize($file)), 'ext' => $ext);
             }
             $list[] = array('name' => $t, 'dir' => base64_encode($path), 'path' => $this->dir . $path, 'ico' => $ico, 'isimg' => in_array($ext, array('gif', 'jpg', 'png', 'jpeg', 'bmp')) ? 1 : 0, 'isdir' => is_dir($this->dir . $path) ? 1 : 0, 'fileinfo' => $fileinfo, 'url' => is_dir($this->dir . $path) ? url('admin/attachment/index', array('dir' => base64_encode($path), 'iframe' => $iframe)) : '');
         }
     }
     $this->view->assign(array('dir' => $this->dir . $dir, 'istop' => $dir ? 1 : 0, 'pdir' => url('admin/attachment/index', array('dir' => base64_encode(str_replace(basename($dir), '', $dir)), 'iframe' => $iframe)), 'list' => $list, 'iframe' => $iframe));
     $this->view->display('admin/attachment_list');
 }
示例#3
0
 /**
  * 附件管理
  */
 public function attachmentAction()
 {
     $dir = urldecode($this->get('dir'));
     $type = $this->get('type');
     $mdir = 'uploadfiles/member/' . $this->memberinfo['id'] . '/';
     //会员附件目录
     $mdir = $type == 1 ? $mdir . 'file/' : $mdir . 'image/';
     if ($this->checkFileName($dir)) {
         $this->memberMsg(lang('m-con-20'), url('member/content/attachment', array('type' => $type)));
     }
     $dir = substr($dir, 0, 1) == '/' ? substr($dir, 1) : $dir;
     $data = file_list::get_file_list($mdir . $dir . '/');
     $list = array();
     if ($data) {
         foreach ($data as $t) {
             $path = $mdir . $dir . '/' . $t;
             $ext = is_dir($path) ? 'dir' : strtolower(trim(substr(strrchr($t, '.'), 1, 10)));
             $ico = file_exists(basename(VIEW_DIR) . '/admin/images/ext/' . $ext . '.gif') ? $ext . '.gif' : $ext . '.png';
             $info = array();
             if (is_file($path)) {
                 if (strpos($t, '.thumb.') !== false) {
                     continue;
                 }
                 $info = array('ext' => $ext, 'path' => $path, 'time' => date('Y-m-d H:i:s', filemtime($path)), 'size' => formatFileSize(filesize($path), 2));
             }
             $list[] = array('dir' => urlencode($dir . '/' . $t), 'ico' => $ico, 'url' => is_dir($path) ? url('member/content/attachment', array('dir' => urlencode($dir . '/' . $t), 'type' => $type)) : '', 'name' => $t, 'path' => $path, 'info' => $info, 'isimg' => in_array($ext, array('gif', 'jpg', 'png', 'jpeg', 'bmp')) ? 1 : 0, 'isdir' => is_dir($path) ? 1 : 0);
         }
     }
     $this->view->assign(array('dir' => $dir, 'type' => $type, 'list' => $list, 'pdir' => url('member/content/attachment', array('dir' => urlencode(str_replace(basename($dir), '', $dir)), 'type' => $type)), 'istop' => $dir ? 1 : 0, 'countsize' => formatFileSize(count_member_size($this->memberinfo['id'], $type == 1 ? 'file' : 'image'), 2), 'meta_title' => lang('m-con-5') . '-' . lang('member') . '-' . $this->site['SITE_NAME']));
     $this->view->display('member/attachment');
 }
示例#4
0
 /**
  * 在线插件中心
  */
 public function onlineAction()
 {
     $name = urlencode($this->site['SITE_NAME']);
     $site = urlencode(SITE_URL);
     $list = file_list::get_file_list($this->dir);
     //扫描插件目录
     $data = array();
     if ($list) {
         foreach ($list as $id => $dir) {
             if (!in_array($dir, array('.', '..', '.svn')) && is_dir($this->dir . $dir)) {
                 $file = $this->dir . $dir . DIRECTORY_SEPARATOR . 'config.php';
                 if (file_exists($file)) {
                     $setting = (require $file);
                     $markid = (int) $setting['key'];
                     if ($markid) {
                         $data[$markid] = $setting['version'];
                     }
                 }
             }
         }
     }
     $data = base64_encode(json_encode($data));
     $this->view->assign('url', 'http://www.dayrui.com/index.php?c=v1&m=app&admin=' . ADMIN_NAMESPACE . '&site=' . $site . '&name=' . $name . '&data=' . $data . '&version=' . CMS_VERSION);
     $this->view->display('admin/plugin_online');
 }
示例#5
0
 /**
  * 文件上传
  * @param  $fields		上传字段 'file'
  * @param  $type		文件类型  array(jpg,gif)
  * @param  $size		文件大小  MB
  * @param  $img			图片配置参数
  * @param  $mark		图片水印
  * @param  $admin		是否来自后台
  * @param  $stype		上传方式  swf或者ke
  * @param  $ofile		原文件
  * @param  $document	后台栏目归档目录
  * @return Array		返回数组
  */
 private function upload($fields, $type, $size, $img = null, $mark = true, $admin = 0, $stype = null, $ofile = null, $document = null)
 {
     $path = 'uploadfiles/';
     $upload = $this->instance('file_upload');
     if (empty($admin) && $this->memberinfo) {
         $uid = $this->memberinfo['id'];
         //会员附件归类
         if ($uid) {
             $path .= 'member/' . $uid . '/';
             if (isset($this->membergroup[$this->memberinfo['groupid']]['filesize']) && $this->membergroup[$this->memberinfo['groupid']]['filesize']) {
                 $c = count_member_size($this->memberinfo['id']);
                 if ($c > $this->membergroup[$this->memberinfo['groupid']]['filesize'] * 1024 * 1024) {
                     $this->attMsg(lang('att-7', array('1' => $this->membergroup[$this->memberinfo['groupid']]['filesize'], '2' => formatFileSize($c))), $stype);
                 }
             }
         }
         $document = null;
     } elseif ($admin) {
         $uid = (int) get_cookie('member_id');
     } else {
         //$this->attMsg(lang('att-0'), $stype);
         $uid = 0;
         $patp = 'uploadfiles/guest/';
     }
     $upload->set($_FILES[$fields])->set_limit_size(1024 * 1024 * $size)->set_limit_type($type);
     //设置路径和名称
     $ext = $upload->fileext();
     if (stripos($ext, 'php') !== FALSE) {
         return array('result' => '文件格式被系统禁止');
     }
     if (in_array($ext, array('jpg', 'jpeg', 'bmp', 'png', 'gif'))) {
         $dir = 'image';
         $upload->set_image($img['w'], $img['h'], $img['t']);
     } else {
         $dir = 'file';
     }
     $path .= $dir . '/' . (empty($document) || $document == 'undefined' || !preg_match('/^[a-zA-Z_0-9]+$/', $document) ? '' : $document . '/');
     if ($ofile && is_file($ofile) && strpos($path, dirname(dirname($ofile))) === 0) {
         //判断原文件
         $path = dirname($ofile) . '/';
         $file = $fname = basename($ofile);
     } else {
         $path .= date('Ym') . '/';
         $data = file_list::get_file_list($path);
         $name = count($data) + 1;
         $name = is_file($path . $name . '.' . $ext) ? $name . str_replace('0.', '_', (double) microtime()) : $name;
         $file = $upload->filename();
         $fname = $name . '.' . $ext;
     }
     $result = $upload->upload($path, $fname);
     //上传成功处理图片
     if (!$result && $dir == 'image') {
         $this->watermark($path . $fname);
     }
     return array('result' => $result, 'path' => $path . $fname, 'file' => $file, 'ext' => $dir == 'image' ? 1 : $ext);
 }
示例#6
0
 /**
  * 清除攻击日志
  */
 public function clearattackAction()
 {
     $time = strtotime('-30 day');
     $logsdir = APP_ROOT . 'cache' . DIRECTORY_SEPARATOR . 'attack' . DIRECTORY_SEPARATOR;
     $filedata = file_list::get_file_list($logsdir);
     $count = 0;
     if ($filedata) {
         foreach ($filedata as $file) {
             if (substr($file, -4) == '.log') {
                 $name = substr($file, 0, 4) . '-' . substr($file, 4, 2) . '-' . substr($file, 6, 2);
                 if ($time > strtotime($name)) {
                     @unlink($logsdir . $file);
                     $count++;
                 }
             }
         }
     }
     $this->adminMsg(lang('a-ind-32') . '(#' . $count . ')', purl('index/attack'), 3, 1, 1);
 }
示例#7
0
 /**
  * 站点配置
  */
 public function configAction()
 {
     //加载配置文件.
     $siteid = $this->get('id') ? $this->get('id') : $this->siteid;
     $config = self::load_config('site' . DIRECTORY_SEPARATOR . $siteid);
     if ($this->post('submit')) {
         $data = $this->post('data');
         $body = "<?php" . PHP_EOL . "if (!defined('IN_FINECMS')) exit();" . PHP_EOL . PHP_EOL . "/**" . PHP_EOL . " * " . $data['SITE_NAME'] . "配置" . PHP_EOL . " */" . PHP_EOL . "return array(" . PHP_EOL . PHP_EOL;
         foreach ($this->string as $var => $str) {
             if ($var == 'SITE_LANGUAGE' && empty($data[$var])) {
                 $value = "'zh-cn'";
             } elseif ($var == 'SITE_DOMAIN') {
                 $value = "'" . $config['SITE_DOMAIN'] . "'";
             } elseif ($var == 'SITE_EXTEND_ID') {
                 $value = "'" . $config['SITE_EXTEND_ID'] . "'";
             } else {
                 $value = $data[$var] == 'false' || $data[$var] == 'true' ? $data[$var] : "'" . $data[$var] . "'";
             }
             $body .= "\t'" . strtoupper($var) . "'" . $this->setspace($var) . " => " . $value . ",  //" . $str . PHP_EOL;
         }
         $body .= PHP_EOL . ");";
         file_put_contents(CONFIG_DIR . 'site' . DIRECTORY_SEPARATOR . $siteid . '.ini.php', $body);
         $this->adminMsg(lang('success'), purl('site/config', array('id' => $siteid, 'typeid' => $this->post('typeid'))), 3, 1, 1);
     }
     //模板风格
     $theme = '';
     $file_list = file_list::get_file_list(VIEW_DIR);
     foreach ($file_list as $t) {
         if (is_dir(VIEW_DIR . $t) && strpos($t, 'mobile_') === false && !in_array($t, array('error', 'admin', 'index.html', 'install', 'mobile'))) {
             $theme .= '<option value="' . $t . '" ' . ($config['SITE_THEME'] == $t ? 'selected' : '') . '>' . $t . '</option>';
         }
     }
     $this->view->assign(array('site' => auth::check($this->roleid, 'site-index', 'admin') ? 1 : 0, 'data' => $config, 'theme' => $theme, 'langs' => file_list::get_file_list(EXTENSION_DIR . 'language' . DIRECTORY_SEPARATOR), 'typeid' => $this->get('typeid') ? $this->get('typeid') : 1, 'string' => $this->string, 'images' => file_list::get_file_list(EXTENSION_DIR . 'watermark' . DIRECTORY_SEPARATOR)));
     $this->view->display('admin/site_config');
 }