| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- <?php
- namespace App\Game\Services;
- use App\Util;
- use GuzzleHttp\Client;
- use GuzzleHttp\Exception\RequestException;
- class ServerService
- {
- static $example=[
- 'Bangladesh'=>'',
- 'Pakistan'=>'',
- 'Latin'=>'',
- 'OrgBrazil'=>'',
- 'Brazil'=>'',
- 'Europe'=>'',
- 'Russia'=>'',
- 'Mexico'=>'',
- 'Singapore'=>''
- ];
- static $codeToServer = [
- '6f83' => [
- 'Subsite' => 'Bangladesh',
- 'Country' => 'Bangladesh',
- 'Currency' => 'BDT',
- 'Lang' => 'bn',
- 'ServerRegion' => 'ap-south-bd',
- 'Api' => 'http://bdapi.24680.org'
- ],
- 'b1ec' => [
- 'Subsite' => 'Pakistan',
- 'Country' => 'Pakistan',
- 'Currency' => 'PKR',
- 'Lang' => 'en',
- 'ServerRegion' => 'me-east',
- 'Api' => 'http://pkapi.24680.org'
- ],
- '9bf6' => [
- 'Subsite' => 'OrgBrazil',
- 'Country' => 'Brazil',
- 'Currency' => 'BRL',
- 'Lang' => 'pt',
- 'ServerRegion' => 'sa-east-org',
- 'Api' => 'http://api.ouro777.com'
- ],
- '3ef5' => [
- 'Subsite' => 'Latin',
- 'Country' => 'Peru_Colombia',
- 'Currency' => 'USD',
- 'Lang' => 'pt',
- 'ServerRegion' => 'sa-west',
- 'Api' => 'http://saapi.24680.org'
- ],
- 'eb1a' => [
- 'Subsite' => 'Brazil',
- 'Country' => 'Brazil',
- 'Currency' => 'BRL',
- 'Lang' => 'pt',
- 'ServerRegion' => 'sa-east',
- 'Api' => 'http://brapi.24680.org'
- ],
- '90dd' => [
- 'Subsite' => 'Europe',
- 'Country' => 'German',
- 'Currency' => 'EUR',
- 'Lang' => 'en',
- 'ServerRegion' => 'eu-central',
- 'Api' => 'http://euapi.24680.org'
- ],
- '720d' => [
- 'Subsite' => 'Russia',
- 'Country' => 'Russia',
- 'Currency' => 'RUB',
- 'Lang' => 'ru',
- 'ServerRegion' => 'eu-russian',
- 'Api' => 'http://ruapi.24680.org'
- ],
- '2b80' => [
- 'Subsite' => 'Mexico',
- 'Country' => 'Mexico',
- 'Currency' => 'MXN',
- 'Lang' => 'es',
- 'ServerRegion' => 'na-mexico',
- 'Api' => 'http://mxapi.24680.org'
- ],
- ];
- public static function GetGlobalServerInfoByCode($code)
- {
- return self::$codeToServer[$code] ?? self::$codeToServer['90dd'];
- }
- public static function GetGlobalServerInfoBySubsite($subsite)
- {
- foreach (self::$codeToServer as $code => $server) {
- if ($server['Subsite'] == $subsite) {
- return $server;
- }
- }
- return self::$codeToServer['90dd'];
- }
- public static function IsLocalUser($GlobalUID)
- {
- return self::GetGlobalServerInfoByGUID($GlobalUID)['ServerRegion'] == env('REGION_24680', 'sa-east');
- }
- /**
- * @param $GlobalUID
- * @return string[]
- */
- public static function GetGlobalServerInfoByGUID($GlobalUID)
- {
- ////"917c74999c-b53b-eb1a-0004478930"
- $codes = explode("-", $GlobalUID);
- $config = @self::$codeToServer[$codes[2]];
- if(!$config)return self::$codeToServer['eb1a'];
- return $config;
- }
- public static function GetApiByGUID($GlobalUID)
- {
- return self::GetGlobalServerInfoByGUID($GlobalUID)['Api'];
- }
- public static function GlobalToUserID($GlobalUID)
- {
- return intval(explode('-', $GlobalUID)[3]);
- }
- public static function GetLocalSign()
- {
- return substr(md5(env('REGION_24680', 'sa-east')),0,4);
- }
- public static function RedirectToSub($GlobalUID)
- {
- $apiurl = self::GetApiByGUID($GlobalUID);
- // 获取当前请求的 GET 和 POST 数据
- // $getData = $request->query(); // 获取 GET 数据
- $postData = $_POST; // 获取 POST 数据
- $client = new Client();
- $response = $client->post($apiurl . $_SERVER['REQUEST_URI'], [
- 'verify'=>false,
- 'form_params' => $postData, // 传递 POST 数据// 'query' => $getData, // 传递 GET 数据
- ]);
- $res = json_decode($response->getBody(), true);
- // Util::WriteLog('subserver',$res);
- return $res;
- }
- }
|