mirror of
https://github.com/ProxyPanel/ProxyPanel.git
synced 2026-04-13 07:59:20 +00:00
1. 全面改写项目-管理面板的路由; 2. 拆分过于Contoller; 3. 优化了按钮过多的图表的显示; 4. 初步应用 Laravel的 表单验证功能; 5. 初步应用 Laravel的 component 功能 拆分/模块化前端代码; 6. 优化部分系统的判断逻辑; 7. 针对2.4.0以前的面板,追加辅助矫正数据库的sql文件;
51 lines
1.3 KiB
PHP
51 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use App\Components\IP;
|
|
use Cache;
|
|
use Closure;
|
|
use Log;
|
|
use Response;
|
|
|
|
class isSecurity
|
|
{
|
|
/**
|
|
* 是否需要安全码才访问(仅用于登录页)
|
|
*
|
|
* @param $request
|
|
* @param Closure $next
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$ip = IP::getClientIP();
|
|
$code = $request->securityCode;
|
|
$cacheKey = 'SecurityLogin_'.ip2long($ip);
|
|
$websiteSecurityCode = sysConfig('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>',
|
|
],
|
|
403
|
|
);
|
|
}
|
|
|
|
Cache::put($cacheKey, $ip, 7200); // 2小时之内无需再次输入安全码访问
|
|
}
|
|
|
|
return $next($request);
|
|
}
|
|
}
|