MRBS 1.12.2 等保2.0二级整改完整提交
包含:登录失败锁定、90天密码有效期、30分钟会话超时、 强制改密、登录审计日志、屏幕水印、企业背景图、 备案信息固定底部、favicon、JS空集合保护、 会话过期体验优化(403 JSON)、display_errors 关闭、 固定 key 根治 Integrity check failed 等全部改动 注意:config.inc.php/.htaccess/.user.ini 含敏感信息, 通过 .gitignore 排除,勿推送到公开仓库。
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace MRBS\Intl;
|
||||
|
||||
use MRBS\Language;
|
||||
use MRBS\System;
|
||||
|
||||
class LocaleSwitcher
|
||||
{
|
||||
private $category;
|
||||
private $locale;
|
||||
private $old_locale;
|
||||
|
||||
|
||||
public function __construct(int $category, string $locale)
|
||||
{
|
||||
$this->category = $category;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
|
||||
public function switch()
|
||||
{
|
||||
// It's not worth testing whether the new locale is the same as the old one, thereby saving us setting
|
||||
// the locale again. That's because setting the locale on Unix systems seems to be about 100 times
|
||||
// faster than on Windows. So on Unix systems, it's not worth worrying about. And on Windows, we have
|
||||
// to set the locale again anyway in case another script running in the same process has changed the
|
||||
// locale since we first set it. See the warning on the PHP manual page for setlocale():
|
||||
//
|
||||
// "The locale information is maintained per process, not per thread. If you are running PHP on a
|
||||
// multithreaded server API like IIS or Apache on Windows, you may experience sudden changes in locale
|
||||
// settings while a script is running, though the script itself never called setlocale(). This happens
|
||||
// due to other scripts running in different threads of the same process at the same time, changing the
|
||||
// process-wide locale using setlocale()."
|
||||
$this->old_locale = setlocale($this->category, '0');
|
||||
Language::setLocale($this->category, $this->locale);
|
||||
}
|
||||
|
||||
|
||||
public function restore()
|
||||
{
|
||||
if (!isset($this->old_locale))
|
||||
{
|
||||
throw new \RuntimeException("switch() must be called before restore().");
|
||||
}
|
||||
|
||||
if (false === setlocale($this->category, $this->old_locale))
|
||||
{
|
||||
// Shouldn't happen as the old locale was what the system told us it was.
|
||||
throw new \RuntimeException("Could not restore locale to '" . $this->old_locale . "'");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user