summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/mod/pages.php40
-rw-r--r--mod.php1
-rw-r--r--templates/mod/dashboard.html3
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) %}
<li><a href="?/rebuild">{% trans 'Rebuild' %}</a></li>
- {% if config.cache.enabled %}
- <li><a href="?/flushcache">{% trans 'Clear cache' %}</a></li>
- {% endif %}
{% endif %}
{% if mod|hasPermission(config.mod.show_config) %}