PPSimController.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. <?php
  2. namespace App\Http\Controllers\Game;
  3. use App\Facade\TableName;
  4. use App\Game\GameCard;
  5. use App\Game\Config\PPGameIDs;
  6. use App\Game\GlobalUserInfo;
  7. use App\Game\LogGamecardClick;
  8. use App\Game\Services\OuroGameService;
  9. use App\Game\Services\PgSoftService;
  10. use App\Game\Services\PlatformService;
  11. use App\Game\Services\ServerService;
  12. use App\Http\helper\ApiSign;
  13. use App\Models\AccountsInfo;
  14. use App\Notification\TelegramBot;
  15. use App\Util;
  16. use App\Utility\SetNXLock;
  17. use Illuminate\Http\Request;
  18. use Illuminate\Routing\Controller;
  19. use Illuminate\Support\Facades\Crypt;
  20. use Illuminate\Support\Facades\DB;
  21. use Illuminate\Support\Facades\Redis;
  22. class PPSimController extends Controller
  23. {
  24. public function __construct()
  25. {
  26. }
  27. public function launch9x(Request $request)
  28. {
  29. $gid = $request->input('gid');
  30. $level=$request->input('level',0);
  31. $lang=$request->input('lang',env('DEFAULT_LOCALE','pu'));
  32. $userid = $request->UserID;
  33. $lang=['pu'=>'pt','en'=>'en','sp'=>'es'][$lang]??$lang;
  34. $protocol = $request->isSecure() ? 'https://' : 'http://';
  35. $domain = $protocol . $request->getHost();
  36. $rid=substr($gid,2);
  37. $params=[
  38. 'norot'=>1,
  39. 'lang'=>$lang,
  40. 'level'=>$level,
  41. 'gid'=>$rid,
  42. 'UserID'=>$userid,
  43. 't'=>time()
  44. ];
  45. $params['sign'] = ApiSign::sign($params);
  46. $url="$domain/api/pgsoft/lunchorg?".http_build_query($params);
  47. switch(substr($gid,0,2)){
  48. //igt
  49. case "92":
  50. $url = "$domain/api/igt/lunchorg?".http_build_query($params);
  51. break;
  52. //jili
  53. case "91":
  54. $url = "$domain/api/jiligames/lunchorg?".http_build_query($params);
  55. break;
  56. //pg
  57. case "90":
  58. $url="$domain/api/pgsoft/lunchorg?".http_build_query($params);
  59. break;
  60. default:
  61. $url="$domain/api/pp-0-/lunchorg?".http_build_query($params);
  62. break;
  63. }
  64. return redirect($url);
  65. }
  66. public function gameLunch(Request $request)
  67. {
  68. $gid = $request->input('gid');
  69. $user = $request->user();
  70. if (!$user) {
  71. $userid = $request->UserID;
  72. $GlobalUID = 'a1b1c1-b53b-'.ServerService::GetLocalSign().'-' . $userid;
  73. $user=GlobalUserInfo::getGameUserInfo('UserID',$userid);
  74. if(!$user){
  75. $user=AccountsInfo::find($userid);
  76. }
  77. }else{
  78. $GlobalUID = $user->GlobalUID;
  79. $userid = $user->UserID;
  80. }
  81. $lang = GlobalUserInfo::getLocaleByUserID($userid,$request->input('language', env('DEFAULT_LOCALE', 'en')));
  82. $gamecard = GameCard::where('gid', $gid)->where('brand', 'PragmaticPlay')->first();
  83. if($gamecard){
  84. $gamecard->increment('play_num', 1);
  85. LogGamecardClick::recordClick($gamecard->id, $userid);
  86. GameCard::$enableStateCheck = false;
  87. }
  88. $gameName=$gamecard->title;
  89. $data = ['UserID' => ServerService::GlobalToUserID($GlobalUID)];
  90. $Currency = env("CONFIG_24680_CURRENCY", "USD");
  91. $CurrencySymbol = env("CONFIG_24680_DOLLAR", "$");
  92. $data['currency'] = $Currency;
  93. $data['dollar'] = $CurrencySymbol;
  94. if(!is_array($user))$user=$user->toArray();
  95. $data = array_merge($data, $user);
  96. $session = $data;
  97. $token = md5($GlobalUID.'|'.microtime());
  98. Redis::setex($token, 7200, json_encode($session));
  99. $gamecode=$gid;
  100. $short2=substr($gamecode, 0, 2);
  101. $host='test.pgn-nmu2nd.com';
  102. $game_url='https://'.$host.'/';
  103. $hide_logo=PPGameIDs::$ids[$gamecode]['hide_logo']||false;
  104. return view('game.ppsim.html5', compact('host', 'token','gamecode','short2','lang','gameName','game_url','hide_logo'));
  105. }
  106. public function leaveOrg(Request $request){
  107. $UserID = $request->UserID;
  108. try {
  109. DB::connection('write')->table('QPTreasureDB.dbo.GameScoreLocker')
  110. ->where('UserID', $UserID)
  111. ->delete();
  112. } catch (\Throwable $e) {
  113. }
  114. return '<script>
  115. if(window.parent&&window.parent!=window){
  116. window.parent.postMessage("backhome","*")
  117. }else {
  118. document.location = "game://a=1&b=2";
  119. }
  120. </script>';
  121. }
  122. public function gameLunchOrg(Request $request)
  123. {
  124. $gid = $request->input('gid');
  125. $level=$request->input('level',0);
  126. $lang=$request->input('lang',env('DEFAULT_LOCALE','pu'));
  127. $lang=['pu'=>'pt','en'=>'en','sp'=>'es'][$lang]??$lang;
  128. // $lang='pt';
  129. $userid = $request->UserID;
  130. $GlobalUID = 'a1b1c1-b53b-'.ServerService::GetLocalSign().'-' . $userid;
  131. GameCard::$enableStateCheck = false;
  132. // $gamecard = GameCard::where('gid', $gid)->first();
  133. // $in_gameid = OuroGameService::getUserInGame($userid, $GlobalUID);
  134. // if ($in_gameid != intval($gamecard->id)) {
  135. // Util::WriteLog('24680game', compact('in_gameid', 'gamecard', 'GlobalUID'));
  136. //// die;
  137. // }
  138. //
  139. // $gamecard = GameCard::where('gid', $gid)->where('brand', 'PGSoft')->first();
  140. // $gamecard->increment('play_num', 1);
  141. // //$this->logGameClick($gamecard->id,$userid);
  142. //
  143. // LogGamecardClick::recordClick($gamecard->id, $userid);
  144. // $lang = GlobalUserInfo::getLocale();
  145. $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"];
  146. if (!in_array($lang, array_keys($supportLang))) {
  147. $lang = 'en';
  148. }
  149. $lang=$supportLang[$lang];
  150. $cdnserver = 'https://sjj.pgn-nmu2nd.com';
  151. $LogonPass='123';
  152. $sign = GlobalUserInfo::genGuuidSign((object)compact('GlobalUID','LogonPass'));
  153. $or = $this->convertString(env('JILI_GAME_DOMAIN','jj.pgn-nmu2nd.com'));
  154. // $api = $this->convertString('orgbr.pgn-nmu2nd.com');
  155. // $api = $this->convertString('api.pgn-nmu2nd.com');
  156. $data=['UserID'=>ServerService::GlobalToUserID($GlobalUID)];
  157. $gameIdToCodes=[302=>'mcp',51=>'mc',49=>'fullhouse',403=>'fullhouse3',300=>'fg3',223=>'fgp',109=>'fg',35=>'ols2',258=>'dl',47=>'bfs',421=>'lj'];
  158. $params = ['lang' => $lang, 'ssoKey' => $sign, 'apiId' => 2,'gameId'=>$gid,'gs'=>$or,'domain_platform'=>$or,'domain_gs'=>$or,'be'=>$or];
  159. $url = $cdnserver . "/{$gameIdToCodes[$gid]}/index.html?" . http_build_query($params).'&iu=true&legalLang=true';
  160. // 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
  161. $trans="no-rotated-iframe-container";
  162. $posClass = "defaultPos";
  163. $iconClass="widthIcon";
  164. if(in_array($gid,[49,403])){
  165. $iconClass="heightIcon";
  166. if (strpos(strtolower($request->header('User-Agent')), 'iphone') !== false) {
  167. $posClass = "iosPos";
  168. $iconClass="widthIcon";
  169. $trans="rotated-iframe-container";
  170. }
  171. }
  172. $leaveUrl=$request->getSchemeAndHttpHost().'/api/jiligames/leave?UserID='.$userid;
  173. echo '<!DOCTYPE html>
  174. <html lang="en">
  175. <head>
  176. <meta charset="UTF-8">
  177. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  178. <title>JiliGames</title>
  179. <style>
  180. body, html {
  181. margin: 0;
  182. padding: 0;
  183. background: #000;
  184. height: 100vh;
  185. overflow: hidden;
  186. -webkit-overflow-scrolling: touch; /* 启用惯性滚动 */
  187. }
  188. .rotated-iframe-container {
  189. width: 100vh; /* 旋转后高度变为宽度 */
  190. height: 100vw; /* 旋转后宽度变为高度 */
  191. transform: rotate(-90deg);
  192. transform-origin: top right;
  193. position: absolute;
  194. top: 0;
  195. right: 100%;
  196. overflow: hidden;
  197. }
  198. .no-rotated-iframe-container {
  199. width: 100vw; /* 旋转后高度变为宽度 */
  200. height: 100vh; /* 旋转后宽度变为高度 */
  201. position: absolute;
  202. top: 0;
  203. }
  204. .rotated-iframe {
  205. width: 100%;
  206. height: 100%;
  207. transform-origin: top right;
  208. }
  209. .widthIcon{
  210. width: 13vh; height: 13%;
  211. }
  212. .heightIcon{
  213. width: 13%; height: 13vw;
  214. }
  215. .defaultPos{
  216. position: absolute; top: 10px; left: 10px; z-index: 9999;
  217. }
  218. .iosPos{
  219. position: absolute; bottom: 10px; left: 10px; z-index: 9999; transform: rotate(-90deg);
  220. }
  221. </style>
  222. </head>
  223. <body>
  224. <script>
  225. document.addEventListener("touchstart", (e) => {
  226. // 确保滑动事件生效
  227. }, { passive: true });
  228. document.addEventListener("touchmove", (e) => {
  229. // 确保惯性滚动生效
  230. }, { passive: true });
  231. function backhome(){
  232. var xhr = new XMLHttpRequest();
  233. var url = "'.$leaveUrl.'"; // 这里替换成你实际要访问的 URL
  234. window.location.href=url;
  235. // console.log(url);
  236. // xhr.open("GET", url, true);
  237. // xhr.send();
  238. // setTimeout(()=>{
  239. // if(window.parent&&window.parent!=window){
  240. // window.parent.postMessage("backhome","*")
  241. // }else {
  242. // document.location = "game://a=1&b=2";
  243. // }
  244. // },500)
  245. // document.body.innerHTML=`<span style="color:#000">${url}</span>`;
  246. }
  247. </script>
  248. <div class="'.$trans.'">
  249. <!-- 嵌入的 iframe -->
  250. <iframe class="rotated-iframe" frameborder="0" src="'.$url.'"></iframe>
  251. </div>
  252. <div id="game-lobby" style="" class="'.$iconClass.' '.$posClass.'">
  253. <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>
  254. </div>
  255. </body>
  256. </html>';
  257. return "";
  258. }
  259. private function convertString($input)
  260. {
  261. return strrev($input);
  262. }
  263. }