/** * 更新系统 */ public function upgrade() { \Model\Option::getUpdate(); $version = \Model\Option::findOption('version')['value']; $content = \Model\Content::findContent('update_list', $version, 'update_list_pre_version'); $this->assign($content); $this->assign('title', \Model\Menu::getTitleWithMenu()); $this->layout(); }
/** * 获取系统更新信息 * @return boolean 返回抓去结果 */ public static function getUpdate() { $version = \Model\Option::findOption('version')['value']; $findUpdate = \Model\Content::findContent('update_list', $version, 'update_list_pre_version'); if (empty($findUpdate)) { $update = \Model\Extra::getUpdate($version); return $update['status']; } }
public function __init() { parent::__init(); $this->table = strtolower(MODULE); $this->fieldPrefix = $this->table . "_"; $this->model = \Model\Model::findModel($this->table, 'model_name'); if (empty($this->model)) { $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_MODEL']); } $this->assign('fieldPrefix', $this->fieldPrefix); $this->theme = \Model\Option::findOption('theme'); }
/** * 更新用户头像 */ public function setHead() { if (empty($_FILES['file']['tmp_name'])) { $this->error('请选择您要裁剪的头像'); } $width = $this->isP('width', '请选择您要裁剪的高度'); $height = $this->isP('height', '请选择您要裁剪的高度'); $x = $this->p('x'); $y = $this->p('y'); $allowFormat = json_decode(\Model\Option::findOption('upload_img')['value'], true); $extension = pathinfo($_FILES['file']['name'])['extension']; if (!in_array($extension, $allowFormat)) { $this->error('图片格式不被支持'); } $uploadPath = PES_PATH . $this->loadConfig('UPLOAD_PATH'); if (is_dir($uploadPath) === false) { mkdir($uploadPath); fopen("{$uploadPath}/index.html", 'w'); } $savePath = $uploadPath . date('/Ymd/'); if (is_dir($savePath) === false) { mkdir($savePath); fopen("{$savePath}/index.html", 'w'); } $name = uniqid() . ".{$extension}"; switch (strtolower($extension)) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($_FILES['file']['tmp_name']); break; case 'gif': $image = imagecreatefromgif($_FILES['file']['tmp_name']); break; case 'png': $image = imagecreatefrompng($_FILES['file']['tmp_name']); break; } $cutimg = imagecreatetruecolor($width, $height); $alpha = imagecolorallocatealpha($cutimg, 0, 0, 0, 127); imagefill($cutimg, 0, 0, $alpha); imagecopyresampled($cutimg, $image, 0, 0, $x, $y, $width, $height, $width, $height); imagepng($cutimg, $savePath . $name); imagedestroy($cutimg); imagedestroy($back); $updateHeadPath = str_replace(PES_PATH, "", $savePath . $name); $setHeadResult = $this->db('user')->where('user_id = :user_id')->update(array('noset' => array('user_id' => $_SESSION['team']['user_id']), 'user_head' => DOCUMENT_ROOT . $updateHeadPath)); if ($setHeadResult == false) { $this->error('设置头像失败'); } $_SESSION['team']['user_head'] = DOCUMENT_ROOT . $updateHeadPath; $this->success('设置成功!', $this->url('Team-Index-dynamic')); }
public function __init() { parent::__init(); if (empty($_FILES)) { $this->callBack($GLOBALS['_LANG']['UPLOAD']['EMPTY_UPLOAD'], '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 . $this->loadConfig('UPLOAD_PATH'); /** * 分析上传目录 */ $this->uploadFileType = pathinfo($_FILES['file']['name']); /** * 存储路径 */ $this->savePath = $this->uploadPath . date('/Ymd/'); /** * 移除完整的目录信息 * 以便记录入库 */ $this->recordPath = DOCUMENT_ROOT . 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'); } }
/** * 注册帐号 */ 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')); }
/** * 字段添加/编辑 */ public function fieldAction() { $fieldId = $this->g('id'); $modelId = $this->isG('model', '请选择模型'); $model = \Model\ModelManage::findModel($modelId); if (empty($fieldId)) { $this->assign('method', 'POST'); $this->assign('title', "添加字段 - {$model['lang_key']}"); } else { $field = \Model\Field::findField($fieldId); if (empty($field)) { $this->error('不存在的字段'); } $this->assign($field); $this->assign('method', 'PUT'); $this->assign('title', "编辑字段 - {$model['lang_key']}"); } $fieldTypeOption = \Model\Option::findOption('fieldType'); $this->assign('fieldTypeList', json_decode($fieldTypeOption['value'], true)); $this->assign('modelId', $modelId); $this->layout(); }
/** * 字段添加/编辑 */ public function fieldAction() { $fieldId = $this->g('id'); $modelId = $this->isG('model', $GLOBALS['_LANG']['MODEL']['SELECT_MODEL_ID']); $model = \Model\Model::findModel($modelId); if (empty($fieldId)) { $this->assign('method', 'POST'); $this->assign('title', $GLOBALS['_LANG']['MODEL']['FIELD_ADD'] . " - {$model['lang_key']}"); } else { $field = \Model\Field::findField($fieldId); if (empty($field)) { $this->error($GLOBALS['_LANG']['MODEL']['NOT_EXIST_FIELD']); } $this->assign($field); $this->assign('method', 'PUT'); $this->assign('title', "{$GLOBALS['_LANG']['MODEL']['FIELD_EDIT']} - {$model['lang_key']}"); } $fieldTypeOption = \Model\Option::findOption('fieldType'); $this->assign('fieldTypeList', json_decode($fieldTypeOption['value'], true)); $this->assign('modelId', $modelId); $this->layout(); }
/** * 全体动态 */ public function dynamic() { $page = new \Expand\Team\Page(); $page->listRows = "30"; $total = count($this->db('dynamic AS d')->field('d.dynamic_id')->join("{$this->prefix}task AS t ON t.task_id = d.task_id")->order('dynamic_id DESC')->group('d.dynamic_id')->select()); $count = $page->total($total); $page->handle(); $list = $this->db('dynamic AS d')->join("{$this->prefix}task AS t ON t.task_id = d.task_id")->order('dynamic_id DESC')->group('d.dynamic_id')->limit("{$page->firstRow}, {$page->listRows}")->select(); $show = $page->show(); $this->assign('page', $show); $this->assign('list', $list); //获取更新信息 $updateTips = $this->db('update_list')->where('update_list_read = 0')->order('update_list_type DESC')->find(); $this->assign('updateTips', $updateTips); $this->assign('title', \Model\Menu::getTitleWithMenu()); //每天下午3点开始10分钟将自动检测更新 if (date('hi') >= '1500' && date('hi') <= '1510') { $update = \Model\Option::getUpdate(); if ($update['status'] == '-1') { $this->assign('noCurl', '1'); } } $this->layout(); }
/** * 导入数据库 */ 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('安装完成!'); }
/** * 选择前后台主题名称 */ private function chooseTheme() { if (GROUP == 'Admin') { $themeName = \Model\Option::findOption('backstagetheme'); } else { $themeName = \Model\Option::findOption('theme'); } return $themeName['value']; }
public function __init() { parent::__init(); $this->assign('sitetile', \Model\Option::findOption('sitetitle')['value']); $this->assign('signup', \Model\Option::findOption('signup')['value']); }
public function index() { $this->assign('sitetile', \Model\Option::findOption('sitetitle')['value']); $this->assign('menu', \Model\Menu::menu($_SESSION['team']['user_group_id'])); $this->display(); }
/** * 安装结束,移除下载的更新文件 */ public function installEnd() { $version = \Model\Option::findOption('version')['value']; $findUpdate = \Model\Content::findContent('update_list', $version, 'update_list_pre_version'); //设置系统版本 $this->db('option')->where('option_name = :option_name')->update(array('noset' => array('option_name' => 'version'), 'value' => $findUpdate['update_list_version'])); //设置版本为已读. $this->db('update_list')->where('update_list_version = :update_list_version')->update(array('noset' => array('update_list_version' => $findUpdate['update_list_version']), 'update_list_read' => '1')); $this->success('系统更新已完成'); }