This commit is contained in:
Anonymous 2019-10-23 18:13:54 +08:00
parent 51cf3b1b76
commit 0b62ae8591
10 changed files with 100 additions and 51 deletions

View File

@ -19,31 +19,31 @@ class ConfigController extends Controller
return response([ return response([
'data' => [ 'data' => [
'invite' => [ 'invite' => [
'invite_force' => (int)config('v2panel.invite_force', env('DEFAULT_INVITE_FORCE')), 'invite_force' => (int)config('v2board.invite_force', env('DEFAULT_INVITE_FORCE')),
'invite_commission' => config('v2panel.invite_commission', env('DEFAULT_INVITE_COMMISSION')), 'invite_commission' => config('v2board.invite_commission', env('DEFAULT_INVITE_COMMISSION')),
'invite_gen_limit' => config('v2panel.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT')) 'invite_gen_limit' => config('v2board.invite_gen_limit', env('DEFAULT_INVITE_GEN_LIMIT'))
], ],
'site' => [ 'site' => [
'stop_register' => (int)config('v2panel.stop_register', env('DEFAULT_STOP_REGISTER')), 'stop_register' => (int)config('v2board.stop_register', env('DEFAULT_STOP_REGISTER')),
'email_verify' => (int)config('v2panel.email_verify', env('DEFAULT_EMAIL_VERIFY')), 'email_verify' => (int)config('v2board.email_verify', env('DEFAULT_EMAIL_VERIFY')),
'app_name' => config('v2panel.app_name', env('APP_NAME')), 'app_name' => config('v2board.app_name', env('APP_NAME')),
'app_url' => config('v2panel.app_url', env('APP_URL')) 'app_url' => config('v2board.app_url', env('APP_URL'))
], ],
'pay' => [ 'pay' => [
// alipay // alipay
'alipay_enable' => (int)config('v2panel.alipay_enable'), 'alipay_enable' => (int)config('v2board.alipay_enable'),
'alipay_appid' => config('v2panel.alipay_appid'), 'alipay_appid' => config('v2board.alipay_appid'),
'alipay_pubkey' => config('v2panel.alipay_pubkey'), 'alipay_pubkey' => config('v2board.alipay_pubkey'),
'alipay_privkey' => config('v2panel.alipay_privkey'), 'alipay_privkey' => config('v2board.alipay_privkey'),
// stripe // stripe
'stripe_sk_live' => config('v2panel.stripe_sk_live'), 'stripe_sk_live' => config('v2board.stripe_sk_live'),
'stripe_pk_live' => config('v2panel.stripe_pk_live'), 'stripe_pk_live' => config('v2board.stripe_pk_live'),
'stripe_alipay_enable' => (int)config('v2panel.stripe_alipay_enable'), 'stripe_alipay_enable' => (int)config('v2board.stripe_alipay_enable'),
'stripe_wepay_enable' => (int)config('v2panel.stripe_wepay_enable'), 'stripe_wepay_enable' => (int)config('v2board.stripe_wepay_enable'),
'stripe_webhook_key' => config('v2panel.stripe_webhook_key') 'stripe_webhook_key' => config('v2board.stripe_webhook_key')
], ],
'server' => [ '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) { public function save (ConfigSave $request) {
$data = $request->input(); $data = $request->input();
$array = \Config::get('v2panel'); $array = \Config::get('v2board');
foreach ($data as $k => $v) { foreach ($data as $k => $v) {
if (!in_array($k, ConfigSave::filter())) { if (!in_array($k, ConfigSave::filter())) {
abort(500, '禁止修改'); abort(500, '禁止修改');
@ -59,7 +59,7 @@ class ConfigController extends Controller
$array[$k] = $v; $array[$k] = $v;
} }
$data = var_export($array, 1); $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, '修改失败'); abort(500, '修改失败');
} }
\Artisan::call('config:cache'); \Artisan::call('config:cache');

View File

@ -28,6 +28,9 @@ class ClientController extends Controller
if(strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) { if(strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) {
die($this->quantumult($user, $server)); die($this->quantumult($user, $server));
} }
if(strpos($_SERVER['HTTP_USER_AGENT'], 'clash_win') !== false) {
die($this->clash($user, $server));
}
die($this->origin($user, $server)); die($this->origin($user, $server));
} }
@ -43,7 +46,7 @@ class ClientController extends Controller
$uri = ''; $uri = '';
header('subscription-userinfo: upload='.$user->u.'; download='.$user->d.';total='.$user->transfer_enable); header('subscription-userinfo: upload='.$user->u.'; download='.$user->d.';total='.$user->transfer_enable);
foreach($server as $item) { 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); return base64_encode($uri);
} }
@ -66,4 +69,50 @@ class ClientController extends Controller
} }
return base64_encode($uri); 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
]);
}
} }

