Example #1
0
 /**
  * 更新路由规则
  * @description 在非操作路由规则新增/更新,程序将仅判断文件是否存在,不存在则创建。反之则更新路由规则
  */
 public function after()
 {
     //路由规则文件
     $routeFileName = md5(\Core\Func\CoreFunc::loadConfig('PRIVATE_KEY')) . '_route.php';
     $routePath = PES_PATH . "/Config/Route/{$routeFileName}";
     $routeUrl = PES_PATH . "/Config/RouteUrl/{$routeFileName}";
     //检查路由规则文件是否存在。文件不存在则创建。只有在路由规则编辑中才会触发更新
     if (is_file($routeUrl) && is_file($routeUrl) && (GROUP != self::MATCH_GROUP || MODULE != 'Route' || ACTION != 'action')) {
         return true;
     }
     $route = \Model\Content::listContent(['table' => 'route', 'condition' => 'route_status = 1', 'order' => 'route_listsort ASC, route_id DESC']);
     if (empty($route)) {
         unlink($routePath);
         unlink($routeUrl);
     } else {
         $routeStr['route'] = $routeStr['url'] = "<?php\r\n return array(\r\n";
         foreach ($route as $key => $value) {
             $routeStr['route'] .= " '{$value['route_rule']}' => '{$value['route_controller']}',  \r\n";
             $routeStr['url'] .= " '{$value['route_hash']}' => '{$value['route_rule']}', \r\n";
         }
         $routeStr['route'] .= ");\r\n";
         $routeStr['url'] .= ");\r\n";
         //写入自定义路由规则
         $routeFopen = fopen($routePath, 'w+');
         fwrite($routeFopen, $routeStr['route']);
         fclose($routeFopen);
         //写入\Core\Func\Core::url()方法使用的匹配路由规则
         $urlFopen = fopen($routeUrl, 'w+');
         fwrite($urlFopen, $routeStr['url']);
         fclose($urlFopen);
     }
 }
Example #2
0
 /**
  * 生成URL链接
  * @param type $controller 链接的控制器
  * @param array $param 参数
  * @param type $filterHtmlSuffix 是否强制过滤HTML后缀 | 由于ajax GET请求中,若不过滤HTML,将会引起404的问题
  * @return type 返回URL
  */
 public function url($controller, $param = array(), $filterHtmlSuffix = false)
 {
     $url = \Core\Func\CoreFunc::url($controller, $param);
     if ($filterHtmlSuffix == true) {
         if (substr($url, '-5') == '.html') {
             return substr($url, '0', '-5');
         }
     }
     return $url;
 }
Example #3
0
 /**
  * 添加内容
  */
 public function action($jump = TRUE, $commit = TRUE)
 {
     if ($this->p('password')) {
         $password = $this->p('password');
         if ($password != $this->p('confirm_password')) {
             $this->error('两次输入的密码不一致');
         }
         $_POST['password'] = (string) \Core\Func\CoreFunc::generatePwd($this->isP('account', '请提交帐号') . $password, 'PRIVATE_KEY');
     }
     parent::action();
 }
Example #4
0
 public function index()
 {
     $data['user_account'] = $data['user_mail'] = $this->isP('account', '请提交账号信息');
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($this->isP('passwd', '请提交密码'));
     $login = $this->db('user')->where('(user_account = :user_account OR user_mail = :user_mail ) AND user_password = :user_password ')->find($data);
     if (empty($login)) {
         $this->error('帐号或者密码错误');
     }
     $this->setLogin($login);
     $this->success('登录成功', $this->url(GROUP . '-Index-index'));
 }
Example #5
0
 public function before()
 {
     if (METHOD == 'POST') {
         $this->isP('password', '请填写密码');
     }
     if (empty($_POST['password'])) {
         $_POST['password'] = \Model\Content::findContent('user', $_POST['id'], 'user_id')['user_password'];
     } else {
         $_POST['password'] = (string) \Core\Func\CoreFunc::generatePwd($this->p('password'));
     }
 }
