Skip to content

Commit

Permalink
修复密码错误时 html 输出不完整的 bug; 压缩部分动态输出的 JavaScript 代码
Browse files Browse the repository at this point in the history
  • Loading branch information
lc6464 committed Feb 16, 2021
1 parent 969bf39 commit 279603a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 21 deletions.
23 changes: 22 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ function CheckPassword(bool $IsReturnBool = false)
return $return;
}
if (!$return) { // 若 $IsReturnBool 为 false 且验证失败,则执行 dl_error
global $system_start_time;
dl_error("密码错误", "请检查你输入的密码!");
exit; // 结束进程
echo Footer;
die('</div><script>console.log("后端计算时间:' . (microtime(true) - $system_start_time) . 's");</script></body></html>');
}
} else { // 若不校验密码则永远 true
return true;
Expand Down Expand Up @@ -313,3 +315,22 @@ function GetList(string $Shorturl, string $Dir, bool $IsRoot, string $Password)
}
return $result;
}
$getConstant = function (string $name) {
return constant($name);
};
$JSCode = array("get" => function (string $value) {
$value = preg_replace('# *//.*#', '', $value);
$value = preg_replace('#/\*.*?\*/#s', '', $value);
$value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value);
$value = preg_replace('#([,;{])[ \t]*?\r?\n[ \t]*([^ \t])#', '$1 $2', $value);
$value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value);
$value = preg_replace('#([^ \t])[ \t]*?\r?\n[ \t]*?\}#', '$1 }', $value);
$value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value);
$value = preg_replace('#([,;{])\t+#', '$1 ', $value);
$value = preg_replace('#\t+\}#', ' }', $value);
$value = preg_replace('#(\r?\n|\t| ){2,}#', '$1', $value);
return $value;
}, "echo" => function (string $value) {
global $JSCode;
echo $JSCode['get']($value);
});
49 changes: 29 additions & 20 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,26 +87,35 @@
<script src="static/color.js"></script>
<script src="static/functions.js"></script>
<script defer src="static/ready.js"></script>
<script>
function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, filesize) {
<?php
if (IsConfirmDownload)
echo 'Swal.fire({
title: "' . Language["ConfirmTitle"] . '",
html: "' . Language["ConfirmText"] . '",
icon: "warning",
showCancelButton: true,
confirmButtonText: "' . Language["ConfirmmButtonText"] . '",
reverseButtons: true
}).then(function(e) {
if (e.isConfirmed) {
dl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, filesize);
}
});';
else echo 'dl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, filesize);';
?>
<?php
if (isset($_POST["surl"])) {
echo '<script>';
if (IsConfirmDownload) {
$Language = Language;
$JSCode['echo'](
<<<Function
function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, filesize) {
Swal.fire({
title: "{$Language["ConfirmTitle"]}",
html: "{$Language["ConfirmText"]}",
icon: "warning",
showCancelButton: true,
confirmButtonText: "{$Language["ConfirmmButtonText"]}",
reverseButtons: true
}).then(function(e) {
if (e.isConfirmed) {
dl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, filesize);
}
</script>
});
}
Function
);
} else {
echo 'let confirmdl = dl;';
}
echo '</script>';
}
?>
</head>

<body>
Expand Down Expand Up @@ -138,7 +147,7 @@ function confirmdl(fs_id, timestamp, sign, randsk, share_id, uk, bdstoken, files
} elseif (isset($_GET["usersettings"])) { // 用户设置页面
require("usersettings.php");
} elseif (isset($_POST["surl"])) { // 解析链接页面
echo '<script>setTimeout(() => Swal.fire(\'' . Language["TipTitle"] . '\',\'' . Language["TimeoutTip"] . '\',\'info\'), 300000);</script>';
echo '<script>setTimeout(() => Swal.fire("' . Language["TipTitle"] . '","' . Language["TimeoutTip"] . '","info"), 300000);</script>';
CheckPassword();
$surl = $_POST["surl"]; // 含有1
$pwd = (!empty($_POST["pwd"])) ? $_POST["pwd"] : "";
Expand Down

0 comments on commit 279603a

Please sign in to comment.