View File

@ -12,12 +12,12 @@ class OrderController extends Controller
public function stripeNotify (Request $request) { public function stripeNotify (Request $request) {
Log::info('stripeNotifyData: ' . json_encode($request->input())); Log::info('stripeNotifyData: ' . json_encode($request->input()));
\Stripe\Stripe::setApiKey(config('v2panel.stripe_sk_live')); \Stripe\Stripe::setApiKey(config('v2board.stripe_sk_live'));
try { try {
$event = \Stripe\Webhook::constructEvent( $event = \Stripe\Webhook::constructEvent(
file_get_contents('php://input'), file_get_contents('php://input'),
$_SERVER['HTTP_STRIPE_SIGNATURE'], $_SERVER['HTTP_STRIPE_SIGNATURE'],
config('v2panel.stripe_webhook_key') config('v2board.stripe_webhook_key')
); );
} catch (\Stripe\Error\SignatureVerification $e) { } catch (\Stripe\Error\SignatureVerification $e) {
abort(400); abort(400);

View File

@ -28,7 +28,7 @@ class InviteController extends Controller
->where('status', 0) ->where('status', 0)
->get(); ->get();
for ($i = 0; $i < count($codes); $i++) { 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 = [ $stat = [
//已注册用户数 //已注册用户数

View File

@ -67,7 +67,7 @@ class OrderController extends Controller
$order->total_amount = $plan[$request->input('cycle')]; $order->total_amount = $plan[$request->input('cycle')];
if ($user->invite_user_id) { if ($user->invite_user_id) {
$order->invite_user_id = $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()) { if (!$order->save()) {
abort(500, '订单创建失败'); abort(500, '订单创建失败');
@ -92,7 +92,7 @@ class OrderController extends Controller
// return type => 0: QRCode / 1: URL // return type => 0: QRCode / 1: URL
case 0: case 0:
// alipayF2F // alipayF2F
if (!(int)config('v2panel.alipay_enable')) { if (!(int)config('v2board.alipay_enable')) {
abort(500, '支付方式不可用'); abort(500, '支付方式不可用');
} }
return response([ return response([
@ -101,7 +101,7 @@ class OrderController extends Controller
]); ]);
case 2: case 2:
// stripeAlipay // stripeAlipay
if (!(int)config('v2panel.stripe_alipay_enable')) { if (!(int)config('v2board.stripe_alipay_enable')) {
abort(500, '支付方式不可用'); abort(500, '支付方式不可用');
} }
return response([ return response([
@ -110,7 +110,7 @@ class OrderController extends Controller
]); ]);
case 3: case 3:
// stripeWepay // stripeWepay
if (!(int)config('v2panel.stripe_wepay_enable')) { if (!(int)config('v2board.stripe_wepay_enable')) {
abort(500, '支付方式不可用'); abort(500, '支付方式不可用');
} }
return response([ return response([
@ -137,7 +137,7 @@ class OrderController extends Controller
public function getPaymentMethod () { public function getPaymentMethod () {
$data = []; $data = [];
if ((int)config('v2panel.alipay_enable')) { if ((int)config('v2board.alipay_enable')) {
$alipayF2F = new \StdClass(); $alipayF2F = new \StdClass();
$alipayF2F->name = '支付宝'; $alipayF2F->name = '支付宝';
$alipayF2F->method = 0; $alipayF2F->method = 0;
@ -145,7 +145,7 @@ class OrderController extends Controller
array_push($data, $alipayF2F); array_push($data, $alipayF2F);
} }
if ((int)config('v2panel.stripe_alipay_enable')) { if ((int)config('v2board.stripe_alipay_enable')) {
$stripeAlipay = new \StdClass(); $stripeAlipay = new \StdClass();
$stripeAlipay->name = '支付宝'; $stripeAlipay->name = '支付宝';
$stripeAlipay->method = 2; $stripeAlipay->method = 2;
@ -153,7 +153,7 @@ class OrderController extends Controller
array_push($data, $stripeAlipay); array_push($data, $stripeAlipay);
} }
if ((int)config('v2panel.stripe_wepay_enable')) { if ((int)config('v2board.stripe_wepay_enable')) {
$stripeWepay = new \StdClass(); $stripeWepay = new \StdClass();
$stripeWepay->name = '微信'; $stripeWepay->name = '微信';
$stripeWepay->method = 3; $stripeWepay->method = 3;
@ -169,13 +169,13 @@ class OrderController extends Controller
private function alipayF2F ($tradeNo, $totalAmount) { private function alipayF2F ($tradeNo, $totalAmount) {
$gateway = Omnipay::create('Alipay_AopF2F'); $gateway = Omnipay::create('Alipay_AopF2F');
$gateway->setSignType('RSA2'); //RSA/RSA2 $gateway->setSignType('RSA2'); //RSA/RSA2
$gateway->setAppId(config('v2panel.alipay_appid')); $gateway->setAppId(config('v2board.alipay_appid'));
$gateway->setPrivateKey(config('v2panel.alipay_privkey')); // 可以是路径,也可以是密钥内容 $gateway->setPrivateKey(config('v2board.alipay_privkey')); // 可以是路径,也可以是密钥内容
$gateway->setAlipayPublicKey(config('v2panel.alipay_pubkey')); // 可以是路径,也可以是密钥内容 $gateway->setAlipayPublicKey(config('v2board.alipay_pubkey')); // 可以是路径,也可以是密钥内容
$gateway->setNotifyUrl(config('v2panel.app_url', env('APP_URL')) . '/api/v1/guest/order/alipayNotify'); $gateway->setNotifyUrl(config('v2board.app_url', env('APP_URL')) . '/api/v1/guest/order/alipayNotify');
$request = $gateway->purchase(); $request = $gateway->purchase();
$request->setBizContent([ $request->setBizContent([
'subject' => config('v2panel.app_name') . ' - 订阅', 'subject' => config('v2board.app_name') . ' - 订阅',
'out_trade_no' => $tradeNo, 'out_trade_no' => $tradeNo,
'total_amount' => $totalAmount / 100 'total_amount' => $totalAmount / 100
]); ]);
@ -194,13 +194,13 @@ class OrderController extends Controller
if (!$exchange) { if (!$exchange) {
abort(500, '货币转换超时,请稍后再试'); abort(500, '货币转换超时,请稍后再试');
} }
Stripe::setApiKey(config('v2panel.stripe_sk_live')); Stripe::setApiKey(config('v2board.stripe_sk_live'));
$source = Source::create([ $source = Source::create([
'amount' => floor($order->total_amount * $exchange), 'amount' => floor($order->total_amount * $exchange),
'currency' => 'hkd', 'currency' => 'hkd',
'type' => 'alipay', 'type' => 'alipay',
'redirect' => [ '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']) { if (!$source['redirect']['url']) {
@ -218,13 +218,13 @@ class OrderController extends Controller
if (!$exchange) { if (!$exchange) {
abort(500, '货币转换超时,请稍后再试'); abort(500, '货币转换超时,请稍后再试');
} }
Stripe::setApiKey(config('v2panel.stripe_sk_live')); Stripe::setApiKey(config('v2board.stripe_sk_live'));
$source = Source::create([ $source = Source::create([
'amount' => floor($order->total_amount * $exchange), 'amount' => floor($order->total_amount * $exchange),
'currency' => 'hkd', 'currency' => 'hkd',
'type' => 'wechat', 'type' => 'wechat',
'redirect' => [ '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']) { if (!$source['wechat']['qr_code_url']) {

View File

@ -13,7 +13,7 @@ class CommController extends Controller
{ {
public function isEmailVerify () { public function isEmailVerify () {
return response([ 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, '验证码已发送,请过一会在请求'); abort(500, '验证码已发送,请过一会在请求');
} }
$code = rand(100000, 999999); $code = rand(100000, 999999);
$subject = config('v2panel.app_name', 'V2Panel') . '邮箱验证码'; $subject = config('v2board.app_name', 'V2Panel') . '邮箱验证码';
Mail::send( Mail::send(
'mail.sendEmailVerify', 'mail.sendEmailVerify',
[ [
'code' => $code, 'code' => $code,
'name' => config('v2panel.app_name', 'V2Panel') 'name' => config('v2board.app_name', 'V2Panel')
], ],
function ($message) use($email, $subject) { function ($message) use($email, $subject) {
$message->to($email)->subject($subject); $message->to($email)->subject($subject);

View File

@ -15,15 +15,15 @@ use App\Models\InviteCode;
class RegisterController extends Controller class RegisterController extends Controller
{ {
public function index (RegisterIndex $request) { 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, '本站已关闭注册'); 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'))) { if (empty($request->input('invite_code'))) {
abort(500, '必须使用邀请码才可以注册'); 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'); $redisKey = 'sendEmailVerify:' . $request->input('email');
if (empty($request->input('email_code'))) { if (empty($request->input('email_code'))) {
abort(500, '邮箱验证码不能为空'); abort(500, '邮箱验证码不能为空');
@ -49,7 +49,7 @@ class RegisterController extends Controller
->where('status', 0) ->where('status', 0)
->first(); ->first();
if (!$inviteCode) { if (!$inviteCode) {
if ((int)config('v2panel.invite_force', env('DEFAULT_INVITE_FOCE'))) { if ((int)config('v2board.invite_force', env('DEFAULT_INVITE_FOCE'))) {
abort(500, '邀请码无效'); abort(500, '邀请码无效');
} }
} }
@ -61,7 +61,7 @@ class RegisterController extends Controller
if (!$user->save()) { if (!$user->save()) {
abort(500, '注册失败'); 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); Redis::del($redisKey);
} }
return response()->json([ return response()->json([

View File

@ -45,7 +45,7 @@ class UserController extends Controller
if ($user->plan_id) { if ($user->plan_id) {
$user['plan'] = Plan::find($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 = [ $stat = [
Order::where('status', 0) Order::where('status', 0)
->where('user_id', $request->session()->get('id')) ->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([ return response([
'data' => [ 'data' => [
'user' => $user, 'user' => $user,

View File

@ -20,7 +20,7 @@ class Server
if (empty($token)) { if (empty($token)) {
abort(500, 'token is null'); abort(500, 'token is null');
} }
if ($token !== config('v2panel.server_token')) { if ($token !== config('v2board.server_token')) {
abort(500, 'token is error'); abort(500, 'token is error');
} }
return $next($request); return $next($request);

View File

@ -13,6 +13,6 @@
Route::get('/', function () { Route::get('/', function () {
return view('app', [ return view('app', [
'title' => config('v2panel.app_name', env('APP_NAME')) 'title' => config('v2board.app_name', env('APP_NAME'))
]); ]);
}); });