IgtSimController.php 19 KB

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