You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.7 KiB
PHTML
83 lines
2.7 KiB
PHTML
|
2 months ago
|
<?php
|
||
|
|
|
||
|
|
namespace App\Controllers;
|
||
|
|
|
||
|
|
use App\Models\Configurations;
|
||
|
|
use App\Models\InviteCode;
|
||
|
|
use App\Models\User;
|
||
|
|
use App\Models\Code;
|
||
|
|
use App\Models\Payback;
|
||
|
|
use App\Models\Paylist;
|
||
|
|
use App\Services\Auth;
|
||
|
|
use App\Services\Config;
|
||
|
|
use App\Services\RedisClient;
|
||
|
|
use App\Utils\Tools;
|
||
|
|
|
||
|
|
/**
|
||
|
|
* HomeController
|
||
|
|
*/
|
||
|
|
class HomeController extends BaseController
|
||
|
|
{
|
||
|
|
|
||
|
|
public function __construct()
|
||
|
|
{
|
||
|
|
$configurations = $this->getDomainConfigurations();
|
||
|
|
$redis = new RedisClient();
|
||
|
|
$domain = $_SERVER['HTTP_HOST'];
|
||
|
|
$this->applyDomainTheme($configurations);
|
||
|
|
|
||
|
|
if ($this->domainMatchesConfigHost($configurations, 'host_1', $domain)) {
|
||
|
|
$this->cdn = $redis->get('admin_cdn', 60, function () {
|
||
|
|
return Configurations::where('name', 'admin_cdn')->value('value');
|
||
|
|
});
|
||
|
|
} elseif ($this->domainMatchesConfigHost($configurations, 'host_5', $domain)) {
|
||
|
|
// 如果 host_2 匹配
|
||
|
|
$this->cdn = $redis->get('backup_cdn', 60, function () {
|
||
|
|
return Configurations::where('name', 'backup_cdn')->value('value');
|
||
|
|
});
|
||
|
|
} else {
|
||
|
|
$this->cdn = $redis->get('cdn', 60, function () {
|
||
|
|
return Configurations::where('name', 'cdn')->value('value');
|
||
|
|
});
|
||
|
|
$this->backup_cdn = $redis->get('backup_cdn', 60, function () {
|
||
|
|
return Configurations::where('name', 'backup_cdn')->value('value');
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->seo = $redis->get('seo', 60, function () {
|
||
|
|
return Configurations::where('name', 'seo')->value('value');
|
||
|
|
});
|
||
|
|
$this->language = $redis->get('language', 60, function () {
|
||
|
|
return Configurations::where('name', 'language')->value('value');
|
||
|
|
});
|
||
|
|
$this->appName = Config::get('appName');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function index()
|
||
|
|
{
|
||
|
|
return $this->view()->assign('cdn', $this->cdn)->assign('backup_cdn', $this->backup_cdn)->assign('appName', $this->appName)->assign('seo', $this->seo)->assign('language', $this->language)->display('index.tpl');
|
||
|
|
}
|
||
|
|
|
||
|
|
public function page404($request, $response, $args)
|
||
|
|
{
|
||
|
|
$newResponse = $response->withStatus(404);
|
||
|
|
$newResponse->getBody()->write($this->view()->fetch('404.tpl'));
|
||
|
|
return $newResponse;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function page405($request, $response, $args)
|
||
|
|
{
|
||
|
|
$newResponse = $response->withStatus(405);
|
||
|
|
$newResponse->getBody()->write($this->view()->fetch('405.tpl'));
|
||
|
|
return $newResponse;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function page500($request, $response, $args)
|
||
|
|
{
|
||
|
|
$newResponse = $response->withStatus(500);
|
||
|
|
$newResponse->getBody()->write($this->view()->fetch('500.tpl'));
|
||
|
|
return $newResponse;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|