mirror of
https://github.com/v2board/v2board.git
synced 2025-01-09 23:59:11 +08:00
format
This commit is contained in:
parent
35f954cd84
commit
f7fdfadfb0
@ -54,5 +54,5 @@ class CheckCommission extends Command
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -49,5 +49,5 @@ class CheckExpire extends Command
|
||||
$user->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,16 +56,18 @@ class CheckOrder extends Command
|
||||
$this->orderHandle($item);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private function orderHandle ($order) {
|
||||
|
||||
private function orderHandle($order)
|
||||
{
|
||||
$user = User::find($order->user_id);
|
||||
return $this->buy($order, $user);
|
||||
}
|
||||
|
||||
private function buy ($order, $user) {
|
||||
|
||||
private function buy($order, $user)
|
||||
{
|
||||
$plan = Plan::find($order->plan_id);
|
||||
// change plan process
|
||||
if ($order->type === 3) {
|
||||
@ -82,16 +84,21 @@ class CheckOrder extends Command
|
||||
$order->save();
|
||||
}
|
||||
}
|
||||
|
||||
private function getTime ($str, $timestamp) {
|
||||
|
||||
private function getTime($str, $timestamp)
|
||||
{
|
||||
if ($timestamp < time()) {
|
||||
$timestamp = time();
|
||||
}
|
||||
switch ($str) {
|
||||
case 'month_price': return strtotime('+1 month', $timestamp);
|
||||
case 'quarter_price': return strtotime('+3 month', $timestamp);
|
||||
case 'half_year_price': return strtotime('+6 month', $timestamp);
|
||||
case 'year_price': return strtotime('+12 month', $timestamp);
|
||||
case 'month_price':
|
||||
return strtotime('+1 month', $timestamp);
|
||||
case 'quarter_price':
|
||||
return strtotime('+3 month', $timestamp);
|
||||
case 'half_year_price':
|
||||
return strtotime('+6 month', $timestamp);
|
||||
case 'year_price':
|
||||
return strtotime('+12 month', $timestamp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,8 +46,9 @@ class SendRemindMail extends Command
|
||||
if ($user->remind_traffic) $this->remindTraffic($user);
|
||||
}
|
||||
}
|
||||
|
||||
private function remindExpire ($user) {
|
||||
|
||||
private function remindExpire($user)
|
||||
{
|
||||
if (($user->expired_at - 86400) < time() && $user->expired_at > time()) {
|
||||
SendEmail::dispatch([
|
||||
'email' => $user->email,
|
||||
@ -61,11 +62,12 @@ class SendRemindMail extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function remindTraffic ($user) {
|
||||
private function remindTraffic($user)
|
||||
{
|
||||
if ($this->remindTrafficIsWarnValue(($user->u + $user->d), $user->transfer_enable)) {
|
||||
$sendCount = MailLog::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
->where('template_name', 'mail.sendRemindTraffic')
|
||||
->count();
|
||||
$sendCount = MailLog::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
->where('template_name', 'mail.sendRemindTraffic')
|
||||
->count();
|
||||
if ($sendCount > 0) return;
|
||||
SendEmail::dispatch([
|
||||
'email' => $user->email,
|
||||
@ -78,8 +80,9 @@ class SendRemindMail extends Command
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
private function remindTrafficIsWarnValue ($ud, $transfer_enable) {
|
||||
|
||||
private function remindTrafficIsWarnValue($ud, $transfer_enable)
|
||||
{
|
||||
if ($ud <= 0) return false;
|
||||
if (($ud / $transfer_enable * 100) < 80) return false;
|
||||
return true;
|
||||
|
@ -47,7 +47,8 @@ class V2boardCache extends Command
|
||||
$this->setMonthRegisterTotal();
|
||||
}
|
||||
|
||||
private function setMonthIncome() {
|
||||
private function setMonthIncome()
|
||||
{
|
||||
Cache::put(
|
||||
'month_income',
|
||||
Order::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
@ -57,7 +58,8 @@ class V2boardCache extends Command
|
||||
);
|
||||
}
|
||||
|
||||
private function setMonthRegisterTotal() {
|
||||
private function setMonthRegisterTotal()
|
||||
{
|
||||
Cache::put(
|
||||
'month_register_total',
|
||||
User::where('created_at', '>=', strtotime(date('Y-m-1')))
|
||||
|
@ -46,39 +46,41 @@ class V2boardInstall extends Command
|
||||
\Artisan::call('key:generate');
|
||||
sleep(2);
|
||||
\Artisan::call('config:cache');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/install.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {}
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/install.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach ($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
$email = '';
|
||||
while (!$email) {
|
||||
$email = $this->ask('请输入管理员邮箱?');
|
||||
$email = $this->ask('请输入管理员邮箱?');
|
||||
}
|
||||
$password = '';
|
||||
while (!$password) {
|
||||
$password = $this->ask('请输入管理员密码?');
|
||||
$password = $this->ask('请输入管理员密码?');
|
||||
}
|
||||
if (!$this->registerAdmin($email, $password)) {
|
||||
abort(500, '管理员账号注册失败,请重试');
|
||||
abort(500, '管理员账号注册失败,请重试');
|
||||
}
|
||||
|
||||
$this->info('一切就绪');
|
||||
|
||||
$this->info('一切就绪');
|
||||
\File::put(base_path() . '/.lock', time());
|
||||
}
|
||||
|
||||
private function registerAdmin ($email, $password) {
|
||||
|
||||
private function registerAdmin($email, $password)
|
||||
{
|
||||
$user = new User();
|
||||
$user->email = $email;
|
||||
$user->password = password_hash($password, PASSWORD_DEFAULT);
|
||||
|
@ -39,22 +39,23 @@ class V2boardUpdate extends Command
|
||||
public function handle()
|
||||
{
|
||||
\Artisan::call('config:cache');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/update.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
DB::connection()->getPdo();
|
||||
$file = \File::get(base_path() . '/update.sql');
|
||||
if (!$file) {
|
||||
abort(500, '数据库文件不存在');
|
||||
}
|
||||
$sql = str_replace("\n", "", $file);
|
||||
$sql = preg_split("/;/", $sql);
|
||||
if (!is_array($sql)) {
|
||||
abort(500, '数据库文件格式有误');
|
||||
}
|
||||
$this->info('正在导入数据库请稍等...');
|
||||
foreach($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {}
|
||||
}
|
||||
foreach ($sql as $item) {
|
||||
try {
|
||||
DB::select(DB::raw($item));
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
$this->info('更新完毕');
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ class Kernel extends ConsoleKernel
|
||||
/**
|
||||
* Define the application's command schedule.
|
||||
*
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @param \Illuminate\Console\Scheduling\Schedule $schedule
|
||||
* @return void
|
||||
*/
|
||||
protected function schedule(Schedule $schedule)
|
||||
@ -44,7 +44,7 @@ class Kernel extends ConsoleKernel
|
||||
*/
|
||||
protected function commands()
|
||||
{
|
||||
$this->load(__DIR__.'/Commands');
|
||||
$this->load(__DIR__ . '/Commands');
|
||||
|
||||
require base_path('routes/console.php');
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Report or log an exception.
|
||||
*
|
||||
* @param \Exception $exception
|
||||
* @param \Exception $exception
|
||||
* @return void
|
||||
*/
|
||||
public function report(Exception $exception)
|
||||
@ -40,8 +40,8 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Exception $exception
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function render($request, Exception $exception)
|
||||
|
@ -11,11 +11,13 @@ use App\Models\User;
|
||||
|
||||
class ConfigController extends Controller
|
||||
{
|
||||
public function init () {
|
||||
public function init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function fetch () {
|
||||
public function fetch()
|
||||
{
|
||||
return response([
|
||||
'data' => [
|
||||
'invite' => [
|
||||
@ -61,8 +63,9 @@ class ConfigController extends Controller
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (ConfigSave $request) {
|
||||
|
||||
public function save(ConfigSave $request)
|
||||
{
|
||||
$data = $request->input();
|
||||
$array = \Config::get('v2board');
|
||||
foreach ($data as $k => $v) {
|
||||
@ -72,7 +75,7 @@ class ConfigController extends Controller
|
||||
$array[$k] = $v;
|
||||
}
|
||||
$data = var_export($array, 1);
|
||||
if(!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
|
||||
if (!\File::put(base_path() . '/config/v2board.php', "<?php\n return $data ;")) {
|
||||
abort(500, '修改失败');
|
||||
}
|
||||
\Artisan::call('config:cache');
|
||||
|
@ -10,13 +10,15 @@ use App\Utils\Helper;
|
||||
|
||||
class CouponController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Coupon::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (CouponSave $request) {
|
||||
public function save(CouponSave $request)
|
||||
{
|
||||
$params = $request->only([
|
||||
'name',
|
||||
'type',
|
||||
@ -26,23 +28,24 @@ class CouponController extends Controller
|
||||
'limit_use'
|
||||
]);
|
||||
|
||||
if (!$request->input('id')) {
|
||||
$params['code'] = Helper::randomChar(8);
|
||||
if (!Coupon::create($params)) {
|
||||
abort(500, '创建失败');
|
||||
}
|
||||
} else {
|
||||
if (!Coupon::find($request->input('id'))->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
}
|
||||
if (!$request->input('id')) {
|
||||
$params['code'] = Helper::randomChar(8);
|
||||
if (!Coupon::create($params)) {
|
||||
abort(500, '创建失败');
|
||||
}
|
||||
} else {
|
||||
if (!Coupon::find($request->input('id'))->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop (Request $request) {
|
||||
public function drop(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数有误');
|
||||
}
|
||||
@ -58,4 +61,4 @@ class CouponController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,8 @@ use App\Jobs\SendEmail;
|
||||
|
||||
class MailController extends Controller
|
||||
{
|
||||
public function send (MailSend $request) {
|
||||
public function send(MailSend $request)
|
||||
{
|
||||
if ($request->input('type') == 2 && empty($request->input('receiver'))) {
|
||||
abort(500, '收件人不能为空');
|
||||
}
|
||||
@ -38,4 +39,4 @@ class MailController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,15 @@ use Cache;
|
||||
|
||||
class NoticeController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Notice::orderBy('id', 'DESC')->get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (NoticeSave $request) {
|
||||
public function save(NoticeSave $request)
|
||||
{
|
||||
$data = $request->only([
|
||||
'title',
|
||||
'content',
|
||||
@ -36,7 +38,8 @@ class NoticeController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop (Request $request) {
|
||||
public function drop(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ use App\Models\Plan;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$current = $request->input('current') ? $request->input('current') : 1;
|
||||
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
|
||||
$orderModel = Order::orderBy('created_at', 'DESC');
|
||||
@ -42,7 +43,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (OrderUpdate $request) {
|
||||
public function update(OrderUpdate $request)
|
||||
{
|
||||
$updateData = $request->only([
|
||||
'status',
|
||||
'commission_status'
|
||||
@ -63,7 +65,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function repair (Request $request) {
|
||||
public function repair(Request $request)
|
||||
{
|
||||
if (empty($request->input('trade_no'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
|
@ -12,13 +12,15 @@ use App\Models\User;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Plan::get()
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (PlanSave $request) {
|
||||
|
||||
public function save(PlanSave $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$plan = Plan::find($request->input('id'));
|
||||
if (!$plan) {
|
||||
@ -35,13 +37,14 @@ class PlanController extends Controller
|
||||
$plan->quarter_price = $request->input('quarter_price');
|
||||
$plan->half_year_price = $request->input('half_year_price');
|
||||
$plan->year_price = $request->input('year_price');
|
||||
|
||||
|
||||
return response([
|
||||
'data' => $plan->save()
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop (Request $request) {
|
||||
|
||||
public function drop(Request $request)
|
||||
{
|
||||
if (Order::where('plan_id', $request->input('id'))->first()) {
|
||||
abort(500, '该订阅下存在订单无法删除');
|
||||
}
|
||||
@ -59,12 +62,13 @@ class PlanController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (PlanUpdate $request) {
|
||||
public function update(PlanUpdate $request)
|
||||
{
|
||||
$updateData = $request->only([
|
||||
'show',
|
||||
'renew'
|
||||
]);
|
||||
|
||||
|
||||
$plan = Plan::find($request->input('id'));
|
||||
if (!$plan) {
|
||||
abort(500, '该订阅不存在');
|
||||
|
@ -14,7 +14,8 @@ use Cache;
|
||||
|
||||
class ServerController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$server = Server::get();
|
||||
for ($i = 0; $i < count($server); $i++) {
|
||||
if (!empty($server[$i]['tags'])) {
|
||||
@ -32,7 +33,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (ServerSave $request) {
|
||||
public function save(ServerSave $request)
|
||||
{
|
||||
$params = $request->only([
|
||||
'show',
|
||||
'group_id',
|
||||
@ -58,18 +60,18 @@ class ServerController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->input('id')) {
|
||||
$server = Server::find($request->input('id'));
|
||||
if (!$server) {
|
||||
abort(500, '服务器不存在');
|
||||
}
|
||||
if (!$server->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
if ($request->input('id')) {
|
||||
$server = Server::find($request->input('id'));
|
||||
if (!$server) {
|
||||
abort(500, '服务器不存在');
|
||||
}
|
||||
if (!$server->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
if (!Server::create($params)) {
|
||||
abort(500, '创建失败');
|
||||
@ -80,7 +82,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function groupFetch (Request $request) {
|
||||
public function groupFetch(Request $request)
|
||||
{
|
||||
if ($request->input('group_id')) {
|
||||
return response([
|
||||
'data' => [ServerGroup::find($request->input('group_id'))]
|
||||
@ -91,7 +94,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function groupSave (Request $request) {
|
||||
public function groupSave(Request $request)
|
||||
{
|
||||
if (empty($request->input('name'))) {
|
||||
abort(500, '组名不能为空');
|
||||
}
|
||||
@ -108,7 +112,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function groupDrop (Request $request) {
|
||||
public function groupDrop(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$serverGroup = ServerGroup::find($request->input('id'));
|
||||
if (!$serverGroup) {
|
||||
@ -135,7 +140,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop (Request $request) {
|
||||
public function drop(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$server = Server::find($request->input('id'));
|
||||
if (!$server) {
|
||||
@ -147,7 +153,8 @@ class ServerController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (ServerUpdate $request) {
|
||||
public function update(ServerUpdate $request)
|
||||
{
|
||||
$params = $request->only([
|
||||
'show',
|
||||
]);
|
||||
|
@ -14,7 +14,8 @@ use Cache;
|
||||
|
||||
class StatController extends Controller
|
||||
{
|
||||
public function getOverride (Request $request) {
|
||||
public function getOverride(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => [
|
||||
'month_income' => Cache::get('month_income'),
|
||||
|
@ -10,7 +10,8 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$ticket = Ticket::where('id', $request->input('id'))
|
||||
->first();
|
||||
@ -43,7 +44,8 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply (Request $request) {
|
||||
public function reply(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
@ -75,7 +77,8 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function close (Request $request) {
|
||||
public function close(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
|
@ -9,13 +9,15 @@ use App\Models\Tutorial;
|
||||
|
||||
class TutorialController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Tutorial::all()
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (TutorialSave $request) {
|
||||
public function save(TutorialSave $request)
|
||||
{
|
||||
$params = $request->only([
|
||||
'title',
|
||||
'description',
|
||||
@ -23,22 +25,23 @@ class TutorialController extends Controller
|
||||
'icon'
|
||||
]);
|
||||
|
||||
if (!$request->input('id')) {
|
||||
if (!Tutorial::create($params)) {
|
||||
abort(500, '创建失败');
|
||||
}
|
||||
} else {
|
||||
if (!Tutorial::find($request->input('id'))->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
}
|
||||
if (!$request->input('id')) {
|
||||
if (!Tutorial::create($params)) {
|
||||
abort(500, '创建失败');
|
||||
}
|
||||
} else {
|
||||
if (!Tutorial::find($request->input('id'))->update($params)) {
|
||||
abort(500, '保存失败');
|
||||
}
|
||||
}
|
||||
|
||||
return response([
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function show (Request $request) {
|
||||
public function show(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数有误');
|
||||
}
|
||||
@ -56,7 +59,8 @@ class TutorialController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function drop (Request $request) {
|
||||
public function drop(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数有误');
|
||||
}
|
||||
@ -72,4 +76,4 @@ class TutorialController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,8 @@ use App\Models\Plan;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$current = $request->input('current') ? $request->input('current') : 1;
|
||||
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
|
||||
$userModel = User::orderBy('created_at', 'DESC');
|
||||
@ -35,7 +36,8 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function id2UserInfo ($id) {
|
||||
public function id2UserInfo($id)
|
||||
{
|
||||
if (empty($id)) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
@ -50,17 +52,18 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (UserUpdate $request) {
|
||||
$updateData = $request->only([
|
||||
'email',
|
||||
'password',
|
||||
'transfer_enable',
|
||||
'expired_at',
|
||||
public function update(UserUpdate $request)
|
||||
{
|
||||
$updateData = $request->only([
|
||||
'email',
|
||||
'password',
|
||||
'transfer_enable',
|
||||
'expired_at',
|
||||
'banned',
|
||||
'plan_id',
|
||||
'commission_rate',
|
||||
'is_admin'
|
||||
]);
|
||||
'is_admin'
|
||||
]);
|
||||
$user = User::find($request->input('id'));
|
||||
if (!$user) {
|
||||
abort(500, '用户不存在');
|
||||
@ -69,9 +72,9 @@ class UserController extends Controller
|
||||
abort(500, '邮箱已被使用');
|
||||
}
|
||||
if (isset($updateData['password'])) {
|
||||
$updateData['password'] = password_hash($updateData['password'], PASSWORD_DEFAULT);
|
||||
$updateData['password'] = password_hash($updateData['password'], PASSWORD_DEFAULT);
|
||||
} else {
|
||||
unset($updateData['password']);
|
||||
unset($updateData['password']);
|
||||
}
|
||||
$updateData['transfer_enable'] = $updateData['transfer_enable'] * 1073741824;
|
||||
if (isset($updateData['plan_id'])) {
|
||||
|
@ -16,7 +16,8 @@ class AppController extends Controller
|
||||
CONST SOCKS_PORT = 10010;
|
||||
CONST HTTP_PORT = 10011;
|
||||
|
||||
public function data (Request $request) {
|
||||
public function data(Request $request)
|
||||
{
|
||||
$user = $request->user;
|
||||
$nodes = [];
|
||||
if ($user->plan_id) {
|
||||
@ -49,7 +50,8 @@ class AppController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function config (Request $request) {
|
||||
public function config(Request $request)
|
||||
{
|
||||
if (empty($request->input('server_id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
@ -77,17 +79,23 @@ class AppController extends Controller
|
||||
$json->outbound->streamSettings->network = $server->network;
|
||||
if ($server->settings) {
|
||||
switch ($server->network) {
|
||||
case 'tcp': $json->outbound->streamSettings->tcpSettings = json_decode($server->settings);
|
||||
case 'tcp':
|
||||
$json->outbound->streamSettings->tcpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'kcp': $json->outbound->streamSettings->kcpSettings = json_decode($server->settings);
|
||||
case 'kcp':
|
||||
$json->outbound->streamSettings->kcpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'ws': $json->outbound->streamSettings->wsSettings = json_decode($server->settings);
|
||||
case 'ws':
|
||||
$json->outbound->streamSettings->wsSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'http': $json->outbound->streamSettings->httpSettings = json_decode($server->settings);
|
||||
case 'http':
|
||||
$json->outbound->streamSettings->httpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'domainsocket': $json->outbound->streamSettings->dsSettings = json_decode($server->settings);
|
||||
case 'domainsocket':
|
||||
$json->outbound->streamSettings->dsSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'quic': $json->outbound->streamSettings->quicSettings = json_decode($server->settings);
|
||||
case 'quic':
|
||||
$json->outbound->streamSettings->quicSettings = json_decode($server->settings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -12,133 +12,138 @@ use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
class ClientController extends Controller
|
||||
{
|
||||
public function subscribe (Request $request) {
|
||||
public function subscribe(Request $request)
|
||||
{
|
||||
$user = $request->user;
|
||||
$server = [];
|
||||
if ($user->expired_at > time()) {
|
||||
$servers = Server::where('show', 1)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
foreach ($servers as $item) {
|
||||
$groupId = json_decode($item['group_id']);
|
||||
if (in_array($user->group_id, $groupId)) {
|
||||
array_push($server, $item);
|
||||
}
|
||||
}
|
||||
$servers = Server::where('show', 1)
|
||||
->orderBy('name')
|
||||
->get();
|
||||
foreach ($servers as $item) {
|
||||
$groupId = json_decode($item['group_id']);
|
||||
if (in_array($user->group_id, $groupId)) {
|
||||
array_push($server, $item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult%20X') !== false) {
|
||||
die($this->quantumultX($user, $server));
|
||||
}
|
||||
if(strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) {
|
||||
die($this->quantumult($user, $server));
|
||||
}
|
||||
if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'clash') !== false) {
|
||||
die($this->clash($user, $server));
|
||||
}
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult%20X') !== false) {
|
||||
die($this->quantumultX($user, $server));
|
||||
}
|
||||
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Quantumult') !== false) {
|
||||
die($this->quantumult($user, $server));
|
||||
}
|
||||
if (strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'clash') !== false) {
|
||||
die($this->clash($user, $server));
|
||||
}
|
||||
}
|
||||
die($this->origin($user, $server));
|
||||
}
|
||||
|
||||
private function quantumultX ($user, $server) {
|
||||
$uri = '';
|
||||
foreach($server as $item) {
|
||||
$uri .= "vmess=".$item->host.":".$item->port.", method=none, password=".$user->v2ray_uuid.", fast-open=false, udp-relay=false, tag=".$item->name;
|
||||
if ($item->network == 'ws') {
|
||||
$uri .= ', obfs=ws';
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $uri .= ', obfs-uri=' . $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $uri .= ', obfs-host=' . $wsSettings->headers->Host;
|
||||
}
|
||||
private function quantumultX($user, $server)
|
||||
{
|
||||
$uri = '';
|
||||
foreach ($server as $item) {
|
||||
$uri .= "vmess=" . $item->host . ":" . $item->port . ", method=none, password=" . $user->v2ray_uuid . ", fast-open=false, udp-relay=false, tag=" . $item->name;
|
||||
if ($item->network == 'ws') {
|
||||
$uri .= ', obfs=ws';
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $uri .= ', obfs-uri=' . $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $uri .= ', obfs-host=' . $wsSettings->headers->Host;
|
||||
}
|
||||
}
|
||||
$uri .= "\r\n";
|
||||
}
|
||||
$uri .= "\r\n";
|
||||
}
|
||||
return base64_encode($uri);
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function quantumult ($user, $server) {
|
||||
$uri = '';
|
||||
header('subscription-userinfo: upload='.$user->u.'; download='.$user->d.';total='.$user->transfer_enable);
|
||||
foreach($server as $item) {
|
||||
$str = '';
|
||||
$str .= $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');
|
||||
if ($item->network === 'ws') {
|
||||
$str .= ', obfs=ws';
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $str .= ', obfs-path="'.$wsSettings->path.'"';
|
||||
if (isset($wsSettings->headers->Host)) $str .= ', obfs-header="Host:'.$wsSettings->headers->Host.'"';
|
||||
}
|
||||
private function quantumult($user, $server)
|
||||
{
|
||||
$uri = '';
|
||||
header('subscription-userinfo: upload=' . $user->u . '; download=' . $user->d . ';total=' . $user->transfer_enable);
|
||||
foreach ($server as $item) {
|
||||
$str = '';
|
||||
$str .= $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');
|
||||
if ($item->network === 'ws') {
|
||||
$str .= ', obfs=ws';
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $str .= ', obfs-path="' . $wsSettings->path . '"';
|
||||
if (isset($wsSettings->headers->Host)) $str .= ', obfs-header="Host:' . $wsSettings->headers->Host . '"';
|
||||
}
|
||||
}
|
||||
$uri .= "vmess://" . base64_encode($str) . "\r\n";
|
||||
}
|
||||
$uri .= "vmess://".base64_encode($str)."\r\n";
|
||||
}
|
||||
return base64_encode($uri);
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function origin ($user, $server) {
|
||||
$uri = '';
|
||||
foreach($server as $item) {
|
||||
$uri .= Helper::buildVmessLink($item, $user);
|
||||
}
|
||||
return base64_encode($uri);
|
||||
private function origin($user, $server)
|
||||
{
|
||||
$uri = '';
|
||||
foreach ($server as $item) {
|
||||
$uri .= Helper::buildVmessLink($item, $user);
|
||||
}
|
||||
return base64_encode($uri);
|
||||
}
|
||||
|
||||
private function clash ($user, $server) {
|
||||
$proxy = [];
|
||||
$proxyGroup = [];
|
||||
$proxies = [];
|
||||
foreach ($server as $item) {
|
||||
$array = [];
|
||||
$array['name'] = $item->name;
|
||||
$array['type'] = 'vmess';
|
||||
$array['server'] = $item->host;
|
||||
$array['port'] = $item->port;
|
||||
$array['uuid'] = $user->v2ray_uuid;
|
||||
$array['alterId'] = $user->v2ray_alter_id;
|
||||
$array['cipher'] = 'auto';
|
||||
if ($item->tls) {
|
||||
$array['tls'] = true;
|
||||
private function clash($user, $server)
|
||||
{
|
||||
$proxy = [];
|
||||
$proxyGroup = [];
|
||||
$proxies = [];
|
||||
foreach ($server as $item) {
|
||||
$array = [];
|
||||
$array['name'] = $item->name;
|
||||
$array['type'] = 'vmess';
|
||||
$array['server'] = $item->host;
|
||||
$array['port'] = $item->port;
|
||||
$array['uuid'] = $user->v2ray_uuid;
|
||||
$array['alterId'] = $user->v2ray_alter_id;
|
||||
$array['cipher'] = 'auto';
|
||||
if ($item->tls) {
|
||||
$array['tls'] = true;
|
||||
}
|
||||
if ($item->network == 'ws') {
|
||||
$array['network'] = $item->network;
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $array['ws-path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $array['ws-headers'] = [
|
||||
'Host' => $wsSettings->headers->Host
|
||||
];
|
||||
}
|
||||
}
|
||||
array_push($proxy, $array);
|
||||
array_push($proxies, $item->name);
|
||||
}
|
||||
if ($item->network == 'ws') {
|
||||
$array['network'] = $item->network;
|
||||
if ($item->settings) {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $array['ws-path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $array['ws-headers'] = [
|
||||
'Host' => $wsSettings->headers->Host
|
||||
];
|
||||
}
|
||||
}
|
||||
array_push($proxy, $array);
|
||||
array_push($proxies, $item->name);
|
||||
}
|
||||
array_push($proxyGroup, [
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'type' => 'select',
|
||||
'proxies' => $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')
|
||||
]
|
||||
];
|
||||
return Yaml::dump($config);
|
||||
array_push($proxyGroup, [
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'type' => 'select',
|
||||
'proxies' => $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')
|
||||
]
|
||||
];
|
||||
return Yaml::dump($config);
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,8 @@ use App\Models\Coupon;
|
||||
|
||||
class CouponController extends Controller
|
||||
{
|
||||
public function check (Request $request) {
|
||||
public function check(Request $request)
|
||||
{
|
||||
if (empty($request->input('code'))) {
|
||||
abort(500, '优惠券码不能为空');
|
||||
}
|
||||
@ -28,4 +29,4 @@ class CouponController extends Controller
|
||||
'data' => $coupon
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ use Library\BitpayX;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
public function alipayNotify (Request $request) {
|
||||
public function alipayNotify(Request $request)
|
||||
{
|
||||
Log::info('alipayNotifyData: ' . json_encode($_POST));
|
||||
$gateway = Omnipay::create('Alipay_AopF2F');
|
||||
$gateway->setSignType('RSA2'); //RSA/RSA2
|
||||
@ -24,8 +25,8 @@ class OrderController extends Controller
|
||||
try {
|
||||
/** @var \Omnipay\Alipay\Responses\AopCompletePurchaseResponse $response */
|
||||
$response = $request->send();
|
||||
|
||||
if($response->isPaid()){
|
||||
|
||||
if ($response->isPaid()) {
|
||||
/**
|
||||
* Payment is successful
|
||||
*/
|
||||
@ -34,7 +35,7 @@ class OrderController extends Controller
|
||||
}
|
||||
|
||||
die('success'); //The response should be 'success' only
|
||||
}else{
|
||||
} else {
|
||||
/**
|
||||
* Payment is not successful
|
||||
*/
|
||||
@ -48,7 +49,8 @@ class OrderController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function stripeNotify (Request $request) {
|
||||
public function stripeNotify(Request $request)
|
||||
{
|
||||
Log::info('stripeNotifyData: ' . json_encode($request->input()));
|
||||
|
||||
\Stripe\Stripe::setApiKey(config('v2board.stripe_sk_live'));
|
||||
@ -86,7 +88,8 @@ class OrderController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function bitpayXNotify (Request $request) {
|
||||
public function bitpayXNotify(Request $request)
|
||||
{
|
||||
$inputString = file_get_contents('php://input', 'r');
|
||||
Log::info('bitpayXNotifyData: ' . $inputString);
|
||||
$inputStripped = str_replace(array("\r", "\n", "\t", "\v"), '', $inputString);
|
||||
@ -94,14 +97,14 @@ class OrderController extends Controller
|
||||
|
||||
$bitpayX = new BitpayX(config('v2board.bitpayx_appsecret'));
|
||||
$params = [
|
||||
'status' => $inputJSON['status'],
|
||||
'order_id' => $inputJSON['order_id'],
|
||||
'merchant_order_id' => $inputJSON['merchant_order_id'],
|
||||
'price_amount' => $inputJSON['price_amount'],
|
||||
'price_currency' => $inputJSON['price_currency'],
|
||||
'pay_amount' => $inputJSON['pay_amount'],
|
||||
'pay_currency' => $inputJSON['pay_currency'],
|
||||
'created_at_t' => $inputJSON['created_at_t']
|
||||
'status' => $inputJSON['status'],
|
||||
'order_id' => $inputJSON['order_id'],
|
||||
'merchant_order_id' => $inputJSON['merchant_order_id'],
|
||||
'price_amount' => $inputJSON['price_amount'],
|
||||
'price_currency' => $inputJSON['price_currency'],
|
||||
'pay_amount' => $inputJSON['pay_amount'],
|
||||
'pay_currency' => $inputJSON['pay_currency'],
|
||||
'created_at_t' => $inputJSON['created_at_t']
|
||||
];
|
||||
$strToSign = $bitpayX->prepareSignId($inputJSON['merchant_order_id']);
|
||||
if (!$bitpayX->verify($strToSign, $inputJSON['token'])) {
|
||||
@ -127,7 +130,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function handle ($tradeNo, $callbackNo) {
|
||||
private function handle($tradeNo, $callbackNo)
|
||||
{
|
||||
$order = Order::where('trade_no', $tradeNo)->first();
|
||||
if (!$order) {
|
||||
abort(500, 'order is not found');
|
||||
|
@ -8,7 +8,8 @@ use App\Models\Plan;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$plan = Plan::where('show', 1)->get();
|
||||
return response([
|
||||
'data' => $plan
|
||||
|
@ -11,7 +11,8 @@ use App\Utils\Helper;
|
||||
|
||||
class InviteController extends Controller
|
||||
{
|
||||
public function save (Request $request) {
|
||||
public function save(Request $request)
|
||||
{
|
||||
if (InviteCode::where('user_id', $request->session()->get('id'))->where('status', 0)->count() >= config('v2board.invite_gen_limit', 5)) {
|
||||
abort(500, '已达到创建数量上限');
|
||||
}
|
||||
@ -23,7 +24,8 @@ class InviteController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function details (Request $request) {
|
||||
public function details(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Order::where('invite_user_id', $request->session()->get('id'))
|
||||
->where('status', 3)
|
||||
@ -38,7 +40,8 @@ class InviteController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$codes = InviteCode::where('user_id', $request->session()->get('id'))
|
||||
->where('status', 0)
|
||||
->get();
|
||||
|
@ -9,7 +9,8 @@ use App\Utils\Helper;
|
||||
|
||||
class NoticeController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => Notice::orderBy('created_at', 'DESC')->first()
|
||||
]);
|
||||
|
@ -20,13 +20,14 @@ use Library\BitpayX;
|
||||
|
||||
class OrderController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$order = Order::where('user_id', $request->session()->get('id'))
|
||||
->orderBy('created_at', 'DESC')
|
||||
->get();
|
||||
$plan = Plan::get();
|
||||
for($i = 0; $i < count($order); $i++) {
|
||||
for($x = 0; $x < count($plan); $x++) {
|
||||
for ($i = 0; $i < count($order); $i++) {
|
||||
for ($x = 0; $x < count($plan); $x++) {
|
||||
if ($order[$i]['plan_id'] === $plan[$x]['id']) {
|
||||
$order[$i]['plan'] = $plan[$x];
|
||||
}
|
||||
@ -36,8 +37,9 @@ class OrderController extends Controller
|
||||
'data' => $order
|
||||
]);
|
||||
}
|
||||
|
||||
public function details (Request $request) {
|
||||
|
||||
public function details(Request $request)
|
||||
{
|
||||
$order = Order::where('user_id', $request->session()->get('id'))
|
||||
->where('trade_no', $request->input('trade_no'))
|
||||
->first();
|
||||
@ -54,7 +56,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function isExistNotPayOrderByUserId ($userId) {
|
||||
private function isExistNotPayOrderByUserId($userId)
|
||||
{
|
||||
$order = Order::where('status', 0)
|
||||
->where('user_id', $userId)
|
||||
->first();
|
||||
@ -63,19 +66,20 @@ class OrderController extends Controller
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function save (OrderSave $request) {
|
||||
|
||||
public function save(OrderSave $request)
|
||||
{
|
||||
if ($this->isExistNotPayOrderByUserId($request->session()->get('id'))) {
|
||||
abort(500, '存在未付款订单,请取消后再试');
|
||||
}
|
||||
|
||||
$plan = Plan::find($request->input('plan_id'));
|
||||
$user = User::find($request->session()->get('id'));
|
||||
|
||||
|
||||
if (!$plan) {
|
||||
abort(500, '该订阅不存在');
|
||||
}
|
||||
|
||||
|
||||
if (!($plan->show || $user->plan_id == $plan->id)) {
|
||||
abort(500, '该订阅已售罄');
|
||||
}
|
||||
@ -103,7 +107,7 @@ class OrderController extends Controller
|
||||
abort(500, '优惠券已过期');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
DB::beginTransaction();
|
||||
$order = new Order();
|
||||
$order->user_id = $request->session()->get('id');
|
||||
@ -133,9 +137,11 @@ class OrderController extends Controller
|
||||
// coupon process
|
||||
if (isset($coupon)) {
|
||||
switch ($coupon->type) {
|
||||
case 1: $order->discount_amount = $coupon->value;
|
||||
case 1:
|
||||
$order->discount_amount = $coupon->value;
|
||||
break;
|
||||
case 2: $order->discount_amount = $order->total_amount * ($coupon->value / 100);
|
||||
case 2:
|
||||
$order->discount_amount = $order->total_amount * ($coupon->value / 100);
|
||||
break;
|
||||
}
|
||||
$order->total_amount = $order->total_amount - $order->discount_amount;
|
||||
@ -157,7 +163,7 @@ class OrderController extends Controller
|
||||
DB::rollback();
|
||||
abort(500, '订单创建失败');
|
||||
}
|
||||
|
||||
|
||||
DB::commit();
|
||||
|
||||
return response([
|
||||
@ -165,7 +171,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function checkout (Request $request) {
|
||||
public function checkout(Request $request)
|
||||
{
|
||||
$tradeNo = $request->input('trade_no');
|
||||
$method = $request->input('method');
|
||||
$order = Order::where('trade_no', $tradeNo)
|
||||
@ -218,7 +225,8 @@ class OrderController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function check (Request $request) {
|
||||
public function check(Request $request)
|
||||
{
|
||||
$tradeNo = $request->input('trade_no');
|
||||
$order = Order::where('trade_no', $tradeNo)
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
@ -231,7 +239,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getPaymentMethod () {
|
||||
public function getPaymentMethod()
|
||||
{
|
||||
$data = [];
|
||||
if ((int)config('v2board.alipay_enable')) {
|
||||
$alipayF2F = new \StdClass();
|
||||
@ -270,7 +279,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function cancel (Request $request) {
|
||||
public function cancel(Request $request)
|
||||
{
|
||||
if (empty($request->input('trade_no'))) {
|
||||
abort(500, '参数有误');
|
||||
}
|
||||
@ -292,7 +302,8 @@ class OrderController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function alipayF2F ($tradeNo, $totalAmount) {
|
||||
private function alipayF2F($tradeNo, $totalAmount)
|
||||
{
|
||||
$gateway = Omnipay::create('Alipay_AopF2F');
|
||||
$gateway->setSignType('RSA2'); //RSA/RSA2
|
||||
$gateway->setAppId(config('v2board.alipay_appid'));
|
||||
@ -301,7 +312,7 @@ class OrderController extends Controller
|
||||
$gateway->setNotifyUrl(url('/api/v1/guest/order/alipayNotify'));
|
||||
$request = $gateway->purchase();
|
||||
$request->setBizContent([
|
||||
'subject' => config('v2board.app_name', 'V2Board') . ' - 订阅',
|
||||
'subject' => config('v2board.app_name', 'V2Board') . ' - 订阅',
|
||||
'out_trade_no' => $tradeNo,
|
||||
'total_amount' => $totalAmount / 100
|
||||
]);
|
||||
@ -309,13 +320,14 @@ class OrderController extends Controller
|
||||
$response = $request->send();
|
||||
$result = $response->getAlipayResponse();
|
||||
if ($result['code'] !== '10000') {
|
||||
abort(500, $result['sub_msg']);
|
||||
abort(500, $result['sub_msg']);
|
||||
}
|
||||
// 获取收款二维码内容
|
||||
return $response->getQrCode();
|
||||
}
|
||||
|
||||
private function stripeAlipay ($order) {
|
||||
private function stripeAlipay($order)
|
||||
{
|
||||
$exchange = Helper::exchange('CNY', 'HKD');
|
||||
if (!$exchange) {
|
||||
abort(500, '货币转换超时,请稍后再试');
|
||||
@ -332,7 +344,7 @@ class OrderController extends Controller
|
||||
if (!$source['redirect']['url']) {
|
||||
abort(500, '支付网关请求失败');
|
||||
}
|
||||
|
||||
|
||||
if (!Cache::put($source['id'], $order->trade_no)) {
|
||||
abort(500, '订单创建失败');
|
||||
}
|
||||
@ -340,7 +352,8 @@ class OrderController extends Controller
|
||||
return $source['redirect']['url'];
|
||||
}
|
||||
|
||||
private function stripeWepay ($order) {
|
||||
private function stripeWepay($order)
|
||||
{
|
||||
$exchange = Helper::exchange('CNY', 'HKD');
|
||||
if (!$exchange) {
|
||||
abort(500, '货币转换超时,请稍后再试');
|
||||
@ -364,20 +377,21 @@ class OrderController extends Controller
|
||||
return $source['wechat']['qr_code_url'];
|
||||
}
|
||||
|
||||
private function bitpayX ($order) {
|
||||
private function bitpayX($order)
|
||||
{
|
||||
$bitpayX = new BitpayX(config('v2board.bitpayx_appsecret'));
|
||||
$params = [
|
||||
'merchant_order_id' => 'V2Board_' . $order->trade_no,
|
||||
'price_amount' => $order->total_amount / 100,
|
||||
'price_currency' => 'CNY',
|
||||
'title' => '支付单号:' . $order->trade_no,
|
||||
'description' => '充值:' . $order->total_amount / 100 . ' 元',
|
||||
'callback_url' => url('/api/v1/guest/order/bitpayXNotify'),
|
||||
'success_url' => config('v2board.app_url', env('APP_URL')) . '/#/order',
|
||||
'cancel_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'
|
||||
$params = [
|
||||
'merchant_order_id' => 'V2Board_' . $order->trade_no,
|
||||
'price_amount' => $order->total_amount / 100,
|
||||
'price_currency' => 'CNY',
|
||||
'title' => '支付单号:' . $order->trade_no,
|
||||
'description' => '充值:' . $order->total_amount / 100 . ' 元',
|
||||
'callback_url' => url('/api/v1/guest/order/bitpayXNotify'),
|
||||
'success_url' => config('v2board.app_url', env('APP_URL')) . '/#/order',
|
||||
'cancel_url' => config('v2board.app_url', env('APP_URL')) . '/#/order'
|
||||
];
|
||||
$strToSign = $bitpayX->prepareSignId($params['merchant_order_id']);
|
||||
$params['token'] = $bitpayX->sign($strToSign);
|
||||
$params['token'] = $bitpayX->sign($strToSign);
|
||||
$result = $bitpayX->mprequest($params);
|
||||
Log::info('bitpayXSubmit: ' . json_encode($result));
|
||||
return isset($result['payment_url']) ? $result['payment_url'] : false;
|
||||
|
@ -11,7 +11,8 @@ use Cache;
|
||||
|
||||
class CommController extends Controller
|
||||
{
|
||||
public function config () {
|
||||
public function config()
|
||||
{
|
||||
return response([
|
||||
'data' => [
|
||||
'isEmailVerify' => (int)config('v2board.email_verify', 0) ? 1 : 0,
|
||||
@ -20,13 +21,15 @@ class CommController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function isEmailVerify () {
|
||||
private function isEmailVerify()
|
||||
{
|
||||
return response([
|
||||
'data' => (int)config('v2board.email_verify', 0) ? 1 : 0
|
||||
]);
|
||||
}
|
||||
|
||||
public function sendEmailVerify (CommSendEmailVerify $request) {
|
||||
public function sendEmailVerify(CommSendEmailVerify $request)
|
||||
{
|
||||
$email = $request->input('email');
|
||||
$cacheKey = 'sendEmailVerify:' . $email;
|
||||
if (Cache::get($cacheKey)) {
|
||||
@ -35,14 +38,14 @@ class CommController extends Controller
|
||||
$code = rand(100000, 999999);
|
||||
$subject = config('v2board.app_name', 'V2Board') . '邮箱验证码';
|
||||
Mail::send(
|
||||
'mail.sendEmailVerify',
|
||||
'mail.sendEmailVerify',
|
||||
[
|
||||
'code' => $code,
|
||||
'name' => config('v2board.app_name', 'V2Board'),
|
||||
'url' => config('v2board.app_url')
|
||||
],
|
||||
function ($message) use($email, $subject) {
|
||||
$message->to($email)->subject($subject);
|
||||
function ($message) use ($email, $subject) {
|
||||
$message->to($email)->subject($subject);
|
||||
}
|
||||
);
|
||||
if (count(Mail::failures()) >= 1) {
|
||||
|
@ -11,7 +11,8 @@ use Cache;
|
||||
|
||||
class ForgetController extends Controller
|
||||
{
|
||||
public function index (ForgetIndex $request) {
|
||||
public function index(ForgetIndex $request)
|
||||
{
|
||||
$redisKey = 'sendEmailVerify:' . $request->input('email');
|
||||
if (Cache::get($redisKey) !== $request->input('email_code')) {
|
||||
abort(500, '邮箱验证码有误');
|
||||
|
@ -11,10 +11,11 @@ use App\Utils\Helper;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
public function index (LoginIndex $request) {
|
||||
public function index(LoginIndex $request)
|
||||
{
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
|
||||
|
||||
$user = User::where('email', $email)->first();
|
||||
if (!$user) {
|
||||
abort(500, '用户名或密码错误');
|
||||
@ -22,7 +23,7 @@ class LoginController extends Controller
|
||||
if (!password_verify($password, $user->password)) {
|
||||
abort(500, '用户名或密码错误');
|
||||
}
|
||||
|
||||
|
||||
$request->session()->put('email', $user->email);
|
||||
$request->session()->put('id', $user->id);
|
||||
if ($user->is_admin) {
|
||||
@ -36,7 +37,8 @@ class LoginController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function token2Login (Request $request) {
|
||||
public function token2Login(Request $request)
|
||||
{
|
||||
if ($request->input('token')) {
|
||||
$user = User::where('token', $request->input('token'))->first();
|
||||
if (!$user) {
|
||||
@ -46,7 +48,7 @@ class LoginController extends Controller
|
||||
$key = 'token2Login_' . $code;
|
||||
Cache::put($key, $user->id);
|
||||
Redis::expire($key, 600);
|
||||
$redirect = '/#/login?verify='. $code .'&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
$redirect = '/#/login?verify=' . $code . '&redirect=' . ($request->input('redirect') ? $request->input('redirect') : 'dashboard');
|
||||
if (config('v2board.app_url')) {
|
||||
$location = config('v2board.app_url') . $redirect;
|
||||
} else {
|
||||
@ -77,7 +79,8 @@ class LoginController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function check (Request $request) {
|
||||
public function check(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => $request->session()->get('id') ? true : false
|
||||
]);
|
||||
|
@ -15,11 +15,13 @@ use App\Models\InviteCode;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
private function setTryOut () {
|
||||
private function setTryOut()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function index (RegisterIndex $request) {
|
||||
public function index(RegisterIndex $request)
|
||||
{
|
||||
if ((int)config('v2board.stop_register', 0)) {
|
||||
abort(500, '本站已关闭注册');
|
||||
}
|
||||
|
@ -8,7 +8,8 @@ use App\Models\Plan;
|
||||
|
||||
class PlanController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$plan = Plan::where('id', $request->input('id'))
|
||||
->first();
|
||||
|
@ -1,12 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Server;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller as BaseController;
|
||||
|
||||
class Controller extends BaseController
|
||||
{
|
||||
public function __construct(Request $request) {
|
||||
public function __construct(Request $request)
|
||||
{
|
||||
$token = $request->input('token');
|
||||
if (empty($token)) {
|
||||
abort(500, 'token is null');
|
||||
|
@ -14,8 +14,10 @@ use Cache;
|
||||
class DeepbworkController extends Controller
|
||||
{
|
||||
CONST SERVER_CONFIG = '{"api":{"services":["HandlerService","StatsService"],"tag":"api"},"stats":{},"inbound":{"port":443,"protocol":"vmess","settings":{"clients":[]},"streamSettings":{"network":"tcp"},"tag":"proxy"},"inboundDetour":[{"listen":"0.0.0.0","port":23333,"protocol":"dokodemo-door","settings":{"address":"0.0.0.0"},"tag":"api"}],"log":{"loglevel":"debug","access":"access.log","error":"error.log"},"outbound":{"protocol":"freedom","settings":{}},"routing":{"settings":{"rules":[{"inboundTag":["api"],"outboundTag":"api","type":"field"}]},"strategy":"rules"},"policy":{"levels":{"0":{"handshake":4,"connIdle":300,"uplinkOnly":5,"downlinkOnly":30,"statsUserUplink":true,"statsUserDownlink":true}}}}';
|
||||
|
||||
// 后端获取用户
|
||||
public function user (Request $request) {
|
||||
public function user(Request $request)
|
||||
{
|
||||
$nodeId = $request->input('node_id');
|
||||
$server = Server::find($nodeId);
|
||||
if (!$server) {
|
||||
@ -56,26 +58,27 @@ class DeepbworkController extends Controller
|
||||
}
|
||||
|
||||
// 后端提交数据
|
||||
public function submit (Request $request) {
|
||||
Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input'));
|
||||
public function submit(Request $request)
|
||||
{
|
||||
Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input'));
|
||||
$server = Server::find($request->input('node_id'));
|
||||
if (!$server) {
|
||||
return response([
|
||||
'ret' => 1,
|
||||
'msg' => 'ok'
|
||||
]);
|
||||
return response([
|
||||
'ret' => 1,
|
||||
'msg' => 'ok'
|
||||
]);
|
||||
}
|
||||
$data = file_get_contents('php://input');
|
||||
$data = json_decode($data, true);
|
||||
foreach ($data as $item) {
|
||||
$u = $item['u'] * $server->rate;
|
||||
$d = $item['d'] * $server->rate;
|
||||
$user = User::find($item['user_id']);
|
||||
$user->t = time();
|
||||
$user->u = $user->u + $u;
|
||||
$user->d = $user->d + $d;
|
||||
$u = $item['u'] * $server->rate;
|
||||
$d = $item['d'] * $server->rate;
|
||||
$user = User::find($item['user_id']);
|
||||
$user->t = time();
|
||||
$user->u = $user->u + $u;
|
||||
$user->d = $user->d + $d;
|
||||
$user->save();
|
||||
|
||||
|
||||
$serverLog = new ServerLog();
|
||||
$serverLog->user_id = $item['user_id'];
|
||||
$serverLog->server_id = $request->input('node_id');
|
||||
@ -84,15 +87,16 @@ class DeepbworkController extends Controller
|
||||
$serverLog->rate = $server->rate;
|
||||
$serverLog->save();
|
||||
}
|
||||
|
||||
return response([
|
||||
'ret' => 1,
|
||||
'msg' => 'ok'
|
||||
]);
|
||||
|
||||
return response([
|
||||
'ret' => 1,
|
||||
'msg' => 'ok'
|
||||
]);
|
||||
}
|
||||
|
||||
// 后端获取配置
|
||||
public function config (Request $request) {
|
||||
public function config(Request $request)
|
||||
{
|
||||
$nodeId = $request->input('node_id');
|
||||
$localPort = $request->input('local_port');
|
||||
if (empty($nodeId) || empty($localPort)) {
|
||||
@ -108,26 +112,32 @@ class DeepbworkController extends Controller
|
||||
$json->inbound->streamSettings->network = $server->network;
|
||||
if ($server->settings) {
|
||||
switch ($server->network) {
|
||||
case 'tcp': $json->inbound->streamSettings->tcpSettings = json_decode($server->settings);
|
||||
case 'tcp':
|
||||
$json->inbound->streamSettings->tcpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'kcp': $json->inbound->streamSettings->kcpSettings = json_decode($server->settings);
|
||||
case 'kcp':
|
||||
$json->inbound->streamSettings->kcpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'ws': $json->inbound->streamSettings->wsSettings = json_decode($server->settings);
|
||||
case 'ws':
|
||||
$json->inbound->streamSettings->wsSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'http': $json->inbound->streamSettings->httpSettings = json_decode($server->settings);
|
||||
case 'http':
|
||||
$json->inbound->streamSettings->httpSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'domainsocket': $json->inbound->streamSettings->dsSettings = json_decode($server->settings);
|
||||
case 'domainsocket':
|
||||
$json->inbound->streamSettings->dsSettings = json_decode($server->settings);
|
||||
break;
|
||||
case 'quic': $json->inbound->streamSettings->quicSettings = json_decode($server->settings);
|
||||
case 'quic':
|
||||
$json->inbound->streamSettings->quicSettings = json_decode($server->settings);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((int)$server->tls) {
|
||||
$json->inbound->streamSettings->security = "tls";
|
||||
$tls = (object) array("certificateFile" => "/home/v2ray.crt", "keyFile" => "/home/v2ray.key");
|
||||
$tls = (object)array("certificateFile" => "/home/v2ray.crt", "keyFile" => "/home/v2ray.key");
|
||||
$json->inbound->streamSettings->tlsSettings->certificates[0] = $tls;
|
||||
}
|
||||
|
||||
|
||||
die(json_encode($json, JSON_UNESCAPED_UNICODE));
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,10 @@ use App\Models\User;
|
||||
|
||||
use App\Utils\Helper;
|
||||
|
||||
class ServerController extends Controller {
|
||||
public function fetch (Request $request) {
|
||||
class ServerController extends Controller
|
||||
{
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
$server = [];
|
||||
if ($user->expired_at > time()) {
|
||||
@ -39,23 +41,27 @@ class ServerController extends Controller {
|
||||
]);
|
||||
}
|
||||
|
||||
public function logFetch (Request $request) {
|
||||
$type = $request->input('type') ? $request->input('type') : 0;
|
||||
public function logFetch(Request $request)
|
||||
{
|
||||
$type = $request->input('type') ? $request->input('type') : 0;
|
||||
$current = $request->input('current') ? $request->input('current') : 1;
|
||||
$pageSize = $request->input('pageSize') >= 10 ? $request->input('pageSize') : 10;
|
||||
$serverLogModel = ServerLog::where('user_id', $request->session()->get('id'))
|
||||
->orderBy('created_at', 'DESC');
|
||||
switch ($type) {
|
||||
case 0: $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d')));
|
||||
break;
|
||||
case 1: $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d')) - 604800);
|
||||
break;
|
||||
case 2: $serverLogModel->where('created_at', '>=', strtotime(date('Y-m-1')));
|
||||
}
|
||||
$sum = [
|
||||
'u' => $serverLogModel->sum('u'),
|
||||
'd' => $serverLogModel->sum('d')
|
||||
];
|
||||
switch ($type) {
|
||||
case 0:
|
||||
$serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d')));
|
||||
break;
|
||||
case 1:
|
||||
$serverLogModel->where('created_at', '>=', strtotime(date('Y-m-d')) - 604800);
|
||||
break;
|
||||
case 2:
|
||||
$serverLogModel->where('created_at', '>=', strtotime(date('Y-m-1')));
|
||||
}
|
||||
$sum = [
|
||||
'u' => $serverLogModel->sum('u'),
|
||||
'd' => $serverLogModel->sum('d')
|
||||
];
|
||||
$total = $serverLogModel->count();
|
||||
$res = $serverLogModel->forPage($current, $pageSize)
|
||||
->get();
|
||||
@ -65,4 +71,4 @@ class ServerController extends Controller {
|
||||
'sum' => $sum
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,8 @@ use Illuminate\Support\Facades\DB;
|
||||
|
||||
class TicketController extends Controller
|
||||
{
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$ticket = Ticket::where('id', $request->input('id'))
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
@ -47,7 +48,8 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function save (TicketSave $request) {
|
||||
public function save(TicketSave $request)
|
||||
{
|
||||
DB::beginTransaction();
|
||||
$ticket = Ticket::create(array_merge($request->only([
|
||||
'subject',
|
||||
@ -75,7 +77,8 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function reply (Request $request) {
|
||||
public function reply(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
@ -112,7 +115,8 @@ class TicketController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function close (Request $request) {
|
||||
public function close(Request $request)
|
||||
{
|
||||
if (empty($request->input('id'))) {
|
||||
abort(500, '参数错误');
|
||||
}
|
||||
@ -131,7 +135,8 @@ class TicketController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
private function getLastMessage ($ticketId) {
|
||||
private function getLastMessage($ticketId)
|
||||
{
|
||||
return TicketMessage::where('ticket_id', $ticketId)
|
||||
->orderBy('id', 'DESC')
|
||||
->first();
|
||||
|
@ -9,7 +9,8 @@ use App\Models\Tutorial;
|
||||
|
||||
class TutorialController extends Controller
|
||||
{
|
||||
public function getSubscribeUrl (Request $request) {
|
||||
public function getSubscribeUrl(Request $request)
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
return response([
|
||||
'data' => [
|
||||
@ -18,7 +19,8 @@ class TutorialController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getAppleID (Request $request) {
|
||||
public function getAppleID(Request $request)
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if ($user->expired_at < time()) {
|
||||
return response([
|
||||
@ -34,7 +36,8 @@ class TutorialController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function fetch (Request $request) {
|
||||
public function fetch(Request $request)
|
||||
{
|
||||
if ($request->input('id')) {
|
||||
$tutorial = Tutorial::where('show', 1)
|
||||
->where('id', $request->input('id'))
|
||||
@ -57,14 +60,14 @@ class TutorialController extends Controller
|
||||
'subscribe_url' => config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'],
|
||||
'app_name' => config('v2board.app_name', 'V2board'),
|
||||
'apple_id' => $user->expired_at > time() ? config('v2board.apple_id', '管理员暂无提供AppleID信息') : '账号过期或未订阅',
|
||||
'apple_id_password' => $user->expired_at > time() ? config('v2board.apple_id_password', '管理员暂无提供AppleID信息') : '账号过期或未订阅'
|
||||
'apple_id_password' => $user->expired_at > time() ? config('v2board.apple_id_password', '管理员暂无提供AppleID信息') : '账号过期或未订阅'
|
||||
]
|
||||
]
|
||||
];
|
||||
// fuck support shadowrocket urlsafeb64 subscribe
|
||||
$response['data']['safe_area_var']['b64_subscribe_url'] = str_replace(
|
||||
array('+','/','='),
|
||||
array('-','_',''),
|
||||
array('+', '/', '='),
|
||||
array('-', '_', ''),
|
||||
base64_encode($response['data']['safe_area_var']['subscribe_url'])
|
||||
);
|
||||
// end
|
||||
|
@ -15,13 +15,15 @@ use App\Models\ServerLog;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
public function logout (Request $request) {
|
||||
public function logout(Request $request)
|
||||
{
|
||||
return response([
|
||||
'data' => $request->session()->flush()
|
||||
]);
|
||||
}
|
||||
|
||||
public function changePassword (Request $request) {
|
||||
public function changePassword(Request $request)
|
||||
{
|
||||
if (empty($request->input('old_password'))) {
|
||||
abort(500, '旧密码不能为空');
|
||||
}
|
||||
@ -41,8 +43,9 @@ class UserController extends Controller
|
||||
'data' => true
|
||||
]);
|
||||
}
|
||||
|
||||
public function info (Request $request) {
|
||||
|
||||
public function info(Request $request)
|
||||
{
|
||||
$user = User::where('id', $request->session()->get('id'))
|
||||
->select([
|
||||
'email',
|
||||
@ -65,7 +68,8 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getStat (Request $request) {
|
||||
public function getStat(Request $request)
|
||||
{
|
||||
$stat = [
|
||||
Order::where('status', 0)
|
||||
->where('user_id', $request->session()->get('id'))
|
||||
@ -81,7 +85,8 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function getSubscribe (Request $request) {
|
||||
public function getSubscribe(Request $request)
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if ($user->plan_id) {
|
||||
$user['plan'] = Plan::find($user->plan_id);
|
||||
@ -94,8 +99,9 @@ class UserController extends Controller
|
||||
'data' => $user
|
||||
]);
|
||||
}
|
||||
|
||||
public function resetSecurity (Request $request) {
|
||||
|
||||
public function resetSecurity(Request $request)
|
||||
{
|
||||
$user = User::find($request->session()->get('id'));
|
||||
$user->v2ray_uuid = Helper::guid(true);
|
||||
$user->token = Helper::guid();
|
||||
@ -107,12 +113,13 @@ class UserController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update (UserUpdate $request) {
|
||||
public function update(UserUpdate $request)
|
||||
{
|
||||
$updateData = $request->only([
|
||||
'remind_expire',
|
||||
'remind_traffic'
|
||||
]);
|
||||
|
||||
|
||||
$user = User::find($request->session()->get('id'));
|
||||
if (!$user) {
|
||||
abort(500, '该用户不存在');
|
||||
|
@ -9,8 +9,8 @@ class Admin
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
@ -9,12 +9,12 @@ class Authenticate extends Middleware
|
||||
/**
|
||||
* Get the path the user should be redirected to when they are not authenticated.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return string
|
||||
*/
|
||||
protected function redirectTo($request)
|
||||
{
|
||||
if (! $request->expectsJson()) {
|
||||
if (!$request->expectsJson()) {
|
||||
return route('login');
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,9 @@ class CORS
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$origin = $request->header('origin');
|
||||
if(empty($origin)){
|
||||
if (empty($origin)) {
|
||||
$referer = $request->header('referer');
|
||||
if(!empty($referer)&&preg_match("/^((https|http):\/\/)?([^\/]+)/i", $referer, $matches)){
|
||||
if (!empty($referer) && preg_match("/^((https|http):\/\/)?([^\/]+)/i", $referer, $matches)) {
|
||||
$origin = $matches[0];
|
||||
}
|
||||
}
|
||||
@ -21,7 +21,7 @@ class CORS
|
||||
$response->header('Access-Control-Allow-Headers', 'Content-Type,X-Requested-With');
|
||||
$response->header('Access-Control-Allow-Credentials', 'true');
|
||||
$response->header('Access-Control-Max-Age', 10080);
|
||||
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,8 @@ class Client
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
@ -9,9 +9,9 @@ class ForceJson
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
|
@ -10,9 +10,9 @@ class RedirectIfAuthenticated
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param string|null $guard
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
|
@ -10,8 +10,8 @@ class Server
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
@ -9,8 +9,8 @@ class User
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
@ -42,10 +42,12 @@ class ConfigSave extends FormRequest
|
||||
'apple_id_password' => ''
|
||||
];
|
||||
|
||||
public static function filter() {
|
||||
// abort(500, json_encode(array_keys(self::RULES)));
|
||||
public static function filter()
|
||||
{
|
||||
// abort(500, json_encode(array_keys(self::RULES)));
|
||||
return array_keys(self::RULES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
@ -55,7 +57,7 @@ class ConfigSave extends FormRequest
|
||||
{
|
||||
return self::RULES;
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -22,7 +22,7 @@ class CouponSave extends FormRequest
|
||||
'limit_use' => 'nullable|integer'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -20,7 +20,7 @@ class MailSend extends FormRequest
|
||||
'receiver' => 'array'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -19,7 +19,7 @@ class NoticeSave extends FormRequest
|
||||
'img_url' => 'url'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -18,7 +18,7 @@ class OrderUpdate extends FormRequest
|
||||
'commission_status' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -23,7 +23,7 @@ class PlanSave extends FormRequest
|
||||
'year_price' => 'nullable|integer'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -18,7 +18,7 @@ class PlanUpdate extends FormRequest
|
||||
'renew' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -26,12 +26,12 @@ class ServerSave extends FormRequest
|
||||
'network' => 'required|in:tcp,kcp,ws,http,domainsocket,quic'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'name.required' => '节点名称不能为空',
|
||||
'group_id.required' => '权限组不能为空',
|
||||
'group_id.required' => '权限组不能为空',
|
||||
'group_id.array' => '权限组格式不正确',
|
||||
'parent_id.integer' => '父ID格式不正确',
|
||||
'host.required' => '节点地址不能为空',
|
||||
|
@ -11,14 +11,14 @@ class ServerUpdate extends FormRequest
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'show' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -19,7 +19,7 @@ class TutorialSave extends FormRequest
|
||||
'icon' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -23,7 +23,7 @@ class UserUpdate extends FormRequest
|
||||
'commission_rate' => 'nullable|integer|min:0|max:100'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -18,7 +18,7 @@ class OrderSave extends FormRequest
|
||||
'cycle' => 'required|in:month_price,quarter_price,half_year_price,year_price'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -17,12 +17,12 @@ class CommSendEmailVerify extends FormRequest
|
||||
'email' => 'required|email'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确'
|
||||
'email.email' => '邮箱格式不正确'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ class ForgetIndex extends FormRequest
|
||||
'email_code' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数',
|
||||
'email_code.required' => '邮箱验证码不能为空'
|
||||
|
@ -18,12 +18,12 @@ class LoginIndex extends FormRequest
|
||||
'password' => 'required|min:8'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数'
|
||||
];
|
||||
|
@ -18,12 +18,12 @@ class RegisterIndex extends FormRequest
|
||||
'password' => 'required|min:8'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
'email.required' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'password.required' => '密码不能为空',
|
||||
'password.min' => '密码必须大于8位数'
|
||||
];
|
||||
|
@ -19,7 +19,7 @@ class TicketSave extends FormRequest
|
||||
'message' => 'required'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -18,7 +18,7 @@ class UserUpdate extends FormRequest
|
||||
'remind_traffic' => 'in:0,1'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
public function messages()
|
||||
{
|
||||
return [
|
||||
|
@ -14,6 +14,7 @@ class SendEmail implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
protected $params;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
@ -36,10 +37,10 @@ class SendEmail implements ShouldQueue
|
||||
$subject = $params['subject'];
|
||||
try {
|
||||
Mail::send(
|
||||
$params['template_name'],
|
||||
$params['template_name'],
|
||||
$params['template_value'],
|
||||
function ($message) use($email, $subject) {
|
||||
$message->to($email)->subject($subject);
|
||||
function ($message) use ($email, $subject) {
|
||||
$message->to($email)->subject($subject);
|
||||
}
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
|
@ -52,8 +52,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,8 +66,8 @@ class RouteServiceProvider extends ServiceProvider
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::prefix('api')
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
->middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
}
|
||||
|
8
app/Utils/CacheKey.php
Normal file
8
app/Utils/CacheKey.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Utils;
|
||||
|
||||
class CacheKey
|
||||
{
|
||||
|
||||
}
|
@ -4,7 +4,8 @@ namespace App\Utils;
|
||||
|
||||
class Helper
|
||||
{
|
||||
public static function guid ($format = false) {
|
||||
public static function guid($format = false)
|
||||
{
|
||||
if (function_exists('com_create_guid') === true) {
|
||||
return md5(trim(com_create_guid(), '{}'));
|
||||
}
|
||||
@ -14,16 +15,18 @@ class Helper
|
||||
if ($format) {
|
||||
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
|
||||
}
|
||||
return md5(vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)).'-'.time());
|
||||
return md5(vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . '-' . time());
|
||||
}
|
||||
|
||||
public static function exchange ($from, $to) {
|
||||
public static function exchange($from, $to)
|
||||
{
|
||||
$result = file_get_contents('https://api.exchangeratesapi.io/latest?symbols=' . $to . '&base=' . $from);
|
||||
$result = json_decode($result, true);
|
||||
return $result['rates'][$to];
|
||||
}
|
||||
|
||||
public static function randomChar($len, $special=false){
|
||||
public static function randomChar($len, $special = false)
|
||||
{
|
||||
$chars = array(
|
||||
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
|
||||
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
|
||||
@ -32,43 +35,44 @@ class Helper
|
||||
"S", "T", "U", "V", "W", "X", "Y", "Z", "0", "1", "2",
|
||||
"3", "4", "5", "6", "7", "8", "9"
|
||||
);
|
||||
|
||||
if($special){
|
||||
|
||||
if ($special) {
|
||||
$chars = array_merge($chars, array(
|
||||
"!", "@", "#", "$", "?", "|", "{", "/", ":", ";",
|
||||
"%", "^", "&", "*", "(", ")", "-", "_", "[", "]",
|
||||
"}", "<", ">", "~", "+", "=", ",", "."
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$charsLen = count($chars) - 1;
|
||||
shuffle($chars);
|
||||
$str = '';
|
||||
for($i=0; $i<$len; $i++){
|
||||
for ($i = 0; $i < $len; $i++) {
|
||||
$str .= $chars[mt_rand(0, $charsLen)];
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function buildVmessLink($item, $user) {
|
||||
public static function buildVmessLink($item, $user)
|
||||
{
|
||||
$config = [
|
||||
"v" => "2",
|
||||
"ps" => $item->name,
|
||||
"add" => $item->host,
|
||||
"port" => $item->port,
|
||||
"id" => $user->v2ray_uuid,
|
||||
"aid" => "2",
|
||||
"net" => $item->network,
|
||||
"type" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $item->tls?"tls":""
|
||||
"ps" => $item->name,
|
||||
"add" => $item->host,
|
||||
"port" => $item->port,
|
||||
"id" => $user->v2ray_uuid,
|
||||
"aid" => "2",
|
||||
"net" => $item->network,
|
||||
"type" => "none",
|
||||
"host" => "",
|
||||
"path" => "",
|
||||
"tls" => $item->tls ? "tls" : ""
|
||||
];
|
||||
if ($item->network == 'ws') {
|
||||
$wsSettings = json_decode($item->settings);
|
||||
if (isset($wsSettings->path)) $config['path'] = $wsSettings->path;
|
||||
if (isset($wsSettings->headers->Host)) $config['host'] = $wsSettings->headers->Host;
|
||||
}
|
||||
return "vmess://".base64_encode(json_encode($config))."\r\n";
|
||||
return "vmess://" . base64_encode(json_encode($config)) . "\r\n";
|
||||
}
|
||||
}
|
||||
|
@ -98,6 +98,6 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'),
|
||||
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
|
||||
|
||||
];
|
||||
|
@ -123,7 +123,7 @@ return [
|
||||
|
||||
'options' => [
|
||||
'cluster' => env('REDIS_CLUSTER', 'redis'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
|
||||
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
|
||||
],
|
||||
|
||||
'default' => [
|
||||
|
@ -51,7 +51,7 @@ return [
|
||||
'public' => [
|
||||
'driver' => 'local',
|
||||
'root' => storage_path('app/public'),
|
||||
'url' => env('APP_URL').'/storage',
|
||||
'url' => env('APP_URL') . '/storage',
|
||||
'visibility' => 'public',
|
||||
],
|
||||
|
||||
|
@ -126,7 +126,7 @@ return [
|
||||
|
||||
'cookie' => env(
|
||||
'SESSION_COOKIE',
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_').'_session'
|
||||
Str::slug(env('APP_NAME', 'laravel'), '_') . '_session'
|
||||
),
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
/** @var \Illuminate\Database\Eloquent\Factory $factory */
|
||||
|
||||
use App\User;
|
||||
use Faker\Generator as Faker;
|
||||
use Illuminate\Support\Str;
|
||||
|
@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Library;
|
||||
|
||||
class BitpayX {
|
||||
class BitpayX
|
||||
{
|
||||
private $bitpayxAppSecret;
|
||||
private $bitpayxGatewayUri;
|
||||
|
||||
/**
|
||||
* 签名初始化
|
||||
* @param merKey 签名密钥
|
||||
*/
|
||||
public function __construct($bitpayxAppSecret) {
|
||||
$this->bitpayxAppSecret = $bitpayxAppSecret;
|
||||
$this->bitpayxGatewayUri = 'https://api.mugglepay.com/v1/';
|
||||
}
|
||||
|
||||
* 签名初始化
|
||||
* @param merKey 签名密钥
|
||||
*/
|
||||
public function __construct($bitpayxAppSecret)
|
||||
{
|
||||
$this->bitpayxAppSecret = $bitpayxAppSecret;
|
||||
$this->bitpayxGatewayUri = 'https://api.mugglepay.com/v1/';
|
||||
}
|
||||
|
||||
public function prepareSignId($tradeno)
|
||||
{
|
||||
$data_sign = array();
|
||||
@ -22,15 +26,18 @@ class BitpayX {
|
||||
ksort($data_sign);
|
||||
return http_build_query($data_sign);
|
||||
}
|
||||
|
||||
public function sign($data)
|
||||
{
|
||||
return strtolower(md5(md5($data) . $this->bitpayxAppSecret));
|
||||
}
|
||||
|
||||
public function verify($data, $signature)
|
||||
{
|
||||
$mySign = $this->sign($data);
|
||||
return $mySign === $signature;
|
||||
}
|
||||
|
||||
public function mprequest($data)
|
||||
{
|
||||
$headers = array('content-type: application/json', 'token: ' . $this->bitpayxAppSecret);
|
||||
@ -48,6 +55,7 @@ class BitpayX {
|
||||
curl_close($curl);
|
||||
return json_decode($data, true);
|
||||
}
|
||||
|
||||
public function mpcheckout($orderId, $data)
|
||||
{
|
||||
$headers = array('content-type: application/json', 'token: ' . $this->bitpayxAppSecret);
|
||||
@ -65,17 +73,21 @@ class BitpayX {
|
||||
curl_close($curl);
|
||||
return json_decode($data, true);
|
||||
}
|
||||
public function refund($merchantTradeNo) {
|
||||
|
||||
public function refund($merchantTradeNo)
|
||||
{
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
public function buildHtml($params, $method = 'post', $target = '_self'){
|
||||
|
||||
public function buildHtml($params, $method = 'post', $target = '_self')
|
||||
{
|
||||
// var_dump($params);exit;
|
||||
$html = "<form id='submit' name='submit' action='".$this->gatewayUri."' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
$html = "<form id='submit' name='submit' action='" . $this->gatewayUri . "' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace Library;
|
||||
|
||||
class TomatoPay {
|
||||
class TomatoPay
|
||||
{
|
||||
private $mchid;
|
||||
private $account;
|
||||
private $key;
|
||||
|
||||
public function __construct($mchid, $account, $key) {
|
||||
public function __construct($mchid, $account, $key)
|
||||
{
|
||||
$this->mchid = $mchid;
|
||||
$this->account = $account;
|
||||
$this->key = $key;
|
||||
}
|
||||
|
||||
public function alipay ($cny, $trade) {
|
||||
|
||||
public function alipay($cny, $trade)
|
||||
{
|
||||
$params = [
|
||||
'mchid' => $this->mchid,
|
||||
'account' => $this->account,
|
||||
@ -24,7 +28,8 @@ class TomatoPay {
|
||||
return $this->buildHtml('https://b.fanqieui.com/gateways/alipay.php', $params);
|
||||
}
|
||||
|
||||
public function wxpay ($cny, $trade) {
|
||||
public function wxpay($cny, $trade)
|
||||
{
|
||||
$params = [
|
||||
'mchid' => $this->mchid,
|
||||
'account' => $this->account,
|
||||
@ -36,21 +41,23 @@ class TomatoPay {
|
||||
return $this->buildHtml('https://b.fanqieui.com/gateways/wxpay.php', $params);
|
||||
}
|
||||
|
||||
public function sign ($params) {
|
||||
$o = '';
|
||||
foreach ($params as $k=>$v){
|
||||
$o.= "$k=".($v)."&";
|
||||
public function sign($params)
|
||||
{
|
||||
$o = '';
|
||||
foreach ($params as $k => $v) {
|
||||
$o .= "$k=" . ($v) . "&";
|
||||
}
|
||||
return md5(substr($o,0,-1).$this->key);
|
||||
return md5(substr($o, 0, -1) . $this->key);
|
||||
}
|
||||
|
||||
public function buildHtml($url, $params, $method = 'post', $target = '_self'){
|
||||
// return var_dump($params);
|
||||
$html = "<form id='submit' name='submit' action='".$url."' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
public function buildHtml($url, $params, $method = 'post', $target = '_self')
|
||||
{
|
||||
// return var_dump($params);
|
||||
$html = "<form id='submit' name='submit' action='" . $url . "' method='$method' target='$target'>";
|
||||
foreach ($params as $key => $value) {
|
||||
$html .= "<input type='hidden' name='$key' value='$value'/>";
|
||||
}
|
||||
$html .= "</form><script>document.forms['submit'].submit();</script>";
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ define('LARAVEL_START', microtime(true));
|
||||
|
|
||||
*/
|
||||
|
||||
require __DIR__.'/../vendor/autoload.php';
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@ -35,7 +35,7 @@ require __DIR__.'/../vendor/autoload.php';
|
||||
|
|
||||
*/
|
||||
|
||||
$app = require_once __DIR__.'/../bootstrap/app.php';
|
||||
$app = require_once __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
@ -1,38 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="./antd.chunk.css?v={{$verison}}">
|
||||
<link rel="stylesheet" href="./umi.css?v={{$verison}}">
|
||||
<link rel="stylesheet" href="./custom.css?v={{$verison}}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
||||
<title>{{$title}}</title>
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,400i,600,700"> -->
|
||||
<script>window.routerBase = "/";</script>
|
||||
<script>
|
||||
window.v2board = {
|
||||
title: '{{$title}}',
|
||||
theme: '{{$theme}}',
|
||||
verison: '{{$verison}}'
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="./vendors.async.js?v={{$verison}}"></script>
|
||||
<script src="./antd.async.js?v={{$verison}}"></script>
|
||||
<script src="./umi.js?v={{$verison}}"></script>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-P1E9Z5LRRK"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-P1E9Z5LRRK');
|
||||
</script>
|
||||
</body>
|
||||
<head>
|
||||
<link rel="stylesheet" href="./antd.chunk.css?v={{$verison}}">
|
||||
<link rel="stylesheet" href="./umi.css?v={{$verison}}">
|
||||
<link rel="stylesheet" href="./custom.css?v={{$verison}}">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no">
|
||||
<title>{{$title}}</title>
|
||||
<!-- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nunito+Sans:300,400,400i,600,700"> -->
|
||||
<script>window.routerBase = "/";</script>
|
||||
<script>
|
||||
window.v2board = {
|
||||
title: '{{$title}}',
|
||||
theme: '{{$theme}}',
|
||||
verison: '{{$verison}}'
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
</html>
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script src="./vendors.async.js?v={{$verison}}"></script>
|
||||
<script src="./antd.async.js?v={{$verison}}"></script>
|
||||
<script src="./umi.js?v={{$verison}}"></script>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-P1E9Z5LRRK"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
|
||||
function gtag() {
|
||||
dataLayer.push(arguments);
|
||||
}
|
||||
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-P1E9Z5LRRK');
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -20,48 +20,48 @@ Route::prefix('v1')
|
||||
->middleware('admin')
|
||||
->group(function () {
|
||||
// Config
|
||||
Route::get ('config/fetch', 'Admin\\ConfigController@fetch');
|
||||
Route::get('config/fetch', 'Admin\\ConfigController@fetch');
|
||||
Route::post('config/save', 'Admin\\ConfigController@save');
|
||||
// Plan
|
||||
Route::get ('plan/fetch', 'Admin\\PlanController@fetch');
|
||||
Route::get('plan/fetch', 'Admin\\PlanController@fetch');
|
||||
Route::post('plan/save', 'Admin\\PlanController@save');
|
||||
Route::post('plan/drop', 'Admin\\PlanController@drop');
|
||||
Route::post('plan/update', 'Admin\\PlanController@update');
|
||||
// Server
|
||||
Route::get ('server/fetch', 'Admin\\ServerController@fetch');
|
||||
Route::get('server/fetch', 'Admin\\ServerController@fetch');
|
||||
Route::post('server/save', 'Admin\\ServerController@save');
|
||||
Route::get ('server/group/fetch', 'Admin\\ServerController@groupFetch');
|
||||
Route::get('server/group/fetch', 'Admin\\ServerController@groupFetch');
|
||||
Route::post('server/group/save', 'Admin\\ServerController@groupSave');
|
||||
Route::post('server/group/drop', 'Admin\\ServerController@groupDrop');
|
||||
Route::post('server/drop', 'Admin\\ServerController@drop');
|
||||
Route::post('server/update', 'Admin\\ServerController@update');
|
||||
// Order
|
||||
Route::get ('order/fetch', 'Admin\\OrderController@fetch');
|
||||
Route::get('order/fetch', 'Admin\\OrderController@fetch');
|
||||
Route::post('order/repair', 'Admin\\OrderController@repair');
|
||||
Route::post('order/update', 'Admin\\OrderController@update');
|
||||
// User
|
||||
Route::get ('user/fetch', 'Admin\\UserController@fetch');
|
||||
Route::get('user/fetch', 'Admin\\UserController@fetch');
|
||||
Route::post('user/update', 'Admin\\UserController@update');
|
||||
Route::get ('user/id2UserInfo/{id}', 'Admin\\UserController@id2UserInfo');
|
||||
Route::get('user/id2UserInfo/{id}', 'Admin\\UserController@id2UserInfo');
|
||||
// Stat
|
||||
Route::get ('stat/getOverride', 'Admin\\StatController@getOverride');
|
||||
Route::get('stat/getOverride', 'Admin\\StatController@getOverride');
|
||||
// Notice
|
||||
Route::get ('notice/fetch', 'Admin\\NoticeController@fetch');
|
||||
Route::get('notice/fetch', 'Admin\\NoticeController@fetch');
|
||||
Route::post('notice/save', 'Admin\\NoticeController@save');
|
||||
Route::post('notice/update', 'Admin\\NoticeController@update');
|
||||
Route::post('notice/drop', 'Admin\\NoticeController@drop');
|
||||
// Ticket
|
||||
Route::get ('ticket/fetch', 'Admin\\TicketController@fetch');
|
||||
Route::get('ticket/fetch', 'Admin\\TicketController@fetch');
|
||||
Route::post('ticket/reply', 'Admin\\TicketController@reply');
|
||||
Route::post('ticket/close', 'Admin\\TicketController@close');
|
||||
// Mail
|
||||
Route::post('mail/send', 'Admin\\MailController@send');
|
||||
// Coupon
|
||||
Route::get ('coupon/fetch', 'Admin\\CouponController@fetch');
|
||||
Route::get('coupon/fetch', 'Admin\\CouponController@fetch');
|
||||
Route::post('coupon/save', 'Admin\\CouponController@save');
|
||||
Route::post('coupon/drop', 'Admin\\CouponController@drop');
|
||||
// Tutorial
|
||||
Route::get ('tutorial/fetch', 'Admin\\TutorialController@fetch');
|
||||
Route::get('tutorial/fetch', 'Admin\\TutorialController@fetch');
|
||||
Route::post('tutorial/save', 'Admin\\TutorialController@save');
|
||||
Route::post('tutorial/show', 'Admin\\TutorialController@show');
|
||||
Route::post('tutorial/drop', 'Admin\\TutorialController@drop');
|
||||
@ -71,41 +71,41 @@ Route::prefix('v1')
|
||||
->middleware('user')
|
||||
->group(function () {
|
||||
// User
|
||||
Route::get ('resetSecurity', 'UserController@resetSecurity');
|
||||
Route::get ('logout', 'UserController@logout');
|
||||
Route::get ('info', 'UserController@info');
|
||||
Route::get('resetSecurity', 'UserController@resetSecurity');
|
||||
Route::get('logout', 'UserController@logout');
|
||||
Route::get('info', 'UserController@info');
|
||||
Route::post('changePassword', 'UserController@changePassword');
|
||||
Route::post('update', 'UserController@update');
|
||||
Route::get ('getSubscribe', 'UserController@getSubscribe');
|
||||
Route::get ('getStat', 'UserController@getStat');
|
||||
Route::get('getSubscribe', 'UserController@getSubscribe');
|
||||
Route::get('getStat', 'UserController@getStat');
|
||||
// Order
|
||||
Route::post('order/save', 'OrderController@save');
|
||||
Route::post('order/checkout', 'OrderController@checkout');
|
||||
Route::get ('order/check', 'OrderController@check');
|
||||
Route::get ('order/details', 'OrderController@details');
|
||||
Route::get ('order/fetch', 'OrderController@fetch');
|
||||
Route::get ('order/getPaymentMethod', 'OrderController@getPaymentMethod');
|
||||
Route::get('order/check', 'OrderController@check');
|
||||
Route::get('order/details', 'OrderController@details');
|
||||
Route::get('order/fetch', 'OrderController@fetch');
|
||||
Route::get('order/getPaymentMethod', 'OrderController@getPaymentMethod');
|
||||
Route::post('order/cancel', 'OrderController@cancel');
|
||||
// Plan
|
||||
Route::get ('plan/fetch', 'PlanController@fetch');
|
||||
Route::get('plan/fetch', 'PlanController@fetch');
|
||||
// Invite
|
||||
Route::get ('invite/save', 'InviteController@save');
|
||||
Route::get ('invite/fetch', 'InviteController@fetch');
|
||||
Route::get ('invite/details', 'InviteController@details');
|
||||
Route::get('invite/save', 'InviteController@save');
|
||||
Route::get('invite/fetch', 'InviteController@fetch');
|
||||
Route::get('invite/details', 'InviteController@details');
|
||||
// Tutorial
|
||||
Route::get ('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl');
|
||||
Route::get ('tutorial/getAppleID', 'TutorialController@getAppleID');
|
||||
Route::get ('tutorial/fetch', 'TutorialController@fetch');
|
||||
Route::get('tutorial/getSubscribeUrl', 'TutorialController@getSubscribeUrl');
|
||||
Route::get('tutorial/getAppleID', 'TutorialController@getAppleID');
|
||||
Route::get('tutorial/fetch', 'TutorialController@fetch');
|
||||
// Notice
|
||||
Route::get ('notice/fetch', 'NoticeController@fetch');
|
||||
Route::get('notice/fetch', 'NoticeController@fetch');
|
||||
// Ticket
|
||||
Route::post('ticket/reply', 'TicketController@reply');
|
||||
Route::post('ticket/close', 'TicketController@close');
|
||||
Route::post('ticket/save', 'TicketController@save');
|
||||
Route::get ('ticket/fetch', 'TicketController@fetch');
|
||||
Route::get('ticket/fetch', 'TicketController@fetch');
|
||||
// Server
|
||||
Route::get ('server/fetch', 'ServerController@fetch');
|
||||
Route::get ('server/log/fetch', 'ServerController@logFetch');
|
||||
Route::get('server/fetch', 'ServerController@fetch');
|
||||
Route::get('server/log/fetch', 'ServerController@logFetch');
|
||||
// Coupon
|
||||
Route::post('coupon/check', 'CouponController@check');
|
||||
});
|
||||
@ -116,12 +116,12 @@ Route::prefix('v1')
|
||||
// Register
|
||||
Route::post('register', 'Passport\\RegisterController@index');
|
||||
// Comm
|
||||
Route::get ('config', 'Passport\\CommController@config');
|
||||
Route::get('config', 'Passport\\CommController@config');
|
||||
Route::post('sendEmailVerify', 'Passport\\CommController@sendEmailVerify');
|
||||
// Login
|
||||
Route::post('login', 'Passport\\LoginController@index');
|
||||
Route::get ('token2Login', 'Passport\\LoginController@token2Login');
|
||||
Route::get ('check', 'Passport\\LoginController@check');
|
||||
Route::get('token2Login', 'Passport\\LoginController@token2Login');
|
||||
Route::get('check', 'Passport\\LoginController@check');
|
||||
// Forget
|
||||
Route::post('forget', 'Passport\\ForgetController@index');
|
||||
});
|
||||
@ -129,7 +129,7 @@ Route::prefix('v1')
|
||||
Route::prefix('guest')
|
||||
->group(function () {
|
||||
// Plan
|
||||
Route::get ('plan/fetch', 'Guest\\PlanController@fetch');
|
||||
Route::get('plan/fetch', 'Guest\\PlanController@fetch');
|
||||
// Order
|
||||
Route::post('order/alipayNotify', 'Guest\\OrderController@alipayNotify');
|
||||
Route::post('order/stripeNotify', 'Guest\\OrderController@stripeNotify');
|
||||
@ -140,17 +140,17 @@ Route::prefix('v1')
|
||||
->middleware('client')
|
||||
->group(function () {
|
||||
// Client
|
||||
Route::get ('subscribe', 'ClientController@subscribe');
|
||||
Route::get('subscribe', 'ClientController@subscribe');
|
||||
// App
|
||||
Route::get ('app/data', 'AppController@data');
|
||||
Route::get ('app/config', 'AppController@config');
|
||||
Route::get('app/data', 'AppController@data');
|
||||
Route::get('app/config', 'AppController@config');
|
||||
});
|
||||
// Server
|
||||
Route::prefix('server')
|
||||
->group(function () {
|
||||
// Deepbwork
|
||||
Route::get ('deepbwork/user', 'Server\\DeepbworkController@user');
|
||||
Route::get ('deepbwork/config', 'Server\\DeepbworkController@config');
|
||||
Route::get('deepbwork/user', 'Server\\DeepbworkController@user');
|
||||
Route::get('deepbwork/config', 'Server\\DeepbworkController@config');
|
||||
Route::post('deepbwork/submit', 'Server\\DeepbworkController@submit');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,5 +12,5 @@
|
||||
*/
|
||||
|
||||
Broadcast::channel('App.User.{id}', function ($user, $id) {
|
||||
return (int) $user->id === (int) $id;
|
||||
return (int)$user->id === (int)$id;
|
||||
});
|
||||
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Web Routes
|
||||
|
@ -14,8 +14,8 @@ $uri = urldecode(
|
||||
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
|
||||
// built-in PHP web server. This provides a convenient way to test a Laravel
|
||||
// application without having installed a "real" web server software here.
|
||||
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
|
||||
if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
require_once __DIR__.'/public/index.php';
|
||||
require_once __DIR__ . '/public/index.php';
|
||||
|
@ -13,7 +13,7 @@ trait CreatesApplication
|
||||
*/
|
||||
public function createApplication()
|
||||
{
|
||||
$app = require __DIR__.'/../bootstrap/app.php';
|
||||
$app = require __DIR__ . '/../bootstrap/app.php';
|
||||
|
||||
$app->make(Kernel::class)->bootstrap();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user