Gazelle/sections/wiki/delete.php

35 lines
755 B
PHP
Raw Normal View History

2011-03-28 14:21:28 +00:00
<?
2013-12-24 08:00:55 +00:00
if (!check_perms('admin_manage_wiki')) {
error(403);
}
if (!isset($_GET['id']) || !is_number($_GET['id'])) {
2011-03-28 14:21:28 +00:00
error(404);
}
2013-12-24 08:00:55 +00:00
$ID = (int)$_GET['id'];
if ($ID == INDEX_ARTICLE) {
error('You cannot delete the main wiki article.');
}
2011-03-28 14:21:28 +00:00
2013-06-06 08:01:03 +00:00
$DB->query("
SELECT Title
FROM wiki_articles
WHERE ID = $ID");
2011-03-28 14:21:28 +00:00
2013-07-10 00:08:53 +00:00
if (!$DB->has_results()) {
2011-03-28 14:21:28 +00:00
error(404);
}
2012-07-25 08:00:15 +00:00
list($Title) = $DB->next_record(MYSQLI_NUM, false);
2011-03-28 14:21:28 +00:00
//Log
2013-06-06 08:01:03 +00:00
Misc::write_log("Wiki article $ID ($Title) was deleted by ".$LoggedUser['Username']);
2011-03-28 14:21:28 +00:00
//Delete
$DB->query("DELETE FROM wiki_articles WHERE ID = $ID");
$DB->query("DELETE FROM wiki_aliases WHERE ArticleID = $ID");
$DB->query("DELETE FROM wiki_revisions WHERE ID = $ID");
2013-12-24 08:00:55 +00:00
Wiki::flush_aliases();
Wiki::flush_article($ID);
2011-03-28 14:21:28 +00:00
header("location: wiki.php");