diff --git a/application/admin/command/Addon.php b/application/admin/command/Addon.php index 302ced6f..c82335d6 100644 --- a/application/admin/command/Addon.php +++ b/application/admin/command/Addon.php @@ -33,6 +33,9 @@ class Addon extends Command { $name = $input->getOption('name') ?: ''; $action = $input->getOption('action') ?: ''; + if(stripos($name, 'addons/')!==false){ + $name = explode('/', $name)[1]; + } //强制覆盖 $force = $input->getOption('force'); //版本 @@ -65,8 +68,8 @@ class Addon extends Command if (is_dir($addonDir)) { rmdirs($addonDir); } - mkdir($addonDir); - mkdir($addonDir . DS . 'controller'); + mkdir($addonDir, 0755, true); + mkdir($addonDir . DS . 'controller', 0755, true); $menuList = \app\common\library\Menu::export($name); $createMenu = $this->getCreateMenu($menuList); $prefix = Config::get('database.prefix'); diff --git a/application/admin/command/Api/template/index.html b/application/admin/command/Api/template/index.html index 1fc0b185..2bb4db90 100755 --- a/application/admin/command/Api/template/index.html +++ b/application/admin/command/Api/template/index.html @@ -437,8 +437,8 @@ $.ajax({ url: $('#apiUrl').val() + url, - data: $(form).attr('method') == 'get' ? $(form).serialize() : formData, - type: $(form).attr('method') + '', + data: $(form).prop('method').toLowerCase() == 'get' ? $(form).serialize() : formData, + type: $(form).prop('method') + '', dataType: 'json', contentType: false, processData: false, diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index c75ce6ea..47756e5c 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -1175,7 +1175,7 @@ EOD; * 获取图片模板数据 * @param string $field * @param string $content - * @return array + * @return string */ protected function getImageUpload($field, $content) { diff --git a/application/admin/command/Crud/stubs/controller.stub b/application/admin/command/Crud/stubs/controller.stub index 9b0d2d1d..73e6aca2 100644 --- a/application/admin/command/Crud/stubs/controller.stub +++ b/application/admin/command/Crud/stubs/controller.stub @@ -14,6 +14,7 @@ class {%controllerName%} extends Backend /** * {%modelName%}模型对象 + * @var \{%modelNamespace%}\{%modelName%} */ protected $model = null; diff --git a/application/admin/command/Crud/stubs/controllerindex.stub b/application/admin/command/Crud/stubs/controllerindex.stub index 5294600c..2771aa63 100755 --- a/application/admin/command/Crud/stubs/controllerindex.stub +++ b/application/admin/command/Crud/stubs/controllerindex.stub @@ -10,6 +10,11 @@ $this->request->filter(['strip_tags']); if ($this->request->isAjax()) { + //如果发送的来源是Selectpage,则转发到Selectpage + if ($this->request->request('keyField')) + { + return $this->selectpage(); + } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $total = $this->model {%relationWithList%} diff --git a/application/admin/command/Install/fastadmin.sql b/application/admin/command/Install/fastadmin.sql index 2881701c..e2b048e2 100755 --- a/application/admin/command/Install/fastadmin.sql +++ b/application/admin/command/Install/fastadmin.sql @@ -50,7 +50,7 @@ CREATE TABLE `fa_admin_log` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', `username` varchar(30) NOT NULL DEFAULT '' COMMENT '管理员名字', - `url` varchar(2000) NOT NULL DEFAULT '' COMMENT '操作页面', + `url` varchar(1500) NOT NULL DEFAULT '' COMMENT '操作页面', `title` varchar(100) NOT NULL DEFAULT '' COMMENT '日志标题', `content` text NOT NULL COMMENT '内容', `ip` varchar(50) NOT NULL DEFAULT '' COMMENT 'IP', @@ -66,6 +66,8 @@ CREATE TABLE `fa_admin_log` ( DROP TABLE IF EXISTS `fa_attachment`; CREATE TABLE `fa_attachment` ( `id` int(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID', + `admin_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '管理员ID', + `user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '会员ID', `url` varchar(255) NOT NULL DEFAULT '' COMMENT '物理路径', `imagewidth` varchar(30) NOT NULL DEFAULT '' COMMENT '宽度', `imageheight` varchar(30) NOT NULL DEFAULT '' COMMENT '高度', @@ -77,7 +79,7 @@ CREATE TABLE `fa_attachment` ( `createtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建日期', `updatetime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '更新时间', `uploadtime` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '上传时间', - `storage` enum('local','upyun','qiniu') NOT NULL DEFAULT 'local' COMMENT '存储位置', + `storage` varchar(100) NOT NULL DEFAULT 'local' COMMENT '存储位置', `sha1` varchar(40) NOT NULL DEFAULT '' COMMENT '文件 sha1编码', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='附件表'; @@ -86,7 +88,7 @@ CREATE TABLE `fa_attachment` ( -- Records of fa_attachment -- ---------------------------- BEGIN; -INSERT INTO `fa_attachment` VALUES (1, '/assets/img/qrcode.png', '150', '150', 'png', 0, 21859, 'image/png', '', 1499681848, 1499681848, 1499681848, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); +INSERT INTO `fa_attachment` VALUES (1, 1, 0, '/assets/img/qrcode.png', '150', '150', 'png', 0, 21859, 'image/png', '', 1499681848, 1499681848, 1499681848, 'local', '17163603d0263e4838b9387ff2cd4877e8b018f6'); COMMIT; -- ---------------------------- @@ -344,7 +346,7 @@ DROP TABLE IF EXISTS `fa_ems`; CREATE TABLE `fa_ems` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'ID', `event` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '事件', - `email` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '邮箱', + `email` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '邮箱', `code` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '验证码', `times` int(10) UNSIGNED NOT NULL DEFAULT 0 COMMENT '验证次数', `ip` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT 'IP', diff --git a/application/admin/controller/Addon.php b/application/admin/controller/Addon.php index f3f5f249..4e3dd473 100644 --- a/application/admin/controller/Addon.php +++ b/application/admin/controller/Addon.php @@ -76,7 +76,7 @@ class Addon extends Backend Service::refresh(); $this->success(); } catch (Exception $e) { - $this->error($e->getMessage()); + $this->error(__($e->getMessage())); } } $this->error(__('Parameter %s can not be empty', '')); @@ -112,9 +112,9 @@ class Addon extends Backend $info['state'] = 1; $this->success(__('Install successful'), null, ['addon' => $info]); } catch (AddonException $e) { - $this->result($e->getData(), $e->getCode(), $e->getMessage()); + $this->result($e->getData(), $e->getCode(), __($e->getMessage())); } catch (Exception $e) { - $this->error($e->getMessage(), $e->getCode()); + $this->error(__($e->getMessage()), $e->getCode()); } } @@ -132,9 +132,9 @@ class Addon extends Backend Service::uninstall($name, $force); $this->success(__('Uninstall successful')); } catch (AddonException $e) { - $this->result($e->getData(), $e->getCode(), $e->getMessage()); + $this->result($e->getData(), $e->getCode(), __($e->getMessage())); } catch (Exception $e) { - $this->error($e->getMessage()); + $this->error(__($e->getMessage())); } } @@ -156,9 +156,9 @@ class Addon extends Backend Cache::rm('__menu__'); $this->success(__('Operate successful')); } catch (AddonException $e) { - $this->result($e->getData(), $e->getCode(), $e->getMessage()); + $this->result($e->getData(), $e->getCode(), __($e->getMessage())); } catch (Exception $e) { - $this->error($e->getMessage()); + $this->error(__($e->getMessage())); } } @@ -222,16 +222,16 @@ class Addon extends Backend $this->success(__('Offline installed tips'), null, ['addon' => $info]); } catch (Exception $e) { @rmdirs($newAddonDir); - throw new Exception($e->getMessage()); + throw new Exception(__($e->getMessage())); } } catch (Exception $e) { @unlink($tmpFile); @rmdirs($tmpAddonDir); - $this->error($e->getMessage()); + $this->error(__($e->getMessage())); } } else { // 上传失败获取错误信息 - $this->error($file->getError()); + $this->error(__($file->getError())); } } @@ -260,9 +260,9 @@ class Addon extends Backend Cache::rm('__menu__'); $this->success(__('Operate successful')); } catch (AddonException $e) { - $this->result($e->getData(), $e->getCode(), $e->getMessage()); + $this->result($e->getData(), $e->getCode(), __($e->getMessage())); } catch (Exception $e) { - $this->error($e->getMessage()); + $this->error(__($e->getMessage())); } } @@ -297,7 +297,7 @@ class Addon extends Backend continue; if (isset($onlineaddons[$v['name']])) { - $v = array_merge($onlineaddons[$v['name']], $v); + $v = array_merge($v, $onlineaddons[$v['name']]); } else { $v['category_id'] = 0; $v['flag'] = ''; @@ -306,6 +306,8 @@ class Addon extends Backend $v['donateimage'] = ''; $v['demourl'] = ''; $v['price'] = '0.00'; + $v['screenshots'] = []; + $v['releaselist'] = []; } $v['url'] = addon_url($v['name']); $v['createtime'] = filemtime(ADDON_PATH . $v['name']); diff --git a/application/admin/controller/Ajax.php b/application/admin/controller/Ajax.php index 24806a2e..697bce4e 100644 --- a/application/admin/controller/Ajax.php +++ b/application/admin/controller/Ajax.php @@ -107,6 +107,8 @@ class Ajax extends Backend $imageheight = isset($imgInfo[1]) ? $imgInfo[1] : $imageheight; } $params = [ + 'admin_id' => (int)$this->auth->id, + 'user_id' => 0, 'filesize' => $fileInfo['size'], 'imagewidth' => $imagewidth, 'imageheight' => $imageheight, diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 611f9fe6..cd05cf64 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -90,6 +90,7 @@ class Index extends Backend $result = $this->auth->login($username, $password, $keeplogin ? 86400 : 0); if ($result === true) { + Hook::listen("admin_login_after", $this->request); $this->success(__('Login successful'), $url, ['url' => $url, 'id' => $this->auth->id, 'username' => $username, 'avatar' => $this->auth->avatar]); } else @@ -109,7 +110,7 @@ class Index extends Backend $background = stripos($background, 'http')===0 ? $background : config('site.cdnurl') . $background; $this->view->assign('background', $background); $this->view->assign('title', __('Login')); - Hook::listen("login_init", $this->request); + Hook::listen("admin_login_init", $this->request); return $this->view->fetch(); } @@ -119,6 +120,7 @@ class Index extends Backend public function logout() { $this->auth->logout(); + Hook::listen("admin_logout_after", $this->request); $this->success(__('Logout successful'), 'index/login'); } diff --git a/application/admin/controller/general/Config.php b/application/admin/controller/general/Config.php index 573a04e3..2f4d1051 100644 --- a/application/admin/controller/general/Config.php +++ b/application/admin/controller/general/Config.php @@ -10,7 +10,7 @@ use think\Exception; /** * 系统配置 * - * @icon fa fa-circle-o + * @icon fa fa-cogs * @remark 可以在此增改系统的变量和分组,也可以自定义分组和变量,如果需要删除请从数据库中删除 */ class Config extends Backend @@ -32,31 +32,26 @@ class Config extends Backend { $siteList = []; $groupList = ConfigModel::getGroupList(); - foreach ($groupList as $k => $v) - { + foreach ($groupList as $k => $v) { $siteList[$k]['name'] = $k; $siteList[$k]['title'] = $v; $siteList[$k]['list'] = []; } - foreach ($this->model->all() as $k => $v) - { - if (!isset($siteList[$v['group']])) - { + foreach ($this->model->all() as $k => $v) { + if (!isset($siteList[$v['group']])) { continue; } $value = $v->toArray(); $value['title'] = __($value['title']); - if (in_array($value['type'], ['select', 'selects', 'checkbox', 'radio'])) - { + if (in_array($value['type'], ['select', 'selects', 'checkbox', 'radio'])) { $value['value'] = explode(',', $value['value']); } $value['content'] = json_decode($value['content'], TRUE); $siteList[$v['group']]['list'][] = $value; } $index = 0; - foreach ($siteList as $k => &$v) - { + foreach ($siteList as $k => &$v) { $v['active'] = !$index ? true : false; $index++; } @@ -71,45 +66,30 @@ class Config extends Backend */ public function add() { - if ($this->request->isPost()) - { + if ($this->request->isPost()) { $params = $this->request->post("row/a"); - if ($params) - { - foreach ($params as $k => &$v) - { + if ($params) { + foreach ($params as $k => &$v) { $v = is_array($v) ? implode(',', $v) : $v; } - try - { - if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array'])) - { + try { + if (in_array($params['type'], ['select', 'selects', 'checkbox', 'radio', 'array'])) { $params['content'] = json_encode(ConfigModel::decode($params['content']), JSON_UNESCAPED_UNICODE); - } - else - { + } else { $params['content'] = ''; } $result = $this->model->create($params); - if ($result !== false) - { - try - { + if ($result !== false) { + try { $this->refreshFile(); $this->success(); - } - catch (Exception $e) - { + } catch (Exception $e) { $this->error($e->getMessage()); } - } - else - { + } else { $this->error($this->model->getError()); } - } - catch (Exception $e) - { + } catch (Exception $e) { $this->error($e->getMessage()); } } @@ -124,23 +104,16 @@ class Config extends Backend */ public function edit($ids = NULL) { - if ($this->request->isPost()) - { + if ($this->request->isPost()) { $row = $this->request->post("row/a"); - if ($row) - { + if ($row) { $configList = []; - foreach ($this->model->all() as $v) - { - if (isset($row[$v['name']])) - { + foreach ($this->model->all() as $v) { + if (isset($row[$v['name']])) { $value = $row[$v['name']]; - if (is_array($value) && isset($value['field'])) - { + if (is_array($value) && isset($value['field'])) { $value = json_encode(ConfigModel::getArrayData($value), JSON_UNESCAPED_UNICODE); - } - else - { + } else { $value = is_array($value) ? implode(',', $value) : $value; } $v['value'] = $value; @@ -148,13 +121,10 @@ class Config extends Backend } } $this->model->allowField(true)->saveAll($configList); - try - { + try { $this->refreshFile(); $this->success(); - } - catch (Exception $e) - { + } catch (Exception $e) { $this->error($e->getMessage()); } } @@ -162,20 +132,20 @@ class Config extends Backend } } + /** + * 刷新配置文件 + */ protected function refreshFile() { $config = []; - foreach ($this->model->all() as $k => $v) - { + foreach ($this->model->all() as $k => $v) { $value = $v->toArray(); - if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) - { + if (in_array($value['type'], ['selects', 'checkbox', 'images', 'files'])) { $value['value'] = explode(',', $value['value']); } - if ($value['type'] == 'array') - { - $value['value'] = (array) json_decode($value['value'], TRUE); + if ($value['type'] == 'array') { + $value['value'] = (array)json_decode($value['value'], TRUE); } $config[$value['name']] = $value['value']; } @@ -183,26 +153,21 @@ class Config extends Backend } /** + * 检测配置项是否存在 * @internal */ public function check() { $params = $this->request->post("row/a"); - if ($params) - { + if ($params) { $config = $this->model->get($params); - if (!$config) - { + if (!$config) { return $this->success(); - } - else - { + } else { return $this->error(__('Name already exist')); } - } - else - { + } else { return $this->error(__('Invalid parameters')); } } @@ -213,19 +178,18 @@ class Config extends Backend */ public function emailtest() { + $row = $this->request->post('row/a'); + \think\Config::set('site', array_merge(\think\Config::get('site'), $row)); $receiver = $this->request->request("receiver"); $email = new Email; $result = $email - ->to($receiver) - ->subject(__("This is a test mail")) - ->message('
卸载将会删除所有插件文件且不可找回!!! 插件如果有创建数据库表请手动删除!!!
如有重要数据请备份后再操作!', 'Upgrade tips' => '确认升级插件?如果之前购买插件时未登录,此次升级可能出现购买后才可以下载的提示!!!
升级后可能出现部分冗余数据记录,请根据需要移除即可!!!