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,84 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
namespace MRBS\Errors\Formatter;
|
||||
|
||||
use Monolog\Formatter\NormalizerFormatter;
|
||||
use function MRBS\escape_html;
|
||||
|
||||
abstract class GeneralFormatter extends NormalizerFormatter
|
||||
{
|
||||
private $useHTML;
|
||||
|
||||
public function __construct(?string $dateFormat = null, $useHTML=false)
|
||||
{
|
||||
$this->useHTML = $useHTML;
|
||||
parent::__construct($dateFormat);
|
||||
}
|
||||
|
||||
|
||||
public function format(array $record): string
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
if (!isset($record['context']['details']))
|
||||
{
|
||||
// This will be when the logger is called directly from the MRBS code, rather than the Errors class.
|
||||
$record['context']['details'] = $record['channel'] . '.' .$record['level_name'] . ' in ' . $record['extra']['file'] . ' at line ' . $record['extra']['line'];
|
||||
}
|
||||
|
||||
$lines[] = $this->escape($record['context']['details']);
|
||||
$lines[] = $this->escape($record['message']);
|
||||
|
||||
// Add in any stacktrace
|
||||
if (!empty($record['context']['backtrace']))
|
||||
{
|
||||
foreach ($record['context']['backtrace'] as $call)
|
||||
{
|
||||
$lines[] = $this->escape($call);
|
||||
}
|
||||
}
|
||||
|
||||
// Add in the GET and POST variables
|
||||
foreach(['$_GET' => 'get', '$_POST' => 'post'] as $name => $var)
|
||||
{
|
||||
if (isset($record['context'][$var]))
|
||||
{
|
||||
$line = $this->escape(print_r($record['context'][$var], true));
|
||||
if ($this->useHTML)
|
||||
{
|
||||
// Replace spaces with non-breaking spaces
|
||||
$line = str_replace(' ', ' ', $line);
|
||||
}
|
||||
// Remove the final new line
|
||||
$line = rtrim($line);
|
||||
if ($this->useHTML)
|
||||
{
|
||||
$line = str_replace("\n", "<br>\n", $line);
|
||||
}
|
||||
$lines[] = "$name: $line";
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->useHTML)
|
||||
{
|
||||
// Make the first line bold.
|
||||
$lines[0] = '<b>' . $lines[0] . '</b>';
|
||||
}
|
||||
|
||||
$result = implode(($this->useHTML) ? "<br>\n" : "\n", $lines);
|
||||
|
||||
if ($this->useHTML)
|
||||
{
|
||||
// Wrap it in a paragraph
|
||||
$result = "<p>\n" . $result . "\n</p>\n";
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
private function escape(string $value): string
|
||||
{
|
||||
return ($this->useHTML) ? escape_html($value) : $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user