DefaultController.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. /**
  3. * Class DefaultController
  4. * @author Blackbinbin
  5. */
  6. class DefaultController extends BaseController {
  7. public function __construct() {
  8. parent::__construct(true);
  9. }
  10. const SERVER_ID = 1; // 客服id
  11. /**
  12. * 判断ip,输出首页
  13. */
  14. public function actionIndex() {
  15. // if (ENV != ENV_DEV) {
  16. // header('Location: https://dice.eosget.io/#/box');
  17. // Response::exitMsg('');
  18. // } else {
  19. // // 清除无效的cookie
  20. // Account::checkToken();
  21. //
  22. // if (ENV != ENV_DEV) {
  23. // $GLOBALS['eosProtocol'] = "https";
  24. // $GLOBALS['eosHost'] = "api.eosbeijing.one";
  25. // $GLOBALS['eosPort'] = 443;
  26. // }
  27. $this->tpl->display('index');
  28. // }
  29. }
  30. /**
  31. * 判断ip,输出首页
  32. */
  33. public function actionMini() {
  34. $this->tpl->display('mini');
  35. }
  36. /**
  37. * 判断ip,输出首页
  38. */
  39. public function actionSw() {
  40. // 不需要默认头部信息
  41. $GLOBALS['FORBID_ORIGIN'] = true;
  42. $path = BASE_DIR . 'dist/sw.js';
  43. // 增加浏览器缓存
  44. $filemd5 = md5_file($path);
  45. $this->_addEtag($filemd5);
  46. $content = file_get_contents($path);
  47. header("Content-Type: application/javascript; charset=utf-8");
  48. Response::exitMsg($content, CODE_SUCCESS, null, true);
  49. }
  50. private function _addEtag($etag) {
  51. // always send headers
  52. header("Etag: $etag");
  53. // exit if not modified
  54. if (@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
  55. header("HTTP/1.1 304 Not Modified");
  56. Response::exitMsg('', CODE_SUCCESS, '304 Not Modified');
  57. }
  58. }
  59. /**
  60. * 分享跳转
  61. * @author solu
  62. * @param $args
  63. */
  64. public function actionShare($args) {
  65. $rules = [
  66. 'group_name' => ['string', 'reg' => '/^[a-z0-9\.]+/i', 'desc' => '群名'],
  67. ];
  68. Param::checkParam2($rules, $args);
  69. $objGroup = new GroupInfo();
  70. $group = $objGroup->objTable->getRow(['group_name' => $args['group_name']], ['_field' => 'group_id, group_name, group_title']);
  71. $groupId = $group['group_id'] ?: GroupInfo::OFFICIAL_ID;
  72. $format = '%s/#/group/%s';
  73. if (is_mobile_request()) {
  74. $format = '%s/h5.html#/group/%s';
  75. }
  76. $url = sprintf($format, URL_SELF, $groupId);
  77. Response::exitMsg("<script>location.replace('{$url}')</script>");
  78. }
  79. /**
  80. * 申请群认证
  81. * @author solu
  82. * @param $args
  83. * @return array
  84. */
  85. public function actionGroupAuth($args) {
  86. $rules = [
  87. 'group_id' => ['int', 'desc' => '群id'],
  88. ];
  89. Param::checkParam2($rules, $args);
  90. $userId = User::getUserId();
  91. if (!(new UserGroup())->isAdmin($args['group_id'], $userId)) {
  92. Response::error(CODE_NO_PERMITION);
  93. }
  94. $serverId = self::SERVER_ID; // 客服id
  95. $msg =<<<MSG
  96. 欢迎申请群组认证,您需要提供如下信息:
  97. 1. 项目地址(如:https://dice.eosget.io)
  98. 2. 代币合约名(如:eosio.token)
  99. 3. 代币名(如:EOS)
  100. 4. Vip合约名(如:eosgetadmin1)
  101. 5. Vip表名(如:vip)
  102. 6. 等级字段名(如:vip_level)
  103. 7. 投注额字段名(如:total_bet_amount)
  104. MSG;
  105. $msg = Utils::encodeRC4($msg);
  106. $objSession = new Session();
  107. $sessionId = Session::getPersonSessionId($serverId, $userId);
  108. try {
  109. $objSession->sendPersonMsg($serverId, $sessionId, Session::MSG_TYPE_TEXT, $msg, true);
  110. } catch (Exception $e) {}
  111. return compact('serverId');
  112. }
  113. /**
  114. * 问题反馈
  115. * @author solu
  116. * @param $args
  117. * @return array
  118. */
  119. public function actionTick($args) {
  120. $rules = [];
  121. Param::checkParam2($rules, $args);
  122. $userId = User::getUserId();
  123. $serverId = self::SERVER_ID; // 客服id
  124. $msg =<<<MSG
  125. Hi,请问您遇到了什么问题?
  126. MSG;
  127. $msg = Utils::encodeRC4($msg);
  128. $objSession = new Session();
  129. $sessionId = Session::getPersonSessionId($serverId, $userId);
  130. try {
  131. $objSession->sendPersonMsg($serverId, $sessionId, Session::MSG_TYPE_TEXT, $msg, true);
  132. } catch (Exception $e) {}
  133. return compact('serverId');
  134. }
  135. }