JiliSimController.php 16 KB

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