S2OJ/web/app/controllers/subdomain/blog/blog_delete.php

38 lines
1.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
requirePHPLib('form');
if (!Auth::check() && UOJConfig::$data['switch']['force-login']) {
redirectToLogin();
}
if (!isNormalUser($myUser) && UOJConfig::$data['switch']['force-login']) {
become403Page();
}
$REQUIRE_LIB['bootstrap5'] = '';
if (!UOJContext::hasBlogPermission()) {
become403Page();
}
if (!isset($_GET['id']) || !validateUInt($_GET['id']) || !($blog = queryBlog($_GET['id'])) || !UOJContext::isHis($blog)) {
become404Page();
}
$delete_form = new UOJForm('delete');
$delete_form->handle = function() {
global $blog;
deleteBlog($blog['id']);
};
$delete_form->submit_button_config['class_str'] = 'btn btn-danger';
$delete_form->submit_button_config['text'] = '是的,我确定要删除';
$delete_form->succ_href = "/archive";
$delete_form->runAtServer();
?>
<?php echoUOJPageHeader('删除博客 - ' . HTML::stripTags($blog['title'])) ?>
<h1 class="h3 text-center">
您真的要删除博客 “<?= $blog['title'] ?>” <span class="fs-5">(博客 ID<?= $blog['id'] ?></span>吗?该操作不可逆!
</h1>
<?php $delete_form->printHTML(); ?>
<?php echoUOJPageFooter() ?>