1
This commit is contained in:
parent
aa03ecf64f
commit
6b276f0353
@ -31,6 +31,12 @@ class GMController extends BaseAuthedController {
|
||||
},
|
||||
'.additem' => function () use($params) {
|
||||
$this->addItem($params);
|
||||
},
|
||||
'.getsystime' => function () use($params) {
|
||||
$this->getSysTime($params);
|
||||
},
|
||||
'.setsystime' => function () use($params) {
|
||||
$this->setSysTime($params);
|
||||
}
|
||||
);
|
||||
$func = getXVal($cmdHash, $cmd);
|
||||
@ -46,7 +52,9 @@ class GMController extends BaseAuthedController {
|
||||
{
|
||||
$this->_rspData(array(
|
||||
'text' => <<<END
|
||||
.additem 道具id 道具数量
|
||||
.additem 道具id 道具数量 //添加道具
|
||||
.getsystime //获取服务器时间
|
||||
.setsystime //设置服务器时间,示例:.setsystime 2021-12-08 00:00:00
|
||||
END
|
||||
));
|
||||
}
|
||||
@ -70,4 +78,33 @@ END
|
||||
));
|
||||
}
|
||||
|
||||
private function getSysTime($params)
|
||||
{
|
||||
$sysTime = phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
||||
$this->_rspData(array(
|
||||
'text' => $sysTime,
|
||||
));
|
||||
}
|
||||
|
||||
private function setSysTime($params)
|
||||
{
|
||||
if (!defined('GLOBAL_TIME_OFFSET_KEY')) {
|
||||
die('不支持设置系统时间');
|
||||
return;
|
||||
}
|
||||
$newtime = strtotime($_REQUET['newtime']);
|
||||
if ($newtime <= 0) {
|
||||
die('时间格式错误');
|
||||
return;
|
||||
}
|
||||
$time_offset = $newtime - phpcommon\getRealTime();
|
||||
$r = new phpcommon\Redis(array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'passwd' => ''
|
||||
|
||||
));
|
||||
$r->set(GLOBAL_TIME_OFFSET_KEY, $time_offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,10 +2,11 @@
|
||||
|
||||
class ToolsController extends BaseController {
|
||||
|
||||
function __construct()
|
||||
public function _handlePre()
|
||||
{
|
||||
parent::_handlePre();
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
die("can't create GMController");
|
||||
die("can't create ToolsController");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -30,30 +31,4 @@ class ToolsController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
public function getSysTime()
|
||||
{
|
||||
echo phpcommon\timestamp_to_datetime(phpcommon\getNowTime());
|
||||
}
|
||||
|
||||
public function setSysTime()
|
||||
{
|
||||
if (!defined('GLOBAL_TIME_OFFSET_KEY')) {
|
||||
die('不支持设置系统时间');
|
||||
return;
|
||||
}
|
||||
$newtime = strtotime($_REQUET['newtime']);
|
||||
if ($newtime <= 0) {
|
||||
die('时间格式错误');
|
||||
return;
|
||||
}
|
||||
$time_offset = $newtime - phpcommon\getRealTime();
|
||||
$r = new phpcommon\Redis(array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => 6379,
|
||||
'passwd' => ''
|
||||
|
||||
));
|
||||
$r->set(GLOBAL_TIME_OFFSET_KEY, $time_offset);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user