JiliSimController.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <?php
  2. namespace App\Http\Controllers\Game;
  3. use App\Facade\TableName;
  4. use App\Game\GameCard;
  5. use App\Game\GlobalUserInfo;
  6. use App\Game\LogGamecardClick;
  7. use App\Game\Services\OuroGameService;
  8. use App\Game\Services\PgSoftService;
  9. use App\Game\Services\PlatformService;
  10. use App\Game\Services\ServerService;
  11. use App\Http\helper\ApiSign;
  12. use App\Models\AccountsInfo;
  13. use App\Notification\TelegramBot;
  14. use App\Util;
  15. use App\Utility\SetNXLock;
  16. use Illuminate\Http\Request;
  17. use Illuminate\Routing\Controller;
  18. use Illuminate\Support\Facades\Crypt;
  19. use Illuminate\Support\Facades\DB;
  20. use Illuminate\Support\Facades\Redis;
  21. class JiliSimController extends Controller
  22. {
  23. public function __construct()
  24. {
  25. }
  26. public function launch9x(Request $request)
  27. {
  28. $gid = $request->input('gid');
  29. $level=$request->input('level',0);
  30. $lang=$request->input('lang',env('DEFAULT_LOCALE','pu'));
  31. $userid = $request->UserID;
  32. $lang=['pu'=>'pt','en'=>'en','sp'=>'es'][$lang]??$lang;
  33. $protocol = $request->isSecure() ? 'https://' : 'http://';
  34. $domain = $protocol . $request->getHost();
  35. $rid=substr($gid,2);
  36. $params=[
  37. 'norot'=>1,
  38. 'lang'=>$lang,
  39. 'level'=>$level,
  40. 'gid'=>$rid,
  41. 'UserID'=>$userid,
  42. 't'=>time()
  43. ];
  44. $params['sign'] = ApiSign::sign($params);
  45. $url="$domain/api/pgsoft/lunchorg?".http_build_query($params);
  46. switch(substr($gid,0,2)){
  47. //jili
  48. case "91":
  49. $url = "$domain/api/jiligames/lunchorg?".http_build_query($params);
  50. break;
  51. //pg
  52. case "90":
  53. break;
  54. }
  55. return redirect($url);
  56. }
  57. public function gameLunch(Request $request)
  58. {
  59. $gid = $request->input('gid');
  60. $level = $request->input('level',0);
  61. $user = $request->user();
  62. $userid = $user->UserID;
  63. $GlobalUID = $user->GlobalUID;
  64. GameCard::$enableStateCheck = false;
  65. $gamecard = GameCard::where('gid', $gid)->first();
  66. $in_gameid = OuroGameService::getUserInGame($userid, $user->GlobalUID);
  67. if ($in_gameid != intval($gamecard->id)) {
  68. Util::WriteLog('24680game', compact('in_gameid', 'gamecard', 'user'));
  69. // die;
  70. }
  71. $gamecard = GameCard::where('gid', $gid)->where('brand', 'JILI')->first();
  72. $gamecard->increment('play_num', 1);
  73. //$this->logGameClick($gamecard->id,$userid);
  74. LogGamecardClick::recordClick($gamecard->id, $userid);
  75. $lang = GlobalUserInfo::getLocale();
  76. GameCard::$enableStateCheck = false;
  77. $supportLang = ['en' => "en-US", 'da' => "da-DK", 'es' => "es-AR", 'id' => "id-ID", 'ja' => "ja-JP", 'ko' => "ko-KR", 'pt' => "pt-BR", 'th' => "th-TH", 'vi' => "vi-VN", 'zh' => "zh-CN", 'my' => "my-MM"];
  78. if (!in_array($lang, array_keys($supportLang))) {
  79. $lang = 'en';
  80. }
  81. $lang=$supportLang[$lang];
  82. $cdnserver = 'https://sjj.pgn-nmu2nd.com';
  83. $LogonPass='123';
  84. $sign = GlobalUserInfo::genGuuidSign((object)compact('GlobalUID','LogonPass'));
  85. $or = $this->convertString(env('JILI_GAME_DOMAIN','jj.pgn-nmu2nd.com'));
  86. $data=['UserID'=>ServerService::GlobalToUserID($GlobalUID)];
  87. // $gameIdToCodes=[302=>'mcp',51=>'mc',49=>'fullhouse',403=>'fullhouse3',300=>'fg3',223=>'fgp',109=>'fg',35=>'ols2',258=>'dl',47=>'bfs',421=>'lj'];
  88. $params = ['lang' => $lang, 'ssoKey' => $sign, 'apiId' => 2,'gameId'=>$gid,'gs'=>$or,'domain_platform'=>$or,'domain_gs'=>$or,'be'=>$or];
  89. $url = $cdnserver . "/{$gid}/index.html?" . http_build_query($params).'&iu=true&legalLang=true';
  90. // https://jj.pgn-nmu2nd.com/mcp/index.html?ssoKey=1e790573d14d23bf6c3c330e3edeef8a1d8b3cae&lang=en-US&legalLang=true&gameId=302&gs=moc.dn2umn-ngp.jj&domain_platform=moc.dn2umn-ngp.jj&domain_gs=semagilij&be=moc.dn2umn-ngp.jj&iu=true&apiId=2&demo=true
  91. echo "<script>
  92. parent.postMessage({cmd:\"closeLoading\"},\"*\");
  93. location.href='$url';
  94. </script>";
  95. return "";
  96. }
  97. public function leaveOrg(Request $request){
  98. $UserID = $request->UserID;
  99. $config = ServerService::GetGlobalServerInfoByCode(ServerService::GetLocalSign());
  100. $api = [
  101. 'Bangladesh'=> "bdapi.pgn-nmu2nd.com",
  102. 'Pakistan' => "pkapi.pgn-nmu2nd.com",
  103. 'OrgBrazil' => "orgbr.pgn-nmu2nd.com",
  104. 'Brazil' => "brapi.pgn-nmu2nd.com",
  105. 'Europe' => "euapi.pgn-nmu2nd.com",
  106. 'Russia' => "ruapi.pgn-nmu2nd.com",
  107. 'Mexico' => "mxapi.pgn-nmu2nd.com",
  108. 'Singapore' => "sgapi.pgn-nmu2nd.com",
  109. 'Latin' => "saapi.pgn-nmu2nd.com",
  110. ][$config['Subsite']];
  111. try {
  112. file_get_contents("https://$api/game-api/000/v2/removePlayer/Get?UserID=$UserID");
  113. }catch (\Exception $e){
  114. }
  115. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreLocker')
  116. ->where('UserID', $UserID)
  117. ->delete();
  118. return '<script>
  119. if(window.parent&&window.parent!=window){
  120. window.parent.postMessage("backhome","*")
  121. }else {
  122. document.location = "game://a=1&b=2";
  123. }
  124. </script>';
  125. }
  126. public function gameLunchOrg(Request $request)
  127. {
  128. $gid = $request->input('gid');
  129. $level=$request->input('level',0);
  130. $lang=$request->input('lang',env('DEFAULT_LOCALE','pu'));
  131. $lang=['pu'=>'pt','en'=>'en','sp'=>'es'][$lang]??$lang;
  132. // $lang='pt';
  133. $userid = $request->UserID;
  134. $GlobalUID = 'a1b1c1-b53b-'.ServerService::GetLocalSign().'-' . $userid;
  135. GameCard::$enableStateCheck = false;
  136. // $gamecard = GameCard::where('gid', $gid)->first();
  137. // $in_gameid = OuroGameService::getUserInGame($userid, $GlobalUID);
  138. // if ($in_gameid != intval($gamecard->id)) {
  139. // Util::WriteLog('24680game', compact('in_gameid', 'gamecard', 'GlobalUID'));
  140. //// die;
  141. // }
  142. //
  143. // $gamecard = GameCard::where('gid', $gid)->where('brand', 'PGSoft')->first();
  144. // $gamecard->increment('play_num', 1);
  145. // //$this->logGameClick($gamecard->id,$userid);
  146. //
  147. // LogGamecardClick::recordClick($gamecard->id, $userid);
  148. // $lang = GlobalUserInfo::getLocale();
  149. $supportLang = ['en' => "en-US", 'da' => "da-DK", 'es' => "es-AR", 'id' => "id-ID", 'ja' => "ja-JP", 'ko' => "ko-KR", 'pt' => "pt-BR", 'th' => "th-TH", 'vi' => "vi-VN", 'zh' => "zh-CN", 'my' => "my-MM"];
  150. if (!in_array($lang, array_keys($supportLang))) {
  151. $lang = 'en';
  152. }
  153. $lang=$supportLang[$lang];
  154. $cdnserver = 'https://sjj.pgn-nmu2nd.com';
  155. $LogonPass='123';
  156. $sign = GlobalUserInfo::genGuuidSign((object)compact('GlobalUID','LogonPass'));
  157. $or = $this->convertString(env('JILI_GAME_DOMAIN','jj.pgn-nmu2nd.com'));
  158. // $api = $this->convertString('orgbr.pgn-nmu2nd.com');
  159. // $api = $this->convertString('api.pgn-nmu2nd.com');
  160. $data=['UserID'=>ServerService::GlobalToUserID($GlobalUID)];
  161. $gameIdToCodes=[302=>'mcp',51=>'mc',49=>'fullhouse',403=>'fullhouse3',300=>'fg3',223=>'fgp',109=>'fg',35=>'ols2',258=>'dl',47=>'bfs',421=>'lj'];
  162. $params = ['lang' => $lang, 'ssoKey' => $sign, 'apiId' => 2,'gameId'=>$gid,'gs'=>$or,'domain_platform'=>$or,'domain_gs'=>$or,'be'=>$or];
  163. $url = $cdnserver . "/{$gameIdToCodes[$gid]}/index.html?" . http_build_query($params).'&iu=true&legalLang=true';
  164. // https://jj.pgn-nmu2nd.com/mcp/index.html?ssoKey=1e790573d14d23bf6c3c330e3edeef8a1d8b3cae&lang=en-US&legalLang=true&gameId=302&gs=moc.dn2umn-ngp.jj&domain_platform=moc.dn2umn-ngp.jj&domain_gs=semagilij&be=moc.dn2umn-ngp.jj&iu=true&apiId=2&demo=true
  165. $trans="no-rotated-iframe-container";
  166. $posClass = "defaultPos";
  167. $iconClass="widthIcon";
  168. if(in_array($gid,[49,403])){
  169. $iconClass="heightIcon";
  170. if (strpos(strtolower($request->header('User-Agent')), 'iphone') !== false) {
  171. $posClass = "iosPos";
  172. $iconClass="widthIcon";
  173. $trans="rotated-iframe-container";
  174. }
  175. }
  176. $leaveUrl=$request->getSchemeAndHttpHost().'/api/jiligames/leave?UserID='.$userid;
  177. echo '<!DOCTYPE html>
  178. <html lang="en">
  179. <head>
  180. <meta charset="UTF-8">
  181. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  182. <title>JiliGames</title>
  183. <style>
  184. body, html {
  185. margin: 0;
  186. padding: 0;
  187. background: #000;
  188. height: 100vh;
  189. overflow: hidden;
  190. -webkit-overflow-scrolling: touch; /* 启用惯性滚动 */
  191. }
  192. .rotated-iframe-container {
  193. width: 100vh; /* 旋转后高度变为宽度 */
  194. height: 100vw; /* 旋转后宽度变为高度 */
  195. transform: rotate(-90deg);
  196. transform-origin: top right;
  197. position: absolute;
  198. top: 0;
  199. right: 100%;
  200. overflow: hidden;
  201. }
  202. .no-rotated-iframe-container {
  203. width: 100vw; /* 旋转后高度变为宽度 */
  204. height: 100vh; /* 旋转后宽度变为高度 */
  205. position: absolute;
  206. top: 0;
  207. }
  208. .rotated-iframe {
  209. width: 100%;
  210. height: 100%;
  211. transform-origin: top right;
  212. }
  213. .widthIcon{
  214. width: 13vh; height: 13%;
  215. }
  216. .heightIcon{
  217. width: 13%; height: 13vw;
  218. }
  219. .defaultPos{
  220. position: absolute; top: 10px; left: 10px; z-index: 9999;
  221. }
  222. .iosPos{
  223. position: absolute; bottom: 10px; left: 10px; z-index: 9999; transform: rotate(-90deg);
  224. }
  225. </style>
  226. </head>
  227. <body>
  228. <script>
  229. document.addEventListener("touchstart", (e) => {
  230. // 确保滑动事件生效
  231. }, { passive: true });
  232. document.addEventListener("touchmove", (e) => {
  233. // 确保惯性滚动生效
  234. }, { passive: true });
  235. function backhome(){
  236. var xhr = new XMLHttpRequest();
  237. var url = "'.$leaveUrl.'"; // 这里替换成你实际要访问的 URL
  238. window.location.href=url;
  239. // console.log(url);
  240. // xhr.open("GET", url, true);
  241. // xhr.send();
  242. // setTimeout(()=>{
  243. // if(window.parent&&window.parent!=window){
  244. // window.parent.postMessage("backhome","*")
  245. // }else {
  246. // document.location = "game://a=1&b=2";
  247. // }
  248. // },500)
  249. // document.body.innerHTML=`<span style="color:#000">${url}</span>`;
  250. }
  251. </script>
  252. <div class="'.$trans.'">
  253. <!-- 嵌入的 iframe -->
  254. <iframe class="rotated-iframe" frameborder="0" src="'.$url.'"></iframe>
  255. </div>
  256. <div id="game-lobby" style="" class="'.$iconClass.' '.$posClass.'">
  257. <a href="#" onclick="backhome()" > <img src="https://static2.pgn-nmu2nd.com/0temp/back.png" style="display: block; width: 100%; height: 100%; margin-left: auto; margin-right: auto;"></a>
  258. </div>
  259. </body>
  260. </html>';
  261. return "";
  262. }
  263. public function loginSession(Request $request)
  264. {
  265. $key=$request->input('key');
  266. $lang=$request->input('lang');
  267. if(Redis::exists($key)){
  268. $session=json_decode(Redis::get($key),true);
  269. }else {
  270. try {
  271. $arr = explode('|', Crypt::decryptString($key));
  272. $GlobalUID = $arr[0];
  273. if (!ServerService::IsLocalUser($GlobalUID)) {
  274. return ServerService::RedirectToSub($GlobalUID);
  275. }
  276. $timestamp = intval($arr[1]);
  277. if (time() > $timestamp) return ['dt' => null, 'err' => ['cd' => 1302, 'msg' => 'Invalid player session', 'tid' => $request->traceId]];
  278. // $user = GlobalUserInfo::getGameUserInfo('GlobalUID', $GlobalUID);
  279. } catch (\Exception $e) {
  280. $this->log($request, "wrong user");
  281. }
  282. if (!isset($GlobalUID) || empty($GlobalUID)) {
  283. return ['dt' => null, 'err' => ['cd' => 1302, 'msg' => 'Invalid player session', 'tid' => $request->traceId]];
  284. }
  285. $data = ['UserID' => ServerService::GlobalToUserID($GlobalUID)];
  286. $Currency = env("CONFIG_24680_CURRENCY", "BRL");
  287. $CurrencySymbol = env("CONFIG_24680_DOLLAR", "R$");
  288. $data['currency'] = $Currency;
  289. $data['dollar'] = $CurrencySymbol;
  290. $roomlevel = $request->btt ?? 1;
  291. $data['limit_room'] = 0;
  292. if ($roomlevel > 1) {
  293. $data['limit_room'] = 1;
  294. }
  295. $account = AccountsInfo::where('UserID', $data['UserID'])->first();
  296. if($account)$account=$account->toArray();
  297. else{
  298. TelegramBot::getDefault()->sendProgramNotify("jili","get account error",compact('GlobalUID','data'));
  299. return ['dt' => null, 'err' => ['cd' => 1302, 'msg' => 'Invalid player session', 'tid' => $request->traceId]];
  300. }
  301. $data = array_merge($data, $account);
  302. $session = $data;
  303. // $add=Redis::get($newToken);
  304. }
  305. if(!isset($session)||empty($session)) return ['dt' => null, 'err' => ['cd' => 1302, 'msg' => 'Invalid player session', 'tid' => $request->traceId]];
  306. $newToken = md5($key);
  307. Redis::setex($newToken, 7200, json_encode($session));
  308. return response()->json([
  309. 'homeUrl' => '',
  310. 'linecode' => 0,
  311. 'profile' => [
  312. 'id' => '',
  313. 'aid' => $session['UserID'],
  314. 'apiId' => 2,
  315. 'transactionMode' => 0,
  316. 'subAgentCode' => 0,
  317. 'isLobbyOpen' => true,
  318. 'meta' => ['agentAccount' => '<nil>'],
  319. 'platform' => '<nil>',
  320. 'lobbyMode' => 0,
  321. 'switchOffs' => [
  322. 2, 3, 4, 5, 25,
  323. 26, 27, 35, 41, 44,
  324. 49
  325. ],
  326. 'wallets' => null,
  327. 'nickname' => $session['NickName'],
  328. 'newNickname' => '',
  329. 'siteId' => 0,
  330. 'account' => $session['Accounts'],
  331. 'coin' => 0,
  332. 'isJPEnabled' => 0,
  333. 'linecode' => 0,
  334. 'prefix' => '',
  335. 'clientMode' => [
  336. ['eventId' => 1, 'value' => [50]],
  337. ['eventId' => 3, 'value' => [10, 20, 30, 40, 50]],
  338. ['eventId' => 7, 'value' => ['400']],
  339. ['eventId' => 8, 'value' => [120]]
  340. ],
  341. 'betLevel' => -1,
  342. 'license' => 0,
  343. 'isGiftCodeOpen' => false,
  344. 'freeSpinBetValue' => 0,
  345. 'apiType' => 0,
  346. 'walletType' => 1
  347. ],
  348. 'token' => $newToken,
  349. 'response' => ['error' => 0, 'message' => '', 'time' => time()],
  350. 'platformVersion' => 'uat.2.0.96',
  351. 'lobbyMode' => 0,
  352. 'disableFullScreen' => 0,
  353. 'country' => env('VALID_COUNTRY'),
  354. 'certId' => 0,
  355. 'certArea' => 0,
  356. 'clientApiParam' => [],
  357. 'itaAuthId' => '',
  358. 'thousandthMode' => '',
  359. // 'add'=>$add
  360. ]);
  361. }
  362. private function convertString($input)
  363. {
  364. return strrev($input);
  365. }
  366. private function log(Request $request, $addLog = "")
  367. {
  368. $post = $request->all();
  369. Util::WriteLog('jilisim', $post);
  370. if (!empty($addLog)) Util::WriteLog('jilisim', $addLog);
  371. }
  372. }