From 19ea6e3d44186544c15166aa13e4faa1b8804c99 Mon Sep 17 00:00:00 2001 From: Michael Save Date: Sat, 21 Apr 2012 15:29:57 +1000 Subject: [PATCH] ?/deletefile --- inc/mod/pages.php | 40 +++++++++++++++++++++++++++++++++++++--- mod.php | 1 + templates/mod/dashboard.html | 3 --- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index d111a480..5bba5145 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -85,6 +85,9 @@ function mod_dashboard() { function mod_noticeboard($page_no = 1) { global $config, $pdo, $mod; + if ($page_no < 1) + error($config['error']['404']); + if (!hasPermission($config['mod']['noticeboard'])) error($config['error']['noaccess']); @@ -113,7 +116,7 @@ function mod_noticeboard($page_no = 1) { $query->execute() or error(db_error($query)); $noticeboard = $query->fetchAll(PDO::FETCH_ASSOC); - if (empty($noticeboard)) + if (empty($noticeboard) && $page_no > 1) error($config['error']['404']); $query = prepare("SELECT COUNT(*) FROM `noticeboard`"); @@ -126,6 +129,9 @@ function mod_noticeboard($page_no = 1) { function mod_log($page_no = 1) { global $config; + if ($page_no < 1) + error($config['error']['404']); + if (!hasPermission($config['mod']['modlog'])) error($config['error']['noaccess']); @@ -135,7 +141,7 @@ function mod_log($page_no = 1) { $query->execute() or error(db_error($query)); $logs = $query->fetchAll(PDO::FETCH_ASSOC); - if (empty($logs)) + if (empty($logs) && $page_no > 1) error($config['error']['404']); $query = prepare("SELECT COUNT(*) FROM `modlogs`"); @@ -308,6 +314,9 @@ function mod_ban() { function mod_bans($page_no = 1) { global $config; + if ($page_no < 1) + error($config['error']['404']); + if (!hasPermission($config['mod']['view_banlist'])) error($config['error']['noaccess']); @@ -344,7 +353,7 @@ function mod_bans($page_no = 1) { $query->execute() or error(db_error($query)); $bans = $query->fetchAll(PDO::FETCH_ASSOC); - if (empty($bans)) + if (empty($bans) && $page_no > 1) error($config['error']['404']); $query = prepare("SELECT COUNT(*) FROM `bans`"); @@ -505,6 +514,26 @@ function mod_delete($board, $post) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); } +function mod_deletefile($board, $post) { + global $config, $mod; + + if (!openBoard($board)) + error($config['error']['noboard']); + + if (!hasPermission($config['mod']['deletefile'], $board)) + error($config['error']['noaccess']); + + // Delete file + deleteFile($post); + // Record the action + modLog("Deleted file from post #{$post}"); + // Rebuild board + buildIndex(); + + // Redirect + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); +} + function mod_user($uid) { global $config, $mod; @@ -699,6 +728,11 @@ function mod_rebuild() { $rebuilt_scripts = array(); if (isset($_POST['rebuild_cache'])) { + if ($config['cache']['enabled']) { + $log[] = 'Flushing cache'; + Cache::flush(); + } + $log[] = 'Clearing template cache'; load_twig(); $twig->clearCacheFiles(); diff --git a/mod.php b/mod.php index 4495ae52..f3726c24 100644 --- a/mod.php +++ b/mod.php @@ -47,6 +47,7 @@ $pages = array( '!^/(\w+)/delete/(\d+)$!' => 'delete', // delete post '!^/(\w+)/ban(&delete)?/(\d+)$!' => 'ban_post', // ban poster + '!^/(\w+)/deletefile/(\d+)$!' => 'deletefile', // delete file from post '!^/(\w+)/(un)?lock/(\d+)$!' => 'lock', // lock thread '!^/(\w+)/(un)?sticky/(\d+)$!' => 'sticky', // sticky thread '!^/(\w+)/bump(un)?lock/(\d+)$!' => 'bumplock', // "bumplock" thread diff --git a/templates/mod/dashboard.html b/templates/mod/dashboard.html index 984aa03e..fc510ac7 100644 --- a/templates/mod/dashboard.html +++ b/templates/mod/dashboard.html @@ -84,9 +84,6 @@ {% if mod|hasPermission(config.mod.rebuild) %}
  • {% trans 'Rebuild' %}
  • - {% if config.cache.enabled %} -
  • {% trans 'Clear cache' %}
  • - {% endif %} {% endif %} {% if mod|hasPermission(config.mod.show_config) %}