From b072c332cf631350dda6418b0640756b14770f21 Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Tue, 10 May 2022 11:42:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=9F=9F=E5=90=8D=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1+=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/admin/controller/Common.php | 36 ++++++++-- app/api/controller/Common.php | 29 ++++++-- app/index/controller/Common.php | 43 +++++++---- app/service/DomainService.php | 123 ++++++++++++++++++++++++++++++++ app/service/StoreService.php | 2 +- 5 files changed, 207 insertions(+), 26 deletions(-) create mode 100644 app/service/DomainService.php diff --git a/app/admin/controller/Common.php b/app/admin/controller/Common.php index 6fe0ae829..835946c76 100755 --- a/app/admin/controller/Common.php +++ b/app/admin/controller/Common.php @@ -35,16 +35,21 @@ class Common extends BaseController // 左边权限菜单 protected $left_menu; - // 当前操作名称 - protected $module_name; - protected $controller_name; - protected $action_name; - // 输入参数 post|get|request protected $data_post; protected $data_get; protected $data_request; + // 当前系统操作名称 + protected $module_name; + protected $controller_name; + protected $action_name; + + // 当前插件操作名称 + protected $plugins_module_name; + protected $plugins_controller_name; + protected $plugins_action_name; + // 分页信息 protected $page; protected $page_size; @@ -143,16 +148,33 @@ class Common extends BaseController $default_theme = 'default'; MyViewAssign('default_theme', $default_theme); - // 当前操作名称 + // 当前系统操作名称 $this->module_name = RequestModule(); $this->controller_name = RequestController(); $this->action_name = RequestAction(); - // 当前操作名称 + // 当前系统操作名称 MyViewAssign('module_name', $this->module_name); MyViewAssign('controller_name', $this->controller_name); MyViewAssign('action_name', $this->action_name); + // 当前插件操作名称, 兼容插件模块名称 + if(empty($this->data_request['pluginsname'])) + { + $this->plugins_module_name = ''; + $this->plugins_controller_name = ''; + $this->plugins_action_name = ''; + } else { + $this->plugins_module_name = $this->data_request['pluginsname']; + $this->plugins_controller_name = empty($this->data_request['pluginscontrol']) ? 'index' : $this->data_request['pluginscontrol']; + $this->plugins_action_name = empty($this->data_request['pluginsaction']) ? 'index' : $this->data_request['pluginsaction']; + } + + // 当前插件操作名称 + MyViewAssign('plugins_module_name', $this->plugins_module_name); + MyViewAssign('plugins_controller_name', $this->plugins_controller_name); + MyViewAssign('plugins_action_name', $this->plugins_action_name); + // 管理员 MyViewAssign('admin', $this->admin); diff --git a/app/api/controller/Common.php b/app/api/controller/Common.php index 65a5a7010..6e9d1581b 100755 --- a/app/api/controller/Common.php +++ b/app/api/controller/Common.php @@ -29,16 +29,21 @@ class Common extends BaseController // 用户信息 protected $user; - // 当前操作名称 - protected $module_name; - protected $controller_name; - protected $action_name; - // 输入参数 post|get|request protected $data_post; protected $data_get; protected $data_request; + // 当前系统操作名称 + protected $module_name; + protected $controller_name; + protected $action_name; + + // 当前插件操作名称 + protected $plugins_module_name; + protected $plugins_controller_name; + protected $plugins_action_name; + // 分页信息 protected $page; protected $page_size; @@ -187,11 +192,23 @@ class Common extends BaseController // 用户数据 $this->user = UserService::LoginUserInfo(); - // 当前操作名称 + // 当前系统操作名称 $this->module_name = RequestModule(); $this->controller_name = RequestController(); $this->action_name = RequestAction(); + // 当前插件操作名称, 兼容插件模块名称 + if(empty($this->data_request['pluginsname'])) + { + $this->plugins_module_name = ''; + $this->plugins_controller_name = ''; + $this->plugins_action_name = ''; + } else { + $this->plugins_module_name = $this->data_request['pluginsname']; + $this->plugins_controller_name = empty($this->data_request['pluginscontrol']) ? 'index' : $this->data_request['pluginscontrol']; + $this->plugins_action_name = empty($this->data_request['pluginsaction']) ? 'index' : $this->data_request['pluginsaction']; + } + // 分页信息 $this->page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1); $this->page_size = 10; diff --git a/app/index/controller/Common.php b/app/index/controller/Common.php index ac881c27d..197eb0582 100755 --- a/app/index/controller/Common.php +++ b/app/index/controller/Common.php @@ -43,19 +43,21 @@ class Common extends BaseController // 用户信息 protected $user; - // 请求参数 - protected $params; - - // 当前操作名称 - protected $module_name; - protected $controller_name; - protected $action_name; - // 输入参数 post|get|request protected $data_post; protected $data_get; protected $data_request; + // 当前系统操作名称 + protected $module_name; + protected $controller_name; + protected $action_name; + + // 当前插件操作名称 + protected $plugins_module_name; + protected $plugins_controller_name; + protected $plugins_action_name; + // 分页信息 protected $page; protected $page_size; @@ -210,16 +212,33 @@ class Common extends BaseController $default_theme = strtolower(MyC('common_default_theme', 'default', true)); MyViewAssign('default_theme', $default_theme); - // 当前操作名称, 兼容插件模块名称 + // 当前系统操作名称 $this->module_name = RequestModule(); $this->controller_name = RequestController(); $this->action_name = RequestAction(); - // 当前操作名称 + // 当前系统操作名称 MyViewAssign('module_name', $this->module_name); MyViewAssign('controller_name', $this->controller_name); MyViewAssign('action_name', $this->action_name); + // 当前插件操作名称, 兼容插件模块名称 + if(empty($this->data_request['pluginsname'])) + { + $this->plugins_module_name = ''; + $this->plugins_controller_name = ''; + $this->plugins_action_name = ''; + } else { + $this->plugins_module_name = $this->data_request['pluginsname']; + $this->plugins_controller_name = empty($this->data_request['pluginscontrol']) ? 'index' : $this->data_request['pluginscontrol']; + $this->plugins_action_name = empty($this->data_request['pluginsaction']) ? 'index' : $this->data_request['pluginsaction']; + } + + // 当前插件操作名称 + MyViewAssign('plugins_module_name', $this->plugins_module_name); + MyViewAssign('plugins_controller_name', $this->plugins_controller_name); + MyViewAssign('plugins_action_name', $this->plugins_action_name); + // 分页信息 $this->page = max(1, isset($this->data_request['page']) ? intval($this->data_request['page']) : 1); $this->page_size = MyC('common_page_size', 10, true); @@ -571,9 +590,9 @@ class Common extends BaseController // 是否插件默认下 if($this->controller_name == 'plugins') { - if(!empty($this->data_request['pluginsname'])) + if(!empty($this->plugins_module_name)) { - $current .= '_'.trim($this->data_request['pluginsname']); + $current .= '_'.trim($this->plugins_module_name); } } diff --git a/app/service/DomainService.php b/app/service/DomainService.php new file mode 100644 index 000000000..dde760613 --- /dev/null +++ b/app/service/DomainService.php @@ -0,0 +1,123 @@ +val('xxx'=>'search/index')] + * @param [array] $params['type'] [输入参数(0 移除, 1 增加)] + */ + public static function DomainUpdate($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'is_array', + 'key_name' => 'inc_domain', + 'is_backend' => 1, + 'error_msg' => '增加域名数据必须为数组', + ], + [ + 'checked_type' => 'is_array', + 'key_name' => 'dec_domain', + 'is_backend' => 1, + 'error_msg' => '移除域名数据必须为数组', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 存在一个增加或移除数据 + if(empty($params['inc_domain']) && empty($params['dec_domain'])) + { + return DataReturn('增加或移除域名必须传递一项', -1); + } + + // 域名配置文件及数据 + $config = []; + $dir = ROOT.'config'; + $domain_file = $dir.'/domain.php'; + if(file_exists($domain_file)) + { + if(is_writable($domain_file)) + { + $res = require $domain_file; + if(!empty($res) && is_array($res)) + { + $config = $res; + } + } else { + return DataReturn('配置文件没写权限['.$domain_file.']', -1); + } + } else { + if(!is_writable($dir)) + { + return DataReturn('配置目录没写权限['.$dir.']', -1); + } + } + + // 去除域名 + if(!empty($config) && !empty($params['dec_domain'])) + { + foreach($params['dec_domain'] as $k=>$v) + { + if(array_key_exists($k, $config)) + { + unset($config[$k]); + } + } + } + // 增加 + if(!empty($params['inc_domain'])) + { + $config = array_merge($config, $params['inc_domain']); + } + + // 生成域名配置文件 + $ret = @file_put_contents($domain_file, ""); + if($ret === false) + { + return DataReturn('域名配置部署失败', -10); + } + return DataReturn('操作成功', 0); + } +} +?> \ No newline at end of file diff --git a/app/service/StoreService.php b/app/service/StoreService.php index 9f9454784..8e1ba8aae 100644 --- a/app/service/StoreService.php +++ b/app/service/StoreService.php @@ -309,7 +309,7 @@ class StoreService // 请求校验 $data = [ 'accounts' => $accounts, - 'authdata' => htmlspecialchars_decode($password), + 'authdata' => empty($password) ? '' : htmlspecialchars_decode($password), 'host' => __MY_HOST__, 'url' => __MY_URL__, 'ver' => APPLICATION_VERSION,