mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-11 23:19:05 +00:00
1. 框架更新至5.8,并且其涉及代码进行修改; 2. 对支付的alipay组件针对php7.2/3进行修改; 3. 重构了节点信息获取逻辑;现在为实时请求; 4. 代码小细节和命名规范
40 lines
980 B
PHP
40 lines
980 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Components\Helpers;
|
|
use Cache;
|
|
use Closure;
|
|
use Log;
|
|
|
|
class isSecurity
|
|
{
|
|
/**
|
|
* 是否需要安全码才访问(仅用于登录页)
|
|
*
|
|
* @param $request
|
|
* @param Closure $next
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$ip = getClientIP();
|
|
$code = $request->securityCode;
|
|
$cacheKey = 'SecurityLogin_'.ip2long($ip);
|
|
$websiteSecurityCode = Helpers::systemConfig()['website_security_code'];
|
|
|
|
if($websiteSecurityCode && !Cache::has($cacheKey)){
|
|
if($code != $websiteSecurityCode){
|
|
Log::info("拒绝非安全入口访问(".$ip.")");
|
|
|
|
return response()->view('auth.error', ['message' => trans('error.SecurityError').', '.trans('error.Visit').'<a href="/login?securityCode=" target="_self">'.trans('error.SecurityEnter').'</a>']);
|
|
}else{
|
|
Cache::put($cacheKey, $ip, 7200); // 2小时之内无需再次输入安全码访问
|
|
}
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|