building-sign/app/controller/Error.php

61 lines
1.5 KiB
PHP
Raw Normal View History

2023-01-09 08:41:41 +00:00
<?php
namespace app\controller;
use app\service\Redis;
use think\response\View;
class Error extends BaseController
{
public function __call($method, $args)
{
if(request()->isAjax()) {
return $this->json(4004, 'error request!');
} else {
$referer = $_SERVER['HTTP_REFERER'] ?? null;
if (empty($referer)) {
$url = '/';
} else {
$domain = $this->request->domain();
$urlInfo = parse_url($referer);
$scheme = $urlInfo['scheme'] ?? '';
$requestSrc = '';
if (!empty($scheme)) {
$requestSrc = $scheme.'://'.($urlInfo['host'] ?? '');
}
if($domain != $requestSrc) {
$url = '/';
} else {
$url = 'javascript:history.back(-1);';
}
}
$result = [
'code' => 404,
'msg' => '无效请求! 没有找到相关资源',
'data' => [],
'url' => $url,
'wait' => 5,
];
return view('/manager/error/jump')->assign($result);
}
}
public function jump()
{
$param = request()->param();
return view()->assign($param);
}
public function notice(): View
{
if (Redis::instance()->get('activity_close') == 0) {
header('Location:/coupon/index');
exit;
}
return view();
}
}