MRBS 1.12.2 等保2.0二级整改完整提交
Docker image / push (push) Canceled after 0s

包含:登录失败锁定、90天密码有效期、30分钟会话超时、
强制改密、登录审计日志、屏幕水印、企业背景图、
备案信息固定底部、favicon、登录页JS修复等全部改动
This commit is contained in:
人事系统开发
2026-09-08 21:19:47 +08:00
commit 48092cab42
2221 changed files with 659586 additions and 0 deletions
+246
View File
@@ -0,0 +1,246 @@
<?php
declare(strict_types=1);
namespace MRBS;
include 'defaultincludes.inc';
require_once 'functions_test.inc';
error_reporting(-1);
ini_set('display_errors', '1');
$color_fail = 'pink';
$color_pass = 'palegreen';
function do_asort(
string $locale,
array &$array,
int $flags=\Collator::SORT_REGULAR,
int $numeric_collation = \Collator::DEFAULT_VALUE
)
{
global $color_fail, $color_pass;
$php_collator = new \Collator($locale);
$php_collator->setAttribute(\Collator::NUMERIC_COLLATION, $numeric_collation);
$mrbs_collator = new \MRBS\Intl\Collator($locale);
$mrbs_collator->setAttribute(\MRBS\Intl\Collator::NUMERIC_COLLATION, $numeric_collation);
$strengths = [
\Collator::PRIMARY,
\Collator::SECONDARY,
\Collator::TERTIARY,
\Collator::QUATERNARY,
\Collator::IDENTICAL
];
foreach ($strengths as $strength)
{
$php_collator->setStrength($strength);
$mrbs_collator->setStrength($strength);
echo "<tr>";
echo "<td>asort</td>";
echo "<td>" . escape_html($locale) . "</td>";
echo "<td>" . implode(',', $array) . "</td>";
echo "<td>" . escape_html($flags) . "</td>";
echo "<td>" . $php_collator->getAttribute(\Collator::NUMERIC_COLLATION) . "</td>";
echo "<td>" . $php_collator->getStrength() . "</td>";
$php_array = $array;
$mrbs_array = $array;
$php_collator->asort($php_array, $flags);
$mrbs_collator->asort($mrbs_array, $flags);
echo "<td>[" . implode(',', array_keys($php_array)) . '] [' . implode(',', array_values($php_array)) . "]</td>";
echo "<td>[" . implode(',', array_keys($mrbs_array)) . '] [' . implode(',', array_values($mrbs_array)) . "]</td>";
// Compare the results
$passed = ($php_array === $mrbs_array);
$color = ($passed) ? $color_pass : $color_fail;
echo '<td style="background-color: ' . $color . '">';
echo ($passed) ? 'Pass' : 'Fail';
echo "</td>";
echo "</tr>\n";
}
echo "<tr><td colspan=\"9\"></td></tr>\n";
}
function test_asort()
{
echo "<h1>Testing asort()</h1>\n";
echo "<table>\n";
echo thead_html(['locale', 'array', 'flags', 'numeric_collation', 'strength']);
echo "<tbody>\n";
$locale = 'en-US';
$array = ['aò', 'Ao', 'ao'];
do_asort($locale, $array);
$locale = 'en-US';
$array = ['a', 'b', 'A', 'B'];
do_asort($locale, $array);
$locale = 'en-US';
$array = ['aBc', 'abC', 'Abc', 'ABc'];
do_asort($locale, $array);
$locale = 'sv';
$array = ['ö', 'ä', 'å'];
do_asort($locale, $array);
$locale = 'sv-SE';
$array = ['ö', 'ä', 'å'];
do_asort($locale, $array);
$locale = 'sv';
$array = ['ö', 'ä', 'å', 'o', 'a', 'e'];
do_asort($locale, $array);
$locale = 'en-US';
$array = ['a10', 'b2', 'A2', 'B10'];
do_asort($locale, $array);
do_asort($locale, $array, \Collator::SORT_NUMERIC);
$array = ['a1', 'a2', 'a10', 'b2', 'b10'];
do_asort($locale, $array, \Collator::SORT_NUMERIC);
$numeric_collation = \Collator::ON;
$locale = 'fr';
$array = ['1', '2', '10'];
do_asort($locale, $array, \Collator::SORT_REGULAR, $numeric_collation);
do_asort($locale, $array, \Collator::SORT_NUMERIC, $numeric_collation);
$array = ['a', 'à', 'â', 'e', 'é'];
do_asort($locale, $array);
$array = array_reverse($array);
do_asort($locale, $array);
$array = ['a', 'A'];
do_asort($locale, $array);
$array = array_reverse($array);
do_asort($locale, $array);
$array = ['Ba', 'aB'];
do_asort($locale, $array);
$array = array_reverse($array);
do_asort($locale, $array);
$array = ['ABC', 'aBc', 'Abc', 'Abc', 'ABc'];
do_asort($locale, $array);
$array = ['ABC', 'aBc', 'Abc', 'Abc', 'ABc'];
do_asort($locale, $array, \Collator::SORT_STRING);
$locale = 'no';
$array = ['æ', 'ø', 'å', 'A', 'AA', 'AB', 'Åb', 'åb'];
do_asort($locale, $array, \Collator::SORT_REGULAR, $numeric_collation);
$locale = 'sv';
$array = ['ä', 'ö', 'å', 'A', 'AA', 'Åb', 'åb'];
do_asort($locale, $array, \Collator::SORT_REGULAR, $numeric_collation);
$locale = 'en-GB';
$array = ['a', 'b', 'c', 'A', 'B', 'aa', 'Aa', 'AB', 'z', 'zb'];
do_asort($locale, $array, \Collator::SORT_REGULAR, $numeric_collation);
echo "</tbody>\n";
echo "</table>\n";
}
function do_compare(string $locale, string $string1, string $string2, int $strength=\Collator::DEFAULT_STRENGTH)
{
global $color_fail, $color_pass;
$php_collator = new \Collator($locale);
$php_collator->setStrength($strength);
$mrbs_collator = new \MRBS\Intl\Collator($locale);
$mrbs_collator->setStrength($strength);
echo "<tr>";
echo "<td>compare</td>";
echo "<td>" . escape_html($locale) . "</td>";
echo "<td>" . escape_html($string1) . "</td>";
echo "<td>" . escape_html($string2) . "</td>";
echo "<td>" . escape_html($strength) . "</td>";
$php_compare = $php_collator->compare($string1, $string2);
$mrbs_compare = $mrbs_collator->compare($string1, $string2);
echo "<td>$php_compare</td>";
echo "<td>$mrbs_compare</td>";
// Compare the results
$passed = ($php_compare === $mrbs_compare);
$color = ($passed) ? $color_pass : $color_fail;
echo '<td style="background-color: ' . $color . '">';
echo ($passed) ? 'Pass' : 'Fail';
echo "</td>";
echo "</tr>\n";
}
function test_compare()
{
echo "<h1>Testing compare()</h1>\n";
echo "<table>\n";
echo thead_html(['locale', 'string1', 'string2', 'strength']);
echo "<tbody>\n";
$tests = [
['locale' => 'fr', 'string1' => 'é', 'string2' => 'è'],
['locale' => 'fr', 'string1' => 'è', 'string2' => 'é'],
['locale' => 'en-GB', 'string1' => 'é', 'string2' => 'è'],
['locale' => 'en-GB', 'string1' => 'Séan', 'string2' => 'Sean'],
['locale' => 'en-GB', 'string1' => 'a', 'string2' => 'A'],
['locale' => 'en-GB', 'string1' => 'A', 'string2' => 'a'],
['locale' => 'en-GB', 'string1' => 'a', 'string2' => 'b'],
['locale' => 'en-GB', 'string1' => 'bA', 'string2' => 'Ba']
];
$strengths = [
\Collator::PRIMARY,
\Collator::SECONDARY,
\Collator::TERTIARY,
\Collator::QUATERNARY,
\Collator::IDENTICAL
];
foreach ($tests as $test)
{
list('locale' => $locale, 'string1' => $string1, 'string2' => $string2) = $test;
foreach ($strengths as $strength)
{
do_compare($locale, $string1, $string2, $strength);
}
echo "<tr><td colspan=\"8\"></td></tr>\n";
}
echo "</tbody>\n";
echo "</table>\n";
}
$loaded_extensions = get_loaded_extensions();
echo "PHP version: " . PHP_VERSION;
echo "<br>\n";
echo "mbstring enabled: " . var_export(in_array('mbstring', $loaded_extensions), true);
echo "<br>\n";
echo "intl enabled: " . var_export(in_array('intl', $loaded_extensions), true);
echo "<br>\n";
echo "<br>\n";
if (!in_array('intl', $loaded_extensions))
{
die("This test needs the 'intl' PHP extension to be loaded.");
}
test_constants('Collator');
test_asort();
test_compare();