Example #6
0
 /**
  * 登录帐号
  */
 public function login()
 {
     $data['user_account'] = $this->isP('account', '请填写帐号');
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('password', '请提交密码'), 'PRIVATE_KEY');
     $check = $this->db('user')->where('user_account = :user_account AND user_password = :user_password AND user_status = 1 ')->find($data);
     if (empty($check)) {
         $this->error('帐号不存在或者密码错误');
     }
     $this->setLogin($check);
     $this->success('登录成功', $this->url('/d/manage', true));
 }
Example #7
0
 /**
  * 更新用户
  */
 public function action($jump = TRUE, $commit = TRUE)
 {
     $user = \Model\Content::findContent('user', (int) $_POST['id'], 'user_id');
     if (empty($user)) {
         $this->error('不存在的用户');
     }
     if ($this->p('password')) {
         $password = $this->p('password');
         if ($password != $this->p('confirm_password')) {
             $this->error('两次输入的密码不一致');
         }
         $_POST['password'] = (string) \Core\Func\CoreFunc::generatePwd($this->isP('account', '请提交帐号') . $password, 'PRIVATE_KEY');
     }
     parent::action();
 }
Example #8
0
 /**
  * 生成分页URL
  * @param $page 当前的分页页码
  * @return string 返回URL
  */
 protected function urlLinkStr($page)
 {
     unset($_GET['s'], $_GET['page'], $_GET[substr($_SERVER['REQUEST_URI'], 1)]);
     //获取路由模式
     $urlModel = \Core\Func\CoreFunc::loadConfig('URLMODEL');
     $url = \Core\Func\CoreFunc::url(GROUP . '-' . MODULE . '-' . ACTION, $_GET, true);
     if (\Core\Func\CoreFunc::$useRoute === true) {
         $suffix = '';
         if ($urlModel['SUFFIX'] == '1') {
             $suffix = '.html';
         }
         return "{$url}/page/{$page}{$suffix}";
     } else {
         return "{$url}&page={$page}";
     }
 }
Example #9
0
 /**
  * 初始化PDO连接
  */
 protected function __initialization()
 {
     $dsn = CoreFunc::loadConfig('DB_TYPE') . ":host=" . CoreFunc::loadConfig('DB_HOST') . ";dbname=" . CoreFunc::loadConfig('DB_NAME') . ";port=" . CoreFunc::loadConfig('DB_PORT');
     try {
         $this->dbh = new \PDO($dsn, CoreFunc::loadConfig('DB_USER'), CoreFunc::loadConfig('DB_PWD'));
         $this->dbh->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
         $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         $this->dbh->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
         $this->dbh->exec('SET NAMES UTF8');
     } catch (\PDOException $e) {
         if (DEBUG == true) {
             die("Error!: {$e->getMessage()} <br/>");
         } else {
             die("Error!: DB ERROR <br/>");
         }
     }
 }
Example #10
0
 public function __init()
 {
     parent::__init();
     if (empty($_FILES)) {
         $this->callBack('没有数据上传', '0');
     }
     /**
      * 获取允许上传的文件格式
      */
     $result = \Model\Option::getOptionRange('upload');
     foreach ($result as $key => $value) {
         $this->allowFormat[$value['option_name']] = json_decode($value['value'], true);
     }
     /**
      * 获取配置文件的上传目录
      */
     $this->uploadPath = PES_PATH . \Core\Func\CoreFunc::loadConfig('UPLOAD_PATH');
     /**
      * 分析上传目录
      */
     $this->uploadFileType = pathinfo($_FILES['file']['name']);
     /**
      * 存储路径
      */
     $this->savePath = $this->uploadPath . date('/Ymd/');
     /**
      * 移除完整的目录信息
      * 以便记录入库
      */
     $this->recordPath = str_replace(PES_PATH, "", $this->savePath);
     /**
      * 判断上传目录是否存在
      */
     if (is_dir($this->uploadPath) === false) {
         mkdir($this->uploadPath);
         fopen("{$this->uploadPath}/index.html", 'w');
     }
     /**
      * 创建以日期形式存储目录
      */
     if (is_dir($this->savePath) === false) {
         mkdir($this->savePath);
         fopen("{$this->savePath}/index.html", 'w');
     }
 }
