IgtSimController.php 17 KB

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