diff --git a/inc/config.php b/inc/config.php index b65c13ba..ec90df46 100644 --- a/inc/config.php +++ b/inc/config.php @@ -959,6 +959,7 @@ $config['mod']['link_ban'] = '[B]'; $config['mod']['link_bandelete'] = '[B&D]'; $config['mod']['link_deletefile'] = '[F]'; + $config['mod']['link_spoilerimage'] = '[S]'; $config['mod']['link_deletebyip'] = '[D+]'; $config['mod']['link_deletebyip_global'] = '[D++]'; $config['mod']['link_sticky'] = '[Sticky]'; diff --git a/inc/display.php b/inc/display.php index 8c7252ec..49565585 100644 --- a/inc/display.php +++ b/inc/display.php @@ -345,6 +345,10 @@ class Post { if (!empty($this->file) && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id); + // Spoiler file (keep post) + if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images']) + $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], 'Spoiler File', 'Are you sure you want to spoiler this file?', $board['uri'] . '/spoiler/' . $this->id); + // Edit post if (hasPermission($config['mod']['editpost'], $board['uri'], $this->mod)) $built .= ' ' . $config['mod']['link_editpost'] . ''; @@ -445,6 +449,10 @@ class Thread { // Delete file (keep post) if (!empty($this->file) && $this->file != 'deleted' && hasPermission($config['mod']['deletefile'], $board['uri'], $this->mod)) $built .= ' ' . secure_link_confirm($config['mod']['link_deletefile'], _('Delete file'), _('Are you sure you want to delete this file?'), $board['dir'] . 'deletefile/' . $this->id); + + // Spoiler file (keep post) + if (!empty($this->file) && $this->file != "deleted" && $this->file != null && $this->thumb != 'spoiler' && hasPermission($config['mod']['spoilerimage'], $board['uri'], $this->mod) && $config['spoiler_images']) + $built .= ' ' . secure_link_confirm($config['mod']['link_spoilerimage'], 'Spoiler File', 'Are you sure you want to spoiler this file?', $board['uri'] . '/spoiler/' . $this->id); // Sticky if (hasPermission($config['mod']['sticky'], $board['uri'], $this->mod)) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 706d747d..8b0c400e 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1360,6 +1360,33 @@ function mod_deletefile($board, $post) { header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); } +function mod_spoiler_image($board, $post) { + global $config, $mod; + + if (!openBoard($board)) + error($config['error']['noboard']); + + if (!hasPermission($config['mod']['spoilerimage'], $board)) + error($config['error']['noaccess']); + + // Delete file + $query = prepare(sprintf("UPDATE `posts_%s` SET `thumb` = :thumb, `thumbwidth` = :thumbwidth, `thumbheight` = :thumbheight WHERE `id` = :id", $board)); + $query->bindValue(':thumb', "spoiler"); + $query->bindValue(':thumbwidth', 128, PDO::PARAM_INT); + $query->bindValue(':thumbheight', 128, PDO::PARAM_INT); + $query->bindValue(':id', $post, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + // Record the action + modLog("Spoilered file from post #{$post}"); + + // Rebuild board + buildIndex(); + + // Redirect + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); +} + function mod_deletebyip($boardName, $post, $global = false) { global $config, $mod, $board;