Example #11
0
 /**
  * 设置语言
  */
 private function setLanguage()
 {
     /**
      * 设置语言
      */
     if (empty($_COOKIE['language'])) {
         $lang = $_SESSION['language'] = \Core\Func\CoreFunc::loadConfig('LANGUAGE');
         setcookie('language', $lang, time() + 604800, '/');
     } else {
         $lang = $_SESSION['language'] = $_COOKIE['language'];
     }
     /**
      * 定义全局语言包
      * @name $_LANG 语言包
      */
     $GLOBALS['_CORELANG'] = (require PES_PATH . "Language/{$lang}/Core/lang.php");
     if (file_exists(PES_PATH . "Language/{$lang}/" . GROUP . "/lang.php")) {
         $GLOBALS['_LANG'] = (require PES_PATH . "Language/{$lang}/" . GROUP . "/lang.php");
     }
 }
Example #12
0
 /**
  * 注册帐号
  */
 public function signup()
 {
     if (\Model\Option::findOption('signup')['value'] == '0') {
         $this->error('本系统没有开启注册。');
     }
     $data['user_account'] = $this->isP('account', '请填写帐号');
     $existAccount = \Model\Content::findContent('user', $data['user_account'], 'user_account');
     if (!empty($existAccount)) {
         $this->error('帐号已存在');
     }
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('password', '请填写密码'), 'PRIVATE_KEY');
     $repwd = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('repassword', '请填写密码'), 'PRIVATE_KEY');
     if ($data['user_password'] != $repwd) {
         $this->error('两次密码不一致');
     }
     $data['user_mail'] = $this->isP('mail', '请填写帐号');
     $existEmail = \Model\Content::findContent('user', $data['user_mail'], 'user_mail');
     if (!empty($existEmail)) {
         $this->error('邮箱地址已存在');
     }
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($data['user_mail']);
     $data['user_name'] = $this->isP('name', '请填写帐号');
     $data['user_status'] = '1';
     $data['user_createtime'] = time();
     $data['user_department_id'] = '2';
     //人事部
     $data['user_group_id'] = '2';
     //普通用户
     $data['user_head'] = $imageDataUri;
     $addResult = $this->db('user')->insert($data);
     if (empty($addResult)) {
         $this->error('注册失败');
     }
     unset($data['user_password']);
     $data['user_id'] = $addResult;
     $this->setLogin($data);
     $this->success('注册成功!', $this->url(GROUP . '-Index-index'));
 }
Example #13
0
 /**
  * URL模式
  * @param type $group 组参数
  */
 protected function urlModel($group = '')
 {
     //这里移除GET中可能潜在影响程序正确处理的数据。
     unset($_GET['s'], $_GET['page'], $_GET[substr($_SERVER['REQUEST_URI'], 1)]);
     $urlModel = \Core\Func\CoreFunc::loadConfig('URLMODEL');
     $url = '';
     if ($urlModel['INDEX'] == '0') {
         $url .= '/index.php/';
     } else {
         $url .= '/';
     }
     /**
      * 正常模式不会生成HTML后缀
      */
     if ($urlModel['SUFFIX'] == '1' && $urlModel['URLMODE'] != '1') {
         $this->suffix = true;
     }
     switch ($urlModel['URLMODE']) {
         case '2':
             $group = empty($group) ? '' : "{$group}-";
             $url .= $group . MODULE . "-" . ACTION;
             $url .= $this->urlLinkStr($_GET, '-');
             $this->linkStr = '-';
             break;
         case '3':
             $group = empty($group) ? '' : "{$group}/";
             $url .= $group . MODULE . "/" . ACTION;
             $url .= $this->urlLinkStr($_GET, '/');
             $this->linkStr = '/';
             break;
         case '1':
         default:
             $url = $urlModel['INDEX'] == '0' ? '/index.php' : '/';
             $group = empty($group) ? '' : "g={$group}&";
             $url .= "?{$group}m=" . MODULE . "&a=" . ACTION;
             $url .= $this->urlLinkStr($_GET);
             $this->linkStr = '';
     }
     return DOCUMENT_ROOT . $url;
 }
