From a1f300cc8f2627c815b6fd054e8d6f3a88eb5ed9 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Tue, 22 Feb 2011 17:38:38 +1100 Subject: Manage boards --- mod.php | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) (limited to 'mod.php') diff --git a/mod.php b/mod.php index 0dfb8262..d438cd9d 100644 --- a/mod.php +++ b/mod.php @@ -194,6 +194,84 @@ header('Location: ' . $_SERVER['HTTP_REFERER'], true, $config['redirect_http']); else header('Location: ?/reports', true, $config['redirect_http']); + } elseif(preg_match('/^\/board\/(\w+)(\/delete)?$/', $query, $matches)) { + if($mod['type'] < $config['mod']['manageboards']) error($config['error']['noaccess']); + + if(!openBoard($matches[1])) + error($config['error']['noboard']); + + if(isset($matches[2]) && $matches[2] == '/delete') { + if($mod['type'] < $config['mod']['deleteboard']) error($config['error']['noaccess']); + // Delete board + + // Delete entire board directory + rrmdir($board['uri'] . '/'); + + // Delete posting table + $query = query(sprintf("DROP TABLE IF EXISTS `posts_%s`", $board['uri'])) or error(db_error()); + + // Clear reports + $query = prepare("DELETE FROM `reports` WHERE `board` = :id"); + $query->bindValue(':id', $board['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + // Delete from table + $query = prepare("DELETE FROM `boards` WHERE `id` = :id"); + $query->bindValue(':id', $board['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + header('Location: ?/', true, $config['redirect_http']); + } elseif(isset($_POST['title']) && isset($_POST['subtitle'])) { + $query = prepare("UPDATE `boards` SET `title` = :title, `subtitle` = :subtitle WHERE `id` = :id"); + $query->bindValue(':title', utf8tohtml($_POST['title'], true)); + + if(!empty($_POST['subtitle'])) + $query->bindValue(':subtitle', utf8tohtml($_POST['subtitle'], true)); + else + $query->bindValue(':subtitle', null, PDO::PARAM_NULL); + + $query->bindValue(':id', $board['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + openBoard($board['uri']); + } + + $body = + '
' . + sprintf($config['board_abbreviation'], $board['uri']) . '' . + ' - ' . $board['name'] . '' . + + // Begin form + '
' . + + '' . + + '' . + '' . + '' . + + '
URI' . $board['uri'] . '
Title
Subtitle
' . + + '' . + + // End form + '
' . + + // Delete button + ($mod['type'] >= $config['mod']['deleteboard'] ? + '

Delete board

' + :'') . + + '
'; + + echo Element('page.html', Array( + 'index'=>$config['root'], + 'title'=>'Manage – ' . sprintf($config['board_abbreviation'], $board['uri']), + 'body'=>$body, + 'mod'=>true + )); } elseif(preg_match('/^\/bans$/', $query)) { if($mod['type'] < $config['mod']['view_banlist']) error($config['error']['noaccess']); @@ -368,6 +446,10 @@ 'subtitle' => $_POST['subtitle'] ); + // HTML characters + $b['title'] = utf8tohtml($b['title'], true); + $b['subtitle'] = utf8tohtml($b['subtitle'], true); + // Check required fields if(empty($b['uri'])) error(sprintf($config['error']['required'], 'URI')); -- cgit v1.3