first commit
This commit is contained in:
47
app/index/middleware/system/IndexInitialize.php
Normal file
47
app/index/middleware/system/IndexInitialize.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare (strict_types=1);
|
||||
// +----------------------------------------------------------------------
|
||||
// | swiftAdmin 极速开发框架 [基于WebMan开发]
|
||||
// +----------------------------------------------------------------------
|
||||
// | Copyright (c) 2020-2030 http://www.swiftadmin.net
|
||||
// +----------------------------------------------------------------------
|
||||
// | swiftAdmin.net High Speed Development Framework
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: meystack <coolsec@foxmail.com> Apache 2.0 License
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\index\middleware\system;
|
||||
use Webman\Http\Request;
|
||||
use Webman\Http\Response;
|
||||
use Webman\MiddlewareInterface;
|
||||
use function redirect;
|
||||
use function root_path;
|
||||
|
||||
/**
|
||||
* 前台应用中间件
|
||||
* Class AppInitialize
|
||||
* @package app\index\middleware\system
|
||||
* @author meystack <
|
||||
*/
|
||||
|
||||
class IndexInitialize implements MiddlewareInterface
|
||||
{
|
||||
public function process(Request $request, callable $handler): Response
|
||||
{
|
||||
try {
|
||||
if (saenv('site_status')) {
|
||||
$content = file_get_contents(root_path('extend/conf/tpl') . 'close.tpl');
|
||||
$content = str_replace('{text}',saenv('site_notice'),$content);
|
||||
return \response($content, 503);
|
||||
}
|
||||
} catch (\Throwable $th) {
|
||||
return \response('Web site has been closed', 503);
|
||||
}
|
||||
|
||||
if (!is_file(root_path('extend/conf').'install.lock')) {
|
||||
return redirect('/install/index');
|
||||
}
|
||||
|
||||
return $handler($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user