Example #14
0
 public function __construct()
 {
     try {
         $config = CoreFunc::loadConfig();
         $configParam = array('DB_TYPE', 'DB_HOST', 'DB_NAME', 'DB_PORT', 'DB_USER', 'DB_PWD', 'DB_PREFIX');
         foreach ($configParam as $value) {
             $useConfig[$value] = !empty($config[GROUP][$value]) ? $config[GROUP][$value] : $config[$value];
         }
         $this->defaultDb = $useConfig['DB_NAME'];
         $dns = "{$useConfig['DB_TYPE']}:host={$useConfig['DB_HOST']};dbname={$useConfig['DB_NAME']};port={$useConfig['DB_PORT']}";
         $this->prefix = $useConfig['DB_PREFIX'];
         $this->dbh = new \PDO($dns, $useConfig['DB_USER'], $useConfig['DB_PWD']);
         $this->dbh->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, \PDO::FETCH_ASSOC);
         $this->dbh->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         $this->dbh->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
         $this->dbh->exec('SET NAMES UTF8');
     } catch (\PDOException $e) {
         if (DEBUG == true) {
             die("Error!: {$e->getMessage()} <br/>");
         } else {
             die("Error!: DB ERROR <br/>");
         }
     }
 }
Example #15
0
 /**
  * 初始化数据库选项
  * @return \Core\Db\Mysql
  */
 public static function __init()
 {
     static $db;
     if (empty($db)) {
         $dbType = CoreFunc::loadConfig('DB_TYPE');
         switch ($dbType) {
             case 'mysql':
                 $db = new Mysql();
                 break;
                 //            扩展其他数据库连接类型
                 //            case '':
                 //                break;
                 //默认为数据库选择mysql
             //            扩展其他数据库连接类型
             //            case '':
             //                break;
             //默认为数据库选择mysql
             default:
                 $db = new Mysql();
                 break;
         }
     }
     return $db;
 }
Example #16
0
 /**
  * 导入数据库
  */
 public function import()
 {
     $title = $this->isP('title', '请填写系统的标题');
     $urlModel = $this->isP('urlModel', '请选择URL模式', FALSE);
     $data['user_account'] = $this->isP('account', '请填写管理员帐号');
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('passwd', '请填写管理员密码'), 'PRIVATE_KEY');
     $data['user_name'] = $this->isP('name', '请填写管理员名称');
     $data['user_mail'] = $this->isP('mail', '请填写管理员邮箱');
     //读取数据库文件
     $sqlFile = file_get_contents(PES_PATH . '/Install/InstallDb/team.sql');
     if (empty($sqlFile)) {
         $this->error('无法读取安装SQL文件');
     }
     //配置PDO信息
     $config = \Core\Func\CoreFunc::loadConfig();
     try {
         $db = new \PDO("mysql:host={$config['DB_HOST']};port={$config['DB_PORT']};dbname={$config['DB_NAME']}", $config['DB_USER'], $config['DB_PWD']);
     } catch (\PDOException $e) {
         $this->error($e->getMessage());
     }
     //安装数据库文件
     $db->exec($sqlFile);
     \Core\Func\CoreFunc::$defaultPath = false;
     require PES_PATH . '/Expand/Identicon/autoload.php';
     $identicon = new \Identicon\Identicon();
     $imageDataUri = $identicon->getImageDataUri($data['user_mail']);
     $data['user_head'] = $imageDataUri;
     $data['user_department_id'] = $data['user_status'] = $data['user_group_id'] = '1';
     //写入管理员帐号
     $this->db('user')->insert($data);
     //更新系统配置
     \Model\Option::update('sitetitle', $title);
     \Model\Option::update('urlModel', $urlModel);
     //更新根目录的index.php
     $readWriteFile = file_get_contents(PES_PATH . '/Install/Write/index.php');
     $fopen = fopen(PES_PATH . '/index.php', 'w+');
     fwrite($fopen, $readWriteFile);
     fclose($fopen);
     //标记程序已安装和移除安装数据库文件
     unlink(PES_PATH . '/Install/index.php');
     unlink(PES_PATH . '/Install/InstallDb/team.sql');
     fclose(fopen(PES_PATH . '/Install/install.txt', 'w+'));
     fclose(fopen(PES_PATH . '/Install/index.html', 'w+'));
     $this->success('安装完成!');
 }
