mirror of
https://github.com/v2board/v2board.git
synced 2025-01-31 02:29:14 +08:00
update
This commit is contained in:
parent
51cf3b1b76
commit
0b62ae8591
@ -19,31 +19,31 @@ class ConfigController extends Controller
|
||||
return response([
|
||||
'data' => [
|
||||
'invite' => [
|
||||
'invite_force' => (int)config('v2panel.invite_force', env('DEFAULT_INVITE_FORCE')),
|
||||
'invite_commission' => config('v2panel.invite_commission', env('DEFAULT_INVITE_COMMISSION')),
|
||||
'invite_gen_limit' => config('v2panel.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT'))
|
||||
'invite_force' => (int)config('v2board.invite_force', env('DEFAULT_INVITE_FORCE')),
|
||||
'invite_commission' => config('v2board.invite_commission', env('DEFAULT_INVITE_COMMISSION')),
|
||||
'invite_gen_limit' => config('v2board.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT'))
|
||||
],
|
||||
'site' => [
|
||||
'stop_register' => (int)config('v2panel.stop_register', env('DEFAULT_STOP_REGISTER')),
|
||||
'email_verify' => (int)config('v2panel.email_verify', env('DEFAULT_EMAIL_VERIFY')),
|
||||
'app_name' => config('v2panel.app_name', env('APP_NAME')),
|
||||
'app_url' => config('v2panel.app_url', env('APP_URL'))
|
||||
'stop_register' => (int)config('v2board.stop_register', env('DEFAULT_STOP_REGISTER')),
|
||||
'email_verify' => (int)config('v2board.email_verify', env('DEFAULT_EMAIL_VERIFY')),
|
||||
'app_name' => config('v2board.app_name', env('APP_NAME')),
|
||||
'app_url' => config('v2board.app_url', env('APP_URL'))
|
||||
],
|
||||
'pay' => [
|
||||
// alipay
|
||||
'alipay_enable' => (int)config('v2panel.alipay_enable'),
|
||||
'alipay_appid' => config('v2panel.alipay_appid'),
|
||||
'alipay_pubkey' => config('v2panel.alipay_pubkey'),
|
||||
'alipay_privkey' => config('v2panel.alipay_privkey'),
|
||||
'alipay_enable' => (int)config('v2board.alipay_enable'),
|
||||
'alipay_appid' => config('v2board.alipay_appid'),
|
||||
'alipay_pubkey' => config('v2board.alipay_pubkey'),
|
||||
'alipay_privkey' => config('v2board.alipay_privkey'),
|
||||
// stripe
|
||||
'stripe_sk_live' => config('v2panel.stripe_sk_live'),
|
||||
'stripe_pk_live' => config('v2panel.stripe_pk_live'),
|
||||
'stripe_alipay_enable' => (int)config('v2panel.stripe_alipay_enable'),
|
||||
'stripe_wepay_enable' => (int)config('v2panel.stripe_wepay_enable'),
|
||||
'stripe_webhook_key' => config('v2panel.stripe_webhook_key')
|
||||
'stripe_sk_live' => config('v2board.stripe_sk_live'),
|
||||
'stripe_pk_live' => config('v2board.stripe_pk_live'),
|
||||
'stripe_alipay_enable' => (int)config('v2board.stripe_alipay_enable'),
|
||||
'stripe_wepay_enable' => (int)config('v2board.stripe_wepay_enable'),
|
||||
'stripe_webhook_key' => config('v2board.stripe_webhook_key')
|
||||
],
|
||||
'server' => [
|
||||
'server_token' => config('v2panel.server_token')
|
||||
'server_token' => config('v2board.server_token')
|
||||
]
|
||||
]
|
||||
]);
|
||||
@ -51,7 +51,7 @@ class ConfigController extends Controller
|
||||
|
||||
public function save (ConfigSave $request) {
|
||||
$data = $request->input();
|
||||
$array = \Config::get('v2panel');
|
||||
$array = \Config::get('v2board');
|
||||
foreach ($data as $k => $v) {
|
||||
if (!in_array($k, ConfigSave::filter())) {
|
||||
abort(500, '禁止修改');
|
||||
@ -59,7 +59,7 @@ class ConfigController extends Controller
|
||||
$array[$k] = $v;
|
||||
}
|
||||
$data = var_export($array, 1);
|
||||
if(!\File::put(base_path() . '/config/v2panel.php', "<?php\n return $data ;")) {
|
||||
if(!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
|
||||
abort(500, '修改失败');
|
||||
}
|
||||
\Artisan::call('config:cache');
|
||||
|
@ -28,6 +28,9 @@ class ClientController extends Controller
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) {
|
||||
die($this->quantumult($user, $server));
|
||||
}
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'clash_win') !== false) {
|
||||
die($this->clash($user, $server));
|
||||
}
|
||||
die($this->origin($user, $server));
|
||||
}
|
||||
|
||||
@ -43,7 +46,7 @@ class ClientController extends Controller
|
||||
$uri = '';
|
||||
header('subscription-userinfo: upload='.$user->u.'; download='.$user->d.';total='.$user->transfer_enable);
|
||||
foreach($server as $item) {
|
||||
$uri .= "vmess://".base64_encode($item->name.'= vmess, '.$item->host.', '.$item->port.', chacha20-ietf-poly1305, "'.$user->v2ray_uuid.'", over-tls='.($item->tls?"true":"false").', certificate=0, group='.config('v2panel.app_name', 'V2Board'))."\r\n";
|
||||
$uri .= "vmess://".base64_encode($item->name.'= vmess, '.$item->host.', '.$item->port.', chacha20-ietf-poly1305, "'.$user->v2ray_uuid.'", over-tls='.($item->tls?"true":"false").', certificate=0, group='.config('v2board.app_name', 'V2Board'))."\r\n";
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
@ -66,4 +69,50 @@ class ClientController extends Controller
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function clash ($user, $server) {
|
||||
$proxy = [];
|
||||
$proxyGroup = [];
|
||||
$proxies = [];
|
||||
$config = [
|
||||
'port' => 7890,
|
||||
'socks-port' => 0,
|
||||
'allow-lan' => false,
|
||||
'mode' => 'Rule',
|
||||
'log-level' => 'info',
|
||||
'external-controller' => '0.0.0.0:9090',
|
||||
'secret' => '',
|
||||
'Proxy' => $proxy,
|
||||
'Proxy Group' => $proxyGroup,
|
||||
'Rule' => [
|
||||
'DOMAIN-SUFFIX,google.com,'.config('v2board.app_name', 'V2Board'),
|
||||
'DOMAIN-KEYWORD,google,'.config('v2board.app_name', 'V2Board'),
|
||||
'DOMAIN,google.com,'.config('v2board.app_name', 'V2Board'),
|
||||
'DOMAIN-SUFFIX,ad.com,REJECT',
|
||||
'IP-CIDR,127.0.0.0/8,DIRECT',
|
||||
'GEOIP,CN,DIRECT',
|
||||
'MATCH,'.config('v2board.app_name', 'V2Board')
|
||||
]
|
||||
];
|
||||
foreach ($server as $item) {
|
||||
$obj = new \StdClass();
|
||||
$obj->name = $item->name;
|
||||
$obj->type = 'vmess';
|
||||
$obj->server = $item->host;
|
||||
$obj->port = $item->port;
|
||||
$obj->uuid = $user->v2ray_uuid;
|
||||
$obj->alterId = $user->v2ray_alter_id;
|
||||
$obj->cipher = 'auto';
|
||||
if ($item->tls) {
|
||||
$obj->tls = true;
|
||||
}
|
||||
array_push($proxy, $obj);
|
||||
array_push($proxies, $item->name);
|
||||
}
|
||||
array_push($proxyGroup, [
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'type' => 'select',
|
||||
'proxies' => $proxies
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ class OrderController extends Controller
|
||||
public function stripeNotify (Request $request) {
|
||||
Log::info('stripeNotifyData: ' . json_encode($request->input()));
|
||||
|
||||
\Stripe\Stripe::setApiKey(config('v2panel.stripe_sk_live'));
|
||||
\Stripe\Stripe::setApiKey(config('v2board.stripe_sk_live'));
|
||||
try {
|
||||
$event = \Stripe\Webhook::constructEvent(
|
||||
file_get_contents('php://input'),
|
||||
$_SERVER['HTTP_STRIPE_SIGNATURE'],
|
||||
config('v2panel.stripe_webhook_key')
|
||||
config('v2board.stripe_webhook_key')
|
||||
);
|
||||
} catch (\Stripe\Error\SignatureVerification $e) {
|
||||
abort(400);
|
||||
|
@ -28,7 +28,7 @@ class InviteController extends Controller
|
||||
->where('status', 0)
|
||||
->get();
|
||||
for ($i = 0; $i < count($codes); $i++) {
|
||||
$codes[$i]['invite_url'] = config('v2panel.app_url', env('APP_URL')) . '/#/register?code=' . $codes[$i]['code'];
|
||||
$codes[$i]['invite_url'] = config('v2board.app_url', env('APP_URL')) . '/#/register?code=' . $codes[$i]['code'];
|
||||
}
|
||||
$stat = [
|
||||
//已注册用户数
|
||||
|
@ -67,7 +67,7 @@ class OrderController extends Controller
|
||||
$order->total_amount = $plan[$request->input('cycle')];
|
||||
if ($user->invite_user_id) {
|
||||
$order->invite_user_id = $user->invite_user_id;
|
||||
$order->commission_balance = $order->total_amount * (config('v2panel.invite_commission', env('DEFAULT_INVITE_COMMISSION')) / 100);
|
||||
$order->commission_balance = $order->total_amount * (config('v2board.invite_commission', env('DEFAULT_INVITE_COMMISSION')) / 100);
|
||||
}
|
||||
if (!$order->save()) {
|
||||
abort(500, '订单创建失败');
|
||||
@ -92,7 +92,7 @@ class OrderController extends Controller
|
||||
// return type => 0: QRCode / 1: URL
|
||||
case 0:
|
||||
// alipayF2F
|
||||
if (!(int)config('v2panel.alipay_enable')) {
|
||||
if (!(int)config('v2board.alipay_enable')) {
|
||||
abort(500, '支付方式不可用');
|
||||
}
|
||||
return response([
|
||||
@ -101,7 +101,7 @@ class OrderController extends Controller
|
||||
]);
|
||||
case 2:
|
||||
// stripeAlipay
|
||||
if (!(int)config('v2panel.stripe_alipay_enable')) {
|
||||
if (!(int)config('v2board.stripe_alipay_enable')) {
|
||||
abort(500, '支付方式不可用');
|
||||
}
|
||||
return response([
|
||||
@ -110,7 +110,7 @@ class OrderController extends Controller
|
||||
]);
|
||||
case 3:
|
||||
// stripeWepay
|
||||
if (!(int)config('v2panel.stripe_wepay_enable')) {
|
||||
if (!(int)config('v2board.stripe_wepay_enable')) {
|
||||
abort(500, '支付方式不可用');
|
||||
}
|
||||
return response([
|
||||
@ -137,7 +137,7 @@ class OrderController extends Controller
|
||||
|
||||
public function getPaymentMethod () {
|
||||
$data = [];
|
||||
if ((int)config('v2panel.alipay_enable')) {
|
||||
if ((int)config('v2board.alipay_enable')) {
|
||||
$alipayF2F = new \StdClass();
|
||||
$alipayF2F->name = '支付宝';
|
||||
$alipayF2F->method = 0;
|
||||
@ -145,7 +145,7 @@ class OrderController extends Controller
|
||||
array_push($data, $alipayF2F);
|
||||
}
|
||||
|
||||
if ((int)config('v2panel.stripe_alipay_enable')) {
|
||||
if ((int)config('v2board.stripe_alipay_enable')) {
|
||||
$stripeAlipay = new \StdClass();
|
||||
$stripeAlipay->name = '支付宝';
|
||||
$stripeAlipay->method = 2;
|
||||
@ -153,7 +153,7 @@ class OrderController extends Controller
|
||||
array_push($data, $stripeAlipay);
|
||||
}
|
||||
|
||||
if ((int)config('v2panel.stripe_wepay_enable')) {
|
||||
if ((int)config('v2board.stripe_wepay_enable')) {
|
||||
$stripeWepay = new \StdClass();
|
||||
$stripeWepay->name = '微信';
|
||||
$stripeWepay->method = 3;
|
||||
@ -169,13 +169,13 @@ class OrderController extends Controller
|
||||
private function alipayF2F ($tradeNo, $totalAmount) {
|
||||
$gateway = Omnipay::create('Alipay_AopF2F');
|
||||
$gateway->setSignType('RSA2'); //RSA/RSA2
|
||||
$gateway->setAppId(config('v2panel.alipay_appid'));
|
||||
$gateway->setPrivateKey(config('v2panel.alipay_privkey')); // 可以是路径,也可以是密钥内容
|
||||
$gateway->setAlipayPublicKey(config('v2panel.alipay_pubkey')); // 可以是路径,也可以是密钥内容
|
||||
$gateway->setNotifyUrl(config('v2panel.app_url', env('APP_URL')) . '/api/v1/guest/order/alipayNotify');
|
||||
$gateway->setAppId(config('v2board.alipay_appid'));
|
||||
$gateway->setPrivateKey(config('v2board.alipay_privkey')); // 可以是路径,也可以是密钥内容
|
||||
$gateway->setAlipayPublicKey(config('v2board.alipay_pubkey')); // 可以是路径,也可以是密钥内容
|
||||
$gateway->setNotifyUrl(config('v2board.app_url', env('APP_URL')) . '/api/v1/guest/order/alipayNotify');
|
||||
$request = $gateway->purchase();
|
||||
$request->setBizContent([
|
||||
'subject' => config('v2panel.app_name') . ' - 订阅',
|
||||
'subject' => config('v2board.app_name') . ' - 订阅',
|
||||
'out_trade_no' => $tradeNo,
|
||||
'total_amount' => $totalAmount / 100
|
||||
]);
|
||||
@ -194,13 +194,13 @@ class OrderController extends Controller
|
||||
if (!$exchange) {
|
||||
abort(500, '货币转换超时,请稍后再试');
|
||||
}
|
||||
Stripe::setApiKey(config('v2panel.stripe_sk_live'));
|
||||
Stripe::setApiKey(config('v2board.stripe_sk_live'));
|
||||
$source = Source::create([
|
||||
'amount' => floor($order->total_amount * $exchange),
|
||||
'currency' => 'hkd',
|
||||
'type' => 'alipay',
|
||||
'redirect' => [
|
||||
'return_url' => config('v2panel.app_url', env('APP_URL')) . '/api/v1/guest/order/stripeReturn'
|
||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/api/v1/guest/order/stripeReturn'
|
||||
]
|
||||
]);
|
||||
if (!$source['redirect']['url']) {
|
||||
@ -218,13 +218,13 @@ class OrderController extends Controller
|
||||
if (!$exchange) {
|
||||
abort(500, '货币转换超时,请稍后再试');
|
||||
}
|
||||
Stripe::setApiKey(config('v2panel.stripe_sk_live'));
|
||||
Stripe::setApiKey(config('v2board.stripe_sk_live'));
|
||||
$source = Source::create([
|
||||
'amount' => floor($order->total_amount * $exchange),
|
||||
'currency' => 'hkd',
|
||||
'type' => 'wechat',
|
||||
'redirect' => [
|
||||
'return_url' => config('v2panel.app_url', env('APP_URL')) . '/api/v1/guest/order/stripeReturn'
|
||||
'return_url' => config('v2board.app_url', env('APP_URL')) . '/api/v1/guest/order/stripeReturn'
|
||||
]
|
||||
]);
|
||||
if (!$source['wechat']['qr_code_url']) {
|
||||
|
@ -13,7 +13,7 @@ class CommController extends Controller
|
||||
{
|
||||
public function isEmailVerify () {
|
||||
return response([
|
||||
'data' => (int)config('v2panel.email_verify', env('DEFAULT_EMAIL_VERIFY')) ? 1 : 0
|
||||
'data' => (int)config('v2board.email_verify', env('DEFAULT_EMAIL_VERIFY')) ? 1 : 0
|
||||
]);
|
||||
}
|
||||
|
||||
@ -24,12 +24,12 @@ class CommController extends Controller
|
||||
abort(500, '验证码已发送,请过一会在请求');
|
||||
}
|
||||
$code = rand(100000, 999999);
|
||||
$subject = config('v2panel.app_name', 'V2Panel') . '邮箱验证码';
|
||||
$subject = config('v2board.app_name', 'V2Panel') . '邮箱验证码';
|
||||
Mail::send(
|
||||
'mail.sendEmailVerify',
|
||||
[
|
||||
'code' => $code,
|
||||
'name' => config('v2panel.app_name', 'V2Panel')
|
||||
'name' => config('v2board.app_name', 'V2Panel')
|
||||
],
|
||||
function ($message) use($email, $subject) {
|
||||
$message->to($email)->subject($subject);
|
||||
|
@ -15,15 +15,15 @@ use App\Models\InviteCode;
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
public function index (RegisterIndex $request) {
|
||||
if ((int)config('v2panel.stop_register', env('DEFAULT_STOP_REGISTER'))) {
|
||||
if ((int)config('v2board.stop_register', env('DEFAULT_STOP_REGISTER'))) {
|
||||
abort(500, '本站已关闭注册');
|
||||
}
|
||||
if ((int)config('v2panel.invite_force', env('DEFAULT_INVITE_FOCE'))) {
|
||||
if ((int)config('v2board.invite_force', env('DEFAULT_INVITE_FOCE'))) {
|
||||
if (empty($request->input('invite_code'))) {
|
||||
abort(500, '必须使用邀请码才可以注册');
|
||||
}
|
||||
}
|
||||
if ((int)config('v2panel.email_verify', env('DEFAULT_EMAIL_VERIFY'))) {
|
||||
if ((int)config('v2board.email_verify', env('DEFAULT_EMAIL_VERIFY'))) {
|
||||
$redisKey = 'sendEmailVerify:' . $request->input('email');
|
||||
if (empty($request->input('email_code'))) {
|
||||
abort(500, '邮箱验证码不能为空');
|
||||
@ -49,7 +49,7 @@ class RegisterController extends Controller
|
||||
->where('status', 0)
|
||||
->first();
|
||||
if (!$inviteCode) {
|
||||
if ((int)config('v2panel.invite_force', env('DEFAULT_INVITE_FOCE'))) {
|
||||
if ((int)config('v2board.invite_force', env('DEFAULT_INVITE_FOCE'))) {
|
||||
abort(500, '邀请码无效');
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ class RegisterController extends Controller
|
||||
if (!$user->save()) {
|
||||
abort(500, '注册失败');
|
||||
}
|
||||
if ((int)config('v2panel.email_verify', env('DEFAULT_EMAIL_VERIFY'))) {
|
||||
if ((int)config('v2board.email_verify', env('DEFAULT_EMAIL_VERIFY'))) {
|
||||
Redis::del($redisKey);
|
||||
}
|
||||
return response()->json([
|
||||
|
@ -45,7 +45,7 @@ class UserController extends Controller
|
||||
if ($user->plan_id) {
|
||||
$user['plan'] = Plan::find($user->plan_id);
|
||||
}
|
||||
$user['subscribe_url'] = config('v2panel.app_url', env('APP_URL')) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
$user['subscribe_url'] = config('v2board.app_url', env('APP_URL')) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
$stat = [
|
||||
Order::where('status', 0)
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
@ -80,7 +80,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
}
|
||||
$user['subscribe_url'] = config('v2panel.app_url', env('APP_URL')) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
$user['subscribe_url'] = config('v2board.app_url', env('APP_URL')) . '/api/v1/client/subscribe?token=' . $user['token'];
|
||||
return response([
|
||||
'data' => [
|
||||
'user' => $user,
|
||||
|
@ -20,7 +20,7 @@ class Server
|
||||
if (empty($token)) {
|
||||
abort(500, 'token is null');
|
||||
}
|
||||
if ($token !== config('v2panel.server_token')) {
|
||||
if ($token !== config('v2board.server_token')) {
|
||||
abort(500, 'token is error');
|
||||
}
|
||||
return $next($request);
|
||||
|
@ -13,6 +13,6 @@
|
||||
|
||||
Route::get('/', function () {
|
||||
return view('app', [
|
||||
'title' => config('v2panel.app_name', env('APP_NAME'))
|
||||
'title' => config('v2board.app_name', env('APP_NAME'))
|
||||
]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user