shopxo/app/service/SystemService.php

193 lines
5.0 KiB
PHP
Raw Normal View History

2019-03-18 13:52:52 +08:00
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
2019-03-18 13:52:52 +08:00
// +----------------------------------------------------------------------
2021-03-16 10:34:52 +08:00
// | Licensed ( https://opensource.org/licenses/mit-license.php )
2019-03-18 13:52:52 +08:00
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\service;
2021-12-07 18:16:37 +08:00
use app\service\UserService;
2019-03-18 13:52:52 +08:00
/**
* 配置服务层
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class SystemService
{
/**
* 系统运行开始
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-18
* @desc description
* @param [array] $params [输入参数]
*/
public static function SystemBegin($params = [])
{
2021-12-07 18:16:37 +08:00
// 基础数据初始化
self::BaseInit($params);
2021-10-30 22:47:49 +08:00
// 钩子
2019-03-18 13:52:52 +08:00
$hook_name = 'plugins_service_system_begin';
2021-07-18 23:42:10 +08:00
MyEventTrigger($hook_name, [
2019-03-18 13:52:52 +08:00
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
]);
}
/**
* 系统运行结束
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-18
* @desc description
* @param [array] $params [输入参数]
*/
public static function SystemEnd($params = [])
{
$hook_name = 'plugins_service_system_end';
2021-07-18 23:42:10 +08:00
MyEventTrigger($hook_name, [
2019-03-18 13:52:52 +08:00
'hook_name' => $hook_name,
'is_backend' => true,
'params' => &$params,
]);
}
2021-07-18 23:42:10 +08:00
2021-11-01 13:43:37 +08:00
/**
2021-12-07 18:16:37 +08:00
* 基础数据初始化
2021-11-01 13:43:37 +08:00
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2019-03-18
* @desc description
* @param [array] $params [输入参数]
*/
2021-12-07 18:16:37 +08:00
public static function BaseInit($params = [])
2021-11-01 13:43:37 +08:00
{
2021-12-07 18:16:37 +08:00
// uuid
$uuid = MySession('uuid');
if(empty($uuid))
2021-11-01 13:43:37 +08:00
{
2021-12-07 18:16:37 +08:00
$uuid = empty($params['uuid']) ? UUId() : $params['uuid'];
MySession('uuid', $uuid);
2022-05-16 16:35:50 +08:00
MyCookie('uuid', $uuid, false);
2021-11-01 13:43:37 +08:00
}
2021-12-07 18:16:37 +08:00
// token
if(!empty($params['token']))
2021-10-30 22:47:49 +08:00
{
2021-12-07 18:16:37 +08:00
$key = UserService::$user_token_key;
MySession($key, $params['token']);
2022-05-16 16:35:50 +08:00
MyCookie($key, $params['token'], false);
2021-12-07 18:16:37 +08:00
}
// 邀请人id
if(!empty($params['referrer']))
{
MySession('share_referrer_id', $params['referrer']);
2022-05-16 16:35:50 +08:00
MyCookie('share_referrer_id', $params['referrer'], false);
2021-10-30 22:47:49 +08:00
}
}
2021-07-18 23:42:10 +08:00
/**
* 系统安装检查
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2021-07-18
* @desc description
* @param [array] $params [输入参数]
*/
public static function SystemInstallCheck($params = [])
{
if(!file_exists(ROOT.'config/database.php'))
{
MyRedirect(__MY_URL__.'install.php?s=index/index', true);
}
}
2022-04-16 00:12:35 +08:00
/**
* 系统类型值
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-15
* @desc description
*/
public static function SystemTypeValue()
{
// 取默认值
$value = SYSTEM_TYPE;
2022-05-14 15:37:28 +08:00
// 默认值则判断是否参数存在值
if($value == 'default')
{
$system_type = MyInput('system_type');
if(!empty($system_type))
{
$value = $system_type;
}
}
2022-04-16 00:12:35 +08:00
// 系统类型钩子
$hook_name = 'plugins_service_system_system_type_value';
MyEventTrigger($hook_name, [
'hook_name' => $hook_name,
'is_backend' => true,
'value' => &$value,
]);
return $value;
}
2022-04-21 22:08:53 +08:00
/**
* 缓存key获取
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-21
* @desc description
* @param [string] $key [缓存key]
*/
public static function CacheKey($key)
{
2022-04-22 09:28:47 +08:00
return MyConfig($key).'_'.SYSTEM_TYPE.'_'.RequestModule();
2022-04-21 22:08:53 +08:00
}
2022-04-24 14:50:38 +08:00
/**
* 获取环境参数最大数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-24
* @desc description
*/
public static function EnvMaxInputVarsCount()
{
return intval(ini_get('max_input_vars'));
}
2022-05-13 18:39:24 +08:00
/**
* 首页地址
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-05-12
* @desc description
*/
public static function HomeUrl()
{
return MyC('common_domain_host', __MY_URL__, true);
}
2019-03-18 13:52:52 +08:00
}
?>