Example #17
0
 /**
  * 生成对应的HTML表单内容
  * @param type $field 提交过来的字段
  */
 public function formList($field)
 {
     switch ($field['field_type']) {
         case 'text':
             require 'theme/text.php';
             break;
         case 'textarea':
             require 'theme/textarea.php';
             break;
         case 'editor':
             /**
              * 将属于必填项的表单名称写入数组
              * 在模板的底部进行一个JS的校验.
              */
             static $checkEditor, $checkEditorName;
             if ($field['field_required'] == '1') {
                 /* 表单名称 */
                 $checkEditor[] = $field['field_name'];
                 /* 显示名称 */
                 $checkEditorName[] = $field['field_display_name'];
             }
             require 'theme/editor.php';
             break;
         case 'date':
             require 'theme/date.php';
             break;
         case 'radio':
             require 'theme/radio.php';
             break;
         case 'checkbox':
             require 'theme/checkbox.php';
             break;
         case 'thumb':
             require 'theme/thumb.php';
             break;
         case 'category':
             \Model\Category::$where = 'm.model_name = "' . MODULE . '"';
             $tree = \Model\Category::getSelectCate($field['value'] ? array($field['value']) : array(), true);
             require 'theme/category.php';
             break;
         case 'select':
             require 'theme/select.php';
             break;
         case 'file':
             require 'theme/file.php';
             break;
         case 'img':
             require 'theme/img.php';
             break;
         case 'theme':
             $themeName = THEME . '/Home/' . \Core\Func\CoreFunc::getThemeName('Home') . '/' . MODULE;
             $themeList = scandir($themeName);
             $theme = ['默认模板' => ''];
             foreach ($themeList as $value) {
                 if ($value != '.' && $value != '..' && $value != '.DS_Store') {
                     $value = str_replace('.php', '', $value);
                     $theme[$value] = $value;
                 }
             }
             $field['field_option'] = json_encode($theme);
             require 'theme/select.php';
             break;
     }
 }
Example #18
0
 /**
  * 扩展模式
  */
 private function expand()
 {
     $requestUri = $this->filterHtmlSuffix($this->changeUrl());
     //拆分数据
     $routeArray = explode('-', $requestUri);
     $routeArray[0] = $this->splitIndex($routeArray[0]);
     //拆分组
     $groupList = explode(',', CoreFunc::loadConfig('APP_GROUP_LIST'));
     //判断URL首个参数是否存在于用户组
     if (in_array($routeArray[0], $groupList)) {
         defined('GROUP') or define('GROUP', $routeArray[0]);
         defined('MODULE') or define('MODULE', $routeArray[1]);
         defined('ACTION') or define('ACTION', $this->splitAction($routeArray[2]));
         unset($routeArray[0], $routeArray[1], $routeArray[2]);
     } else {
         defined('GROUP') or define('GROUP', CoreFunc::loadConfig('DEFAULT_GROUP'));
         defined('MODULE') or define('MODULE', $routeArray[0]);
         defined('ACTION') or define('ACTION', $this->splitAction($routeArray[1]));
         unset($routeArray[0], $routeArray[1]);
     }
     //将剩余的非GMA转化为GET参数,以便调用
     $paramArray = array_chunk($routeArray, 2);
     foreach ($paramArray as $key => $value) {
         $_REQUEST[$value[0]] = $_GET[$value[0]] = $value[1];
     }
 }
