From 8aa3b635c425f30e1e05cada80971129baf0856d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 8 Dec 2021 15:14:17 +0800 Subject: [PATCH] 1 --- doc/Bag.py | 15 ++++++ doc/GM.py | 23 ++++++++ webapp/controller/GMController.class.php | 44 +-------------- webapp/controller/ToolsController.class.php | 59 +++++++++++++++++++++ 4 files changed, 98 insertions(+), 43 deletions(-) create mode 100644 doc/GM.py create mode 100644 webapp/controller/ToolsController.class.php diff --git a/doc/Bag.py b/doc/Bag.py index c807b67..d99cc38 100644 --- a/doc/Bag.py +++ b/doc/Bag.py @@ -38,4 +38,19 @@ class Bag(object): ['property_chg', _common.PropertyChg(), '属性变更'], ] }, + { + 'name': 'rename', + 'desc': '改名(优先扣改名卡没有则扣钻石)', + 'group': 'Bag', + 'url': 'webapp/index.php?c=Bag&a=rename', + 'params': [ + _common.ReqHead(), + ['name', '', '新的角色名'], + ['name_sign', '', '名字签名)'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, ] diff --git a/doc/GM.py b/doc/GM.py new file mode 100644 index 0000000..d1b7c86 --- /dev/null +++ b/doc/GM.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +import _common + +class GM(object): + + def __init__(self): + self.apis = [ + { + 'name': 'exeCmd', + 'desc': '执行gm指令(格式:".指令 参数1 参数2 ...", 查看指令帮助".help")', + 'group': 'GM', + 'url': 'webapp/index.php?c=GM&a=execCmd', + 'params': [ + _common.ReqHead(), + ['cmd', '', '指令及参数'] + ], + 'response': [ + _common.RspHead(), + ['text', '', '回显文字'] + ] + }, + ] diff --git a/webapp/controller/GMController.class.php b/webapp/controller/GMController.class.php index 26e19fa..fe5b3ca 100644 --- a/webapp/controller/GMController.class.php +++ b/webapp/controller/GMController.class.php @@ -10,50 +10,8 @@ class GMController extends BaseController { } } - public function clearDB() + public function execCmd() { - global $g_conf_mysql_cluster; - foreach ($g_conf_mysql_cluster as $mysql_conf) { - $conn = new phpcommon\Mysql(array( - 'host' => $mysql_conf['host'], - 'port' => $mysql_conf['port'], - 'user' => $mysql_conf['user'], - 'passwd' => $mysql_conf['passwd'], - 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] - )); - $tables = $conn->execQueryAsArray('show tables;'); - foreach ($tables as $table) { - $tblName = $table[0]; - $conn->execScript("DELETE FROM {$tblName};", - arary()); - } - } - } - - 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); } } diff --git a/webapp/controller/ToolsController.class.php b/webapp/controller/ToolsController.class.php new file mode 100644 index 0000000..abffda1 --- /dev/null +++ b/webapp/controller/ToolsController.class.php @@ -0,0 +1,59 @@ + $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => DBNAME_PREFIX . $mysql_conf['instance_id'] + )); + $tables = $conn->execQueryAsArray('show tables;'); + foreach ($tables as $table) { + $tblName = $table[0]; + $conn->execScript("DELETE FROM {$tblName};", + arary()); + } + } + } + + 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); + } + +}