IgtSimController.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. <?php
  2. namespace App\Http\Controllers\Game;
  3. use App\Game\Config\IgtData;
  4. use App\Game\GameCard;
  5. use App\Game\GlobalUserInfo;
  6. use App\Game\LogGamecardClick;
  7. use App\Game\Services\ServerService;
  8. use App\Game\Services\IgtUserAgentParser;
  9. use App\Models\AccountsInfo;
  10. use App\Util;
  11. use Illuminate\Http\Request;
  12. use Illuminate\Routing\Controller;
  13. use Illuminate\Support\Facades\DB;
  14. use Illuminate\Support\Facades\Redis;
  15. class IgtSimController extends Controller
  16. {
  17. public function __construct()
  18. {
  19. }
  20. public $gameConfig = [];
  21. public function gameLunch(Request $request)
  22. {
  23. $softwareId = $request->input('softwareid', '200-1551-001');
  24. return $this->renderGateway($request, $softwareId);
  25. }
  26. public function gameLunchOrg(Request $request)
  27. {
  28. $softwareId = $request->input('softwareid', '200-1551-001');
  29. return $this->renderGateway($request, $softwareId);
  30. }
  31. public function leaveOrg(Request $request)
  32. {
  33. $UserID = $request->UserID;
  34. try {
  35. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreLocker')
  36. ->where('UserID', $UserID)
  37. ->delete();
  38. } catch (\Throwable $e) {
  39. }
  40. return '<script>
  41. if(window.parent&&window.parent!=window){
  42. window.parent.postMessage("backhome","*")
  43. }else {
  44. document.location = "game://a=1&b=2";
  45. }
  46. </script>';
  47. }
  48. private function renderGateway(Request $request, string $softwareId)
  49. {
  50. if (!strstr($softwareId, '-')) {
  51. $softwareId = substr($softwareId, 0, 3) . '-' . substr($softwareId, 3, 4) . '-' . substr($softwareId, 7, 3);
  52. }
  53. $gid = $request->input('gid');
  54. $level = $request->input('level', 0);
  55. $user = $request->user();
  56. if (!$user) {
  57. $userid = $request->UserID;
  58. if (!$userid) {
  59. $token = $request->deviceInfoString;
  60. $session = json_decode(Redis::get($token), true);
  61. $userid = $session['UserID'];
  62. if ($session['GlobalUID']) {
  63. $GlobalUID = $session['GlobalUID'];
  64. }
  65. } else {
  66. $GlobalUID = 'a1b1c1-b53b-' . ServerService::GetLocalSign() . '-' . $userid;
  67. }
  68. $user = GlobalUserInfo::getGameUserInfo('UserID', $userid);
  69. if (!$user) {
  70. $user = AccountsInfo::find($userid);
  71. }
  72. } else {
  73. $GlobalUID = $user->GlobalUID;
  74. $userid = $user->UserID;
  75. }
  76. $lang = GlobalUserInfo::getLocaleByUserID($userid, $request->input('language', env('DEFAULT_LOCALE', 'en')));
  77. $gamecard = GameCard::where('gid', $gid)->where('brand', 'IGT')->first();
  78. if ($gamecard) {
  79. $gamecard->increment('play_num', 1);
  80. LogGamecardClick::recordClick($gamecard->id, $userid);
  81. GameCard::$enableStateCheck = false;
  82. }
  83. $data = ['UserID' => ServerService::GlobalToUserID($GlobalUID)];
  84. $Currency = env("CONFIG_24680_CURRENCY", "USD");
  85. $CurrencySymbol = env("CONFIG_24680_DOLLAR", "$");
  86. $data['currency'] = $Currency;
  87. $data['dollar'] = $CurrencySymbol;
  88. if (!is_array($user)) $user = $user->toArray();
  89. $data = array_merge($data, $user);
  90. $session = $data;
  91. $token = md5($GlobalUID . '|' . microtime());
  92. Redis::setex($token, 7200, json_encode($session));
  93. $global = IgtData::$global;
  94. /// 'mainSiteUrl' => 'https://testigt.usgamewin.com/',
  95. // 'rgsServer' => 'https://testigt.usgamewin.com/skb',
  96. // 'rgsCecServer' => 'https://testigt.usgamewin.com/cec',
  97. // 'flightdeckUrl' => 'https://testigt.usgamewin.com/flightdeck/gs/flightdeck',
  98. // 'consoleBaseUrl' => 'https://sigt.usgamewin.com/skins/DV13',
  99. // 'cdnBaseUrl' => 'https://sigt.usgamewin.com',
  100. // //jackpot
  101. // 'jackpotUrl' => 'https://testigt.usgamewin.com',
  102. $configurls=json_decode(env('CONFIG_GAMES'),true);
  103. $configurl=$configurls['igt'];
  104. $apiurl=$configurl['api'];
  105. $cdnurl=$configurl['source'];
  106. if($userid=='80001131'){
  107. $apiurl='test.pgn-nmu2nd.com';
  108. $cdnurl='static.pgn-nmu2nd.com';
  109. }
  110. foreach ($global as $key => $value) {
  111. if(is_string($value))if(strstr($value,'{api}')){
  112. $global[$key]=str_replace('{api}',$apiurl,$value);
  113. }else if(strstr($value,'{cdn}')){
  114. $global[$key]=str_replace('{cdn}',$cdnurl,$value);
  115. }
  116. }
  117. $games = json_decode(file_get_contents(base_path('app/Game/Config/IGTgamesConfig.json')), true);
  118. if (!isset($games[$softwareId])) {
  119. http_response_code(500);
  120. }
  121. $game = $games[$softwareId];
  122. $this->gameConfig = $game;
  123. $lang = in_array($lang, $global['languages']) ? $lang : 'en';
  124. $ua = $request->header('User-Agent', '');
  125. $uaParser = new IgtUserAgentParser($ua);
  126. $deviceConfig = $uaParser->getDeviceConfig();
  127. $isMobile = $this->isMobileUA($ua);
  128. $assetPack = $isMobile ? 'mobile' : 'desktop';
  129. $cdnBase = rtrim($global['cdnBaseUrl'], '/');
  130. $skbGatewayPath = $global['skbGatewayPath'];
  131. $gamePath = $game['gamePath'];
  132. $requireVersion = $global['requireVersion'];
  133. $denomamount = $game['denomamount'] ?? IgtData::$global['denomamount'];
  134. $paramGet = [
  135. 'skincode' => $request->input('skincode', 'MKW'),
  136. 'ipaddress' => $request->ip(),
  137. 'forcelat' => $request->input('forcelat', ''),
  138. 'minbet' => $request->input('minbet', $game['minbet']),
  139. 'deviceInfoString' => $request->input('deviceInfoString', $token),
  140. 'forcelocationstatus' => $request->input('forcelocationstatus', '0'),
  141. 'countrycode' => $request->input('countrycode', 'US'),
  142. 'channel' => $request->input('channel', $isMobile ? 'MOB' : 'INT'),
  143. 'nscode' => $request->input('nscode', 'AGLC'),
  144. 'language' => $lang,
  145. 'technology' => $request->input('technology', 'HTML'),
  146. 'loadskin' => $request->input('loadskin', 'IGT'),
  147. 'forcelng' => $request->input('forcelng', ''),
  148. 'currencycode' => $request->input('currencycode', 'FPY'),
  149. 'securetoken' => $request->input('securetoken', 'RGS-DEMO04.SKB'),
  150. 'softwareid' => $softwareId,
  151. 'forcelocationmessage' => $request->input('forcelocationmessage', '-SUCCESS'),
  152. 'presenttype' => $request->input('presenttype', 'STD'),
  153. 'denomamount' => $denomamount,//$request->input('denomamount', '1.0'),
  154. 'uniqueid' => $request->input('uniqueid', '986'),
  155. ];
  156. $paramRGS = [
  157. 'skincode' => $paramGet['skincode'],
  158. 'minbet' => $game['minbet'],
  159. 'countrycode' => $paramGet['countrycode'],
  160. 'channel' => $paramGet['channel'],
  161. 'language' => $paramGet['language'],
  162. 'nscode' => $paramGet['nscode'],
  163. 'technology' => $paramGet['technology'],
  164. 'currencycode' => $paramGet['currencycode'],
  165. 'securetoken' => $paramGet['securetoken'],
  166. 'playMode' => $request->input('playMode', 'real'),
  167. 'softwareid' => $paramGet['softwareid'],
  168. 'denomamount' => $paramGet['denomamount'],
  169. 'presenttype' => $paramGet['presenttype'],
  170. 'uniqueid' => $paramGet['uniqueid'],
  171. ];
  172. // 注入语言文案
  173. $langMap = json_decode(file_get_contents(base_path('app/Game/Config/IGTlanguages.json')), true);
  174. $strings = is_array($langMap) && isset($langMap[$lang]) && is_array($langMap[$lang]) ? $langMap[$lang] : [];
  175. $jackpotUrl = IgtData::$global['jackpotUrl'];
  176. $jackpotMeterUrl = null;
  177. if (isset(IgtData::$global['jackpotMeterPath'])) {
  178. $jackpotMeterUrl = $jackpotUrl . IgtData::$global['jackpotMeterPath'];
  179. }
  180. $jackpotWinsUrl = null;
  181. if (isset(IgtData::$global['jackpotWinsPath'])) {
  182. $jackpotWinsUrl = $jackpotUrl . IgtData::$global['jackpotWinsPath'];
  183. }
  184. $config = [
  185. 'serverConfig' => [
  186. 'paramGet' => $paramGet,
  187. 'paramRGS' => $paramRGS,
  188. 'softwareid' => $softwareId,
  189. 'nscode' => 'SKB',
  190. 'skincode' => $paramGet['skincode'],
  191. 'server' => $global['rgsServer'],
  192. 'showInitialCashier' => 'false',
  193. 'autopull' => 'N',
  194. 'securetoken' => $paramGet['securetoken'],
  195. 'uniqueid' => $paramGet['uniqueid'],
  196. 'channel' => $paramGet['channel'],
  197. 'presenttype' => $paramGet['presenttype'],
  198. 'buildnumber' => $global['buildnumber'],
  199. 'gameUrl' => $cdnBase . $gamePath . '/launcher.html',
  200. 'requestTimeout' => $global['requestTimeout'],
  201. 'requestRetries' => $global['requestRetries'],
  202. 'ipaddress' => $paramGet['ipaddress'],
  203. 'playMode' => $request->input('playMode', 'real'),
  204. 'denomamount' => $paramGet['denomamount'],//$game['minbet'],
  205. 'countrycode' => $paramGet['countrycode'],
  206. 'revisionTag' => $game['revisionTag'],
  207. 'paramGame' => [
  208. 'skincode' => $paramGet['skincode'],
  209. 'softwareid' => $softwareId,
  210. 'countrycode' => $paramGet['countrycode'],
  211. 'assetPack' => $assetPack,
  212. 'language' => $lang,
  213. 'currencycode' => $paramGet['currencycode'],
  214. 'playMode' => $request->input('playMode', 'real'),
  215. 'revisionTag' => $game['revisionTag'],
  216. ],
  217. 'autospin' => [
  218. 'winLimit' => [1, 2, 5, 10, 100],
  219. 'lossLimit' => [1, 2, 5, 10, 100],
  220. 'steps' => [10, 20, 30, 50, 100],
  221. 'version' => 2,
  222. ],
  223. 'cecServerUrl' => $global['rgsCecServer'],
  224. 'gameVersion' => $game['gameVersion'],
  225. 'sessionToken' => 'IGTGSRID=' . $token,
  226. 'dateFormatter' => [
  227. 'country' => $paramGet['countrycode'],
  228. 'dateFormatterShort' => 'dd/MM/yyyy',
  229. 'dateFormatterLong' => 'dd/MM/yyyy HH:mm:ss',
  230. ],
  231. 'fusionIntegrationInd' => false,
  232. 'pendingGps' => false,
  233. 'checkPass' => false,
  234. 'jackpotMeterUrl' => $jackpotMeterUrl,
  235. 'jackpotWinsUrl' => $jackpotWinsUrl,
  236. 'baseHostUrl' => $cdnBase,
  237. 'needShareButton' => false,
  238. 'nicknameAutoGen' => true,
  239. 'authorizationId' => 0,
  240. 'widgetsEnabled' => true,
  241. 'supportGSPType' => 'widget',
  242. 'showTournmentWelComeMessage' => false,
  243. 'blockInsufficientFund' => false,
  244. 'enableCustomGSP' => false,
  245. 'gameInfoInterval' => '',
  246. ],
  247. 'deviceConfig' => $deviceConfig,
  248. 'kernelConfig' => [
  249. 'splashUrl' => $cdnBase . $gamePath . '/splash.html',
  250. 'serverType' => 'RGS',
  251. 'platformVersion' => $global['platformVersion'],
  252. 'loglevel' => 'WARN',
  253. 'paramSplash' => [
  254. 'skincode' => $paramGet['skincode'],
  255. 'softwareid' => $softwareId,
  256. 'countrycode' => $paramGet['countrycode'],
  257. 'assetPack' => $assetPack,
  258. 'language' => $lang,
  259. 'currencycode' => $paramGet['currencycode'],
  260. 'playMode' => $request->input('playMode', 'real'),
  261. 'revisionTag' => $game['revisionTag'],
  262. ],
  263. 'intVerify' => false,
  264. 'sentryEnabled' => false,
  265. 'showSoundPrompt' => true,
  266. 'reportLevels' => new \stdClass(),
  267. ],
  268. 'consoleConfig' => [
  269. 'paramConsole' => [
  270. 'skincode' => $paramGet['skincode'],
  271. 'softwareid' => $softwareId,
  272. 'nscode' => $paramGet['nscode'],
  273. 'language' => $lang,
  274. 'currencycode' => $paramGet['currencycode'],
  275. 'cashiertype' => 'N',
  276. 'securetoken' => $paramGet['securetoken'],
  277. 'uniqueid' => $paramGet['uniqueid'],
  278. ],
  279. 'lobbyUrl' => $global['mainSiteUrl'],
  280. 'cashiertype' => 'N',
  281. 'TCustomView' => [
  282. 'consoleUrl' => $global['consoleBaseUrl'] . $game['tCustomPath'],
  283. 'resizable' => 'Y',
  284. 'width' => '100',
  285. 'timeout' => '15000',
  286. 'height' => '31',
  287. ],
  288. 'BCustomView' => [
  289. // 'consoleUrl' => $global['consoleBaseUrl'] . $game['bCustomPath'],
  290. // 'resizable' => 'N',
  291. // 'width' => '100%',
  292. // 'timeout' => '15000',
  293. // 'height' => '0%',
  294. ],
  295. ],
  296. 'stringsConfig' => $strings,
  297. 'forceGetParamNames' => [],
  298. 'gameConfig' => [
  299. 'studio' => $game['studio'],
  300. 'gameType' => $game['gameType'],
  301. 'game' => $game['game'],
  302. 'gameWindowWidth' => $game['gameWindowWidth'],
  303. 'spaceBarSpin' => $game['spaceBarSpin'],
  304. 'minbet' => $game['minbet'],
  305. 'gameWindowHeight' => $game['gameWindowHeight'],
  306. 'softDisplay' => $game['softDisplay'],
  307. 'gameTitle' => $game['gameTitle'],
  308. 'assetPack' => $assetPack,
  309. 'language' => $lang,
  310. 'currencycode' => $paramGet['currencycode'],
  311. 'denomid' => $game['denomid'],
  312. 'turboMode' => $game['turboMode'],
  313. 'speedOption' => $game['speedOption'],
  314. 'slamStop' => $game['slamStop'],
  315. 'softwareId' => $softwareId,
  316. 'dealerVoice' => $game['dealerVoice'],
  317. 'gleVersion' => $game['gleVersion'],
  318. 'skbGateWayVersion' => $global['skbGateWayVersion'],
  319. 'autospin' => [
  320. 'winLimit' => [1, 2, 5, 10, 100],
  321. 'lossLimit' => [1, 2, 5, 10, 100],
  322. 'steps' => [10, 20, 30, 50, 100],
  323. 'version' => 2,
  324. ],
  325. 'rgPresentation' => $game['rgPresentation'],
  326. ],
  327. 'gameServiceConfig' => [
  328. 'flightdeck' => [
  329. 'url' => $global['flightdeckUrl'],
  330. ],
  331. ],
  332. 'widgetConfig' => [
  333. 'dcid' => 'SF',
  334. 'connectorUrl' => $global['widgetUrl'],
  335. ],
  336. ];
  337. $configJson = htmlspecialchars(json_encode($config, JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8');
  338. $iconUrl = $cdnBase . $gamePath . '/icons/icon.png';
  339. $html = '<!DOCTYPE html>
  340. <html>
  341. <head>
  342. <meta http-equiv="X-UA-Compatible" content="IE=EDGE">
  343. <meta charset="UTF-8">
  344. <link rel="apple-touch-icon" href="' . $iconUrl . '">
  345. <meta name="apple-mobile-web-app-capable" content="yes">
  346. <script>
  347. (function () {
  348. var scale = 1;
  349. if (navigator.userAgent.match(/\s+[789]_[\d_]+\s+like Mac OS X/) && navigator.userAgent.indexOf("7_0") == -1 && /(iPod|iPhone)/.test(navigator.userAgent)) {
  350. document.write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no, minimal-ui\" />");
  351. } else {
  352. document.write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no, viewport-fit=cover\" />");
  353. }
  354. })();
  355. window.addEventListener("message", function(e){ if(!e.data||!e.data.message) return; var m=document.getElementById("messageBoxDiv"); if(m){ m.style.visibility="visible"; document.getElementById("message").innerHTML=e.data.message; } var c=document.getElementById("container"); if(c&&c.parentNode){ c.parentNode.removeChild(c); } }, true);
  356. </script>
  357. <meta name="com.igt.skateboard.CLIENTCONFIG" content="' . $configJson . '"/>
  358. <title>' . htmlspecialchars($game['gameTitle']) . '</title>
  359. <script type="text/javascript">var require={"waitSeconds":0,"urlArgs":"v=' . $requireVersion . '"};</script>
  360. <link rel="stylesheet" type="text/css" href="' . $cdnBase . $skbGatewayPath . '/css/style.mob.css?v=' . $requireVersion . '">
  361. </head>
  362. <body>
  363. <img id="loader" class="loader" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==">
  364. <div id="messageBoxDiv" class="messageBoxDiv" style="visibility:hidden"><div id="message" class="message"></div></div>
  365. <script data-main="' . $cdnBase . $skbGatewayPath . '/js/kernel.js" src="' . $cdnBase . $skbGatewayPath . '/js/require.js?v=2.1.20"></script>
  366. <script>
  367. parent.postMessage({cmd:"closeLoading"},"*");
  368. window.document.addEventListener("click", (event) => {
  369. window.parent.postMessage({cmd:"clickGame"},"*");
  370. });
  371. </script>
  372. </body>
  373. </html>';
  374. Util::WriteLog('igtsim', ['softwareid' => $softwareId, 'lang' => $lang]);
  375. return response($html);
  376. }
  377. private function isMobileUA(string $ua): bool
  378. {
  379. $ua = strtolower($ua);
  380. $mobiles = ['iphone', 'ipad', 'ipod', 'android', 'mobile'];
  381. foreach ($mobiles as $m) {
  382. if (strpos($ua, $m) !== false) return true;
  383. }
  384. return false;
  385. }
  386. }