Example #19
0
 /**
  * 导入数据库
  */
 public function import()
 {
     $title = $this->isP('title', '请填写系统的标题');
     $urlModel = $this->isP('urlModel', '请选择URL模式', FALSE);
     $data['user_account'] = $this->isP('account', '请填写管理员帐号');
     $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $this->isP('passwd', '请填写管理员密码'), 'PRIVATE_KEY');
     $data['user_name'] = $this->isP('name', '请填写管理员名称');
     $data['user_mail'] = $this->isP('mail', '请填写管理员邮箱');
     //读取数据库文件
     $sqlFile = file_get_contents(PES_PATH . '/Install/InstallDb/doc.sql');
     if (empty($sqlFile)) {
         $this->error('无法读取安装SQL文件');
     }
     //配置PDO信息
     $config = \Core\Func\CoreFunc::loadConfig();
     try {
         //创建数据库
         $tmp = new \PDO("mysql:host={$config['DB_HOST']};port={$config['DB_PORT']}", $config['DB_USER'], $config['DB_PWD']);
         $createDb = "CREATE DATABASE IF NOT EXISTS {$config['DB_NAME']} DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
         $tmp->exec($createDb);
         //连接数据库
         $db = new \PDO("mysql:host={$config['DB_HOST']};port={$config['DB_PORT']};dbname={$config['DB_NAME']}", $config['DB_USER'], $config['DB_PWD']);
     } catch (\PDOException $e) {
         $this->error($e->getMessage());
     }
     //安装数据库文件
     $db->exec($sqlFile);
     $data['user_status'] = '1';
     //写入管理员帐号
     $this->db('user')->insert($data);
     //更新运行的配置文件
     $config = (require PES_PATH . '/Install/Config/config_tmp.php');
     $fopen = fopen(PES_PATH . '/Config/config.php', 'w+');
     if (!$fopen) {
         $this->error('文件无法打开,请检测程序目录是否设置足够的权限');
     }
     $str = "<?php\n \$config = array(\n";
     $str .= "'SITETITLE' => '{$title}',\n";
     foreach (array_merge($config, json_decode($urlModel, true)) as $key => $value) {
         if (is_array($value)) {
             $str .= "'{$key}' => array(\n";
             foreach ($value as $ik => $iv) {
                 $str .= "'{$ik}' => '{$iv}',\n";
             }
             $str .= "),";
         } else {
             $str .= "'{$key}' => '{$value}',\n";
         }
     }
     $str .= ");\n";
     $str .= file_get_contents(PES_PATH . '/Config/config_same.php');
     fwrite($fopen, $str);
     fclose($fopen);
     //更新根目录的index.php
     $readWriteFile = file_get_contents(PES_PATH . '/Install/Write/index.php');
     $fopen = fopen(PES_PATH . '/index.php', 'w+');
     fwrite($fopen, $readWriteFile);
     fclose($fopen);
     //标记程序已安装和移除安装数据库文件
     unlink(PES_PATH . '/Install/index.php');
     unlink(PES_PATH . '/Install/InstallDb/doc.sql');
     fclose(fopen(PES_PATH . '/Install/install.txt', 'w+'));
     fclose(fopen(PES_PATH . '/Install/index.html', 'w+'));
     $this->success('安装完成!');
 }
Example #20
0
 /**
  * 声明DB类
  * @param type $name 表名
  * @return type
  */
 public function db($name = '')
 {
     return \Core\Func\CoreFunc::db($name);
 }
 /**
  * 生成URL链接
  * @param type $controller 链接的控制器
  * @param array $param 参数
  * @return type 返回URL
  */
 protected function url($controller, array $param = array())
 {
     return \Core\Func\CoreFunc::url($controller, $param);
 }
Example #22
0
 /**
  * 正常的路由加载模式
  * @throws Abnormal
  */
 private function normal()
 {
     //获取所有组
     $group = explode(',', CoreFunc::loadConfig('APP_GROUP_LIST'));
     if (!empty($_GET['m']) && !empty($_GET['a'])) {
         //获取组
         if (empty($_GET['g'])) {
             define('GROUP', CoreFunc::loadConfig('DEFAULT_GROUP'));
         } elseif (in_array($_GET['g'], $group)) {
             $key = array_search($_GET['g'], $group);
             define('GROUP', $group[$key]);
         }
         define('MODULE', $_GET['m']);
         define('ACTION', $_GET['a']);
         //清空GET
         unset($_GET['g'], $_GET['m'], $_GET['a']);
     }
 }
