diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 67487c14..667e616c 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -2,12 +2,7 @@ namespace App\Console\Commands; -use App\Utils\Helper; use Illuminate\Console\Command; -use Stripe\Source; -use Stripe\Stripe; -use Stripe\StripeClient; -use Omnipay\Omnipay; class Test extends Command { @@ -42,21 +37,5 @@ class Test extends Command */ public function handle() { - $gateway = Omnipay::create('Stripe'); - $gateway->setApiKey('sk_test_gDIIPtUgWZHbnTR7CUWZS8k500NsLS9SYB'); - - $formData = array('number' => '4242424242424242', 'expiryMonth' => '6', 'expiryYear' => '2030', 'cvv' => '333'); - $response = $gateway->purchase(array('amount' => '10.00', 'currency' => 'USD', 'card' => $formData))->send(); - - if ($response->isRedirect()) { - // redirect to offsite payment gateway - $response->redirect(); - } elseif ($response->isSuccessful()) { - // payment was successful: update database - print_r($response); - } else { - // payment failed: display message to customer - echo $response->getMessage(); - } } } diff --git a/app/Console/Commands/V2boardCache.php b/app/Console/Commands/V2boardCache.php index c5131c4c..835ac03d 100644 --- a/app/Console/Commands/V2boardCache.php +++ b/app/Console/Commands/V2boardCache.php @@ -42,7 +42,6 @@ class V2boardCache extends Command */ public function handle() { - $this->cacheServerStat(); } private function cacheServerStat() @@ -63,8 +62,7 @@ class V2boardCache extends Command 'd' => $serverLog->d, 'online' => $serverLog->online ]; - Cache::put(CacheKey::get('SERVER_STAT', $serverLog->server_id), json_encode($data), 3600); - ServerStat::create($data); +// ServerStat::create($data); } } } diff --git a/app/Http/Controllers/Server/DeepbworkController.php b/app/Http/Controllers/Server/DeepbworkController.php index 96f03406..7c7a2f49 100644 --- a/app/Http/Controllers/Server/DeepbworkController.php +++ b/app/Http/Controllers/Server/DeepbworkController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Server; use App\Services\ServerService; use App\Services\UserService; +use App\Utils\CacheKey; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\User; @@ -36,7 +37,7 @@ class DeepbworkController extends Controller if (!$server) { abort(500, 'fail'); } - Cache::put('server_last_check_at_' . $server->id, time()); + Cache::put(CacheKey::get('SERVER_LAST_CHECK_AT', $server->id), time(), 3600); $serverService = new ServerService(); $users = $serverService->getAvailableUsers(json_decode($server->group_id)); $result = []; @@ -71,6 +72,7 @@ class DeepbworkController extends Controller } $data = file_get_contents('php://input'); $data = json_decode($data, true); + Cache::put(CacheKey::get('SERVER_ONLINE_USER', $server->id), count($data), 3600); $serverService = new ServerService(); $userService = new UserService(); foreach ($data as $item) { diff --git a/app/Http/Controllers/Server/PoseidonController.php b/app/Http/Controllers/Server/PoseidonController.php index 867132ea..d25d37c9 100644 --- a/app/Http/Controllers/Server/PoseidonController.php +++ b/app/Http/Controllers/Server/PoseidonController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Server; use App\Services\ServerService; use App\Services\UserService; +use App\Utils\CacheKey; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use App\Models\User; @@ -34,7 +35,7 @@ class PoseidonController extends Controller if (!$server) { return $this->error("server could not be found", 404); } - Cache::put('server_last_check_at_' . $server->id, time()); + Cache::put(CacheKey::get('SERVER_LAST_CHECK_AT', $server->id), time(), 3600); $serverService = new ServerService(); $users = $serverService->getAvailableUsers(json_decode($server->group_id)); $result = []; @@ -58,14 +59,13 @@ class PoseidonController extends Controller public function submit(Request $request) { if ($r = $this->verifyToken($request)) { return $r; } - - // Log::info('serverSubmitData:' . $request->input('node_id') . ':' . file_get_contents('php://input')); $server = Server::find($request->input('node_id')); if (!$server) { return $this->error("server could not be found", 404); } $data = file_get_contents('php://input'); $data = json_decode($data, true); + Cache::put(CacheKey::get('SERVER_ONLINE_USER', $server->id), count($data), 3600); $serverService = new ServerService(); $userService = new UserService(); foreach ($data as $item) { diff --git a/app/Http/Controllers/User/ServerController.php b/app/Http/Controllers/User/ServerController.php index 871393ce..21e81204 100644 --- a/app/Http/Controllers/User/ServerController.php +++ b/app/Http/Controllers/User/ServerController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers\User; use App\Http\Controllers\Controller; use App\Services\UserService; +use App\Utils\CacheKey; use Illuminate\Http\Request; use Illuminate\Support\Facades\Cache; use App\Models\Server; @@ -33,9 +34,9 @@ class ServerController extends Controller for ($i = 0; $i < count($server); $i++) { $server[$i]['link'] = Helper::buildVmessLink($server[$i], $user); if ($server[$i]['parent_id']) { - $server[$i]['last_check_at'] = Cache::get('server_last_check_at_' . $server[$i]['parent_id']); + $server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_LAST_CHECK_AT', $server[$i]['parent_id'])); } else { - $server[$i]['last_check_at'] = Cache::get('server_last_check_at_' . $server[$i]['id']); + $server[$i]['last_check_at'] = Cache::get(CacheKey::get('SERVER_LAST_CHECK_AT', $server[$i]['id'])); } } return response([ diff --git a/app/Utils/CacheKey.php b/app/Utils/CacheKey.php index d13bfa6f..873ad545 100644 --- a/app/Utils/CacheKey.php +++ b/app/Utils/CacheKey.php @@ -7,7 +7,8 @@ class CacheKey CONST KEYS = [ 'EMAIL_VERIFY_CODE' => '邮箱验证吗', 'LAST_SEND_EMAIL_VERIFY_TIMESTAMP' => '最后一次发送邮箱验证码时间', - 'SERVER_STAT' => '节点统计信息' + 'SERVER_ONLINE_USER' => '节点在线用户', + 'SERVER_LAST_CHECK_AT' => '节点最后检查时间' ]; public static function get(string $key, $uniqueValue)