Use interface constants instead of a dedicate enum class for config types.
This commit is contained in:
parent
5f0e94350f
commit
59a09cf4ac
25 changed files with 95 additions and 106 deletions
38
misuzu.php
38
misuzu.php
|
@ -5,7 +5,7 @@ use Index\Autoloader;
|
|||
use Index\Environment;
|
||||
use Index\Data\ConnectionFailedException;
|
||||
use Index\Data\DbTools;
|
||||
use Misuzu\Config\CfgType;
|
||||
use Misuzu\Config\IConfig;
|
||||
use Misuzu\Config\DbConfig;
|
||||
use Misuzu\Net\IPAddress;
|
||||
use Misuzu\Users\User;
|
||||
|
@ -87,18 +87,18 @@ $cfg->reload();
|
|||
|
||||
Config::init($cfg);
|
||||
|
||||
Mailer::init($cfg->getValue('mail.method', CfgType::T_STR), [
|
||||
'host' => $cfg->getValue('mail.host', CfgType::T_STR),
|
||||
'port' => $cfg->getValue('mail.port', CfgType::T_INT, 25),
|
||||
'username' => $cfg->getValue('mail.username', CfgType::T_STR),
|
||||
'password' => $cfg->getValue('mail.password', CfgType::T_STR),
|
||||
'encryption' => $cfg->getValue('mail.encryption', CfgType::T_STR),
|
||||
'sender_name' => $cfg->getValue('mail.sender.name', CfgType::T_STR),
|
||||
'sender_addr' => $cfg->getValue('mail.sender.address', CfgType::T_STR),
|
||||
Mailer::init($cfg->getValue('mail.method', IConfig::T_STR), [
|
||||
'host' => $cfg->getValue('mail.host', IConfig::T_STR),
|
||||
'port' => $cfg->getValue('mail.port', IConfig::T_INT, 25),
|
||||
'username' => $cfg->getValue('mail.username', IConfig::T_STR),
|
||||
'password' => $cfg->getValue('mail.password', IConfig::T_STR),
|
||||
'encryption' => $cfg->getValue('mail.encryption', IConfig::T_STR),
|
||||
'sender_name' => $cfg->getValue('mail.sender.name', IConfig::T_STR),
|
||||
'sender_addr' => $cfg->getValue('mail.sender.address', IConfig::T_STR),
|
||||
]);
|
||||
|
||||
// replace this with a better storage mechanism
|
||||
define('MSZ_STORAGE', $cfg->getValue('storage.path', CfgType::T_STR, MSZ_ROOT . '/store'));
|
||||
define('MSZ_STORAGE', $cfg->getValue('storage.path', IConfig::T_STR, MSZ_ROOT . '/store'));
|
||||
if(!is_dir(MSZ_STORAGE))
|
||||
mkdir(MSZ_STORAGE, 0775, true);
|
||||
|
||||
|
@ -148,10 +148,10 @@ if(!MSZ_DEBUG) {
|
|||
Template::init($msz, $twigCache ?? null, MSZ_DEBUG);
|
||||
|
||||
Template::set('globals', [
|
||||
'site_name' => $cfg->getValue('site.name', CfgType::T_STR, 'Misuzu'),
|
||||
'site_description' => $cfg->getValue('site.desc', CfgType::T_STR),
|
||||
'site_url' => $cfg->getValue('site.url', CfgType::T_STR),
|
||||
'site_twitter' => $cfg->getValue('social.twitter', CfgType::T_STR),
|
||||
'site_name' => $cfg->getValue('site.name', IConfig::T_STR, 'Misuzu'),
|
||||
'site_description' => $cfg->getValue('site.desc', IConfig::T_STR),
|
||||
'site_url' => $cfg->getValue('site.url', IConfig::T_STR),
|
||||
'site_twitter' => $cfg->getValue('social.twitter', IConfig::T_STR),
|
||||
]);
|
||||
|
||||
Template::addPath(MSZ_TEMPLATES);
|
||||
|
@ -203,7 +203,7 @@ if($authToken->isValid()) {
|
|||
}
|
||||
}
|
||||
|
||||
CSRF::setGlobalSecretKey($cfg->getValue('csrf.secret', CfgType::T_STR, 'soup'));
|
||||
CSRF::setGlobalSecretKey($cfg->getValue('csrf.secret', IConfig::T_STR, 'soup'));
|
||||
CSRF::setGlobalIdentity(
|
||||
UserSession::hasCurrent()
|
||||
? UserSession::getCurrent()->getToken()
|
||||
|
@ -213,15 +213,15 @@ CSRF::setGlobalIdentity(
|
|||
function mszLockdown(): void {
|
||||
global $misuzuBypassLockdown, $cfg;
|
||||
|
||||
if($cfg->getValue('private.enabled', CfgType::T_BOOL)) {
|
||||
if($cfg->getValue('private.enabled', IConfig::T_BOOL)) {
|
||||
$onLoginPage = $_SERVER['PHP_SELF'] === url('auth-login');
|
||||
$onPasswordPage = parse_url($_SERVER['PHP_SELF'], PHP_URL_PATH) === url('auth-forgot');
|
||||
$misuzuBypassLockdown = !empty($misuzuBypassLockdown) || $onLoginPage;
|
||||
|
||||
if(!$misuzuBypassLockdown) {
|
||||
if(UserSession::hasCurrent()) {
|
||||
$privatePermCat = $cfg->getValue('private.perm.cat', CfgType::T_STR);
|
||||
$privatePermVal = $cfg->getValue('private.perm.val', CfgType::T_INT);
|
||||
$privatePermCat = $cfg->getValue('private.perm.cat', IConfig::T_STR);
|
||||
$privatePermVal = $cfg->getValue('private.perm.val', IConfig::T_INT);
|
||||
|
||||
if(!empty($privatePermCat) && $privatePermVal > 0) {
|
||||
if(!perms_check_user($privatePermCat, User::getCurrent()->getId(), $privatePermVal)) {
|
||||
|
@ -230,7 +230,7 @@ function mszLockdown(): void {
|
|||
User::unsetCurrent();
|
||||
}
|
||||
}
|
||||
} elseif(!$onLoginPage && !($onPasswordPage && $cfg->getValue('private.allow_password_reset', CfgType::T_BOOL, true))) {
|
||||
} elseif(!$onLoginPage && !($onPasswordPage && $cfg->getValue('private.allow_password_reset', IConfig::T_BOOL, true))) {
|
||||
url_redirect('auth-login');
|
||||
exit;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue