summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2011-04-03 18:20:55 +1000
committerSavetheinternet <savetheinternet@n0v4.com>2011-04-03 18:20:55 +1000
commit1a378ee6b2aa63bc85966463b13f7ac5ae68138e (patch)
treef4065da8bafab2c349a0a7bc776ff340a90d23b5
parente5d9aa67a11b93256571ddbbe150244ad37849ed (diff)
Public ban messages
-rw-r--r--inc/config.php11
-rw-r--r--inc/mod.php20
-rw-r--r--mod.php18
-rw-r--r--post.php1
4 files changed, 42 insertions, 8 deletions
diff --git a/inc/config.php b/inc/config.php
index 13370614..d4a62d40 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -256,6 +256,12 @@
$config['mod']['noticeboard_display'] = 50;
// Number of entries to summarize and display on the dashboard
$config['mod']['noticeboard_dashboard'] = 5;
+ // Default public ban message
+ $config['mod']['default_ban_message'] = 'USER WAS BANNED FOR THIS POST';
+ // What to append to the post for public bans ("%s" is the message)
+ $config['mod']['ban_message'] = '<span class="public_ban">(%s)</span>';
+ // Wait indefinitely when rebuilding everything
+ $config['mod']['rebuild_timelimit'] = 0;
// Probably best not to change these:
if(!defined('JANITOR')) {
@@ -347,9 +353,8 @@
$config['mod']['noticeboard_post'] = MOD;
// Delete entries from the noticeboard
$config['mod']['noticeboard_delete'] = ADMIN;
-
- // Wait indefinitely when rebuilding everything
- $config['mod']['rebuild_timelimit'] = 0;
+ // Public ban messages; attached to posts
+ $config['mod']['public_ban'] = MOD;
// Mod links (full HTML)
// Correspond to above permission directives
diff --git a/inc/mod.php b/inc/mod.php
index 77c3960c..274159ba 100644
--- a/inc/mod.php
+++ b/inc/mod.php
@@ -146,11 +146,12 @@
return $body;
}
- function form_newBan($ip=null, $reason='', $continue=false, $delete=false, $board=false) {
+ function form_newBan($ip=null, $reason='', $continue=false, $delete=false, $board=false, $allow_public = false) {
+ global $config, $mod;
return '<fieldset><legend>New ban</legend>' .
'<form action="?/ban" method="post">' .
($continue ? '<input type="hidden" name="continue" value="' . htmlentities($continue) . '" />' : '') .
- ($delete ? '<input type="hidden" name="delete" value="' . htmlentities($delete) . '" />' : '') .
+ ($delete || $allow_public ? '<input type="hidden" name="' . (!$allow_public ? 'delete' : 'post') . '" value="' . htmlentities($delete) . '" />' : '') .
($board ? '<input type="hidden" name="board" value="' . htmlentities($board) . '" />' : '') .
'<table>' .
'<tr>' .
@@ -167,6 +168,21 @@
htmlentities($reason) .
'</textarea></td>' .
'</tr>' .
+ ($mod['type'] >= $config['mod']['public_ban'] && $allow_public ?
+ '<tr>' .
+ '<th><label for="message">Message</label></th>' .
+ '<td><input type="checkbox" id="public_message" name="public_message"/>' .
+ ' <input type="text" name="message" id="message" size="35" maxlength="200" value="' . htmlentities($config['mod']['default_ban_message']) . '" />' .
+ ' <span class="unimportant">(public; attached to post)</span></td>' .
+ '<script type="text/javascript">' .
+ 'document.getElementById(\'message\').disabled = true;' .
+ 'document.getElementById(\'public_message\').onchange = function() {' .
+ 'document.getElementById(\'message\').disabled = !this.checked;' .
+ '}' .
+
+ '</script>' .
+ '</tr>'
+ : '') .
'<tr>' .
'<th><label for="length">Length</label></th>' .
'<td><input type="text" name="length" id="length" size="20" maxlength="40" />' .
diff --git a/mod.php b/mod.php
index 8808e896..ebeb9bdd 100644
--- a/mod.php
+++ b/mod.php
@@ -1445,7 +1445,7 @@
// Record the action
modLog('Created a ' . ($expire ? $expire . ' second' : 'permanent') . " ban for {$_POST['ip']} with " . (!empty($_POST['reason']) ? "reason \"{$_POST['reason']}\"" : 'no reason'));
- $query->execute() or error(db_error($query));
+ //$query->execute() or error(db_error($query));
// Delete too
if($mod['type'] >= $config['mod']['delete'] && isset($_POST['delete']) && isset($_POST['board'])) {
@@ -1462,6 +1462,20 @@
buildIndex();
}
+ if($mod['type'] >= $config['mod']['public_ban'] && isset($_POST['post']) && isset($_POST['board']) && isset($_POST['public_message']) && isset($_POST['message'])) {
+ openBoard($_POST['board']);
+
+ $post = round($_POST['post']);
+
+ $query = prepare(sprintf("UPDATE `posts_%s` SET `body` = CONCAT(`body`, :body) WHERE `id` = :id", $board['uri']));
+ $query->bindValue(':id', $post, PDO::PARAM_INT);
+ $query->bindValue(':body', sprintf($config['mod']['ban_message'], htmlentities($_POST['message'])));
+ $query->execute() or error(db_error($query));
+
+ // Record the action
+ modLog("Attached a public ban message for post #{$post}: " . $_POST['message']);
+ }
+
// Redirect
if(isset($_POST['continue']))
header('Location: ' . $_POST['continue'], true, $config['redirect_http']);
@@ -1493,7 +1507,7 @@
$post = $query->fetch();
- $body = form_newBan($post['ip'], null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false, $delete ? $post['id'] : false, $delete ? $boardName : false);
+ $body = form_newBan($post['ip'], null, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : false, $post['id'], $boardName, !$delete);
echo Element('page.html', Array(
'config'=>$config,
diff --git a/post.php b/post.php
index 48c701fd..7c62b8da 100644
--- a/post.php
+++ b/post.php
@@ -493,4 +493,3 @@
}
}
?>
-