87 lines
2.1 KiB
PHP
87 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\config;
|
|
|
|
use app\common\controller\Backend;
|
|
|
|
/**
|
|
* 自动任务配置
|
|
*/
|
|
class Crontab extends Backend
|
|
{
|
|
|
|
/**
|
|
* AttachmentGroup模型对象
|
|
* @var \app\admin\model\attachment\AttachmentGroup
|
|
*/
|
|
protected $model = null;
|
|
|
|
protected $configName = 'crontab';
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
|
|
\app\common\model\fill\Handle::check('app_config',$this->configName);
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function getConfig(){
|
|
$data = \app\common\model\app\Config::getConfig($this->configName);
|
|
|
|
if($data['token'] == '123456'){
|
|
$this->resetToken();
|
|
$data = \app\common\model\app\Config::getConfig($this->configName);
|
|
}
|
|
|
|
$data['request_url'] = $this->getRequestUrl();
|
|
|
|
return $this->success("获取成功",$data);
|
|
}
|
|
|
|
|
|
/**
|
|
* 获取请求地址
|
|
* @return string
|
|
*/
|
|
public function getRequestUrl(){
|
|
global $_W;
|
|
if(\app\common\library\Platform::getSystemType() == 'single'){
|
|
return $_W['siteroot'].'/index.php?i='.$_W['uniacid'].'&route=callback/auto/handle';
|
|
}else{
|
|
return $_W['siteroot'].'/app/index.php?i='.$_W['uniacid'].'&c=entry&m=tuzi_v1&do=index&route=callback/auto/handle';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 刷新 Token
|
|
* @return void
|
|
*/
|
|
public function refreshToken(){
|
|
$this->resetToken();
|
|
return $this->success("刷新成功");
|
|
}
|
|
|
|
public function resetToken(){
|
|
$data = \app\common\model\app\Config::getConfig($this->configName);
|
|
//随机获取 10 位的随机数
|
|
$data['token'] = \fast\Random::alnum(10);
|
|
\app\common\model\app\Config::setConfig($this->configName,$data);
|
|
}
|
|
|
|
/**
|
|
* 获取配置
|
|
* @return mixed
|
|
*/
|
|
public function setConfig(){
|
|
$row = $this->request->post("row/a", [], 'trim');
|
|
$data = \app\common\model\app\Config::setConfig($this->configName,$row);
|
|
return $this->success("保存成功",$data);
|
|
}
|
|
|
|
|
|
}
|