mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add custom subscribe path
This commit is contained in:
parent
fa6670597a
commit
69c85983d1
@ -92,6 +92,7 @@ class ConfigController extends Controller
|
||||
'app_description' => config('v2board.app_description', 'V2Board is best!'),
|
||||
'app_url' => config('v2board.app_url'),
|
||||
'subscribe_url' => config('v2board.subscribe_url'),
|
||||
'subscribe_path' => config('v2board.subscribe_path'),
|
||||
'try_out_plan_id' => (int)config('v2board.try_out_plan_id', 0),
|
||||
'try_out_hour' => (int)config('v2board.try_out_hour', 1),
|
||||
'tos_url' => config('v2board.tos_url'),
|
||||
|
@ -74,7 +74,7 @@ class UserController extends Controller
|
||||
$res[$i]['plan_name'] = $plan[$k]['name'];
|
||||
}
|
||||
}
|
||||
$res[$i]['subscribe_url'] = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $res[$i]['token']);
|
||||
$res[$i]['subscribe_url'] = Helper::getSubscribeUrl($res[$i]['token']);
|
||||
}
|
||||
return response([
|
||||
'data' => $res,
|
||||
@ -165,7 +165,7 @@ class UserController extends Controller
|
||||
$transferEnable = $user['transfer_enable'] ? $user['transfer_enable'] / 1073741824 : 0;
|
||||
$notUseFlow = (($user['transfer_enable'] - ($user['u'] + $user['d'])) / 1073741824) ?? 0;
|
||||
$planName = $user['plan_name'] ?? '无订阅';
|
||||
$subscribeUrl = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user['token']);
|
||||
$subscribeUrl = Helper::getSubscribeUrl($user['token']);
|
||||
$data .= "{$user['email']},{$balance},{$commissionBalance},{$transferEnable},{$notUseFlow},{$expireDate},{$planName},{$subscribeUrl}\r\n";
|
||||
}
|
||||
echo "\xEF\xBB\xBF" . $data;
|
||||
@ -240,7 +240,7 @@ class UserController extends Controller
|
||||
$expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']);
|
||||
$createDate = date('Y-m-d H:i:s', $user['created_at']);
|
||||
$password = $request->input('password') ?? $user['email'];
|
||||
$subscribeUrl = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user['token']);
|
||||
$subscribeUrl = Helper::getSubscribeUrl($user['token']);
|
||||
$data .= "{$user['email']},{$password},{$expireDate},{$user['uuid']},{$createDate},{$subscribeUrl}\r\n";
|
||||
}
|
||||
echo $data;
|
||||
|
@ -24,7 +24,7 @@ class KnowledgeController extends Controller
|
||||
if (!$userService->isAvailable($user)) {
|
||||
$this->formatAccessData($knowledge['body']);
|
||||
}
|
||||
$subscribeUrl = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||
$subscribeUrl = Helper::getSubscribeUrl($user['token']);
|
||||
$knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']);
|
||||
$knowledge['body'] = str_replace('{{subscribeUrl}}', $subscribeUrl, $knowledge['body']);
|
||||
$knowledge['body'] = str_replace('{{urlEncodeSubscribeUrl}}', urlencode($subscribeUrl), $knowledge['body']);
|
||||
|
@ -151,7 +151,7 @@ class UserController extends Controller
|
||||
abort(500, __('Subscription plan does not exist'));
|
||||
}
|
||||
}
|
||||
$user['subscribe_url'] = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||
$user['subscribe_url'] = Helper::getSubscribeUrl($user['token']);
|
||||
$userService = new UserService();
|
||||
$user['reset_day'] = $userService->getResetDay($user);
|
||||
return response([
|
||||
@ -171,7 +171,7 @@ class UserController extends Controller
|
||||
abort(500, __('Reset failed'));
|
||||
}
|
||||
return response([
|
||||
'data' => Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user->token)
|
||||
'data' => Helper::getSubscribeUrl($user['token'])
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ class ConfigSave extends FormRequest
|
||||
'app_description' => '',
|
||||
'app_url' => 'nullable|url',
|
||||
'subscribe_url' => 'nullable',
|
||||
'subscribe_path' => 'nullable',
|
||||
'try_out_enable' => 'in:0,1',
|
||||
'try_out_plan_id' => 'integer',
|
||||
'try_out_hour' => 'numeric',
|
||||
|
@ -12,10 +12,15 @@ class ClientRoute
|
||||
'middleware' => 'client'
|
||||
], function ($router) {
|
||||
// Client
|
||||
$router->get('/subscribe', 'V1\\Client\\ClientController@subscribe');
|
||||
if (!config('v2board.subscribe_path')) {
|
||||
$router->get('/subscribe', 'V1\\Client\\ClientController@subscribe');
|
||||
}
|
||||
// App
|
||||
$router->get('/app/getConfig', 'V1\\Client\\AppController@getConfig');
|
||||
$router->get('/app/getVersion', 'V1\\Client\\AppController@getVersion');
|
||||
});
|
||||
if (config('v2board.subscribe_path')) {
|
||||
\Route::get(config('v2board.subscribe_path'), 'V1\\Client\\ClientController@subscribe');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class Surfboard
|
||||
}
|
||||
|
||||
// Subscription link
|
||||
$subsURL = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||
$subsURL = Helper::getSubscribeUrl($user['token']);
|
||||
$subsDomain = $_SERVER['HTTP_HOST'];
|
||||
|
||||
$config = str_replace('$subs_link', $subsURL, $config);
|
||||
|
@ -64,7 +64,6 @@ class Surge
|
||||
}
|
||||
|
||||
// Subscription link
|
||||
$subsURL = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||
$subsDomain = $_SERVER['HTTP_HOST'];
|
||||
$subsURL = 'https://' . $subsDomain . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
|
||||
|
@ -108,8 +108,10 @@ class Helper
|
||||
}
|
||||
}
|
||||
|
||||
public static function getSubscribeUrl($path)
|
||||
public static function getSubscribeUrl($token)
|
||||
{
|
||||
$path = config('v2board.subscribe_path', '/client/subscribe');
|
||||
$path = "/api/v1{$path}?token={$token}";
|
||||
$subscribeUrls = explode(',', config('v2board.subscribe_url'));
|
||||
$subscribeUrl = $subscribeUrls[rand(0, count($subscribeUrls) - 1)];
|
||||
if ($subscribeUrl) return $subscribeUrl . $path;
|
||||
|
Loading…
Reference in New Issue
Block a user