新增域名服务+细节优化

feat/task1-c-wallet
gongfuxiang 2022-05-10 11:42:10 +08:00
parent 4ac0369d30
commit b072c332cf
5 changed files with 207 additions and 26 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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);
}
}

View File

@ -0,0 +1,123 @@
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
/**
* 域名服务层
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-05-10
* @desc description
*/
class DomainService
{
/**
* 域名更新
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-05-10
* @desc description
* @param [array] $params [输入参数]
* @param [array] $params['domain'] [域名信息key=>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, "<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( https://opensource.org/licenses/mit-license.php )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
// 域名配置文件\nreturn ".var_export($config, true).";\n?>");
if($ret === false)
{
return DataReturn('域名配置部署失败', -10);
}
return DataReturn('操作成功', 0);
}
}
?>

View File

@ -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,