<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\ConfigSite\Admin\Controller; use Illuminate\Routing\Controller; use Illuminate\Support\Facades\Mail; use Illuminate\Support\Facades\View; use ModStart\Admin\Layout\AdminConfigBuilder; use ModStart\Admin\Layout\AdminDialogPage; use ModStart\Core\Input\Response; use ModStart\Core\RateLimit\RateLimitUtil; use ModStart\Core\Util\RedisUtil; use ModStart\Form\Form; use Module\Vendor\Sms\SmsSender; use Module\Vendor\SoftApi\SoftApiUtil; class ConfigController extends Controller { public function site(AdminConfigBuilder $NXyDB) { goto HQu3B; y1JLz: $NXyDB->image('siteFavIco', '网站ICO'); goto j9sbY; ask75: $NXyDB->text('siteSlogan', '网站副标题'); goto bWjbx; kpbDU: $NXyDB->text('siteKeywords', '网站关键词'); goto G4jWm; G4jWm: $NXyDB->textarea('siteDescription', '网站描述'); goto vjpqW; tTznr: $NXyDB->text('siteName', '网站名称'); goto ask75; vjpqW: $NXyDB->text('siteBeian', '备案编号'); goto y1JLz; YaW0N: $NXyDB->image('siteLogo', '网站Logo'); goto tTznr; Br9uC: return $NXyDB->perform(); goto C031I; HQu3B: $NXyDB->pageTitle('基础设置'); goto YaW0N; j9sbY: $NXyDB->color('sitePrimaryColor', '网站主色调'); goto Br9uC; bWjbx: $NXyDB->text('siteDomain', '网站域名'); goto kpbDU; C031I: } public function visit(AdminConfigBuilder $NXyDB) { goto cmiMm; tGS4p: return $NXyDB->perform(); goto wotbM; M950f: $NXyDB->textarea('systemCounterBody', 'body访问统计代码'); goto XUoYo; ZK42Q: $NXyDB->textarea('systemCounter', 'head访问统计代码'); goto M950f; SpLup: $NXyDB->formClass('wide-2'); goto tGS4p; cmiMm: $NXyDB->pageTitle('访问设置'); goto ZK42Q; XUoYo: $NXyDB->text('systemCdnUrl', '网站加速CDN')->help('如 http://cdn.example.com/，以 / 结尾')->rules('regex:/\\/$/i'); goto SpLup; wotbM: } public function email(AdminConfigBuilder $NXyDB) { goto KED8o; n3mqC: $NXyDB->formClass('wide'); goto JqC31; rkXGo: $NXyDB->text('systemEmailSmtpUser', 'SMTP用户'); goto Dc28k; JO6LD: $NXyDB->text('systemEmailSmtpServer', 'SMTP服务器地址'); goto wZyHt; KED8o: $NXyDB->pageTitle('邮箱配置'); goto oCFTH; wZyHt: $NXyDB->switch('systemEmailSmtpSsl', 'SMTP是否为SSL'); goto rkXGo; oCFTH: $NXyDB->switch('systemEmailEnable', '开启邮件发送'); goto JO6LD; Dc28k: $NXyDB->text('systemEmailSmtpPassword', 'SMTP密码'); goto n3mqC; JqC31: return $NXyDB->perform(); goto M0moL; M0moL: } public function emailTest(AdminConfigBuilder $NXyDB) { goto OubeS; DjRlX: $NXyDB->text('email', '测试接收邮箱')->rules('required'); goto qHSiI; OubeS: $NXyDB->pageTitle('邮件发送测试'); goto DjRlX; vg_Vv: return $NXyDB->perform(null, function (Form $EmQdh) { $I3SIX = $EmQdh->dataForming(); $VjXez = $I3SIX['email']; $DxXWh = modstart_config(); config(array('mail' => array('driver' => 'smtp', 'host' => $DxXWh->getWithEnv('systemEmailSmtpServer'), 'port' => $DxXWh->getWithEnv('systemEmailSmtpSsl', false) ? 465 : 25, 'encryption' => $DxXWh->getWithEnv('systemEmailSmtpSsl', false) ? 'ssl' : 'tls', 'from' => array('address' => $DxXWh->getWithEnv('systemEmailSmtpUser'), 'name' => $DxXWh->get('siteName') . ' @ ' . $DxXWh->get('siteDomain')), 'username' => $DxXWh->getWithEnv('systemEmailSmtpUser'), 'password' => $DxXWh->getWithEnv('systemEmailSmtpPassword')))); $s2vDf = $VjXez; $POE6d = '测试邮件'; try { Mail::send('module::ConfigSite.View.test', array(), function ($qFdbi) use($VjXez, $s2vDf, $POE6d) { $qFdbi->to($VjXez, $s2vDf)->subject($POE6d); }); } catch (\Exception $oQDcC) { return Response::generateError('邮件发送失败:(' . $oQDcC->getMessage() . ')'); } return Response::generateSuccess('测试邮件成功发送到' . $VjXez); }); goto xvX30; qHSiI: $NXyDB->formClass('wide'); goto vg_Vv; xvX30: } public function visitLimit(AdminConfigBuilder $NXyDB) { goto Gdyeh; t88Bj: $NXyDB->switch('systemVisitBlackListEnable', '启用黑名单控制'); goto u3mSr; ShN47: $NXyDB->formClass('wide-2'); goto SYORL; u3mSr: $NXyDB->textarea('systemVisitBlackList', '访问黑名单')->help('<p>一行一个，如</p>
<p>192.168.1.1</p>
<p>192.168.1.0/24</p>
<p><a href="javascript:;" data-dialog-request="visit_ips">查看访问IP</a></p>'); goto ShN47; Gdyeh: $NXyDB->pageTitle('访问限制'); goto FGURI; nXUnd: $NXyDB->textarea('systemVisitWhiteList', '访问白名单'); goto t88Bj; FGURI: $NXyDB->switch('systemVisitWhiteListEnable', '启用白名单控制'); goto nXUnd; SYORL: return $NXyDB->perform(); goto AYVj2; AYVj2: } public function visitIps(AdminDialogPage $qDx9U) { if (!!RedisUtil::isEnable()) { return Response::send(-1, '访问IP需要依赖Redis'); } return $qDx9U->pageTitle('访问IP')->body(View::make('module::ConfigSite.View.visitIps', array('ips' => RateLimitUtil::listVisitIps()))->render()); } public function sms(AdminConfigBuilder $NXyDB) { goto y1vcA; LuOjV: $NXyDB->switch('systemSmsEnable', '开启短信发送')->help('<div>访问 <a href="' . SoftApiUtil::url() . '" target="_blank">' . SoftApiUtil::url() . '</a> 申请</div>'); goto fbLP9; y1vcA: $NXyDB->pageTitle('短信设置'); goto LuOjV; fbLP9: $NXyDB->radio('systemSmsSender', '发送类型')->defaultValue(SmsSender::SOFT_API)->options(SmsSender::getList(array(SmsSender::SOFT_API)))->when(SmsSender::SOFT_API, function (Form $EmQdh) { $EmQdh->display('none', '通用短信接口')->help('访问 <a href="https://api.' . __BASE_SITE__ . '" target="_blank">https://api.' . __BASE_SITE__ . '</a> 申请短信服务'); $EmQdh->text('systemSmsSender_softApi_appId', 'AppId'); $EmQdh->text('systemSmsSender_softApi_appSecret', 'AppSecret'); $EmQdh->text('systemSmsSender_softApi_verify_templateId', '验证码模板ID')->help('验证码模板变量为 code'); })->when(SmsSender::ALIYUN, function (Form $EmQdh) { $EmQdh->text('systemSmsSender_aliyun_accessKeyId', 'AccessKeyId'); $EmQdh->text('systemSmsSender_aliyun_accessKeySecret', 'accessKeySecret'); $EmQdh->text('systemSmsSender_aliyun_signName', '短信签名'); $EmQdh->text('systemSmsSender_aliyun_verify_templateId', '验证码模板ID')->help('验证码模板变量为 code'); }); goto JfTEk; g21Jk: return $NXyDB->perform(); goto m1naH; JfTEk: $NXyDB->formClass('wide'); goto g21Jk; m1naH: } public function upload(AdminConfigBuilder $NXyDB) { goto owK5X; sXcNz: $NXyDB->radio('uploadDriver', '上传类型')->defaultValue('local')->options(array('local' => '本地存储', 'ossAliyun' => '阿里云存储'))->when('ossAliyun', function (Form $EmQdh) { $EmQdh->text('uploadDriverDomain', '阿里云OSS域名')->help('如 http://cdn.example.com'); $EmQdh->text('uploadDriverAliyunAccessKeyId', '阿里云OSS AccessKeyId'); $EmQdh->text('uploadDriverAliyunAccessKeySecret', '阿里云OSS AccessKeySecret'); $EmQdh->text('uploadDriverAliyunEndpoint', '阿里云OSS Endpoint'); $EmQdh->text('uploadDriverAliyunBucket', '阿里云OSS Bucket'); }); goto nhPIg; vR1DF: return $NXyDB->perform(); goto SwK2a; owK5X: $NXyDB->pageTitle('上传设置'); goto sXcNz; nhPIg: $NXyDB->formClass('wide-2'); goto vR1DF; SwK2a: } public function errorPage(AdminConfigBuilder $NXyDB) { goto ArUsc; ArUsc: $NXyDB->pageTitle('自定义错误页'); goto ix9_d; oozjZ: $NXyDB->formClass('wide-2'); goto xFpeh; Mxhm8: $NXyDB->textarea('ConfigSite_ErrorPage500', '500错误页面HTML代码')->help('500错误页面指页面程序处理报错的展示页面'); goto oozjZ; xFpeh: return $NXyDB->perform(); goto X3mGb; ix9_d: $NXyDB->textarea('ConfigSite_ErrorPage404', '404错误页面HTML代码')->help('404错误页面指页面不存在的展示页面'); goto Mxhm8; X3mGb: } }