BasicModel.php
4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
// +----------------------------------------------------------------------
// | 狂团[kt8.cn]旗下KtAdmin是为独立版SAAS系统而生的快速开发框架.
// +----------------------------------------------------------------------
// | [KtAdmin] Copyright (c) 2022 http://ktadmin.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
namespace app\base\model\admin\system;
use think\facade\Db;
use think\facade\Session;
use app\base\model\BaseModel;
use think\facade\Env;
/*
* 基础功能model
*/
class BasicModel extends BaseModel
{
/*
* 获取基本配置信息
* uid 登录时存储的uid 唯一
*/
static public function getSite(){
$uid = Session::get("uid");
$res = Db::table("kt_base_agent")->where(["id"=>$uid])->find();
$res['isadmin'] = self::isAdmin($uid) ? true : false;
$res['debug'] = Env::get('APP_DEBUG') ? 1 : 0;
return $res;
}
/*
* 修改基本配置信息
* domain 站点域名
* webname 站点名称
* webtitle 站点标题
* copyright 版权设置
* register_check 注册验证码(开启,关闭)
* registration_audit 注册审核(开启,关闭)----目前不确定代理商是否可以设置此项
* pc_official PC官网(开启,关闭)
*/
static public function setSite($domain,$webname,$webtitle,$copyright,$register_check,$registration_audit,$pc_official,$debug){
$uid = Session::get("uid");
$data["domain"] = $domain;
$data["webname"] = $webname;
$data["webtitle"] = $webtitle;
$data["copyright"] = $copyright;
$data["register_check"] = $register_check;
$data["registration_audit"] = $registration_audit;
$data["pc_official"] = (int)$pc_official?:2;
$res = Db::table("kt_base_agent")->where(["id"=>$uid])->save($data);
if(self::isAdmin($uid)){
$debugt = $debug ? 'true' : 'false';
self::setDebug($debugt);
}
return $res;
}
static public function setDebug($debugt){
$env = file_get_contents(root_path().'.env');
$envArr = explode("\n", $env);
foreach ($envArr as &$v) {
$vArr = explode('=', $v);
if(count($vArr)>0){
if(trim($vArr[0]) == "APP_DEBUG"){
$v = "APP_DEBUG = ".$debugt;
break;
}
}
}
$str = implode("\n", $envArr);
file_put_contents(root_path().'.env',$str);
return "ok";
}
/**
* logo设置
* user_logo 用户后台LOGO
* login_logo 登录页LOGO
* pc_logo PC官网LOGO
*/
static public function setLogo($user_logo=NULL,$login_logo=NULL,$pc_logo=NULL){
$uid = Session::get("uid");
$data["user_logo"] = $user_logo;
$data["login_logo"] = $login_logo;
$data["pc_logo"] = $pc_logo;
$res = Db::table("kt_base_agent")->where(["id"=>$uid])->save($data);
return $res;
}
/**
* login_background 背景图设置
*/
static public function setBackground($login_background=NULL,$login_background_status){
$uid = Session::get("uid");
$data["login_background_status"] = $login_background_status;
$data["login_background"] = $login_background;
$res = Db::table("kt_base_agent")->where(["id"=>$uid])->save($data);
return $res;
}
/**
* 设置其他设置
* kf_code 客服二维码(上传图片)
* gzh_code 公众号二维码 (上传图片)
* company_name 公司名称
* company_address 公司地址
* telephone 联系电话
* qq 联系QQ
* record_number 备案号
* key_word seo关键词
* describe seo描述
*/
static public function setAdditional($kf_code=NULL,$gzh_code=NULL,$company_name=NULL,$company_address=NULL,$telephone=NULL,$qq=NULL,$record_number=NULL,$key_word=NULL,$describe=NULL){
$uid = Session::get("uid");
$data["kf_code"] = $kf_code;
$data["gzh_code"] = $gzh_code;
$data["company_name"] = $company_name;
$data["company_address"] = $company_address;
$data["telephone"] = $telephone;
$data["qq"] = $qq;
$data["record_number"] = $record_number;
$data["key_word"] = $key_word;
$data["describe"] = $describe;
$res = Db::table("kt_base_agent")->where(["id"=>$uid])->save($data);
return $res;
}
}