mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: get subscribe url
This commit is contained in:
parent
d74ab728fe
commit
ed749f85ae
@ -56,13 +56,11 @@ class ConfigController extends Controller
|
|||||||
|
|
||||||
public function setTelegramWebhook(Request $request)
|
public function setTelegramWebhook(Request $request)
|
||||||
{
|
{
|
||||||
$appUrl = config('v2board.app_url');
|
$hookUrl = '/api/v1/guest/telegram/webhook?access_token=' . md5(config('v2board.telegram_bot_token', $request->input('telegram_bot_token')));
|
||||||
if (!$appUrl) abort(500, '请先配置正确的站点地址');
|
$hookUrl - str_replace('http://', 'https://', $hookUrl);
|
||||||
$telegramService = new TelegramService($request->input('telegram_bot_token'));
|
$telegramService = new TelegramService($request->input('telegram_bot_token'));
|
||||||
$telegramService->getMe();
|
$telegramService->getMe();
|
||||||
$telegramService->setWebhook(
|
$telegramService->setWebhook($hookUrl);
|
||||||
$appUrl . '/api/v1/guest/telegram/webhook?access_token=' . md5(config('v2board.telegram_bot_token', $request->input('telegram_bot_token')))
|
|
||||||
);
|
|
||||||
return response([
|
return response([
|
||||||
'data' => true
|
'data' => true
|
||||||
]);
|
]);
|
||||||
|
@ -26,7 +26,7 @@ class PaymentController extends Controller
|
|||||||
{
|
{
|
||||||
$payments = Payment::all();
|
$payments = Payment::all();
|
||||||
foreach ($payments as $k => $v) {
|
foreach ($payments as $k => $v) {
|
||||||
$notifyUrl = config('v2board.app_url') . "/api/v1/guest/payment/notify/{$v->payment}/{$v->uuid}";
|
$notifyUrl = url("/api/v1/guest/payment/notify/{$v->payment}/{$v->uuid}");
|
||||||
if ($v->notify_domain) {
|
if ($v->notify_domain) {
|
||||||
$parseUrl = parse_url($notifyUrl);
|
$parseUrl = parse_url($notifyUrl);
|
||||||
$notifyUrl = $v->notify_domain . $parseUrl['path'];
|
$notifyUrl = $v->notify_domain . $parseUrl['path'];
|
||||||
|
@ -74,7 +74,7 @@ class UserController extends Controller
|
|||||||
$res[$i]['plan_name'] = $plan[$k]['name'];
|
$res[$i]['plan_name'] = $plan[$k]['name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$res[$i]['subscribe_url'] = Helper::getSubscribeHost() . '/api/v1/client/subscribe?token=' . $res[$i]['token'];
|
$res[$i]['subscribe_url'] = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $res[$i]['token']);
|
||||||
}
|
}
|
||||||
return response([
|
return response([
|
||||||
'data' => $res,
|
'data' => $res,
|
||||||
@ -153,7 +153,6 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$data = "邮箱,余额,推广佣金,总流量,剩余流量,套餐到期时间,订阅计划,订阅地址\r\n";
|
$data = "邮箱,余额,推广佣金,总流量,剩余流量,套餐到期时间,订阅计划,订阅地址\r\n";
|
||||||
$baseUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL')));
|
|
||||||
foreach($res as $user) {
|
foreach($res as $user) {
|
||||||
$expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']);
|
$expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']);
|
||||||
$balance = $user['balance'] / 100;
|
$balance = $user['balance'] / 100;
|
||||||
@ -161,7 +160,7 @@ class UserController extends Controller
|
|||||||
$transferEnable = $user['transfer_enable'] ? $user['transfer_enable'] / 1073741824 : 0;
|
$transferEnable = $user['transfer_enable'] ? $user['transfer_enable'] / 1073741824 : 0;
|
||||||
$notUseFlow = (($user['transfer_enable'] - ($user['u'] + $user['d'])) / 1073741824) ?? 0;
|
$notUseFlow = (($user['transfer_enable'] - ($user['u'] + $user['d'])) / 1073741824) ?? 0;
|
||||||
$planName = $user['plan_name'] ?? '无订阅';
|
$planName = $user['plan_name'] ?? '无订阅';
|
||||||
$subscribeUrl = $baseUrl . '/api/v1/client/subscribe?token=' . $user['token'];
|
$subscribeUrl = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user['token']);
|
||||||
$data .= "{$user['email']},{$balance},{$commissionBalance},{$transferEnable},{$notUseFlow},{$expireDate},{$planName},{$subscribeUrl}\r\n";
|
$data .= "{$user['email']},{$balance},{$commissionBalance},{$transferEnable},{$notUseFlow},{$expireDate},{$planName},{$subscribeUrl}\r\n";
|
||||||
}
|
}
|
||||||
echo "\xEF\xBB\xBF" . $data;
|
echo "\xEF\xBB\xBF" . $data;
|
||||||
@ -232,12 +231,11 @@ class UserController extends Controller
|
|||||||
}
|
}
|
||||||
DB::commit();
|
DB::commit();
|
||||||
$data = "账号,密码,过期时间,UUID,创建时间,订阅地址\r\n";
|
$data = "账号,密码,过期时间,UUID,创建时间,订阅地址\r\n";
|
||||||
$baseUrl = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL')));
|
|
||||||
foreach($users as $user) {
|
foreach($users as $user) {
|
||||||
$expireDate = $user['expired_at'] === NULL ? '长期有效' : date('Y-m-d H:i:s', $user['expired_at']);
|
$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']);
|
$createDate = date('Y-m-d H:i:s', $user['created_at']);
|
||||||
$password = $request->input('password') ?? $user['email'];
|
$password = $request->input('password') ?? $user['email'];
|
||||||
$subscribeUrl = $baseUrl . '/api/v1/client/subscribe?token=' . $user['token'];
|
$subscribeUrl = Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user['token']);
|
||||||
$data .= "{$user['email']},{$password},{$expireDate},{$user['uuid']},{$createDate},{$subscribeUrl}\r\n";
|
$data .= "{$user['email']},{$password},{$expireDate},{$user['uuid']},{$createDate},{$subscribeUrl}\r\n";
|
||||||
}
|
}
|
||||||
echo $data;
|
echo $data;
|
||||||
|
@ -54,8 +54,7 @@ class Surfboard
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subscription link
|
// Subscription link
|
||||||
$subsHost = Helper::getSubscribeHost();
|
$subsURL = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||||
$subsURL = "{$subsHost}/api/v1/client/subscribe?token={$user['token']}";
|
|
||||||
$subsDomain = $_SERVER['SERVER_NAME'];
|
$subsDomain = $_SERVER['SERVER_NAME'];
|
||||||
|
|
||||||
$config = str_replace('$subs_link', $subsURL, $config);
|
$config = str_replace('$subs_link', $subsURL, $config);
|
||||||
|
@ -54,8 +54,7 @@ class Surge
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Subscription link
|
// Subscription link
|
||||||
$subsHost = Helper::getSubscribeHost();
|
$subsURL = Helper::getSubscribeHost("/api/v1/client/subscribe?token={$user['token']}");
|
||||||
$subsURL = "{$subsHost}/api/v1/client/subscribe?token={$user['token']}";
|
|
||||||
$subsDomain = $_SERVER['SERVER_NAME'];
|
$subsDomain = $_SERVER['SERVER_NAME'];
|
||||||
|
|
||||||
$config = str_replace('$subs_link', $subsURL, $config);
|
$config = str_replace('$subs_link', $subsURL, $config);
|
||||||
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers\User;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
|
use App\Utils\Helper;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\Knowledge;
|
use App\Models\Knowledge;
|
||||||
|
|
||||||
@ -28,12 +29,7 @@ class KnowledgeController extends Controller
|
|||||||
$appleIdPassword = __('No active subscription. Unable to use our provided Apple ID');
|
$appleIdPassword = __('No active subscription. Unable to use our provided Apple ID');
|
||||||
$this->formatAccessData($knowledge['body']);
|
$this->formatAccessData($knowledge['body']);
|
||||||
}
|
}
|
||||||
$subscribeUrl = config('v2board.app_url', env('APP_URL'));
|
$subscribeUrl = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||||
$subscribeUrls = explode(',', config('v2board.subscribe_url'));
|
|
||||||
if ($subscribeUrls) {
|
|
||||||
$subscribeUrl = $subscribeUrls[rand(0, count($subscribeUrls) - 1)];
|
|
||||||
}
|
|
||||||
$subscribeUrl = "{$subscribeUrl}/api/v1/client/subscribe?token={$user['token']}";
|
|
||||||
$knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']);
|
$knowledge['body'] = str_replace('{{siteName}}', config('v2board.app_name', 'V2Board'), $knowledge['body']);
|
||||||
$knowledge['body'] = str_replace('{{subscribeUrl}}', $subscribeUrl, $knowledge['body']);
|
$knowledge['body'] = str_replace('{{subscribeUrl}}', $subscribeUrl, $knowledge['body']);
|
||||||
$knowledge['body'] = str_replace('{{urlEncodeSubscribeUrl}}', urlencode($subscribeUrl), $knowledge['body']);
|
$knowledge['body'] = str_replace('{{urlEncodeSubscribeUrl}}', urlencode($subscribeUrl), $knowledge['body']);
|
||||||
|
@ -120,7 +120,7 @@ class UserController extends Controller
|
|||||||
abort(500, __('Subscription plan does not exist'));
|
abort(500, __('Subscription plan does not exist'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user['subscribe_url'] = Helper::getSubscribeHost() . "/api/v1/client/subscribe?token={$user['token']}";
|
$user['subscribe_url'] = Helper::getSubscribeUrl("/api/v1/client/subscribe?token={$user['token']}");
|
||||||
$user['reset_day'] = $this->getResetDay($user);
|
$user['reset_day'] = $this->getResetDay($user);
|
||||||
return response([
|
return response([
|
||||||
'data' => $user
|
'data' => $user
|
||||||
@ -139,7 +139,7 @@ class UserController extends Controller
|
|||||||
abort(500, __('Reset failed'));
|
abort(500, __('Reset failed'));
|
||||||
}
|
}
|
||||||
return response([
|
return response([
|
||||||
'data' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user->token
|
'data' => Helper::getSubscribeUrl('/api/v1/client/subscribe?token=' . $user->token)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class PaymentService
|
|||||||
public function pay($order)
|
public function pay($order)
|
||||||
{
|
{
|
||||||
// custom notify domain name
|
// custom notify domain name
|
||||||
$notifyUrl = config('v2board.app_url', env('APP_URL')) . "/api/v1/guest/payment/notify/{$this->method}/{$this->config['uuid']}";
|
$notifyUrl = url("/api/v1/guest/payment/notify/{$this->method}/{$this->config['uuid']}");
|
||||||
if ($this->config['notify_domain']) {
|
if ($this->config['notify_domain']) {
|
||||||
$parseUrl = parse_url($notifyUrl);
|
$parseUrl = parse_url($notifyUrl);
|
||||||
$notifyUrl = $this->config['notify_domain'] . $parseUrl['path'];
|
$notifyUrl = $this->config['notify_domain'] . $parseUrl['path'];
|
||||||
@ -47,7 +47,7 @@ class PaymentService
|
|||||||
|
|
||||||
return $this->payment->pay([
|
return $this->payment->pay([
|
||||||
'notify_url' => $notifyUrl,
|
'notify_url' => $notifyUrl,
|
||||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order/' . $order['trade_no'],
|
'return_url' => config('v2board.app_url') . '/#/order/' . $order['trade_no'],
|
||||||
'trade_no' => $order['trade_no'],
|
'trade_no' => $order['trade_no'],
|
||||||
'total_amount' => $order['total_amount'],
|
'total_amount' => $order['total_amount'],
|
||||||
'user_id' => $order['user_id'],
|
'user_id' => $order['user_id'],
|
||||||
|
@ -103,14 +103,12 @@ class Helper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSubscribeHost()
|
public static function getSubscribeUrl($path)
|
||||||
{
|
{
|
||||||
$subscribeUrl = config('v2board.app_url');
|
|
||||||
$subscribeUrls = explode(',', config('v2board.subscribe_url'));
|
$subscribeUrls = explode(',', config('v2board.subscribe_url'));
|
||||||
if ($subscribeUrls && $subscribeUrls[0]) {
|
$subscribeUrl = $subscribeUrls[rand(0, count($subscribeUrls) - 1)];
|
||||||
$subscribeUrl = $subscribeUrls[rand(0, count($subscribeUrls) - 1)];
|
if ($subscribeUrl) return $subscribeUrl . $path;
|
||||||
}
|
return url($path);
|
||||||
return $subscribeUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function randomPort($range) {
|
public static function randomPort($range) {
|
||||||
|
Loading…
Reference in New Issue
Block a user