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