TestServer.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. namespace loyalsoft;
  3. include_once __DIR__ . '/AppServer.php';
  4. require_once __DIR__ . '/../process/ActiveProc/CipheredBase32.php'; # 算法库
  5. /**
  6. * Description of TestServer
  7. * UT 测试
  8. * 约定: 底划线开头的函数为私有函数,不会在黑窗界面出现.
  9. */
  10. class TestServer {
  11. /**
  12. * 入口函数专用测试
  13. * @param type $req
  14. */
  15. static public function testApi($req) {
  16. DebugHelper::debug($req);
  17. $app = new AppServer();
  18. new Req($req);
  19. $ret = $app->api();
  20. DebugHelper::debug($ret);
  21. }
  22. /**
  23. * 运行环境自检:
  24. * PHP 版本,扩展模块
  25. * redis操作性
  26. * sqldb操作性
  27. */
  28. static function selfTest() {
  29. echoLine("phpver: " . PHP_VERSION . PHP_EOL); # 打印下PHP版本
  30. SelfChecker::CheckConfig(); # 进行配置环境检测
  31. }
  32. //----------------------------------------------------
  33. public function testRedisLua($key, $value) {
  34. $mem = gMem();
  35. $script = <<<SCR
  36. if redis.call("get",KEYS[1]) == ARGV[1]
  37. then
  38. return redis.call("del",KEYS[1])
  39. else
  40. return 0
  41. end
  42. SCR;
  43. DebugHelper:: var_dump($script);
  44. $ret = $mem->redis->eval($script, 1, $key, $value);
  45. DebugHelper:: var_dump($ret);
  46. $mem->close();
  47. }
  48. public function testBinSearch($v) {
  49. $arr = array(1, 2, 3, 4, 4, 11, 12, 124);
  50. $start = 0;
  51. $end = count($arr) - 1;
  52. while ($start <= $end) {
  53. $index = intval(($start + $end) / 2);
  54. if ($v < $arr[$index]) {
  55. $end = $index - 1;
  56. } elseif ($v > $arr[$index]) {
  57. $start = $index + 1;
  58. } else {
  59. echo($index);
  60. return;
  61. }
  62. }
  63. echo($index);
  64. }
  65. /**
  66. * 给玩家发邮件
  67. * @param type $uid
  68. * @param type $zoneid
  69. * @param type $items
  70. * @param type $ctx
  71. */
  72. public static function sendUserEmail($uid, $zoneid, $title, $reward, $ctx) {
  73. $mail = new Ins_Email(null, 1, $title, #
  74. $ctx, $reward);
  75. $list = explode(',', $uid);
  76. if (count($list) != 0) {
  77. foreach ($list as $userId) {
  78. EmailProc::InsertMail($zoneid, $userId, $mail);
  79. }
  80. }
  81. echo '邮件已经成功发送';
  82. }
  83. /**
  84. * 删除账号-区别内外网
  85. * @param type $uid
  86. * @param type $type
  87. */
  88. public function deleteUserUId($uid,$zoneid,$type) {
  89. $mem = gMem();
  90. if($type=='true'){//默认外网
  91. $userUid = "u-".$uid."-".$zoneid."-g";
  92. //u-EA74E58DCEB076ACC2D824684499CDA2-1-m-ci
  93. //u-EA74E58DCEB076ACC2D824684499CDA2-1-m-q
  94. //u-EA74E58DCEB076ACC2D824684499CDA2-1-m-s
  95. //u-EA74E58DCEB076ACC2D824684499CDA2-1-s-cp
  96. $userUidCi = "u-".$uid."-".$zoneid."-m-ci";
  97. $userUidQ = "u-".$uid."-".$zoneid."-m-q";
  98. $userUidS = "u-".$uid."-".$zoneid."-m-s";
  99. $userUidCp = "u-".$uid."-".$zoneid."-s-cp";
  100. } else {
  101. $userUid = "user-".$uid."-zone".$zoneid."-gameinfo";
  102. $userUidCi = "user-".$uid."-zone".$zoneid."-mail-curid";
  103. $userUidQ = "user-".$uid."-zone".$zoneid."-mail-queue";
  104. $userUidS = "user-".$uid."-zone".$zoneid."-mail-sysrecord";
  105. $userUidGuild = "user-".$uid."-zone".$zoneid."-guild";
  106. if($mem->exists($userUidGuild)){
  107. $mem->delete($userUidGuild);
  108. }
  109. }
  110. if($mem->exists($userUid)){
  111. $mem->delete($userUid);
  112. }
  113. if($mem->exists($userUidCi)){
  114. $mem->delete($userUidCi);
  115. }
  116. if($mem->exists($userUidQ)){
  117. $mem->delete($userUidQ);
  118. }
  119. if($mem->exists($userUidS)){
  120. $mem->delete($userUidS);
  121. }
  122. echo '删除账号成功';
  123. }
  124. }