ApiSingleController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Facade\TableName;
  4. use App\Http\Controllers\Controller;
  5. use App\Http\helper\HttpCurl;
  6. use App\Http\helper\NumConfig;
  7. use App\Jobs\Order;
  8. use App\Models\Cpf;
  9. use App\Models\Installation;
  10. use App\Models\PrivateMail;
  11. use App\Models\RecordScoreInfo;
  12. use App\Services\Goopago;
  13. use App\Services\IpCheck;
  14. use App\Services\OrderServices;
  15. use App\Services\StoredProcedure;
  16. use App\Util;
  17. use App\Utility\SetNXLock;
  18. use Illuminate\Http\Request;
  19. use Illuminate\Support\Facades\DB;
  20. use Illuminate\Support\Facades\Redis;
  21. use Log;
  22. // use Yansongda\Pay\Log;
  23. class ApiSingleController extends Controller
  24. {
  25. public function AdjustLog(Request $request)
  26. {
  27. $data = $request->all();
  28. // 从请求中提取数据并保存到数据库
  29. $installation=Installation::query()->where('gps_adid', $request->gps_adid)
  30. ->where('app_token', $request->app_token)->first();
  31. if($installation){
  32. if ($request->has('fb_install_referrer') && !empty($request->fb_install_referrer)) {
  33. $installation->update(["fb_install_referrer"=>$request->fb_install_referrer]);
  34. }
  35. }else{
  36. Installation::create($request->only([
  37. 'app_token', 'app_name', 'app_name_dashboard', 'activity_kind',
  38. 'adid', 'gps_adid', 'country', 'city', 'language', 'is_organic',
  39. 'first_tracker', 'fb_install_referrer', 'device_manufacturer', 'device_name','ip_address','meta_install_referrer'
  40. ]));
  41. }
  42. Util::WriteLog("adjust",json_encode($request->all(),JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
  43. }
  44. public function checkAppKey(Request $request,$appkey)
  45. {
  46. $lang=$request->l??substr( @$_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 5 );
  47. $this->checkAppKeyWithLang($request,$appkey,$lang);
  48. }
  49. public function checkAppKeyWithLang(Request $request,$appkey,$lang)
  50. {
  51. $goView=0;
  52. //含有参数adjust=gps_adid
  53. $isCheckAdjust=$request->adjust??false;
  54. if(strstr($appkey,"_")){
  55. $goView=1;
  56. $appkey_arr=explode("_",$appkey);
  57. $appkey=$appkey_arr[0];
  58. $lang=$appkey_arr[1];
  59. }
  60. $rediskey="package_appkey_$appkey";
  61. if(Redis::exists($rediskey)){
  62. $app=json_decode(Redis::get($rediskey));
  63. }else{
  64. $app=DB::connection('write')->table('QPPlatformDB.dbo.ChannelPackageName')->where('AppKey', $appkey)->first();
  65. Redis::set($rediskey, json_encode($app));
  66. Redis::expire($rediskey,600);
  67. }
  68. //不再设置范围内
  69. if(!isset($app)||empty($app)) {
  70. http_response_code(404);
  71. die;
  72. }
  73. //进来的数据不对等
  74. if(isset($request->package)&&$request->package!=$app->PackageName){
  75. die;
  76. }
  77. $service = new IpCheck();
  78. $login_ip = $request->header("X_REAL_IP")??$request->ip();
  79. $package=$app->PackageName;
  80. $ipcheck=$service->ipCheck($login_ip,$package,1,false);
  81. $lastRes=$service->lastLocation??"";
  82. $params=$request->all();
  83. // unset($params['a']);
  84. // unset($params['l']);
  85. // $params['locale']=$lang;
  86. // $params['appkey']=$appkey;
  87. // $newh5="https://www.ouro777.com/client/h2/?".http_build_query($params);
  88. $newh5=$app->AppCheckDomain.'/'.$appkey.'_'.$lang.'/';
  89. // $newh5="https://www.ouro777.com/client/h2/";
  90. if($goView==0){
  91. $attr=$request->a??"";
  92. Util::WriteLog('h5',compact('lang','package','ipcheck','login_ip','lastRes','attr','newh5'));
  93. }else{
  94. $attr=$request->attr??"";
  95. Util::WriteLog('h5view',compact('lang','package','ipcheck','login_ip','lastRes','attr','params'));
  96. }
  97. if($isCheckAdjust){
  98. if($ipcheck) {
  99. $installations = Installation::query()->where('gps_adid', $isCheckAdjust)->get();
  100. foreach ($installations as $installation) {
  101. if(!empty($installation->fb_install_referrer)){
  102. exit(json_encode(['adid'=>$isCheckAdjust,'fb_install_referrer'=>$installation->fb_install_referrer,'meta_install_referrer'=>$installation->meta_install_referrer]));
  103. }
  104. }
  105. }
  106. exit(json_encode(['adid'=>$isCheckAdjust,'fb_install_referrer'=>'','meta_install_referrer'=>'']));
  107. }
  108. //封死英文
  109. if(strstr($lang,"en")){
  110. http_response_code(404);
  111. exit("");
  112. }else if($ipcheck){
  113. if($goView){
  114. // echo file_get_contents("https://cdn.moeda777.com/client/h2/index.data?111");
  115. // exit();
  116. exit(view("game.ouro.red777"));
  117. if(DB::table(TableName::QPAccountsDB() . 'AccountsInfo')->where('Channel',303)->where('RegisterMachine',$_REQUEST['adid'])->where('RegisterDate','<','2024-05-27')->exists()){
  118. //go old
  119. exit(view("game.ouro.red777"));
  120. }
  121. $query_string = http_build_query($_REQUEST);
  122. $redirect_url = 'https://cdn.moeda777.com/client/h2/pwa.html?' . $query_string;
  123. header("Location: $redirect_url", true, 302);
  124. exit();
  125. }else {
  126. $type = $request->t ?? "plain";
  127. if ($type == 'json') {
  128. exit(json_encode(['res' => 1, 'url' => $newh5]));
  129. } else {
  130. exit($newh5);
  131. }
  132. }
  133. }else{
  134. // exit($login_ip);
  135. http_response_code(404);
  136. exit("");
  137. }
  138. }
  139. public function FrontCheck(Request $request)
  140. {
  141. $lang=$request->l??"";
  142. $service = new IpCheck();
  143. $login_ip = $request->ip();
  144. $host=$_SERVER["HTTP_HOST"];
  145. $package="dhy.task.management";
  146. if($host=="ade246929caadac25.awsglobalaccelerator.com"){
  147. $package="vn.vastgroup.autojobs";
  148. }
  149. $ipcheck=$service->ipCheck($login_ip,$package,1);
  150. $lastRes=$service->lastLocation??"";
  151. Util::WriteLog('front',compact('lang','package','ipcheck','login_ip','lastRes'));
  152. //封死英文
  153. if(strstr($lang,"en")){
  154. http_response_code(404);
  155. exit();
  156. }else if($ipcheck){
  157. echo "1";die;
  158. }else{
  159. http_response_code(404);
  160. exit();
  161. }
  162. }
  163. public function LoginIP_Pigpig(Request $request){
  164. $this->LoginIP_Single($request,'com.pig.tomoney');
  165. }
  166. public function LoginIP_West(Request $request){
  167. $this->LoginIP_Single($request,'com.west.frzyapp');
  168. }
  169. public function LoginIP_Zeus(Request $request){
  170. http_response_code(404);
  171. exit();
  172. // $this->LoginIP_Single($request,'com.olympus.zgame');
  173. }
  174. public function LoginIP_SuperOX(Request $request){
  175. $this->CheckIpResult($request,'com.superox.xiaomi',1);
  176. }
  177. public function CheckIpResult(Request $request,$package=null,$forcePass=0){
  178. // $deviceid = $request->get('d')??"";
  179. // $v = $request->get('v')??1;
  180. // $v=intval($v);
  181. $package=$package??"com.carnivalgame.sppp";
  182. $service = new IpCheck();
  183. $login_ip = $request->ip();
  184. $ipcheck=$service->ipCheck($login_ip,$package,1);
  185. Util::WriteLog('single',compact('package','forcePass','ipcheck'));
  186. if($forcePass&&$ipcheck){
  187. echo "1";die;
  188. }else{
  189. http_response_code(404);
  190. exit();
  191. }
  192. }
  193. public function LoginIP_Single(Request $request,$package=null){
  194. // $deviceid = $request->get('d')??"";
  195. // $v = $request->get('v')??1;
  196. // $v=intval($v);
  197. $package=$package??"com.carnivalgame.sppp";
  198. $v=1;
  199. $service = new IpCheck();
  200. $login_ip = $request->ip();
  201. $ipcheck=$service->ipCheck($login_ip,$package,1);
  202. if($ipcheck){
  203. $js=<<<JS
  204. class DownloadB{
  205. static getInstance(){
  206. if(this.instance==null){
  207. this.instance=new DownloadB();
  208. this.instance.init();
  209. }
  210. return this.instance;
  211. }
  212. init(){
  213. this.downloadUrl="http://192.168.1.3:8080/assets.zip";
  214. this.CACHE_PATH="GameAssets";
  215. this.HotUpdateSearchPathsKey="SLOKEY";
  216. if (window.gameNative) {this.CACHE_PATH=window.gameNative.fileUtils.getWritablePath()+this.CACHE_PATH;}
  217. }
  218. showProgressBar(){
  219. if (window.gameLoadingPanel) {
  220. let txt="Downloading "+0+"%";
  221. window.gameLoadingPanel.show(txt);
  222. }
  223. }
  224. updateProgressLabel(txt){
  225. }
  226. updateProgressBar(progress){
  227. if (window.gameLoadingPanel) {
  228. if (window.gameLoadingPanel.node.active==false) {
  229. this.showProgressBar();
  230. }
  231. let radio=progress/100;
  232. let txt="Downloading "+progress+"%";
  233. window.gameLoadingPanel.showProgress(radio,txt);
  234. }
  235. }
  236. //ui
  237. uint8ArrayToInt(uint8Array){
  238. var buffer = uint8Array.buffer;
  239. var view = new DataView(buffer);
  240. var num = view.getInt32(0);
  241. return num;
  242. }
  243. uint8ArrayToString(uint8Array){
  244. var str="";
  245. for (var i = 0; i < uint8Array.length; i++) {
  246. str+=String.fromCharCode(uint8Array[i]);
  247. }
  248. return str;
  249. }
  250. //不存在创建
  251. checkDir(path){
  252. if (window.gameNative) {
  253. let arr=path.split("/");
  254. arr.pop();
  255. let dir=this.CACHE_PATH;
  256. for (var i = 0; i < arr.length; i++) {
  257. dir=dir+"/"+arr[i];
  258. if (!window.gameNative.fileUtils.isDirectoryExist(dir)){
  259. window.gameNative.fileUtils.createDirectory(dir);
  260. }
  261. }
  262. }
  263. }
  264. writeFile(path,filedata){
  265. this.checkDir(path);
  266. if (window.gameNative) {
  267. let fullpath=this.CACHE_PATH+"/"+path;
  268. window.gameNative.fileUtils.writeDataToFile(filedata, fullpath);
  269. }
  270. }
  271. unpack(data,callback){
  272. this.updateProgressLabel("Processing resources…");
  273. if (window.gameNative) {
  274. if (window.gameNative.fileUtils.isDirectoryExist(this.CACHE_PATH)) {
  275. window.gameNative.fileUtils.removeDirectory(this.CACHE_PATH);
  276. }
  277. window.gameNative.fileUtils.createDirectory(this.CACHE_PATH);
  278. }
  279. let dataarr=new Uint8Array(data);
  280. let datalen=dataarr.length;
  281. if (datalen<8) {return;}
  282. let pos=0;
  283. while(pos<datalen){
  284. let lenarr=dataarr.slice(pos,pos+8);
  285. let pathlen=this.uint8ArrayToInt(lenarr.slice(0,4));
  286. let filelen=this.uint8ArrayToInt(lenarr.slice(4,8));
  287. let sdatapos=pos+8;
  288. let epathpos=sdatapos+pathlen;
  289. let pathdata=dataarr.slice(sdatapos,epathpos);
  290. let sfilepos=sdatapos+pathlen;
  291. let efilepos=epathpos+filelen;
  292. let filedata=dataarr.slice(sfilepos,efilepos);
  293. let filepath=this.uint8ArrayToString(pathdata);
  294. let path=filepath;
  295. this.writeFile(path,filedata);
  296. pos+=(8+pathlen+filelen);
  297. }
  298. if (callback) {callback();}
  299. }
  300. updateSearchPaths(){
  301. cc.sys.localStorage.setItem(this.HotUpdateSearchPathsKey, "BDONWLOAD");
  302. }
  303. downloadDone(){
  304. let self=this;
  305. setTimeout(()=>{
  306. try{
  307. self.updateSearchPaths();
  308. // if (this.helper) {this.helper.init()}
  309. }
  310. catch(e){
  311. console.log(e);
  312. }
  313. cc.game.restart();
  314. }, 500);
  315. }
  316. startDownload(){
  317. let url=this.downloadUrl;
  318. this.showProgressBar();
  319. let self=this;
  320. cc.assetManager.loadRemote(url, {
  321. ext: ".bin",
  322. onFileProgress: (current, total) => {
  323. let progress=Math.floor((current/total)*100);
  324. self.updateProgressBar(progress);
  325. }
  326. }, (err, bufferAsset) => {
  327. if (err) {
  328. return;
  329. }
  330. self.updateProgressBar(100);
  331. let cachePath=cc.assetManager.cacheManager.getCache(url);
  332. let data=window.gameNative.fileUtils.getDataFromFile(cachePath);
  333. self.unpack(data,function(){
  334. self.downloadDone();
  335. });
  336. })
  337. }
  338. }
  339. let loop=setInterval(function(){
  340. if (window.gamePopBox!=null) {
  341. clearInterval(loop);
  342. window.stopLoading=true;
  343. DownloadB.getInstance().startDownload();
  344. }
  345. },100)
  346. JS;
  347. }else{
  348. http_response_code(404);
  349. exit();
  350. }
  351. echo $js;die;
  352. }
  353. }