v2board/app/Http/Controllers/Client/ClientController.php

42 lines
1.4 KiB
PHP
Raw Normal View History

2019-10-29 15:33:36 +08:00
<?php
2020-01-29 16:08:50 +08:00
namespace App\Http\Controllers\Client;
2019-10-29 15:33:36 +08:00
use App\Http\Controllers\Client\Protocols\V2rayN;
2019-10-29 15:33:36 +08:00
use App\Http\Controllers\Controller;
2020-06-12 00:18:35 +08:00
use App\Services\ServerService;
2020-01-29 16:08:50 +08:00
use Illuminate\Http\Request;
2020-02-28 01:12:55 +08:00
use App\Services\UserService;
2019-10-29 15:33:36 +08:00
class ClientController extends Controller
{
2020-01-11 13:36:52 +08:00
public function subscribe(Request $request)
{
2020-10-24 23:08:14 +08:00
$flag = $request->input('flag')
2020-10-24 23:43:45 +08:00
?? (isset($_SERVER['HTTP_USER_AGENT'])
2020-10-24 23:08:14 +08:00
? $_SERVER['HTTP_USER_AGENT']
2020-10-24 23:43:45 +08:00
: '');
2020-10-24 23:08:14 +08:00
$flag = strtolower($flag);
2019-10-29 15:33:36 +08:00
$user = $request->user;
2020-02-07 19:34:24 +08:00
// account not expired and is not banned.
2020-02-28 17:16:05 +08:00
$userService = new UserService();
if ($userService->isAvailable($user)) {
2020-06-12 00:18:35 +08:00
$serverService = new ServerService();
2020-11-14 17:26:17 +08:00
$servers = $serverService->getAvailableServers($user);
2020-10-24 23:08:14 +08:00
if ($flag) {
2021-07-02 22:34:42 +08:00
foreach (glob(app_path('Http//Controllers//Client//Protocols') . '/*.php') as $file) {
$file = 'App\\Http\\Controllers\\Client\\Protocols\\' . basename($file, '.php');
$class = new $file($user, $servers);
if (strpos($flag, $class->flag) !== false) {
die($class->handle());
}
}
}
// todo 1.5.3 remove
$class = new V2rayN($user, $servers);
die($class->handle());
2021-07-02 21:24:39 +08:00
die('该客户端暂不支持进行订阅');
}
}
2019-10-29 15:33:36 +08:00
}