IgtSimController.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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. $games = json_decode(file_get_contents(base_path('app/Game/Config/IGTgamesConfig.json')), true);
  95. if (!isset($games[$softwareId])) {
  96. http_response_code(500);
  97. }
  98. $game = $games[$softwareId];
  99. $this->gameConfig = $game;
  100. $lang = in_array($lang, $global['languages']) ? $lang : 'en';
  101. $ua = $request->header('User-Agent', '');
  102. $uaParser = new IgtUserAgentParser($ua);
  103. $deviceConfig = $uaParser->getDeviceConfig();
  104. $isMobile = $this->isMobileUA($ua);
  105. $assetPack = $isMobile ? 'mobile' : 'desktop';
  106. $cdnBase = rtrim($global['cdnBaseUrl'], '/');
  107. $skbGatewayPath = $global['skbGatewayPath'];
  108. $gamePath = $game['gamePath'];
  109. $requireVersion = $global['requireVersion'];
  110. $denomamount = $game['denomamount'] ?? IgtData::$global['denomamount'];
  111. $paramGet = [
  112. 'skincode' => $request->input('skincode', 'MKW'),
  113. 'ipaddress' => $request->ip(),
  114. 'forcelat' => $request->input('forcelat', ''),
  115. 'minbet' => $request->input('minbet', $game['minbet']),
  116. 'deviceInfoString' => $request->input('deviceInfoString', $token),
  117. 'forcelocationstatus' => $request->input('forcelocationstatus', '0'),
  118. 'countrycode' => $request->input('countrycode', 'US'),
  119. 'channel' => $request->input('channel', $isMobile ? 'MOB' : 'INT'),
  120. 'nscode' => $request->input('nscode', 'AGLC'),
  121. 'language' => $lang,
  122. 'technology' => $request->input('technology', 'HTML'),
  123. 'loadskin' => $request->input('loadskin', 'IGT'),
  124. 'forcelng' => $request->input('forcelng', ''),
  125. 'currencycode' => $request->input('currencycode', 'FPY'),
  126. 'securetoken' => $request->input('securetoken', 'RGS-DEMO04.SKB'),
  127. 'softwareid' => $softwareId,
  128. 'forcelocationmessage' => $request->input('forcelocationmessage', '-SUCCESS'),
  129. 'presenttype' => $request->input('presenttype', 'STD'),
  130. 'denomamount' => $denomamount,//$request->input('denomamount', '1.0'),
  131. 'uniqueid' => $request->input('uniqueid', '986'),
  132. ];
  133. $paramRGS = [
  134. 'skincode' => $paramGet['skincode'],
  135. 'minbet' => $game['minbet'],
  136. 'countrycode' => $paramGet['countrycode'],
  137. 'channel' => $paramGet['channel'],
  138. 'language' => $paramGet['language'],
  139. 'nscode' => $paramGet['nscode'],
  140. 'technology' => $paramGet['technology'],
  141. 'currencycode' => $paramGet['currencycode'],
  142. 'securetoken' => $paramGet['securetoken'],
  143. 'playMode' => $request->input('playMode', 'real'),
  144. 'softwareid' => $paramGet['softwareid'],
  145. 'denomamount' => $paramGet['denomamount'],
  146. 'presenttype' => $paramGet['presenttype'],
  147. 'uniqueid' => $paramGet['uniqueid'],
  148. ];
  149. // 注入语言文案
  150. $langMap = json_decode(file_get_contents(base_path('app/Game/Config/IGTlanguages.json')), true);
  151. $strings = is_array($langMap) && isset($langMap[$lang]) && is_array($langMap[$lang]) ? $langMap[$lang] : [];
  152. $jackpotUrl = IgtData::$global['jackpotUrl'];
  153. $jackpotMeterUrl = null;
  154. if (isset(IgtData::$global['jackpotMeterPath'])) {
  155. $jackpotMeterUrl = $jackpotUrl . IgtData::$global['jackpotMeterPath'];
  156. }
  157. $jackpotWinsUrl = null;
  158. if (isset(IgtData::$global['jackpotWinsPath'])) {
  159. $jackpotWinsUrl = $jackpotUrl . IgtData::$global['jackpotWinsPath'];
  160. }
  161. $config = [
  162. 'serverConfig' => [
  163. 'paramGet' => $paramGet,
  164. 'paramRGS' => $paramRGS,
  165. 'softwareid' => $softwareId,
  166. 'nscode' => 'SKB',
  167. 'skincode' => $paramGet['skincode'],
  168. 'server' => $global['rgsServer'],
  169. 'showInitialCashier' => 'false',
  170. 'autopull' => 'N',
  171. 'securetoken' => $paramGet['securetoken'],
  172. 'uniqueid' => $paramGet['uniqueid'],
  173. 'channel' => $paramGet['channel'],
  174. 'presenttype' => $paramGet['presenttype'],
  175. 'buildnumber' => $global['buildnumber'],
  176. 'gameUrl' => $cdnBase . $gamePath . '/launcher.html',
  177. 'requestTimeout' => $global['requestTimeout'],
  178. 'requestRetries' => $global['requestRetries'],
  179. 'ipaddress' => $paramGet['ipaddress'],
  180. 'playMode' => $request->input('playMode', 'real'),
  181. 'denomamount' => $paramGet['denomamount'],//$game['minbet'],
  182. 'countrycode' => $paramGet['countrycode'],
  183. 'revisionTag' => $game['revisionTag'],
  184. 'paramGame' => [
  185. 'skincode' => $paramGet['skincode'],
  186. 'softwareid' => $softwareId,
  187. 'countrycode' => $paramGet['countrycode'],
  188. 'assetPack' => $assetPack,
  189. 'language' => $lang,
  190. 'currencycode' => $paramGet['currencycode'],
  191. 'playMode' => $request->input('playMode', 'real'),
  192. 'revisionTag' => $game['revisionTag'],
  193. ],
  194. 'autospin' => [
  195. 'winLimit' => [1, 2, 5, 10, 100],
  196. 'lossLimit' => [1, 2, 5, 10, 100],
  197. 'steps' => [10, 20, 30, 50, 100],
  198. 'version' => 2,
  199. ],
  200. 'cecServerUrl' => $global['rgsCecServer'],
  201. 'gameVersion' => $game['gameVersion'],
  202. 'sessionToken' => 'IGTGSRID=' . $token,
  203. 'dateFormatter' => [
  204. 'country' => $paramGet['countrycode'],
  205. 'dateFormatterShort' => 'dd/MM/yyyy',
  206. 'dateFormatterLong' => 'dd/MM/yyyy HH:mm:ss',
  207. ],
  208. 'fusionIntegrationInd' => false,
  209. 'pendingGps' => false,
  210. 'checkPass' => false,
  211. 'jackpotMeterUrl' => $jackpotMeterUrl,
  212. 'jackpotWinsUrl' => $jackpotWinsUrl,
  213. 'baseHostUrl' => $cdnBase,
  214. 'needShareButton' => false,
  215. 'nicknameAutoGen' => true,
  216. 'authorizationId' => 0,
  217. 'widgetsEnabled' => true,
  218. 'supportGSPType' => 'widget',
  219. 'showTournmentWelComeMessage' => false,
  220. 'blockInsufficientFund' => false,
  221. 'enableCustomGSP' => false,
  222. 'gameInfoInterval' => '',
  223. ],
  224. 'deviceConfig' => $deviceConfig,
  225. 'kernelConfig' => [
  226. 'splashUrl' => $cdnBase . $gamePath . '/splash.html',
  227. 'serverType' => 'RGS',
  228. 'platformVersion' => $global['platformVersion'],
  229. 'loglevel' => 'WARN',
  230. 'paramSplash' => [
  231. 'skincode' => $paramGet['skincode'],
  232. 'softwareid' => $softwareId,
  233. 'countrycode' => $paramGet['countrycode'],
  234. 'assetPack' => $assetPack,
  235. 'language' => $lang,
  236. 'currencycode' => $paramGet['currencycode'],
  237. 'playMode' => $request->input('playMode', 'real'),
  238. 'revisionTag' => $game['revisionTag'],
  239. ],
  240. 'intVerify' => false,
  241. 'sentryEnabled' => false,
  242. 'showSoundPrompt' => true,
  243. 'reportLevels' => new \stdClass(),
  244. ],
  245. 'consoleConfig' => [
  246. 'paramConsole' => [
  247. 'skincode' => $paramGet['skincode'],
  248. 'softwareid' => $softwareId,
  249. 'nscode' => $paramGet['nscode'],
  250. 'language' => $lang,
  251. 'currencycode' => $paramGet['currencycode'],
  252. 'cashiertype' => 'N',
  253. 'securetoken' => $paramGet['securetoken'],
  254. 'uniqueid' => $paramGet['uniqueid'],
  255. ],
  256. 'lobbyUrl' => $global['mainSiteUrl'],
  257. 'cashiertype' => 'N',
  258. 'TCustomView' => [
  259. 'consoleUrl' => $global['consoleBaseUrl'] . $game['tCustomPath'],
  260. 'resizable' => 'Y',
  261. 'width' => '100',
  262. 'timeout' => '15000',
  263. 'height' => '31',
  264. ],
  265. 'BCustomView' => [
  266. // 'consoleUrl' => $global['consoleBaseUrl'] . $game['bCustomPath'],
  267. // 'resizable' => 'N',
  268. // 'width' => '100%',
  269. // 'timeout' => '15000',
  270. // 'height' => '0%',
  271. ],
  272. ],
  273. 'stringsConfig' => $strings,
  274. 'forceGetParamNames' => [],
  275. 'gameConfig' => [
  276. 'studio' => $game['studio'],
  277. 'gameType' => $game['gameType'],
  278. 'game' => $game['game'],
  279. 'gameWindowWidth' => $game['gameWindowWidth'],
  280. 'spaceBarSpin' => $game['spaceBarSpin'],
  281. 'minbet' => $game['minbet'],
  282. 'gameWindowHeight' => $game['gameWindowHeight'],
  283. 'softDisplay' => $game['softDisplay'],
  284. 'gameTitle' => $game['gameTitle'],
  285. 'assetPack' => $assetPack,
  286. 'language' => $lang,
  287. 'currencycode' => $paramGet['currencycode'],
  288. 'denomid' => $game['denomid'],
  289. 'turboMode' => $game['turboMode'],
  290. 'speedOption' => $game['speedOption'],
  291. 'slamStop' => $game['slamStop'],
  292. 'softwareId' => $softwareId,
  293. 'dealerVoice' => $game['dealerVoice'],
  294. 'gleVersion' => $game['gleVersion'],
  295. 'skbGateWayVersion' => $global['skbGateWayVersion'],
  296. 'autospin' => [
  297. 'winLimit' => [1, 2, 5, 10, 100],
  298. 'lossLimit' => [1, 2, 5, 10, 100],
  299. 'steps' => [10, 20, 30, 50, 100],
  300. 'version' => 2,
  301. ],
  302. 'rgPresentation' => $game['rgPresentation'],
  303. ],
  304. 'gameServiceConfig' => [
  305. 'flightdeck' => [
  306. 'url' => $global['flightdeckUrl'],
  307. ],
  308. ],
  309. 'widgetConfig' => [
  310. 'dcid' => 'SF',
  311. 'connectorUrl' => $global['widgetUrl'],
  312. ],
  313. ];
  314. $configJson = htmlspecialchars(json_encode($config, JSON_UNESCAPED_SLASHES), ENT_QUOTES, 'UTF-8');
  315. $iconUrl = $cdnBase . $gamePath . '/icons/icon.png';
  316. $html = '<!DOCTYPE html>
  317. <html>
  318. <head>
  319. <meta http-equiv="X-UA-Compatible" content="IE=EDGE">
  320. <meta charset="UTF-8">
  321. <link rel="apple-touch-icon" href="' . $iconUrl . '">
  322. <meta name="apple-mobile-web-app-capable" content="yes">
  323. <script>
  324. (function () {
  325. var scale = 1;
  326. if (navigator.userAgent.match(/\s+[789]_[\d_]+\s+like Mac OS X/) && navigator.userAgent.indexOf("7_0") == -1 && /(iPod|iPhone)/.test(navigator.userAgent)) {
  327. document.write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no, minimal-ui\" />");
  328. } else {
  329. document.write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=" + scale + ", minimum-scale=" + scale + ", maximum-scale=" + scale + ", user-scalable=no, viewport-fit=cover\" />");
  330. }
  331. })();
  332. 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);
  333. </script>
  334. <meta name="com.igt.skateboard.CLIENTCONFIG" content="' . $configJson . '"/>
  335. <title>' . htmlspecialchars($game['gameTitle']) . '</title>
  336. <script type="text/javascript">var require={"waitSeconds":0,"urlArgs":"v=' . $requireVersion . '"};</script>
  337. <link rel="stylesheet" type="text/css" href="' . $cdnBase . $skbGatewayPath . '/css/style.mob.css?v=' . $requireVersion . '">
  338. </head>
  339. <body>
  340. <img id="loader" class="loader" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==">
  341. <div id="messageBoxDiv" class="messageBoxDiv" style="visibility:hidden"><div id="message" class="message"></div></div>
  342. <script data-main="' . $cdnBase . $skbGatewayPath . '/js/kernel.js" src="' . $cdnBase . $skbGatewayPath . '/js/require.js?v=2.1.20"></script>
  343. <script>
  344. parent.postMessage({cmd:"closeLoading"},"*");
  345. window.document.addEventListener("click", (event) => {
  346. window.parent.postMessage({cmd:"clickGame"},"*");
  347. });
  348. </script>
  349. </body>
  350. </html>';
  351. Util::WriteLog('igtsim', ['softwareid' => $softwareId, 'lang' => $lang]);
  352. return response($html);
  353. }
  354. private function isMobileUA(string $ua): bool
  355. {
  356. $ua = strtolower($ua);
  357. $mobiles = ['iphone', 'ipad', 'ipod', 'android', 'mobile'];
  358. foreach ($mobiles as $m) {
  359. if (strpos($ua, $m) !== false) return true;
  360. }
  361. return false;
  362. }
  363. }