mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
commit
c1f0521955
@ -117,11 +117,13 @@ class CheckOrder extends Command
|
||||
$user->expired_at = time();
|
||||
}
|
||||
$user->transfer_enable = $plan->transfer_enable * 1073741824;
|
||||
// 当续费清空流量或用户先前是一次性订阅
|
||||
if ((int)config('v2board.renew_reset_traffic_enable', 1) || $user->expired_at === NULL) {
|
||||
$user->u = 0;
|
||||
$user->d = 0;
|
||||
}
|
||||
|
||||
// 续费重置&类型=续费
|
||||
if ((int)config('v2board.renew_reset_traffic_enable', 1) && $order->type === 2) $this->buyReset($user);
|
||||
// 购买前用户过期为NULL(一次性)
|
||||
if ($user->expired_at === NULL) $this->buyReset($user);
|
||||
// 新购
|
||||
if ($order->type === 1) $this->buyReset($user);
|
||||
$user->plan_id = $plan->id;
|
||||
$user->group_id = $plan->group_id;
|
||||
$user->expired_at = $this->getTime($order->cycle, $user->expired_at);
|
||||
|
@ -7,6 +7,7 @@ use App\Models\User;
|
||||
|
||||
class ResetTraffic extends Command
|
||||
{
|
||||
protected $user;
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
@ -29,6 +30,8 @@ class ResetTraffic extends Command
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->user = User::where('expired_at', '!=', NULL)
|
||||
->where('expired_at', '>', time());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -38,23 +41,22 @@ class ResetTraffic extends Command
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = User::where('expired_at', '!=', NULL)
|
||||
->where('expired_at', '>', time());
|
||||
$resetTrafficMethod = config('v2board.reset_traffic_method', 0);
|
||||
switch ((int)$resetTrafficMethod) {
|
||||
// 1 a month
|
||||
case 0:
|
||||
$this->resetByMonthFirstDay($user);
|
||||
$this->resetByMonthFirstDay();
|
||||
break;
|
||||
// expire day
|
||||
case 1:
|
||||
$this->resetByExpireDay($user);
|
||||
$this->resetByExpireDay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function resetByMonthFirstDay($user):void
|
||||
{
|
||||
$user = $this->user;
|
||||
if ((string)date('d') === '01') {
|
||||
$user->update([
|
||||
'u' => 0,
|
||||
@ -63,8 +65,9 @@ class ResetTraffic extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function resetByExpireDay($user):void
|
||||
private function resetByExpireDay():void
|
||||
{
|
||||
$user = $this->user;
|
||||
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||
$users = [];
|
||||
foreach ($user->get() as $item) {
|
||||
|
@ -31,7 +31,7 @@ class Kernel extends ConsoleKernel
|
||||
$schedule->command('check:commission')->everyMinute();
|
||||
// reset
|
||||
$schedule->command('reset:traffic')->daily();
|
||||
$schedule->command('reset:serverLog')->monthly();
|
||||
$schedule->command('reset:serverLog')->quarterly();
|
||||
// send
|
||||
$schedule->command('send:remindMail')->dailyAt('11:30');
|
||||
}
|
||||
|
@ -82,31 +82,47 @@ class ConfigController extends Controller
|
||||
'stripe_webhook_key' => config('v2board.stripe_webhook_key'),
|
||||
'stripe_currency' => config('v2board.stripe_currency', 'hkd'),
|
||||
// bitpayx
|
||||
'bitpayx_name' => config('v2board.bitpayx_name', '聚合支付'),
|
||||
'bitpayx_name' => config('v2board.bitpayx_name', '在线支付'),
|
||||
'bitpayx_enable' => (int)config('v2board.bitpayx_enable', 0),
|
||||
'bitpayx_appsecret' => config('v2board.bitpayx_appsecret'),
|
||||
// paytaro
|
||||
'paytaro_name' => config('v2board.paytaro_name', '聚合支付'),
|
||||
'paytaro_enable' => (int)config('v2board.paytaro_enable', 0),
|
||||
'paytaro_app_id' => config('v2board.paytaro_app_id'),
|
||||
'paytaro_app_secret' => config('v2board.paytaro_app_secret')
|
||||
// mGate
|
||||
'mgate_name' => config('v2board.mgate_name', '在线支付'),
|
||||
'mgate_enable' => (int)config('v2board.mgate_enable', 0),
|
||||
'mgate_url' => config('v2board.mgate_url'),
|
||||
'mgate_app_id' => config('v2board.mgate_app_id'),
|
||||
'mgate_app_secret' => config('v2board.mgate_app_secret'),
|
||||
// Epay
|
||||
'epay_name' => config('v2board.epay_name', '在线支付'),
|
||||
'epay_enable' => (int)config('v2board.epay_enable', 0),
|
||||
'epay_url' => config('v2board.epay_url'),
|
||||
'epay_pid' => config('v2board.epay_pid'),
|
||||
'epay_key' => config('v2board.epay_key'),
|
||||
],
|
||||
'frontend' => [
|
||||
'frontend_theme_sidebar' => config('v2board.frontend_theme_sidebar', 'light'),
|
||||
'frontend_theme_header' => config('v2board.frontend_theme_header', 'dark'),
|
||||
'frontend_theme_color' => config('v2board.frontend_theme_color', 'default'),
|
||||
'frontend_background_url' => config('v2board.frontend_background_url')
|
||||
'frontend_background_url' => config('v2board.frontend_background_url'),
|
||||
'frontend_admin_path' => config('v2board.frontend_admin_path', 'admin')
|
||||
],
|
||||
'server' => [
|
||||
'server_token' => config('v2board.server_token'),
|
||||
'server_license' => config('v2board.server_license'),
|
||||
'server_log_level' => config('v2board.server_log_level', 'none')
|
||||
'server_log_enable' => config('v2board.server_log_enable', 0),
|
||||
'server_v2ray_domain' => config('v2board.server_v2ray_domain'),
|
||||
'server_v2ray_protocol' => config('v2board.server_v2ray_protocol'),
|
||||
],
|
||||
'tutorial' => [
|
||||
'apple_id' => config('v2board.apple_id')
|
||||
],
|
||||
'email' => [
|
||||
'email_template' => config('v2board.email_template', 'default')
|
||||
'email_template' => config('v2board.email_template', 'default'),
|
||||
'email_host' => config('v2board.email_host'),
|
||||
'email_port' => config('v2board.email_port'),
|
||||
'email_username' => config('v2board.email_username'),
|
||||
'email_password' => config('v2board.email_password'),
|
||||
'email_encryption' => config('v2board.email_encryption'),
|
||||
'email_from_address' => config('v2board.email_from_address')
|
||||
],
|
||||
'telegram' => [
|
||||
'telegram_bot_enable' => config('v2board.telegram_bot_enable', 0),
|
||||
@ -121,7 +137,7 @@ class ConfigController extends Controller
|
||||
$data = $request->input();
|
||||
$array = \Config::get('v2board');
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, array_keys(ConfigSave::RULES))) {
|
||||
if (!in_array($k, array_keys($request->validated()))) {
|
||||
abort(500, '参数' . $k . '不在规则内,禁止修改');
|
||||
}
|
||||
$array[$k] = $v;
|
||||
@ -130,10 +146,10 @@ class ConfigController extends Controller
|
||||
if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
|
||||
abort(500, '修改失败');
|
||||
}
|
||||
\Artisan::call('config:cache');
|
||||
if (function_exists('opcache')) {
|
||||
if (function_exists('opcache_reset')) {
|
||||
opcache_reset();
|
||||
}
|
||||
\Artisan::call('config:cache');
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
|
@ -23,12 +23,12 @@ class CouponController extends Controller
|
||||
|
||||
public function save(CouponSave $request)
|
||||
{
|
||||
$params = $request->only(array_keys(CouponSave::RULES));
|
||||
$params = $request->validated();
|
||||
if (isset($params['limit_plan_ids'])) {
|
||||
$params['limit_plan_ids'] = json_encode($params['limit_plan_ids']);
|
||||
}
|
||||
if (!$request->input('id')) {
|
||||
if (!$params['code']) {
|
||||
if (!isset($params['code'])) {
|
||||
$params['code'] = Helper::randomChar(8);
|
||||
}
|
||||
if (!Coupon::create($params)) {
|
||||
|
@ -42,7 +42,7 @@ class PlanController extends Controller
|
||||
|
||||
public function save(PlanSave $request)
|
||||
{
|
||||
$params = $request->only(array_keys(PlanSave::RULES));
|
||||
$params = $request->validated();
|
||||
if ($request->input('id')) {
|
||||
$plan = Plan::find($request->input('id'));
|
||||
if (!$plan) {
|
||||
|
@ -23,7 +23,7 @@ class TrojanController extends Controller
|
||||
$server[$i]['tags'] = json_decode($server[$i]['tags']);
|
||||
}
|
||||
$server[$i]['group_id'] = json_decode($server[$i]['group_id']);
|
||||
$server[$i]['online'] = Cache::get(CacheKey::get('SERVER_TROJAN_ONLINE_USER', $server[$i]['id']));
|
||||
$server[$i]['online'] = Cache::get(CacheKey::get('SERVER_TROJAN_ONLINE_USER', $server[$i]['parent_id'] ? $server[$i]['parent_id'] : $server[$i]['id']));
|
||||
if ($server[$i]['parent_id']) {
|
||||
$server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_TROJAN_LAST_CHECK_AT', $server[$i]['parent_id']));
|
||||
} else {
|
||||
@ -37,7 +37,7 @@ class TrojanController extends Controller
|
||||
|
||||
public function save(ServerTrojanSave $request)
|
||||
{
|
||||
$params = $request->only(array_keys(ServerTrojanSave::RULES));
|
||||
$params = $request->validated();
|
||||
$params['group_id'] = json_encode($params['group_id']);
|
||||
if (isset($params['tags'])) {
|
||||
$params['tags'] = json_encode($params['tags']);
|
||||
|
@ -37,7 +37,7 @@ class V2rayController extends Controller
|
||||
|
||||
public function save(ServerV2raySave $request)
|
||||
{
|
||||
$params = $request->only(array_keys(ServerV2raySave::RULES));
|
||||
$params = $request->validated();
|
||||
$params['group_id'] = json_encode($params['group_id']);
|
||||
if (isset($params['tags'])) {
|
||||
$params['tags'] = json_encode($params['tags']);
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Jobs\SendEmailJob;
|
||||
use App\Services\TicketService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Ticket;
|
||||
@ -63,27 +64,12 @@ class TicketController extends Controller
|
||||
if (empty($request->input('message'))) {
|
||||
abort(500, '消息不能为空');
|
||||
}
|
||||
$ticket = Ticket::where('id', $request->input('id'))
|
||||
->first();
|
||||
if (!$ticket) {
|
||||
abort(500, '工单不存在');
|
||||
}
|
||||
if ($ticket->status) {
|
||||
abort(500, '工单已关闭,无法回复');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
$ticketMessage = TicketMessage::create([
|
||||
'user_id' => $request->session()->get('id'),
|
||||
'ticket_id' => $ticket->id,
|
||||
'message' => $request->input('message')
|
||||
]);
|
||||
$ticket->last_reply_user_id = $request->session()->get('id');
|
||||
if (!$ticketMessage || !$ticket->save()) {
|
||||
DB::rollback();
|
||||
abort(500, '工单回复失败');
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendEmailNotify($ticket, $ticketMessage);
|
||||
$ticketService = new TicketService();
|
||||
$ticketService->replyByAdmin(
|
||||
$request->input('id'),
|
||||
$request->input('message'),
|
||||
$request->session()->get('id')
|
||||
);
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
@ -107,24 +93,4 @@ class TicketController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
// 半小时内不再重复通知
|
||||
private function sendEmailNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
||||
{
|
||||
$user = User::find($ticket->user_id);
|
||||
$cacheKey = 'ticket_sendEmailNotify_' . $ticket->user_id;
|
||||
if (!Cache::get($cacheKey)) {
|
||||
Cache::put($cacheKey, 1, 1800);
|
||||
SendEmailJob::dispatch([
|
||||
'email' => $user->email,
|
||||
'subject' => '您在' . config('v2board.app_name', 'V2Board') . '的工单得到了回复',
|
||||
'template_name' => 'notify',
|
||||
'template_value' => [
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'url' => config('v2board.app_url'),
|
||||
'content' => "主题:{$ticket->subject}\r\n回复内容:{$ticketMessage->message}"
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ class TutorialController extends Controller
|
||||
|
||||
public function save(TutorialSave $request)
|
||||
{
|
||||
$params = $request->only(array_keys(TutorialSave::RULES));
|
||||
$params = $request->validated();
|
||||
|
||||
if (!$request->input('id')) {
|
||||
if (!Tutorial::create($params)) {
|
||||
|
@ -53,7 +53,7 @@ class UserController extends Controller
|
||||
|
||||
public function update(UserUpdate $request)
|
||||
{
|
||||
$params = $request->only(array_keys(UserUpdate::RULES));
|
||||
$params = $request->validated();
|
||||
$user = User::find($request->input('id'));
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
|
@ -49,7 +49,10 @@ class AppController extends Controller
|
||||
public function getVersion()
|
||||
{
|
||||
return response([
|
||||
'data' => '4.0.0'
|
||||
'data' => [
|
||||
'version' => '4.0.0',
|
||||
'download_url' => ''
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Services\ServerService;
|
||||
use App\Utils\Clash;
|
||||
use App\Utils\QuantumultX;
|
||||
use App\Utils\Shadowrocket;
|
||||
use App\Utils\Surge;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Server;
|
||||
@ -41,6 +42,9 @@ class ClientController extends Controller
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'surge') !== false) {
|
||||
die($this->surge($user, $servers['vmess'], $servers['trojan']));
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'shadowrocket') !== false) {
|
||||
die($this->shadowrocket($user, $servers['vmess'], $servers['trojan']));
|
||||
}
|
||||
}
|
||||
die($this->origin($user, $servers['vmess'], $servers['trojan']));
|
||||
}
|
||||
@ -66,9 +70,28 @@ class ClientController extends Controller
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function shadowrocket($user, $vmess = [], $trojan = [])
|
||||
{
|
||||
$uri = '';
|
||||
//display remaining traffic and expire date
|
||||
$upload = round($user->u / (1024*1024*1024), 2);
|
||||
$download = round($user->d / (1024*1024*1024), 2);
|
||||
$totalTraffic = round($user->transfer_enable / (1024*1024*1024), 2);
|
||||
$expiredDate = date('Y-m-d', $user->expired_at);
|
||||
$uri .= "STATUS=🚀↑:{$upload}GB,↓:{$download}GB,TOT:{$totalTraffic}GB💡Expires:{$expiredDate}\r\n";
|
||||
foreach ($vmess as $item) {
|
||||
$uri .= Shadowrocket::buildVmess($user->uuid, $item);
|
||||
}
|
||||
foreach ($trojan as $item) {
|
||||
$uri .= Shadowrocket::buildTrojan($user->uuid, $item);
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function quantumultX($user, $vmess = [], $trojan = [])
|
||||
{
|
||||
$uri = '';
|
||||
header("subscription-userinfo: upload={$user->u}; download={$user->d}; total={$user->transfer_enable}; expire={$user->expired_at}");
|
||||
foreach ($vmess as $item) {
|
||||
$uri .= QuantumultX::buildVmess($user->uuid, $item);
|
||||
}
|
||||
|
@ -3,14 +3,16 @@
|
||||
namespace App\Http\Controllers\Guest;
|
||||
|
||||
use App\Services\OrderService;
|
||||
use App\Services\TelegramService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Order;
|
||||
use Library\Epay;
|
||||
use Omnipay\Omnipay;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Library\BitpayX;
|
||||
use Library\PayTaro;
|
||||
use Library\MGate;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
@ -128,12 +130,22 @@ class OrderController extends Controller
|
||||
]));
|
||||
}
|
||||
|
||||
public function payTaroNotify(Request $request)
|
||||
public function mgateNotify(Request $request)
|
||||
{
|
||||
// Log::info('payTaroNotify: ' . json_encode($request->input()));
|
||||
$mgate = new MGate(config('v2board.mgate_url'), config('v2board.mgate_app_id'), config('v2board.mgate_app_secret'));
|
||||
if (!$mgate->verify($request->input())) {
|
||||
abort(500, 'fail');
|
||||
}
|
||||
if (!$this->handle($request->input('out_trade_no'), $request->input('trade_no'))) {
|
||||
abort(500, 'fail');
|
||||
}
|
||||
die('success');
|
||||
}
|
||||
|
||||
$payTaro = new PayTaro(config('v2board.paytaro_app_id'), config('v2board.paytaro_app_secret'));
|
||||
if (!$payTaro->verify($request->input())) {
|
||||
public function epayNotify(Request $request)
|
||||
{
|
||||
$epay = new Epay(config('v2board.epay_url'), config('v2board.epay_pid'), config('v2board.epay_key'));
|
||||
if (!$epay->verify($request->input())) {
|
||||
abort(500, 'fail');
|
||||
}
|
||||
if (!$this->handle($request->input('out_trade_no'), $request->input('trade_no'))) {
|
||||
@ -149,6 +161,16 @@ class OrderController extends Controller
|
||||
abort(500, 'order is not found');
|
||||
}
|
||||
$orderService = new OrderService($order);
|
||||
return $orderService->success($callbackNo);
|
||||
if (!$orderService->success($callbackNo)) {
|
||||
return false;
|
||||
}
|
||||
$telegramService = new TelegramService();
|
||||
$message = sprintf(
|
||||
"💰成功收款%s元\n———————————————\n订单号:%s",
|
||||
$order->total_amount / 100,
|
||||
$order->trade_no
|
||||
);
|
||||
$telegramService->sendMessageWithAdmin($message);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Utils\Helper;
|
||||
use App\Services\TicketService;
|
||||
|
||||
class TelegramController extends Controller
|
||||
{
|
||||
@ -24,14 +25,13 @@ class TelegramController extends Controller
|
||||
$this->msg = $this->getMessage($request->input());
|
||||
if (!$this->msg) return;
|
||||
try {
|
||||
switch($this->msg->command) {
|
||||
case '/bind': $this->bind();
|
||||
switch($this->msg->message_type) {
|
||||
case 'send':
|
||||
$this->fromSend();
|
||||
break;
|
||||
case '/traffic': $this->traffic();
|
||||
case 'reply':
|
||||
$this->fromReply();
|
||||
break;
|
||||
case '/getlatesturl': $this->getLatestUrl();
|
||||
break;
|
||||
default: $this->help();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$telegramService = new TelegramService();
|
||||
@ -39,6 +39,29 @@ class TelegramController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
private function fromSend()
|
||||
{
|
||||
switch($this->msg->command) {
|
||||
case '/bind': $this->bind();
|
||||
break;
|
||||
case '/traffic': $this->traffic();
|
||||
break;
|
||||
case '/getlatesturl': $this->getLatestUrl();
|
||||
break;
|
||||
case '/unbind': $this->unbind();
|
||||
break;
|
||||
default: $this->help();
|
||||
}
|
||||
}
|
||||
|
||||
private function fromReply()
|
||||
{
|
||||
// ticket
|
||||
if (preg_match("/[#](.*)/", $this->msg->reply_text, $match)) {
|
||||
$this->replayTicket($match[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private function getMessage(array $data)
|
||||
{
|
||||
if (!isset($data['message'])) return false;
|
||||
@ -50,6 +73,11 @@ class TelegramController extends Controller
|
||||
$obj->args = array_slice($text, 1);
|
||||
$obj->chat_id = $data['message']['chat']['id'];
|
||||
$obj->message_id = $data['message']['message_id'];
|
||||
$obj->message_type = !isset($data['message']['reply_to_message']) ? 'send' : 'reply';
|
||||
$obj->text = $data['message']['text'];
|
||||
if ($obj->message_type === 'reply') {
|
||||
$obj->reply_text = $data['message']['reply_to_message']['text'];
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
@ -71,6 +99,9 @@ class TelegramController extends Controller
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
}
|
||||
if ($user->telegram_id) {
|
||||
abort(500, '该账号已经绑定了Telegram账号');
|
||||
}
|
||||
$user->telegram_id = $msg->chat_id;
|
||||
if (!$user->save()) {
|
||||
abort(500, '设置失败');
|
||||
@ -79,6 +110,24 @@ class TelegramController extends Controller
|
||||
$telegramService->sendMessage($msg->chat_id, '绑定成功');
|
||||
}
|
||||
|
||||
private function unbind()
|
||||
{
|
||||
$msg = $this->msg;
|
||||
if (!$msg->is_private) return;
|
||||
$user = User::where('telegram_id', $msg->chat_id)->first();
|
||||
$telegramService = new TelegramService();
|
||||
if (!$user) {
|
||||
$this->help();
|
||||
$telegramService->sendMessage($msg->chat_id, '没有查询到您的用户信息,请先绑定账号', 'markdown');
|
||||
return;
|
||||
}
|
||||
$user->telegram_id = NULL;
|
||||
if (!$user->save()) {
|
||||
abort(500, '解绑失败');
|
||||
}
|
||||
$telegramService->sendMessage($msg->chat_id, '解绑成功', 'markdown');
|
||||
}
|
||||
|
||||
private function help()
|
||||
{
|
||||
$msg = $this->msg;
|
||||
@ -87,7 +136,8 @@ class TelegramController extends Controller
|
||||
$commands = [
|
||||
'/bind 订阅地址 - 绑定你的' . config('v2board.app_name', 'V2Board') . '账号',
|
||||
'/traffic - 查询流量信息',
|
||||
'/getlatesturl - 获取最新的' . config('v2board.app_name', 'V2Board') . '网址'
|
||||
'/getlatesturl - 获取最新的' . config('v2board.app_name', 'V2Board') . '网址',
|
||||
'/unbind - 解除绑定'
|
||||
];
|
||||
$text = implode(PHP_EOL, $commands);
|
||||
$telegramService->sendMessage($msg->chat_id, "你可以使用以下命令进行操作:\n\n$text", 'markdown');
|
||||
@ -124,4 +174,24 @@ class TelegramController extends Controller
|
||||
);
|
||||
$telegramService->sendMessage($msg->chat_id, $text, 'markdown');
|
||||
}
|
||||
|
||||
private function replayTicket($ticketId)
|
||||
{
|
||||
$msg = $this->msg;
|
||||
if (!$msg->is_private) return;
|
||||
$user = User::where('telegram_id', $msg->chat_id)->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
}
|
||||
$ticketService = new TicketService();
|
||||
if ($user->is_admin) {
|
||||
$ticketService->replyByAdmin(
|
||||
$ticketId,
|
||||
$msg->text,
|
||||
$user->id
|
||||
);
|
||||
}
|
||||
$telegramService = new TelegramService();
|
||||
$telegramService->sendMessage($msg->chat_id, "#`{$ticketId}` 的工单已回复成功", 'markdown');
|
||||
}
|
||||
}
|
||||
|
@ -136,17 +136,11 @@ class AuthController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
// 准备废弃
|
||||
public function token2Login(Request $request)
|
||||
{
|
||||
if ($request->input('token')) {
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
return header('Location:' . config('v2board.app_url'));
|
||||
}
|
||||
$code = Helper::guid();
|
||||
$key = 'token2Login_' . $code;
|
||||
Cache::put($key, $user->id, 600);
|
||||
$redirect = '/#/login?verify=' . $code . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
$redirect = '/#/login?verify=' . $request->input('token') . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
if (config('v2board.app_url')) {
|
||||
$location = config('v2board.app_url') . $redirect;
|
||||
} else {
|
||||
@ -156,7 +150,7 @@ class AuthController extends Controller
|
||||
}
|
||||
|
||||
if ($request->input('verify')) {
|
||||
$key = 'token2Login_' . $request->input('verify');
|
||||
$key = CacheKey::get('TEMP_TOKEN', $request->input('verify'));
|
||||
$userId = Cache::get($key);
|
||||
if (!$userId) {
|
||||
abort(500, '令牌有误');
|
||||
@ -180,6 +174,21 @@ class AuthController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function getTempToken(Request $request)
|
||||
{
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
}
|
||||
|
||||
$code = Helper::guid();
|
||||
$key = CacheKey::get('TEMP_TOKEN', $code);
|
||||
Cache::put($key, $user->id, 60);
|
||||
return response([
|
||||
'data' => $code
|
||||
]);
|
||||
}
|
||||
|
||||
public function check(Request $request)
|
||||
{
|
||||
$data = [
|
||||
|
@ -18,7 +18,8 @@ use Omnipay\Omnipay;
|
||||
use Stripe\Stripe;
|
||||
use Stripe\Source;
|
||||
use Library\BitpayX;
|
||||
use Library\PayTaro;
|
||||
use Library\MGate;
|
||||
use Library\Epay;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
@ -96,6 +97,10 @@ class OrderController extends Controller
|
||||
abort(500, '必须存在订阅才可以购买流量重置包');
|
||||
}
|
||||
|
||||
if ($request->input('cycle') === 'reset_price' && $user->expired_at <= time()) {
|
||||
abort(500, '当前订阅已过期,无法购买重置包');
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
$order = new Order();
|
||||
$orderService = new OrderService($order);
|
||||
@ -209,12 +214,12 @@ class OrderController extends Controller
|
||||
'data' => $this->bitpayX($order)
|
||||
]);
|
||||
case 5:
|
||||
if (!(int)config('v2board.paytaro_enable')) {
|
||||
if (!(int)config('v2board.mgate_enable')) {
|
||||
abort(500, '支付方式不可用');
|
||||
}
|
||||
return response([
|
||||
'type' => 1,
|
||||
'data' => $this->payTaro($order)
|
||||
'data' => $this->mgate($order)
|
||||
]);
|
||||
case 6:
|
||||
if (!(int)config('v2board.stripe_card_enable')) {
|
||||
@ -224,6 +229,14 @@ class OrderController extends Controller
|
||||
'type' => 2,
|
||||
'data' => $this->stripeCard($order, $request->input('token'))
|
||||
]);
|
||||
case 7:
|
||||
if (!(int)config('v2board.epay_enable')) {
|
||||
abort(500, '支付方式不可用');
|
||||
}
|
||||
return response([
|
||||
'type' => 1,
|
||||
'data' => $this->epay($order)
|
||||
]);
|
||||
default:
|
||||
abort(500, '支付方式不存在');
|
||||
}
|
||||
@ -278,9 +291,9 @@ class OrderController extends Controller
|
||||
array_push($data, $bitpayX);
|
||||
}
|
||||
|
||||
if ((int)config('v2board.paytaro_enable')) {
|
||||
if ((int)config('v2board.mgate_enable')) {
|
||||
$obj = new \StdClass();
|
||||
$obj->name = config('v2board.paytaro_name', '在线支付');
|
||||
$obj->name = config('v2board.mgate_name', '在线支付');
|
||||
$obj->method = 5;
|
||||
$obj->icon = 'wallet';
|
||||
array_push($data, $obj);
|
||||
@ -294,6 +307,14 @@ class OrderController extends Controller
|
||||
array_push($data, $obj);
|
||||
}
|
||||
|
||||
if ((int)config('v2board.epay_enable')) {
|
||||
$obj = new \StdClass();
|
||||
$obj->name = config('v2board.epay_name', '在线支付');
|
||||
$obj->method = 7;
|
||||
$obj->icon = 'wallet';
|
||||
array_push($data, $obj);
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => $data
|
||||
]);
|
||||
@ -450,16 +471,28 @@ class OrderController extends Controller
|
||||
return isset($result['payment_url']) ? $result['payment_url'] : false;
|
||||
}
|
||||
|
||||
private function payTaro($order)
|
||||
private function mgate($order)
|
||||
{
|
||||
$payTaro = new PayTaro(config('v2board.paytaro_app_id'), config('v2board.paytaro_app_secret'));
|
||||
$result = $payTaro->pay([
|
||||
'app_id' => config('v2board.paytaro_app_id'),
|
||||
$mgate = new MGate(config('v2board.mgate_url'), config('v2board.mgate_app_id'), config('v2board.mgate_app_secret'));
|
||||
$result = $mgate->pay([
|
||||
'app_id' => config('v2board.mgate_app_id'),
|
||||
'out_trade_no' => $order->trade_no,
|
||||
'total_amount' => $order->total_amount,
|
||||
'notify_url' => url('/api/v1/guest/order/payTaroNotify'),
|
||||
'notify_url' => url('/api/v1/guest/order/mgateNotify'),
|
||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'
|
||||
]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function epay($order)
|
||||
{
|
||||
$epay = new Epay(config('v2board.epay_url'), config('v2board.epay_pid'), config('v2board.epay_key'));
|
||||
return $epay->pay([
|
||||
'money' => $order->total_amount / 100,
|
||||
'name' => $order->trade_no,
|
||||
'notify_url' => url('/api/v1/guest/order/epayNotify'),
|
||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/#/order',
|
||||
'out_trade_no' => $order->trade_no
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ use App\Http\Requests\User\TicketSave;
|
||||
use App\Http\Requests\User\TicketWithdraw;
|
||||
use App\Jobs\SendTelegramJob;
|
||||
use App\Models\User;
|
||||
use App\Services\TelegramService;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketMessage;
|
||||
@ -188,13 +189,7 @@ class TicketController extends Controller
|
||||
|
||||
private function sendNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
||||
{
|
||||
if (!config('v2board.telegram_bot_enable', 0)) return;
|
||||
$users = User::where('is_admin', 1)
|
||||
->where('telegram_id', '!=', NULL)
|
||||
->get();
|
||||
foreach ($users as $user) {
|
||||
$text = "📮工单提醒 #{$ticket->id}\n———————————————\n主题:\n`{$ticket->subject}`\n内容:\n`{$ticketMessage->message}`";
|
||||
SendTelegramJob::dispatch($user->telegram_id, $text);
|
||||
}
|
||||
$telegramService = new TelegramService();
|
||||
$telegramService->sendMessageWithAdmin("📮工单提醒 #{$ticket->id}\n———————————————\n主题:\n`{$ticket->subject}`\n内容:\n`{$ticketMessage->message}`");
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
$user['subscribe_url'] = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
$user['reset_day'] = $this->getResetDay($user);
|
||||
return response([
|
||||
'data' => $user
|
||||
]);
|
||||
@ -160,4 +161,24 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
private function getResetDay(User $user)
|
||||
{
|
||||
if ($user->expired_at <= time() || $user->expired_at === NULL) return null;
|
||||
$day = date('d', $user->expired_at);
|
||||
$today = date('d');
|
||||
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||
|
||||
if ((int)config('v2board.reset_traffic_method') === 0) {
|
||||
return $lastDay - $today;
|
||||
}
|
||||
if ((int)config('v2board.reset_traffic_method') === 1) {
|
||||
if ((int)$day >= (int)$today) {
|
||||
return $day - $today;
|
||||
} else {
|
||||
return $lastDay - $today + $day;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -6,75 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ConfigSave extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
// invite & commission
|
||||
'safe_mode_enable' => 'in:0,1',
|
||||
'invite_force' => 'in:0,1',
|
||||
'invite_commission' => 'integer',
|
||||
'invite_gen_limit' => 'integer',
|
||||
'invite_never_expire' => 'in:0,1',
|
||||
'commission_first_time_enable' => 'in:0,1',
|
||||
'commission_auto_check_enable' => 'in:0,1',
|
||||
// site
|
||||
'stop_register' => 'in:0,1',
|
||||
'email_verify' => 'in:0,1',
|
||||
'app_name' => '',
|
||||
'app_description' => '',
|
||||
'app_url' => 'nullable|url',
|
||||
'subscribe_url' => 'nullable|url',
|
||||
'try_out_enable' => 'in:0,1',
|
||||
'try_out_plan_id' => 'integer',
|
||||
'try_out_hour' => 'numeric',
|
||||
'email_whitelist_enable' => 'in:0,1',
|
||||
'email_whitelist_suffix' => '',
|
||||
'email_gmail_limit_enable' => 'in:0,1',
|
||||
// subscribe
|
||||
'plan_change_enable' => 'in:0,1',
|
||||
'reset_traffic_method' => 'in:0,1',
|
||||
'renew_reset_traffic_enable' => 'in:0,1',
|
||||
// server
|
||||
'server_token' => 'nullable|min:16',
|
||||
'server_license' => 'nullable',
|
||||
'server_log_level' => 'nullable|in:debug,info,warning,error,none',
|
||||
// alipay
|
||||
'alipay_enable' => 'in:0,1',
|
||||
'alipay_appid' => 'nullable|integer|min:16',
|
||||
'alipay_pubkey' => 'max:2048',
|
||||
'alipay_privkey' => 'max:2048',
|
||||
// stripe
|
||||
'stripe_alipay_enable' => 'in:0,1',
|
||||
'stripe_wepay_enable' => 'in:0,1',
|
||||
'stripe_card_enable' => 'in:0,1',
|
||||
'stripe_sk_live' => '',
|
||||
'stripe_pk_live' => '',
|
||||
'stripe_webhook_key' => '',
|
||||
'stripe_currency' => 'in:hkd,usd,sgd,eur,gbp',
|
||||
// bitpayx
|
||||
'bitpayx_name' => '',
|
||||
'bitpayx_enable' => 'in:0,1',
|
||||
'bitpayx_appsecret' => '',
|
||||
// paytaro
|
||||
'paytaro_name' => '',
|
||||
'paytaro_enable' => 'in:0,1',
|
||||
'paytaro_app_id' => '',
|
||||
'paytaro_app_secret' => '',
|
||||
// frontend
|
||||
'frontend_theme_sidebar' => 'in:dark,light',
|
||||
'frontend_theme_header' => 'in:dark,light',
|
||||
'frontend_theme_color' => 'in:default,darkblue,black',
|
||||
'frontend_background_url' => 'nullable|url',
|
||||
// tutorial
|
||||
'apple_id' => 'email',
|
||||
'apple_id_password' => '',
|
||||
// email
|
||||
'email_template' => '',
|
||||
// telegram
|
||||
'telegram_bot_enable' => 'in:0,1',
|
||||
'telegram_bot_token' => '',
|
||||
'telegram_discuss_id' => '',
|
||||
'telegram_channel_id' => ''
|
||||
];
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -82,7 +13,90 @@ class ConfigSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
// invite & commission
|
||||
'safe_mode_enable' => 'in:0,1',
|
||||
'invite_force' => 'in:0,1',
|
||||
'invite_commission' => 'integer',
|
||||
'invite_gen_limit' => 'integer',
|
||||
'invite_never_expire' => 'in:0,1',
|
||||
'commission_first_time_enable' => 'in:0,1',
|
||||
'commission_auto_check_enable' => 'in:0,1',
|
||||
// site
|
||||
'stop_register' => 'in:0,1',
|
||||
'email_verify' => 'in:0,1',
|
||||
'app_name' => '',
|
||||
'app_description' => '',
|
||||
'app_url' => 'nullable|url',
|
||||
'subscribe_url' => 'nullable|url',
|
||||
'try_out_enable' => 'in:0,1',
|
||||
'try_out_plan_id' => 'integer',
|
||||
'try_out_hour' => 'numeric',
|
||||
'email_whitelist_enable' => 'in:0,1',
|
||||
'email_whitelist_suffix' => '',
|
||||
'email_gmail_limit_enable' => 'in:0,1',
|
||||
// subscribe
|
||||
'plan_change_enable' => 'in:0,1',
|
||||
'reset_traffic_method' => 'in:0,1',
|
||||
'renew_reset_traffic_enable' => 'in:0,1',
|
||||
// server
|
||||
'server_token' => 'nullable|min:16',
|
||||
'server_license' => 'nullable',
|
||||
'server_log_enable' => 'in:0,1',
|
||||
'server_v2ray_domain' => '',
|
||||
'server_v2ray_protocol' => '',
|
||||
// alipay
|
||||
'alipay_enable' => 'in:0,1',
|
||||
'alipay_appid' => 'nullable|integer|min:16',
|
||||
'alipay_pubkey' => 'max:2048',
|
||||
'alipay_privkey' => 'max:2048',
|
||||
// stripe
|
||||
'stripe_alipay_enable' => 'in:0,1',
|
||||
'stripe_wepay_enable' => 'in:0,1',
|
||||
'stripe_card_enable' => 'in:0,1',
|
||||
'stripe_sk_live' => '',
|
||||
'stripe_pk_live' => '',
|
||||
'stripe_webhook_key' => '',
|
||||
'stripe_currency' => 'in:hkd,usd,sgd,eur,gbp,jpy,cad',
|
||||
// bitpayx
|
||||
'bitpayx_name' => '',
|
||||
'bitpayx_enable' => 'in:0,1',
|
||||
'bitpayx_appsecret' => '',
|
||||
// mGate
|
||||
'mgate_name' => '',
|
||||
'mgate_enable' => 'in:0,1',
|
||||
'mgate_url' => 'nullable|url',
|
||||
'mgate_app_id' => '',
|
||||
'mgate_app_secret' => '',
|
||||
// Epay
|
||||
'epay_name' => '',
|
||||
'epay_enable' => 'in:0,1',
|
||||
'epay_url' => 'nullable|url',
|
||||
'epay_pid' => '',
|
||||
'epay_key' => '',
|
||||
// frontend
|
||||
'frontend_theme_sidebar' => 'in:dark,light',
|
||||
'frontend_theme_header' => 'in:dark,light',
|
||||
'frontend_theme_color' => 'in:default,darkblue,black',
|
||||
'frontend_background_url' => 'nullable|url',
|
||||
'frontend_admin_path' => '',
|
||||
// tutorial
|
||||
'apple_id' => 'email',
|
||||
'apple_id_password' => '',
|
||||
// email
|
||||
'email_template' => '',
|
||||
'email_host' => '',
|
||||
'email_port' => '',
|
||||
'email_username' => '',
|
||||
'email_password' => '',
|
||||
'email_encryption' => '',
|
||||
'email_from_address' => '',
|
||||
// telegram
|
||||
'telegram_bot_enable' => 'in:0,1',
|
||||
'telegram_bot_token' => '',
|
||||
'telegram_discuss_id' => '',
|
||||
'telegram_channel_id' => ''
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,16 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class CouponSave extends FormRequest
|
||||
{
|
||||
const RULES = [
|
||||
'name' => 'required',
|
||||
'type' => 'required|in:1,2',
|
||||
'value' => 'required|integer',
|
||||
'started_at' => 'required|integer',
|
||||
'ended_at' => 'required|integer',
|
||||
'limit_use' => 'nullable|integer',
|
||||
'limit_plan_ids' => 'nullable|array',
|
||||
'code' => ''
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -23,7 +13,16 @@ class CouponSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'name' => 'required',
|
||||
'type' => 'required|in:1,2',
|
||||
'value' => 'required|integer',
|
||||
'started_at' => 'required|integer',
|
||||
'ended_at' => 'required|integer',
|
||||
'limit_use' => 'nullable|integer',
|
||||
'limit_plan_ids' => 'nullable|array',
|
||||
'code' => ''
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,18 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class PlanSave extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
'name' => 'required',
|
||||
'content' => '',
|
||||
'group_id' => 'required',
|
||||
'transfer_enable' => 'required',
|
||||
'month_price' => 'nullable|integer',
|
||||
'quarter_price' => 'nullable|integer',
|
||||
'half_year_price' => 'nullable|integer',
|
||||
'year_price' => 'nullable|integer',
|
||||
'onetime_price' => 'nullable|integer',
|
||||
'reset_price' => 'nullable|integer'
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -25,7 +13,18 @@ class PlanSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'name' => 'required',
|
||||
'content' => '',
|
||||
'group_id' => 'required',
|
||||
'transfer_enable' => 'required',
|
||||
'month_price' => 'nullable|integer',
|
||||
'quarter_price' => 'nullable|integer',
|
||||
'half_year_price' => 'nullable|integer',
|
||||
'year_price' => 'nullable|integer',
|
||||
'onetime_price' => 'nullable|integer',
|
||||
'reset_price' => 'nullable|integer'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,19 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServerTrojanSave extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
'show' => '',
|
||||
'name' => 'required',
|
||||
'group_id' => 'required|array',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'host' => 'required',
|
||||
'port' => 'required',
|
||||
'server_port' => 'required',
|
||||
'allow_insecure' => 'nullable|in:0,1',
|
||||
'server_name' => 'nullable',
|
||||
'tags' => 'nullable|array',
|
||||
'rate' => 'required|numeric'
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -26,7 +13,19 @@ class ServerTrojanSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'show' => '',
|
||||
'name' => 'required',
|
||||
'group_id' => 'required|array',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'host' => 'required',
|
||||
'port' => 'required',
|
||||
'server_port' => 'required',
|
||||
'allow_insecure' => 'nullable|in:0,1',
|
||||
'server_name' => 'nullable',
|
||||
'tags' => 'nullable|array',
|
||||
'rate' => 'required|numeric'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,23 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class ServerV2raySave extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
'show' => '',
|
||||
'name' => 'required',
|
||||
'group_id' => 'required|array',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'host' => 'required',
|
||||
'port' => 'required',
|
||||
'server_port' => 'required',
|
||||
'tls' => 'required',
|
||||
'tags' => 'nullable|array',
|
||||
'rate' => 'required|numeric',
|
||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic',
|
||||
'networkSettings' => '',
|
||||
'ruleSettings' => '',
|
||||
'tlsSettings' => '',
|
||||
'dnsSettings' => ''
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -30,7 +13,23 @@ class ServerV2raySave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'show' => '',
|
||||
'name' => 'required',
|
||||
'group_id' => 'required|array',
|
||||
'parent_id' => 'nullable|integer',
|
||||
'host' => 'required',
|
||||
'port' => 'required',
|
||||
'server_port' => 'required',
|
||||
'tls' => 'required',
|
||||
'tags' => 'nullable|array',
|
||||
'rate' => 'required|numeric',
|
||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic',
|
||||
'networkSettings' => '',
|
||||
'ruleSettings' => '',
|
||||
'tlsSettings' => '',
|
||||
'dnsSettings' => ''
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,12 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class TutorialSave extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
'title' => 'required',
|
||||
// 1:windows 2:macos 3:ios 4:android 5:linux 6:router
|
||||
'category_id' => 'required|in:1,2,3,4,5,6',
|
||||
'steps' => 'required'
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -19,7 +13,12 @@ class TutorialSave extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'title' => 'required',
|
||||
// 1:windows 2:macos 3:ios 4:android 5:linux 6:router
|
||||
'category_id' => 'required|in:1,2,3,4,5,6',
|
||||
'steps' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -6,21 +6,6 @@ use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UserUpdate extends FormRequest
|
||||
{
|
||||
CONST RULES = [
|
||||
'email' => 'required|email',
|
||||
'password' => 'nullable',
|
||||
'transfer_enable' => 'numeric',
|
||||
'expired_at' => 'nullable|integer',
|
||||
'banned' => 'required|in:0,1',
|
||||
'plan_id' => 'nullable|integer',
|
||||
'commission_rate' => 'nullable|integer|min:0|max:100',
|
||||
'discount' => 'nullable|integer|min:0|max:100',
|
||||
'is_admin' => 'required|in:0,1',
|
||||
'u' => 'integer',
|
||||
'd' => 'integer',
|
||||
'balance' => 'integer',
|
||||
'commission_balance' => 'integer'
|
||||
];
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -28,7 +13,21 @@ class UserUpdate extends FormRequest
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return self::RULES;
|
||||
return [
|
||||
'email' => 'required|email',
|
||||
'password' => 'nullable',
|
||||
'transfer_enable' => 'numeric',
|
||||
'expired_at' => 'nullable|integer',
|
||||
'banned' => 'required|in:0,1',
|
||||
'plan_id' => 'nullable|integer',
|
||||
'commission_rate' => 'nullable|integer|min:0|max:100',
|
||||
'discount' => 'nullable|integer|min:0|max:100',
|
||||
'is_admin' => 'required|in:0,1',
|
||||
'u' => 'integer',
|
||||
'd' => 'integer',
|
||||
'balance' => 'integer',
|
||||
'commission_balance' => 'integer'
|
||||
];
|
||||
}
|
||||
|
||||
public function messages()
|
||||
|
@ -16,7 +16,8 @@ class GuestRoute
|
||||
$router->post('/order/alipayNotify', 'Guest\\OrderController@alipayNotify');
|
||||
$router->post('/order/stripeNotify', 'Guest\\OrderController@stripeNotify');
|
||||
$router->post('/order/bitpayXNotify', 'Guest\\OrderController@bitpayXNotify');
|
||||
$router->post('/order/payTaroNotify', 'Guest\\OrderController@payTaroNotify');
|
||||
$router->post('/order/mgateNotify', 'Guest\\OrderController@mgateNotify');
|
||||
$router->post('/order/epayNotify', 'Guset\\OrderController@epayNotify');
|
||||
// Telegram
|
||||
$router->post('/telegram/webhook', 'Guest\\TelegramController@webhook');
|
||||
});
|
||||
|
@ -10,14 +10,13 @@ class PassportRoute
|
||||
$router->group([
|
||||
'prefix' => 'passport'
|
||||
], function ($router) {
|
||||
// TODO: 1.1.1 abolish
|
||||
$router->post('/login', 'Passport\\AuthController@login');
|
||||
// Auth
|
||||
$router->post('/auth/register', 'Passport\\AuthController@register');
|
||||
$router->post('/auth/login', 'Passport\\AuthController@login');
|
||||
$router->get ('/auth/token2Login', 'Passport\\AuthController@token2Login');
|
||||
$router->get ('/auth/check', 'Passport\\AuthController@check');
|
||||
$router->post('/auth/forget', 'Passport\\AuthController@forget');
|
||||
$router->post('/auth/getTempToken', 'Passport\\AuthController@getTempToken');
|
||||
// Comm
|
||||
$router->get ('/comm/config', 'Passport\\CommController@config');
|
||||
$router->post('/comm/sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
|
||||
|
@ -7,6 +7,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Mail;
|
||||
use App\Models\MailLog;
|
||||
|
||||
@ -34,6 +35,15 @@ class SendEmailJob implements ShouldQueue
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
if (config('v2board.email_host')) {
|
||||
Config::set('mail.host', config('v2board.email_host', env('mail.host')));
|
||||
Config::set('mail.port', config('v2board.email_port', env('mail.port')));
|
||||
Config::set('mail.encryption', config('v2board.email_encryption', env('mail.encryption')));
|
||||
Config::set('mail.username', config('v2board.email_username', env('mail.username')));
|
||||
Config::set('mail.password', config('v2board.email_password', env('mail.password')));
|
||||
Config::set('mail.from.address', config('v2board.email_from_address', env('mail.from.address')));
|
||||
Config::set('mail.from.name', config('v2board.app_name', 'V2Board'));
|
||||
}
|
||||
$params = $this->params;
|
||||
$email = $params['email'];
|
||||
$subject = $params['subject'];
|
||||
|
@ -46,7 +46,7 @@ class OrderService
|
||||
$order = $this->order;
|
||||
if ($order->cycle === 'reset_price') {
|
||||
$order->type = 4;
|
||||
} else if ($user->plan_id !== NULL && $order->plan_id !== $user->plan_id) {
|
||||
} else if ($user->plan_id !== NULL && $order->plan_id !== $user->plan_id && $user->expired_at > time()) { // 用户订阅存在且用户订阅与购买订阅不同且用户订阅未过期 === 更换
|
||||
if (!(int)config('v2board.plan_change_enable', 1)) abort(500, '目前不允许更改订阅,请联系客服或提交工单操作');
|
||||
$order->type = 3;
|
||||
$this->getSurplusValue($user, $order);
|
||||
@ -56,9 +56,9 @@ class OrderService
|
||||
} else {
|
||||
$order->total_amount = $order->total_amount - $order->surplus_amount;
|
||||
}
|
||||
} else if ($user->expired_at > time() && $order->plan_id == $user->plan_id) {
|
||||
} else if ($user->expired_at > time() && $order->plan_id == $user->plan_id) { // 用户订阅未过期且购买订阅与当前订阅相同 === 续费
|
||||
$order->type = 2;
|
||||
} else {
|
||||
} else { // 新购
|
||||
$order->type = 1;
|
||||
}
|
||||
}
|
||||
|
@ -171,27 +171,42 @@ class ServerService
|
||||
|
||||
private function setRule(Server $server, object $json)
|
||||
{
|
||||
$domainRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_domain')));
|
||||
$protocolRules = array_filter(explode(PHP_EOL, config('v2board.server_v2ray_protocol')));
|
||||
if ($server->ruleSettings) {
|
||||
$rules = json_decode($server->ruleSettings);
|
||||
$ruleSettings = json_decode($server->ruleSettings);
|
||||
// domain
|
||||
if (isset($rules->domain) && !empty($rules->domain)) {
|
||||
$rules->domain = array_filter($rules->domain);
|
||||
$domainObj = new \StdClass();
|
||||
$domainObj->type = 'field';
|
||||
$domainObj->domain = $rules->domain;
|
||||
$domainObj->outboundTag = 'block';
|
||||
array_push($json->routing->rules, $domainObj);
|
||||
if (isset($ruleSettings->domain)) {
|
||||
$ruleSettings->domain = array_filter($ruleSettings->domain);
|
||||
if (!empty($ruleSettings->domain)) {
|
||||
$domainRules = array_merge($domainRules, $ruleSettings->domain);
|
||||
}
|
||||
}
|
||||
// protocol
|
||||
if (isset($rules->protocol) && !empty($rules->protocol)) {
|
||||
$rules->protocol = array_filter($rules->protocol);
|
||||
$protocolObj = new \StdClass();
|
||||
$protocolObj->type = 'field';
|
||||
$protocolObj->protocol = $rules->protocol;
|
||||
$protocolObj->outboundTag = 'block';
|
||||
array_push($json->routing->rules, $protocolObj);
|
||||
if (isset($ruleSettings->protocol)) {
|
||||
$ruleSettings->protocol = array_filter($ruleSettings->protocol);
|
||||
if (!empty($ruleSettings->protocol)) {
|
||||
$protocolRules = array_merge($protocolRules, $ruleSettings->protocol);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($domainRules)) {
|
||||
$domainObj = new \StdClass();
|
||||
$domainObj->type = 'field';
|
||||
$domainObj->domain = $domainRules;
|
||||
$domainObj->outboundTag = 'block';
|
||||
array_push($json->routing->rules, $domainObj);
|
||||
}
|
||||
if (!empty($protocolRules)) {
|
||||
$protocolObj = new \StdClass();
|
||||
$protocolObj->type = 'field';
|
||||
$protocolObj->protocol = $protocolRules;
|
||||
$protocolObj->outboundTag = 'block';
|
||||
array_push($json->routing->rules, $protocolObj);
|
||||
}
|
||||
if (empty($domainRules) && empty($protocolRules)) {
|
||||
$json->inbound->sniffing->enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
private function setTls(Server $server, object $json)
|
||||
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\Jobs\SendTelegramJob;
|
||||
use App\Models\User;
|
||||
use \Curl\Curl;
|
||||
|
||||
class TelegramService {
|
||||
@ -43,4 +45,15 @@ class TelegramService {
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function sendMessageWithAdmin($message)
|
||||
{
|
||||
if (!config('v2board.telegram_bot_enable', 0)) return;
|
||||
$users = User::where('is_admin', 1)
|
||||
->where('telegram_id', '!=', NULL)
|
||||
->get();
|
||||
foreach ($users as $user) {
|
||||
SendTelegramJob::dispatch($user->telegram_id, $message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
57
app/Services/TicketService.php
Normal file
57
app/Services/TicketService.php
Normal file
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Jobs\SendEmailJob;
|
||||
use App\Models\Ticket;
|
||||
use App\Models\TicketMessage;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TicketService {
|
||||
public function replyByAdmin($ticketId, $message, $userId):void
|
||||
{
|
||||
$ticket = Ticket::where('id', $ticketId)
|
||||
->first();
|
||||
if (!$ticket) {
|
||||
abort(500, '工单不存在');
|
||||
}
|
||||
if ($ticket->status) {
|
||||
abort(500, '工单已关闭,无法回复');
|
||||
}
|
||||
DB::beginTransaction();
|
||||
$ticketMessage = TicketMessage::create([
|
||||
'user_id' => $userId,
|
||||
'ticket_id' => $ticket->id,
|
||||
'message' => $message
|
||||
]);
|
||||
$ticket->last_reply_user_id = $userId;
|
||||
if (!$ticketMessage || !$ticket->save()) {
|
||||
DB::rollback();
|
||||
abort(500, '工单回复失败');
|
||||
}
|
||||
DB::commit();
|
||||
$this->sendEmailNotify($ticket, $ticketMessage);
|
||||
}
|
||||
|
||||
// 半小时内不再重复通知
|
||||
private function sendEmailNotify(Ticket $ticket, TicketMessage $ticketMessage)
|
||||
{
|
||||
$user = User::find($ticket->user_id);
|
||||
$cacheKey = 'ticket_sendEmailNotify_' . $ticket->user_id;
|
||||
if (!Cache::get($cacheKey)) {
|
||||
Cache::put($cacheKey, 1, 1800);
|
||||
SendEmailJob::dispatch([
|
||||
'email' => $user->email,
|
||||
'subject' => '您在' . config('v2board.app_name', 'V2Board') . '的工单得到了回复',
|
||||
'template_name' => 'notify',
|
||||
'template_value' => [
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'url' => config('v2board.app_url'),
|
||||
'content' => "主题:{$ticket->subject}\r\n回复内容:{$ticketMessage->message}"
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
@ -10,7 +10,8 @@ class CacheKey
|
||||
'SERVER_V2RAY_ONLINE_USER' => '节点在线用户',
|
||||
'SERVER_V2RAY_LAST_CHECK_AT' => '节点最后检查时间',
|
||||
'SERVER_TROJAN_ONLINE_USER' => 'trojan节点在线用户',
|
||||
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间'
|
||||
'SERVER_TROJAN_LAST_CHECK_AT' => 'trojan节点最后检查时间',
|
||||
'TEMP_TOKEN' => '临时令牌'
|
||||
];
|
||||
|
||||
public static function get(string $key, $uniqueValue)
|
||||
|
@ -15,10 +15,12 @@ class Clash
|
||||
$array['uuid'] = $uuid;
|
||||
$array['alterId'] = 2;
|
||||
$array['cipher'] = 'auto';
|
||||
$array['udp'] = true;
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
$array['tls'] = true;
|
||||
if (isset($tlsSettings->allowInsecure)) $array['skip-cert-verify'] = ($tlsSettings->allowInsecure ? true : false );
|
||||
if (isset($tlsSettings->serverName)) $array['servername'] = $tlsSettings->serverName;
|
||||
}
|
||||
if ($server->network == 'ws') {
|
||||
$array['network'] = $server->network;
|
||||
@ -41,6 +43,7 @@ class Clash
|
||||
$array['server'] = $server->host;
|
||||
$array['port'] = $server->port;
|
||||
$array['password'] = $password;
|
||||
$array['udp'] = true;
|
||||
$array['sni'] = $server->server_name;
|
||||
if ($server->allow_insecure) {
|
||||
$array['skip-cert-verify'] = true;
|
||||
|
3
app/Utils/Helper.php
Executable file → Normal file
3
app/Utils/Helper.php
Executable file → Normal file
@ -62,7 +62,8 @@ class Helper
|
||||
$server->name = rawurlencode($server->name);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name
|
||||
'peer' => $server->server_name,
|
||||
'sni' => $server->server_name
|
||||
]);
|
||||
$uri = "trojan://{$user->uuid}@{$server->host}:{$server->port}?{$query}#{$server->name}";
|
||||
$uri .= "\r\n";
|
||||
|
@ -7,26 +7,44 @@ class QuantumultX
|
||||
{
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$uri = "vmess=" . $server->host . ":" . $server->port . ", method=none, password=" . $uuid . ", fast-open=false, udp-relay=false, tag=" . $server->name;
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
if ($server->network === 'tcp') $uri .= ', obfs=over-tls';
|
||||
if (isset($tlsSettings->allowInsecure)) {
|
||||
// Default: tls-verification=true
|
||||
$uri .= ', tls-verification=' . ($tlsSettings->allowInsecure ? "false" : "true");
|
||||
}
|
||||
if (isset($tlsSettings->serverName)) {
|
||||
$uri .= ', obfs-host=' . $tlsSettings->serverName;
|
||||
$config = [
|
||||
"vmess={$server->host}:{$server->port}",
|
||||
"method=chacha20-poly1305",
|
||||
"password={$uuid}",
|
||||
"tag={$server->name}"
|
||||
];
|
||||
if ($server->network === 'tcp') {
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, 'obfs=over-tls');
|
||||
if (isset($tlsSettings->allowInsecure)) {
|
||||
// Tips: allowInsecure=false = tls-verification=true
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true');
|
||||
}
|
||||
if (isset($tlsSettings->serverName)) {
|
||||
array_push($config, "obfs-host={$tlsSettings->serverName}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($server->network === 'ws') {
|
||||
$uri .= ', obfs=' . ($server->tls ? 'wss' : 'ws');
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
array_push($config, 'obfs=wss');
|
||||
if (isset($tlsSettings->allowInsecure)) {
|
||||
array_push($config, $tlsSettings->allowInsecure ? 'tls-verification=false' : 'tls-verification=true');
|
||||
}
|
||||
} else {
|
||||
array_push($config, 'obfs=ws');
|
||||
}
|
||||
if ($server->networkSettings) {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
if (isset($wsSettings->path)) $uri .= ', obfs-uri=' . $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $uri .= ', obfs-host=' . $wsSettings->headers->Host;
|
||||
if (isset($wsSettings->path)) array_push($config, "obfs-uri={$wsSettings->path}");
|
||||
if (isset($wsSettings->headers->Host)) array_push($config, "obfs-host={$wsSettings->headers->Host}");
|
||||
}
|
||||
}
|
||||
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
@ -38,13 +56,14 @@ class QuantumultX
|
||||
"password={$password}",
|
||||
"over-tls=true",
|
||||
$server->server_name ? "tls-host={$server->server_name}" : "",
|
||||
$server->allow_insecure ? 'tls-verification=true' : 'tls-verification=false',
|
||||
// Tips: allowInsecure=false = tls-verification=true
|
||||
$server->allow_insecure ? 'tls-verification=false' : 'tls-verification=true',
|
||||
"fast-open=false",
|
||||
"udp-relay=false",
|
||||
"tag={$server->name}"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode($config, ',');
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
43
app/Utils/Shadowrocket.php
Normal file
43
app/Utils/Shadowrocket.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
|
||||
class Shadowrocket
|
||||
{
|
||||
public static function buildVmess($uuid, $server)
|
||||
{
|
||||
$userinfo = base64_encode('auto:' . $uuid . '@' . $server->host . ':' . $server->port);
|
||||
$config = [
|
||||
'remark' => $server->name
|
||||
];
|
||||
if ($server->tls) {
|
||||
$tlsSettings = json_decode($server->tlsSettings);
|
||||
$config['tls'] = 1;
|
||||
if (isset($tlsSettings->serverName)) $config['peer'] = $tlsSettings->serverName;
|
||||
if (isset($tlsSettings->allowInsecure)) $config['allowInsecure'] = 1;
|
||||
}
|
||||
if ($server->network === 'ws') {
|
||||
$wsSettings = json_decode($server->networkSettings);
|
||||
$config['obfs'] = "websocket";
|
||||
if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $config['obfsParam'] = $wsSettings->headers->Host;
|
||||
}
|
||||
$query = http_build_query($config, null, '&', PHP_QUERY_RFC3986);
|
||||
$uri = "vmess://{$userinfo}?{$query}&tfo=1";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
||||
public static function buildTrojan($password, $server)
|
||||
{
|
||||
$server->name = rawurlencode($server->name);
|
||||
$query = http_build_query([
|
||||
'allowInsecure' => $server->allow_insecure,
|
||||
'peer' => $server->server_name
|
||||
]);
|
||||
$uri = "trojan://{$password}@{$server->host}:{$server->port}?{$query}&tfo=1#{$server->name}";
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
}
|
@ -39,7 +39,7 @@ class Surge
|
||||
"tfo=true"
|
||||
];
|
||||
$config = array_filter($config);
|
||||
$uri = implode($config, ',');
|
||||
$uri = implode(',', $config);
|
||||
$uri .= "\r\n";
|
||||
return $uri;
|
||||
}
|
||||
|
@ -236,5 +236,5 @@ return [
|
||||
| The only modification by laravel config
|
||||
|
|
||||
*/
|
||||
'version' => '1.3.1-r.2'
|
||||
'version' => '1.3.2-d.1'
|
||||
];
|
||||
|
@ -296,3 +296,7 @@ CHANGE `show` `show` tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否显示' AFTE
|
||||
|
||||
ALTER TABLE `v2_server_trojan`
|
||||
ADD `server_name` varchar(255) NULL AFTER `allow_insecure`;
|
||||
|
||||
UPDATE `v2_server` SET
|
||||
`ruleSettings` = NULL
|
||||
WHERE `ruleSettings` = '{}';
|
||||
|
42
library/Epay.php
Normal file
42
library/Epay.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Library;
|
||||
|
||||
class Epay
|
||||
{
|
||||
private $pid;
|
||||
private $key;
|
||||
private $url;
|
||||
|
||||
public function __construct($url, $pid, $key)
|
||||
{
|
||||
$this->pid = $pid;
|
||||
$this->key = $key;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function pay($params)
|
||||
{
|
||||
$params['pid'] = $this->pid;
|
||||
ksort($params);
|
||||
reset($params);
|
||||
$str = stripslashes(urldecode(http_build_query($params))) . $this->key;
|
||||
$params['sign'] = md5($str);
|
||||
$params['sign_type'] = 'MD5';
|
||||
return $this->url . '/submit.php?' . http_build_query($params);
|
||||
}
|
||||
|
||||
public function verify($params)
|
||||
{
|
||||
$sign = $params['sign'];
|
||||
unset($params['sign']);
|
||||
unset($params['sign_type']);
|
||||
ksort($params);
|
||||
reset($params);
|
||||
$str = stripslashes(urldecode(http_build_query($params))) . $this->key;
|
||||
if ($sign !== md5($str)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
@ -4,15 +4,17 @@ namespace Library;
|
||||
|
||||
use \Curl\Curl;
|
||||
|
||||
class PayTaro
|
||||
class MGate
|
||||
{
|
||||
private $appId;
|
||||
private $appSecret;
|
||||
private $url;
|
||||
|
||||
public function __construct($appId, $appSecret)
|
||||
public function __construct($url, $appId, $appSecret)
|
||||
{
|
||||
$this->appId = $appId;
|
||||
$this->appSecret = $appSecret;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function pay($params)
|
||||
@ -21,14 +23,20 @@ class PayTaro
|
||||
$str = http_build_query($params) . $this->appSecret;
|
||||
$params['sign'] = md5($str);
|
||||
$curl = new Curl();
|
||||
$curl->post('https://api.paytaro.com/v1/gateway/fetch', http_build_query($params));
|
||||
$curl->post($this->url . '/v1/gateway/fetch', http_build_query($params));
|
||||
$result = $curl->response;
|
||||
if (!$result) {
|
||||
abort(500, '网络异常');
|
||||
}
|
||||
if ($curl->error) {
|
||||
$errors = (array)$result->errors;
|
||||
abort(500, $errors[array_keys($errors)[0]][0]);
|
||||
if (isset($result->errors)) {
|
||||
$errors = (array)$result->errors;
|
||||
abort(500, $errors[array_keys($errors)[0]][0]);
|
||||
}
|
||||
if (isset($result->message)) {
|
||||
abort(500, $result->message);
|
||||
}
|
||||
abort(500, '未知错误');
|
||||
}
|
||||
$curl->close();
|
||||
if (!isset($result->data->trade_no)) {
|
2
public/assets/admin/umi.css
vendored
2
public/assets/admin/umi.css
vendored
File diff suppressed because one or more lines are too long
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
2
public/assets/user/umi.css
vendored
2
public/assets/user/umi.css
vendored
File diff suppressed because one or more lines are too long
2
public/assets/user/umi.js
vendored
2
public/assets/user/umi.js
vendored
File diff suppressed because one or more lines are too long
@ -10,7 +10,7 @@
|
||||
|
||||
## Demo
|
||||
|
||||
[Demo](https://v2board.com) site provided by 👉[Moack](https://www.moack.co.kr/dedicated.php)👈
|
||||
[Demo](https://v2board.com)
|
||||
|
||||
## Document
|
||||
[Click](https://docs.v2board.com)
|
||||
@ -19,4 +19,4 @@
|
||||
ETH&(USDT-ERC20): 0x84F85A89105B93F74c3b5db6410Ee8630F01063f
|
||||
|
||||
## Other
|
||||
Telegram Channel: [@v2board](https://t.me/v2board)
|
||||
Telegram Channel: [@v2board](https://t.me/v2board)
|
||||
|
@ -30,7 +30,7 @@ Route::get('/', function (Request $request) {
|
||||
]);
|
||||
});
|
||||
|
||||
Route::get('/admin', function () {
|
||||
Route::get('/' . config('v2board.frontend_admin_path', 'admin'), function () {
|
||||
return view('admin', [
|
||||
'title' => config('v2board.app_name', 'V2Board'),
|
||||
'theme_sidebar' => config('v2board.frontend_theme_sidebar', 'light'),
|
||||
|
Loading…
Reference in New Issue
Block a user