118 lines
5.1 KiB
PHP
118 lines
5.1 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\admin\controller;
|
|
|
|
use app\admin\BaseController;
|
|
use app\admin\validate\ConfCheck;
|
|
use think\exception\ValidateException;
|
|
use think\facade\View;
|
|
|
|
class Conf extends BaseController
|
|
{
|
|
//网站信息
|
|
public function web()
|
|
{
|
|
$conf = get_config('webconfig');
|
|
$webConf = [
|
|
'title' => empty($conf['title']) ? '' : $conf['title'],
|
|
'keywords' => empty($conf['keywords']) ? '' : $conf['keywords'],
|
|
'desc' => empty($conf['desc']) ? '' : $conf['desc'],
|
|
'logo' => empty($conf['logo']) ? '' : $conf['logo'],
|
|
'admin_title' => empty($conf['admin_title']) ? '' : $conf['admin_title'],
|
|
'icp' => empty($conf['icp']) ? '' : $conf['icp'],
|
|
'code' => empty($conf['code']) ? '' : $conf['code'],
|
|
'domain' => empty($conf['domain']) ? '' : $conf['domain'],
|
|
'version' => empty($conf['version']) ? '' : $conf['version'],
|
|
'port_cache_time' => empty($conf['port_cache_time']) ? '' : $conf['port_cache_time'],
|
|
];
|
|
return view('', ['webConf' => $webConf]);
|
|
}
|
|
|
|
//提交网站信息
|
|
public function web_submit()
|
|
{
|
|
$param = get_params();
|
|
try {
|
|
validate(ConfCheck::class)->scene('web')->check($param);
|
|
} catch (ValidateException $e) {
|
|
// 验证失败 输出错误信息
|
|
return to_assign(0, $e->getError());
|
|
}
|
|
$conf = "<?php return ['admin_title'=>'{$param["admin_title"]}','title'=>'{$param["title"]}','keywords'=>'{$param["keywords"]}','logo'=>'{$param["logo"]}','desc'=>'{$param["desc"]}','icp'=>'{$param["icp"]}','code'=>'{$param["code"]}','domain'=>'{$param["domain"]}','version'=>'{$param["version"]}','port_cache_time'=>'{$param["port_cache_time"]}'];";
|
|
file_put_contents(CMS_ROOT . "config/webconfig.php", $conf);
|
|
add_log('edit',0,$param);
|
|
return to_assign();
|
|
}
|
|
|
|
//邮箱配置
|
|
public function email()
|
|
{
|
|
$conf = get_config('emailconfig');
|
|
$emailConf = [
|
|
'smtp' => empty($conf['smtp']) ? '' : $conf['smtp'],
|
|
'username' => empty($conf['username']) ? '' : $conf['username'],
|
|
'password' => empty($conf['password']) ? '' : $conf['password'],
|
|
'port' => empty($conf['port']) ? '' : $conf['port'],
|
|
'email' => empty($conf['email']) ? '' : $conf['email'],
|
|
'from' => empty($conf['from']) ? '' : $conf['from'],
|
|
'template' => empty($conf['template']) ? '' : $conf['template'],
|
|
];
|
|
return view('', ['emailConf' => $emailConf]);
|
|
}
|
|
|
|
//提交邮箱配置
|
|
public function email_submit()
|
|
{
|
|
$param = get_params();
|
|
try {
|
|
validate(ConfCheck::class)->scene('email')->check($param);
|
|
} catch (ValidateException $e) {
|
|
// 验证失败 输出错误信息
|
|
return to_assign(0, $e->getError());
|
|
}
|
|
$conf = "<?php return ['smtp'=>'{$param["smtp"]}','username'=>'{$param["username"]}','password'=>'{$param["password"]}','port'=>'{$param["port"]}','email'=>'{$param["email"]}','from'=>'{$param["from"]}','template'=>'{$param["template"]}'];";
|
|
file_put_contents(CMS_ROOT . "config/emailconfig.php", $conf);
|
|
add_log('edit',0,$param);
|
|
return to_assign();
|
|
}
|
|
|
|
//微信配置
|
|
public function wechat()
|
|
{
|
|
$conf = get_config('wechatconfig');
|
|
$wechatConf = [
|
|
'Token' => empty($conf['Token']) ? '' : $conf['Token'],
|
|
'appID' => empty($conf['appID']) ? '' : $conf['appID'],
|
|
'appsecret' => empty($conf['appsecret']) ? '' : $conf['appsecret'],
|
|
//微信支付商户号
|
|
'MCHID' => empty($conf['MCHID']) ? '' : $conf['MCHID'],
|
|
//微信支付API密钥
|
|
'SECRECT_KEY' => empty($conf['SECRECT_KEY']) ? '' : $conf['SECRECT_KEY'],
|
|
//微信支付证书路径
|
|
'CERT_URL' => empty($conf['CERT_URL']) ? '' : $conf['CERT_URL'],
|
|
//微信支付回调地址
|
|
'PAY_BACK_URL' => empty($conf['PAY_BACK_URL']) ? '' : $conf['PAY_BACK_URL'],
|
|
//微信登录回调地址
|
|
'LOGIN_BACK_URL' => empty($conf['LOGIN_BACK_URL']) ? '' : $conf['LOGIN_BACK_URL'],
|
|
];
|
|
return view('', ['wechatConf' => $wechatConf]);
|
|
}
|
|
|
|
//微信配置配置
|
|
public function wechat_submit()
|
|
{
|
|
$param = get_params();
|
|
try {
|
|
validate(ConfCheck::class)->scene('wechat')->check($param);
|
|
} catch (ValidateException $e) {
|
|
// 验证失败 输出错误信息
|
|
return to_assign(0, $e->getError());
|
|
}
|
|
$conf = "<?php return ['Token'=>'{$param["Token"]}','LOGIN_BACK_URL' => '{$param["LOGIN_BACK_URL"]}','appID'=>'{$param["appID"]}','appsecret'=>'{$param["appsecret"]}','MCHID' => '{$param["MCHID"]}','SECRECT_KEY' => '{$param["SECRECT_KEY"]}','CERT_URL' => '{$param["CERT_URL"]}','PAY_BACK_URL' => '{$param["PAY_BACK_URL"]}'];";
|
|
file_put_contents(CMS_ROOT . "config/wechatconfig.php", $conf);
|
|
add_log('edit',0,$param);
|
|
return to_assign();
|
|
}
|
|
}
|