Example #23
0
 /**
  * 下载文件
  * @param type $url 下载文件的地址
  */
 private function getFile($url)
 {
     $uploadPath = PES_PATH . \Core\Func\CoreFunc::loadConfig('UPLOAD_PATH');
     if (!is_dir($uploadPath)) {
         mkdir($uploadPath);
     }
     $downLoadpath = "{$uploadPath}/update";
     if (!is_dir($downLoadpath)) {
         mkdir($downLoadpath);
     }
     $fileInfo = pathinfo($url);
     $newfname = "{$downLoadpath}/{$fileInfo['basename']}";
     //防止多次下载,引起主站负担过重.
     if (is_file($newfname)) {
         return true;
     }
     $file = fopen($url, "rb");
     if ($file) {
         $newf = fopen($newfname, "wb");
         if ($newf) {
             while (!feof($file)) {
                 fwrite($newf, fread($file, 1024 * 8), 1024 * 8);
             }
         }
     } else {
         $this->error('文件下载失败');
     }
     if ($file) {
         fclose($file);
     }
     if ($newf) {
         fclose($newf);
     }
 }
Example #24
0
 /**
  * 菜单基础表单
  */
 public static function baseFrom()
 {
     $fieldPrefix = "user_";
     $model = \Model\Model::findModel('user', 'model_name');
     $field = \Model\Field::fieldList($model['model_id'], '1');
     if (self::p('method') == 'PUT') {
         if (!($data['noset']['user_id'] = self::isP('user_id'))) {
             return self::error($GLOBALS['_LANG']['USER']['LOST_USER_ID']);
         }
         if (!self::findUser($data['noset']['user_id'])) {
             return self::error($GLOBALS['_LANG']['USER']['NOT_EXITS_USER']);
         }
     } elseif (self::p('method') == 'POST') {
         $data['user_createtime'] = time();
     }
     foreach ($field as $value) {
         /**
          * 判断提交的字段是否为数组
          */
         if (is_array($_POST[$value['field_name']])) {
             $_POST[$fieldPrefix . $value['field_name']] = implode(',', $_POST[$fieldPrefix . $value['field_name']]);
         }
         /**
          * 时间转换为时间戳
          */
         if ($value['field_type'] == 'date') {
             $_POST[$fieldPrefix . $value['field_name']] = strtotime($_POST[$fieldPrefix . $value['field_name']]);
         }
         if ($value['field_required'] == '1') {
             if (!($data[$fieldPrefix . $value['field_name']] = self::isP($fieldPrefix . $value['field_name'])) && !is_numeric($data[$fieldPrefix . $value['field_name']])) {
                 return self::error($value['display_name'] . $GLOBALS['_LANG']['COMMON']['REQUIRED']);
             }
         } else {
             if (!($data[$fieldPrefix . $value['field_name']] = self::p($fieldPrefix . $value['field_name']))) {
                 $data[$fieldPrefix . $value['field_name']] = $value['field_default'];
             }
         }
     }
     /**
      * 先移除密码
      */
     unset($data['user_password']);
     if (self::p('user_password')) {
         $password = self::p('user_password');
         if ($password != self::p('confirm_password')) {
             return self::error($GLOBALS['_LANG']['USER']['CONFIRM_PASSWORD_ERROR']);
         }
         $data['user_password'] = \Core\Func\CoreFunc::generatePwd($data['user_account'] . $password, 'PRIVATE_KEY');
     } elseif (self::p('method') == 'POST' && !self::p('user_password')) {
         return self::error($GLOBALS['_LANG']['USER']['ENTER_PASSWORD']);
     }
     return self::success($data);
 }
Example #25
0
 /**
  * 获取系统配置信息
  * @param type $name 配置信息 | 为空则获取所有
  * @return type 返回配置信息
  */
 private static function loadConfig($name = NULL)
 {
     return \Core\Func\CoreFunc::loadConfig($name);
 }
Example #26
0
 /**
  * 获取模板
  */
 private function getTemplate()
 {
     $theme = \Core\Func\CoreFunc::getThemeName();
     $path = THEME . '/' . GROUP . "/{$theme}/";
     if (file_exists($path . MODULE . '/' . MODULE . '_' . ACTION . '.php')) {
         require $path . MODULE . '/' . MODULE . '_' . ACTION . '.php';
     } elseif (file_exists($path . MODULE . '_' . ACTION . '.php')) {
         require $path . MODULE . '_' . ACTION . '.php';
     } else {
         return false;
     }
 }