123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- <?php
- class DefaultController extends BaseController {
- protected $ajaxLoginActions = [
- 'tick',
- ];
- public function __construct() {
- parent::__construct(true);
- }
-
- public function actionIndex() {
- $this->tpl->display('index');
- }
-
- public function actionMini() {
- $html = $this->tpl->fetch('mini');
- $html = str_replace('<link rel=manifest ', '<link ', $html);
- Response::exitMsg($html, CODE_SUCCESS, '', true);
- }
- public function actionPC() {
- $html = $this->tpl->fetch('pc');
-
- $html = str_replace('/dist/manifest.json', '/manifest_pc.json', $html);
- Response::exitMsg($html, CODE_SUCCESS, '', true);
- }
- public function actionH5() {
- $html = $this->tpl->fetch('h5');
- $html = str_replace('/dist/manifest.json', '/manifest_h5.json', $html);
-
- Response::exitMsg($html, CODE_SUCCESS, '', true);
- }
- public function actionManifest($args) {
- if ($args['type'] == 'pc') {
- $startUrl = '/pc.html?pwa=1';
- } else {
- $startUrl = '/h5.html?pwa=1';
- }
- $this->tpl->assign(compact('startUrl'));
- $this->tpl->postfix = '.json';
- if (ENV == ENV_DEV) {
- $env = '[测试]';
- } else if (ENV == ENV_NEW) {
- $env = '[预发布]';
- } else {
- $env = '';
- }
-
- $GLOBALS['FORBID_ORIGIN'] = true;
- header("Content-Type: application/json; charset=utf-8");
- $this->tpl->assign(compact('env'));
- $this->tpl->display('manifest', CODE_SUCCESS);
- }
-
- public function actionSw() {
-
- $GLOBALS['FORBID_ORIGIN'] = true;
- $path = BASE_DIR . 'dist/sw.js';
-
- $filemd5 = md5_file($path);
- $this->_addEtag($filemd5);
- $content = file_get_contents($path);
- header("Content-Type: application/javascript; charset=utf-8");
- Response::exitMsg($content, CODE_SUCCESS, null, true);
- }
- private function _addEtag($etag) {
-
- header("Etag: $etag");
-
- if (@trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
- header("HTTP/1.1 304 Not Modified");
- Response::exitMsg('', CODE_SUCCESS, '304 Not Modified');
- }
- }
-
- public function actionShare($args) {
- $rules = [
- 'group_name' => ['string', 'reg' => '/^[a-z0-9\.]+/i', 'desc' => '群名'],
- ];
- Param::checkParam2($rules, $args);
- $objGroup = new GroupInfo();
- $group = $objGroup->objTable->getRow(['group_name' => $args['group_name']], ['_field' => 'group_id, group_name, group_title']);
- $groupId = $group['group_id'] ?: GroupInfo::OFFICIAL_ID;
- $format = '%s/#/group/%s';
- if (is_mobile_request()) {
- $format = '%s/h5.html#/group/%s';
- }
- $url = sprintf($format, URL_SELF, $groupId);
- Response::exitMsg("<script>location.replace('{$url}')</script>");
- }
-
- public function actionGroupAuth($args) {
- $rules = [
- 'group_id' => ['int', 'desc' => '群id'],
- ];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- if (!(new UserGroup())->isAdmin($args['group_id'], $userId)) {
- Response::error(CODE_NO_PERMITION);
- }
- $serverId = CHAT_SERVER_ID;
- $msg =<<<MSG
- 欢迎申请群组认证,您需要提供如下信息:
- 1. 项目地址(如:https://vsbet.io/)
- 2. 代币合约名(如:vsvscontract)
- 3. 代币名(如:VS)
- -------以下内容为可选提供----------
- 4. Vip合约名(如:vsvsvsvipvip)
- 5. Vip表名(如:t.player)
- 6. 等级字段名(如:vip_level)
- 7. 投注额字段名(如:total_energy)
- 4~7选项,用于后续在聊天内显示用户vip等功能。
- MSG;
- $msg = Utils::encodeRC4($msg);
- $objSession = new Session();
- $sessionId = Session::getPersonSessionId($serverId, $userId);
- try {
- $objSession->sendPersonMsg($serverId, $sessionId, Session::MSG_TYPE_TEXT, $msg, true);
- } catch (Exception $e) {}
- return compact('serverId');
- }
-
- public function actionTick($args) {
- $rules = [];
- Param::checkParam2($rules, $args);
- $userId = User::getUserId();
- $serverId = CHAT_SERVER_ID;
- $msg =<<<MSG
- Hi,请问您遇到了什么问题?
- MSG;
- $msg = Utils::encodeRC4($msg);
- $objSession = new Session();
- $sessionId = Session::getPersonSessionId($serverId, $userId);
- try {
- $objSession->sendPersonMsg($serverId, $sessionId, Session::MSG_TYPE_TEXT, $msg, true);
- } catch (Exception $e) {}
- return compact('serverId');
- }
-
- public function actionDiscovery($args) {
- $rules = [];
- Param::checkParam2($rules, $args);
- $objGame = new TableHelper('hot_game', 'dw_chat');
- $hotGame = $objGame->getAll(['state' => 1], [
- '_sortKey' => 'game_sort DESC',
- '_limit' => 8,
- ]);
- $hotGroup = (new GroupInfo())->getHotList();
- return compact('hotGame', 'hotGroup');
- }
- }
|