wusheng233喵喵ICP备案+酱酱窝存档记录


源代码: admin-index3.php

<?php
include __DIR__ . "/../password.php";
require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../Assets/helpers.php";
require_once __DIR__ . "/helpers.php";
require_once __DIR__ . "/../init.php";

if (!empty($_GET["password"]) && $_GET["password"] == $password) {

?>
    <!DOCTYPE html>
    <html lang="zh-CN">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <!-- 引入MDUI的CSS -->
        <link rel="stylesheet" href="/Assets/css/mdui.min.css">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>编辑公告の后台</title>
        <link rel="stylesheet" href="/Assets/css/mdui.min.css">
        <link href="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.css" rel="stylesheet">
        <script src="https://cdn.bootcdn.net/ajax/libs/nprogress/0.2.0/nprogress.min.js"></script>
        <script>
            NProgress.configure({
                minimum: 0.08,
                showSpinner: true,
                parent: '#item-list'
            })
            window.addEventListener('load', () => {
                NProgress.done();
            });
            document.addEventListener('readystatechange', () => {
                if (document.readyState === 'interactive') {
                    NProgress.start();
                } else if (document.readyState === 'complete') {
                    NProgress.done();
                }
            });
        </script>
        <div class="mdui-container mdui-typo">
            <h1 class="mdui-typo-display-1">
                编辑公告の后台
                <a no-pjax href="index2.php?password=<?php echo htmlspecialchars($_GET["password"]); ?>">前往 - 列表</a>
                |
                <a no-pjax href="index1.php?password=<?php echo htmlspecialchars($_GET["password"]); ?>">前往 - 等待审核列表</a>
            </h1>
            <div class="mdui-divider"></div>
            <div id="item-list">
                <?php
                if (!empty($_POST["notice_content"])) {
                    // 火绒会误报
                    $filePath = "$global_assets_data_dir/notice.md";

                    // 备份旧的公告文件
                    if (file_exists($filePath)) {
                        $backupFilePath = dirname($filePath) . '/notice_backup_' . date('Ymd_His') . '.md';
                        if (!co--------py($filePath, $backupFilePath)) {
                            echo ('公告文件备份失败,但不影响更新公告');
                        }
                    }
                    //file_put_contents($filePath, $_POST['notice_content']);

                    header("Location: ?&password={$_GET['password']}&success=true");
                }
                ?>
                <form method="POST" class="mdui-typo">
                    <div class="mdui-textfield mdui-textfield-floating-label">
                        <label class="mdui-textfield-label">编辑公告内容</label>
                        <textarea class="mdui-textfield-input" name="notice_content"><?= file_get_contents($global_assets_data_dir . '/notice.md'); ?></textarea>
                    </div>
                    <button type="submit" class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent">保存</button>
                    <?php
                    if (isset($_GET['success'])) {
                        $success = $_GET['success'] === 'true';
                        $message = $success ? ($_GET['msg'] ?? '操作成功!') : ($_GET['msg'] ?? '操作失败!');
                        echo $message;
                    }
                    ?>
                </form>
                <div class="mdui-typo">
                    内容预览:
                    <pre>
                    <?php
                    $Parsedown = new Parsedown();
                    echo $Parsedown->text($global_site_notice);
                    ?>
                    </pre>
                </div>
            </div>
        </div>
        <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
        <script src="https://cdn.bootcdn.net/ajax/libs/mdui/1.0.2/js/mdui.min.js"></script>
    </head>

    </html>
<?php
} else {
    http_response_code(404);
}
这个网站由wusheng233制作,生成了静态页面