diff --git a/app/Controllers/LinkController.php b/app/Controllers/LinkController.php index 11a74922..24f564e7 100644 --- a/app/Controllers/LinkController.php +++ b/app/Controllers/LinkController.php @@ -10,6 +10,7 @@ use App\Models\Smartline; use App\Utils\ConfRender; use App\Utils\Tools; use App\Utils\URL; +use App\Services\Config; /** * HomeController @@ -103,35 +104,35 @@ class LinkController extends BaseController ->withHeader('Content-type', ' application/octet-stream; charset=utf-8') ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=Quantumult.conf'); - $newResponse->getBody()->write(LinkController::GetQuantumult($user, $quantumult)); + $newResponse->getBody()->write(self::GetQuantumult($user, $quantumult)); return $newResponse; } elseif (in_array($surge, array(1, 2, 3))) { $newResponse = $response ->withHeader('Content-type', ' application/octet-stream; charset=utf-8') ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=Surge.conf'); - $newResponse->getBody()->write(LinkController::GetSurge($user, $surge, $opts)); + $newResponse->getBody()->write(self::GetSurge($user, $surge, $opts)); return $newResponse; } elseif ($surfboard == 1) { $newResponse = $response ->withHeader('Content-type', ' application/octet-stream; charset=utf-8') ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=Surfboard.conf'); - $newResponse->getBody()->write(LinkController::GetSurfboard($user)); + $newResponse->getBody()->write(self::GetSurfboard($user)); return $newResponse; } elseif ($clash == 1) { $newResponse = $response ->withHeader('Content-type', ' application/octet-stream; charset=utf-8') ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=config.yml'); - $newResponse->getBody()->write(LinkController::GetClash($user, $opts)); + $newResponse->getBody()->write(self::GetClash($user, $opts)); return $newResponse; } elseif ($ssd == 1) { $newResponse = $response ->withHeader('Content-type', ' application/octet-stream; charset=utf-8') ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=SSD.txt'); - $newResponse->getBody()->write(LinkController::GetSSD($user)); + $newResponse->getBody()->write(self::GetSSD($user)); return $newResponse; } else { $newResponse = $response @@ -139,7 +140,7 @@ class LinkController extends BaseController ->withHeader('Cache-Control', 'no-store, no-cache, must-revalidate') ->withHeader('Content-Disposition', ' attachment; filename=' . $token . '.txt') ->withHeader('Subscription-Userinfo', ' upload='.$user->u.'; download='.$user->d.'; total='.$user->transfer_enable.'; expire='.strtotime($user->class_expire).''); - $newResponse->getBody()->write(LinkController::GetSub($user, $sub, $opts)); + $newResponse->getBody()->write(self::GetSub($user, $sub, $opts)); return $newResponse; } } @@ -149,7 +150,7 @@ class LinkController extends BaseController if ($int == 0) { $int = ""; } - $userapiUrl = Config::get('subUrl') . LinkController::GenerateSSRSubCode($user->id, 0); + $userapiUrl = Config::get('subUrl') . self::GenerateSSRSubCode($user->id, 0); $return_info = [ "link" => $userapiUrl, // sub @@ -176,7 +177,7 @@ class LinkController extends BaseController public static function GetSurge($user, $surge, $opts) { - $subInfo = LinkController::GetSubinfo($user, $surge); + $subInfo = self::GetSubinfo($user, $surge); $userapiUrl = $subInfo['surge']; $proxy_name = ""; $proxy_group = ""; @@ -223,7 +224,7 @@ class LinkController extends BaseController public static function GetQuantumult($user, $quantumult = 0) { - $subInfo = LinkController::GetSubinfo($user, 0); + $subInfo = self::GetSubinfo($user, 0); $proxys = []; $groups = []; $subUrl = ""; @@ -320,7 +321,7 @@ class LinkController extends BaseController public static function GetSurfboard($user) { - $subInfo = LinkController::GetSubinfo($user, 0); + $subInfo = self::GetSubinfo($user, 0); $userapiUrl = $subInfo['surfboard']; $ss_name = ""; $ss_group = ""; @@ -342,7 +343,7 @@ class LinkController extends BaseController public static function GetClash($user, $opts) { - $subInfo = LinkController::GetSubinfo($user, 0); + $subInfo = self::GetSubinfo($user, 0); $userapiUrl = $subInfo['clash']; $confs = []; $proxy_confs = []; diff --git a/app/Utils/Tools.php b/app/Utils/Tools.php index b4f13486..1b9f9a5c 100644 --- a/app/Utils/Tools.php +++ b/app/Utils/Tools.php @@ -455,14 +455,14 @@ class Tools 'tls' => '' ]; $item['add'] = $server[0]; - if ($server[1] == "0" or $server[1] == "") { + if ($server[1] == '0' or $server[1] == '') { $item['port'] = 443; } else { $item['port'] = (int)$server[1]; } $item['aid'] = (int)$server[2]; - $item['net'] = "tcp"; - $item['type'] = "none"; + $item['net'] = 'tcp'; + $item['type'] = 'none'; if (count($server) >= 4) { $item['net'] = $server[3]; if ($item['net'] == 'ws') { @@ -472,7 +472,7 @@ class Tools } } if (count($server) >= 5) { - if (in_array($item['net'], array("kcp", "http"))) { + if (in_array($item['net'], array('kcp', 'http'))) { $item['type'] = $server[4]; } elseif ($server[4] == 'ws') { $item['net'] = 'ws'; @@ -482,11 +482,11 @@ class Tools } if (count($server) >= 6) { $item = array_merge($item, URL::parse_args($server[5])); - if (array_key_exists("server", $item)) { + if (array_key_exists('server', $item)) { $item['add'] = $item['server']; unset($item['server']); } - if (array_key_exists("outside_port", $item)) { + if (array_key_exists('outside_port', $item)) { $item['port'] = (int)$item['outside_port']; unset($item['outside_port']); } @@ -497,7 +497,7 @@ class Tools public static function checkTls($node) { $server = Tools::v2Array($node); - if ($server['tls'] == "tls" && Tools::is_ip($server['add'])) { + if ($server['tls'] == 'tls' && Tools::is_ip($server['add'])) { return false; } else { return true; @@ -514,7 +514,7 @@ class Tools 'tls' => '' ]; $item['add'] = $server[0]; - if ($server[1] == "0" or $server[1] == "") { + if ($server[1] == '0' or $server[1] == '') { $item['port'] = 443; } else { $item['port'] = (int)$server[1]; @@ -534,11 +534,11 @@ class Tools } if (count($server) >= 6) { $item = array_merge($item, URL::parse_args($server[5])); - if (array_key_exists("server", $item)) { + if (array_key_exists('server', $item)) { $item['add'] = $item['server']; unset($item['server']); } - if (array_key_exists("outside_port", $item)) { + if (array_key_exists('outside_port', $item)) { $item['port'] = (int)$item['outside_port']; unset($item['outside_port']); } diff --git a/config/routes.php b/config/routes.php index e1d4b012..e8c27d96 100644 --- a/config/routes.php +++ b/config/routes.php @@ -92,63 +92,63 @@ $app->group('/user', function () { $this->post('/buy', App\Controllers\UserController::class . ':buy'); // Relay Mange - $this->get('/relay', 'App\Controllers\RelayController:index'); - $this->get('/relay/create', 'App\Controllers\RelayController:create'); - $this->post('/relay', 'App\Controllers\RelayController:add'); - $this->get('/relay/{id}/edit', 'App\Controllers\RelayController:edit'); - $this->put('/relay/{id}', 'App\Controllers\RelayController:update'); - $this->delete('/relay', 'App\Controllers\RelayController:delete'); - - $this->get('/ticket', 'App\Controllers\UserController:ticket'); - $this->get('/ticket/create', 'App\Controllers\UserController:ticket_create'); - $this->post('/ticket', 'App\Controllers\UserController:ticket_add'); - $this->get('/ticket/{id}/view', 'App\Controllers\UserController:ticket_view'); - $this->put('/ticket/{id}', 'App\Controllers\UserController:ticket_update'); + $this->get('/relay', App\Controllers\RelayController::class . ':index'); + $this->get('/relay/create', App\Controllers\RelayController::class . ':create'); + $this->post('/relay', App\Controllers\RelayController::class . ':add'); + $this->get('/relay/{id}/edit', App\Controllers\RelayController::class . ':edit'); + $this->put('/relay/{id}', App\Controllers\RelayController::class . ':update'); + $this->delete('/relay', App\Controllers\RelayController::class . ':delete'); + + $this->get('/ticket', App\Controllers\UserController::class . ':ticket'); + $this->get('/ticket/create', App\Controllers\UserController::class . ':ticket_create'); + $this->post('/ticket', App\Controllers\UserController::class . ':ticket_add'); + $this->get('/ticket/{id}/view', App\Controllers\UserController::class . ':ticket_view'); + $this->put('/ticket/{id}', App\Controllers\UserController::class . ':ticket_update'); - $this->post('/buy_invite', 'App\Controllers\UserController:buyInvite'); - $this->post('/custom_invite', 'App\Controllers\UserController:customInvite'); - $this->get('/edit', 'App\Controllers\UserController:edit'); - $this->post('/password', 'App\Controllers\UserController:updatePassword'); - $this->post('/wechat', 'App\Controllers\UserController:updateWechat'); - $this->post('/ssr', 'App\Controllers\UserController:updateSSR'); - $this->post('/theme', 'App\Controllers\UserController:updateTheme'); - $this->post('/mail', 'App\Controllers\UserController:updateMail'); - $this->post('/sspwd', 'App\Controllers\UserController:updateSsPwd'); - $this->post('/method', 'App\Controllers\UserController:updateMethod'); - $this->post('/hide', 'App\Controllers\UserController:updateHide'); - $this->get('/sys', 'App\Controllers\UserController:sys'); - $this->get('/trafficlog', 'App\Controllers\UserController:trafficLog'); - $this->get('/kill', 'App\Controllers\UserController:kill'); - $this->post('/kill', 'App\Controllers\UserController:handleKill'); - $this->get('/logout', 'App\Controllers\UserController:logout'); - $this->get('/backtoadmin', 'App\Controllers\UserController:backtoadmin'); - $this->get('/code', 'App\Controllers\UserController:code'); - $this->get('/alipay', 'App\Controllers\UserController:alipay'); - $this->post('/code/f2fpay', 'App\Services\Payment:purchase'); - $this->get('/code/codepay', 'App\Services\Payment:purchase'); - $this->get('/code_check', 'App\Controllers\UserController:code_check'); - $this->post('/code', 'App\Controllers\UserController:codepost'); - $this->post('/gacheck', 'App\Controllers\UserController:GaCheck'); - $this->post('/gaset', 'App\Controllers\UserController:GaSet'); - $this->get('/gareset', 'App\Controllers\UserController:GaReset'); - $this->get('/telegram_reset', 'App\Controllers\UserController:telegram_reset'); - $this->get('/discord_reset', 'App\Controllers\UserController:discord_reset'); - $this->post('/resetport', 'App\Controllers\UserController:ResetPort'); - $this->post('/specifyport', 'App\Controllers\UserController:SpecifyPort'); - $this->post('/pacset', 'App\Controllers\UserController:PacSet'); - $this->post('/unblock', 'App\Controllers\UserController:Unblock'); - $this->get('/bought', 'App\Controllers\UserController:bought'); - $this->delete('/bought', 'App\Controllers\UserController:deleteBoughtGet'); - - $this->get('/url_reset', 'App\Controllers\UserController:resetURL'); - - $this->get('/inviteurl_reset', 'App\Controllers\UserController:resetInviteURL'); + $this->post('/buy_invite', App\Controllers\UserController::class . ':buyInvite'); + $this->post('/custom_invite', App\Controllers\UserController::class . ':customInvite'); + $this->get('/edit', App\Controllers\UserController::class . ':edit'); + $this->post('/password', App\Controllers\UserController::class . ':updatePassword'); + $this->post('/wechat', App\Controllers\UserController::class . ':updateWechat'); + $this->post('/ssr', App\Controllers\UserController::class . ':updateSSR'); + $this->post('/theme', App\Controllers\UserController::class . ':updateTheme'); + $this->post('/mail', App\Controllers\UserController::class . ':updateMail'); + $this->post('/sspwd', App\Controllers\UserController::class . ':updateSsPwd'); + $this->post('/method', App\Controllers\UserController::class . ':updateMethod'); + $this->post('/hide', App\Controllers\UserController::class . ':updateHide'); + $this->get('/sys', App\Controllers\UserController::class . ':sys'); + $this->get('/trafficlog', App\Controllers\UserController::class . ':trafficLog'); + $this->get('/kill', App\Controllers\UserController::class . ':kill'); + $this->post('/kill', App\Controllers\UserController::class . ':handleKill'); + $this->get('/logout', App\Controllers\UserController::class . ':logout'); + $this->get('/backtoadmin', App\Controllers\UserController::class . ':backtoadmin'); + $this->get('/code', App\Controllers\UserController::class . ':code'); + $this->get('/alipay', App\Controllers\UserController::class . ':alipay'); + $this->post('/code/f2fpay', App\Services\Payment::class . ':purchase'); + $this->get('/code/codepay', App\Services\Payment::class . ':purchase'); + $this->get('/code_check', App\Controllers\UserController::class . ':code_check'); + $this->post('/code', App\Controllers\UserController::class . ':codepost'); + $this->post('/gacheck', App\Controllers\UserController::class . ':GaCheck'); + $this->post('/gaset', App\Controllers\UserController::class . ':GaSet'); + $this->get('/gareset', App\Controllers\UserController::class . ':GaReset'); + $this->get('/telegram_reset', App\Controllers\UserController::class . ':telegram_reset'); + $this->get('/discord_reset', App\Controllers\UserController::class . ':discord_reset'); + $this->post('/resetport', App\Controllers\UserController::class . ':ResetPort'); + $this->post('/specifyport', App\Controllers\UserController::class . ':SpecifyPort'); + $this->post('/pacset', App\Controllers\UserController::class . ':PacSet'); + $this->post('/unblock', App\Controllers\UserController::class . ':Unblock'); + $this->get('/bought', App\Controllers\UserController::class . ':bought'); + $this->delete('/bought', App\Controllers\UserController::class . ':deleteBoughtGet'); + + $this->get('/url_reset', App\Controllers\UserController::class . ':resetURL'); + + $this->get('/inviteurl_reset', App\Controllers\UserController::class . ':resetInviteURL'); // Switch Type || SS/SSR - $this->post('/switchtype', 'App\Controllers\UserController:switchType'); + $this->post('/switchtype', App\Controllers\UserController::class . ':switchType'); // getUserAllURL - $this->get('/getUserAllURL', 'App\Controllers\UserController:getUserAllURL'); + $this->get('/getUserAllURL', App\Controllers\UserController::class . ':getUserAllURL'); //Reconstructed Payment System $this->post('/payment/purchase', App\Services\Payment::class . ':purchase'); @@ -398,10 +398,10 @@ $app->group('/admin', function () { //doc $app->group('/doc', function () { - $this->get('', 'App\Controllers\HomeController:docCenter'); - $this->get('/', 'App\Controllers\HomeController:docCenter'); + $this->get('', App\Controllers\HomeController::class . ':docCenter'); + $this->get('/', App\Controllers\HomeController::class . ':docCenter'); }); -$app->get('/sublink', 'App\Controllers\HomeController:sublinkOut'); +$app->get('/sublink', App\Controllers\HomeController::class . ':sublinkOut'); //doc end // Run Slim Routes for App