From eea4e42609e319b38f14bca9f31cc3327ffaf175 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 9 Sep 2013 01:33:51 +1000 Subject: Add ability to create custom user/permissions groups --- templates/mod/config-editor.html | 9 +++++---- templates/mod/user.html | 20 +++++++------------- templates/mod/users.html | 11 ++++++----- 3 files changed, 18 insertions(+), 22 deletions(-) (limited to 'templates') diff --git a/templates/mod/config-editor.html b/templates/mod/config-editor.html index a43f8cf7..4f4cba93 100644 --- a/templates/mod/config-editor.html +++ b/templates/mod/config-editor.html @@ -42,10 +42,11 @@ {% elseif var.permissions %} {% elseif var.type == 'integer' %} diff --git a/templates/mod/user.html b/templates/mod/user.html index 1bb297af..89240824 100644 --- a/templates/mod/user.html +++ b/templates/mod/user.html @@ -28,21 +28,15 @@ {% if new %} - {% trans 'Class' %} + {% trans 'Group' %} diff --git a/templates/mod/users.html b/templates/mod/users.html index fbd43b32..984c48e1 100644 --- a/templates/mod/users.html +++ b/templates/mod/users.html @@ -15,9 +15,10 @@ {{ user.id }} {{ user.username|e }} - {% if user.type == constant('JANITOR') %}{% trans 'Janitor' %} - {% elseif user.type == constant('MOD') %}{% trans 'Mod' %} - {% elseif user.type == constant('ADMIN') %}{% trans 'Admin' %} + {% if config.mod.groups[user.type] %} + {{ config.mod.groups[user.type] }} + {% else %} + {% trans 'Unknown' %} ({{ user.type }}) {% endif %} @@ -46,10 +47,10 @@ {% endif %} - {% if mod|hasPermission(config.mod.promoteusers) and user.type < constant('ADMIN') %} + {% if mod|hasPermission(config.mod.promoteusers) and user.type < constant(config.mod.groups[0:-1]|last) %} ▲ {% endif %} - {% if mod|hasPermission(config.mod.promoteusers) and user.type > constant('JANITOR') %} + {% if mod|hasPermission(config.mod.promoteusers) and user.type > constant(config.mod.groups|first) %} ▼ {% endif %} {% if mod|hasPermission(config.mod.modlog) %} -- cgit v1.3 From a9b93d27606f75ec0094702e1d0781da4815ee6b Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 9 Sep 2013 19:17:18 +1000 Subject: "Are you sure you want to demote yourself?" --- templates/mod/users.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/mod/users.html b/templates/mod/users.html index 984c48e1..b4c666e1 100644 --- a/templates/mod/users.html +++ b/templates/mod/users.html @@ -51,7 +51,7 @@ ▲ {% endif %} {% if mod|hasPermission(config.mod.promoteusers) and user.type > constant(config.mod.groups|first) %} - ▼ + ▼ {% endif %} {% if mod|hasPermission(config.mod.modlog) %} [{% trans 'log' %}] -- cgit v1.3 From 2fae55c0942f5cb192e5f1caaf57f419a245a3fb Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 9 Sep 2013 19:59:25 +1000 Subject: debug/sql: show "NULL" for null columns --- templates/mod/debug/sql.html | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'templates') diff --git a/templates/mod/debug/sql.html b/templates/mod/debug/sql.html index 755995f9..249d05e3 100644 --- a/templates/mod/debug/sql.html +++ b/templates/mod/debug/sql.html @@ -16,7 +16,13 @@ {% for row in result %} {% for col in row %} - {{ col | e }} + + {% if col != null %} + {{ col | e }} + {% else %} + NULL + {% endif %} + {% endfor %} {% endfor %} -- cgit v1.3 From 5da8f28726078e3dcc3bab427998f88d2e1fea56 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 9 Sep 2013 20:16:13 +1000 Subject: Improvements to ?/debug/antispam and ?/debug/recentc --- inc/mod/pages.php | 12 +++++++++- templates/mod/debug/antispam.html | 26 ++++++++++++++++----- templates/mod/debug/recent_posts.html | 43 +++++++++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 9 deletions(-) (limited to 'templates') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 5af6dc10..ce7bdffb 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2328,11 +2328,21 @@ function mod_debug_recent_posts() { $query = query($query) or error(db_error()); $posts = $query->fetchAll(PDO::FETCH_ASSOC); + // Fetch recent posts from flood prevention cache + $query = query("SELECT * FROM ``flood`` ORDER BY `time` DESC") or error(db_error()); + $flood_posts = $query->fetchAll(PDO::FETCH_ASSOC); + foreach ($posts as &$post) { $post['snippet'] = pm_snippet($post['body']); + foreach ($flood_posts as $flood_post) { + if ($flood_post['time'] == $post['time'] && + $flood_post['posthash'] == make_comment_hex($post['body_nomarkup']) && + $flood_post['filehash'] == $post['filehash']) + $post['in_flood_table'] = true; + } } - mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts)); + mod_page(_('Debug: Recent posts'), 'mod/debug/recent_posts.html', array('posts' => $posts, 'flood_posts' => $flood_posts)); } function mod_debug_sql() { diff --git a/templates/mod/debug/antispam.html b/templates/mod/debug/antispam.html index 95aa61a6..9979a093 100644 --- a/templates/mod/debug/antispam.html +++ b/templates/mod/debug/antispam.html @@ -14,11 +14,14 @@ {{ config.board_abbreviation|sprintf(hash.board) }} - {% if hash.thread %} + {% if hash.thread > 0 %} {{ hash.thread }} + {% elseif hash.thread < 0 %} + Index (page {{ - hash.thread }}) {% else %} - - {% endif %} + {% endif %} + {{ hash.hash }} @@ -28,7 +31,11 @@ {% if hash.expires %} - {{ hash.expires|until }} + {% if hash.expires < time() %} + {{ hash.expires|ago }} ago + {% else %} + {{ hash.expires|until }} + {% endif %} {% else %} - @@ -55,11 +62,14 @@ {{ config.board_abbreviation|sprintf(hash.board) }} - {% if hash.thread %} + {% if hash.thread > 0 %} {{ hash.thread }} + {% elseif hash.thread < 0 %} + Index (page {{ - hash.thread }}) {% else %} - - {% endif %} + {% endif %} + {{ hash.hash }} @@ -69,7 +79,11 @@ {% if hash.expires %} - {{ hash.expires|until }} + {% if hash.expires < time() %} + {{ hash.expires|ago }} ago + {% else %} + {{ hash.expires|until }} + {% endif %} {% else %} - diff --git a/templates/mod/debug/recent_posts.html b/templates/mod/debug/recent_posts.html index b84d24ab..e4eb4f3a 100644 --- a/templates/mod/debug/recent_posts.html +++ b/templates/mod/debug/recent_posts.html @@ -1,3 +1,40 @@ +

+ Flood prevention cache: +

+ + + + + + + + + {% for post in flood_posts %} + + + + + + + + {% endfor %} +
#TimeBoardPost hashFile hash
{{ post.id }} + {{ post.time | ago }} ago + + + {{ config.board_abbreviation|sprintf(post.board) }} + + {{ post.posthash }} + {% if post.filehash %} + {{ post.filehash }} + {% else %} + No file + {% endif %} +
+ +

+ Most recent {{ posts|count }} posts: +

@@ -12,11 +49,13 @@ {% for post in posts %} - ').append($td.find('input[type="submit"]')).insertAfter($td); + } + + if ($td.find('input[type="file"]').length) { + if ($td.find('input[name="file_url"]').length) { + $file_url = $td.find('input[name="file_url"]'); + + // Make a new row for it + $newRow = $(''); + + $file_url.clone().attr('placeholder', _('Upload URL')).appendTo($newRow.find('td')); + $file_url.parent().remove(); + + $newRow.insertBefore(this); + + $td.find('label').remove(); + $td.contents().filter(function() { + return this.nodeType == 3; // Node.TEXT_NODE + }).remove(); + $td.find('input[name="file_url"]').removeAttr('id'); + } + } + } }); -}); + + $postForm.find('textarea[name="body"]').removeAttr('id').removeAttr('cols').attr('placeholder', _('Comment')); + + $postForm.find('br').remove(); + $postForm.find('table').prepend(''); + + $postForm.attr('id', 'quick-reply'); + + $postForm.appendTo($('body')); + + // Synchronise body text with original post form + $('#body').bind('change input propertychange', function() { + $postForm.find('textarea[name="body"]').val($(this).val()); + }); + $postForm.find('textarea[name="body"]').bind('change input propertychange', function() { + $('#body').val($(this).val()); + }); + // Synchronise other inputs + $('form[name="post"] input[type="text"]').bind('change input propertychange', function() { + $postForm.find('input[name="' + $(this).attr('name') + '"]').val($(this).val()); + }); + $postForm.find('input[type="text"]').bind('change input propertychange', function() { + $('form[name="post"] input[name="' + $(this).attr('name') + '"]').val($(this).val()); + }); +}; +$(window).on('cite', function() { + show_quick_reply(); + $('#quick-reply textarea').focus(); +}); diff --git a/templates/main.js b/templates/main.js index 144c5f62..c0961878 100644 --- a/templates/main.js +++ b/templates/main.js @@ -198,6 +198,10 @@ function citeReply(id) { // ??? body.value += '>>' + id + '\n'; } + if ($) { + $(window).trigger('cite', id); + $(body).change(); + } } function rememberStuff() { -- cgit v1.3 From c8f2f00320dd90ff51dec4de0286a9415aba4b0b Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 07:31:05 +1000 Subject: fix bug with quick-reply and make it nicer --- js/quick-reply.js | 13 +++++++++++-- templates/main.js | 6 +++--- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'templates') diff --git a/js/quick-reply.js b/js/quick-reply.js index 3ff6002c..6f5c79d8 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -13,7 +13,9 @@ var show_quick_reply = function(){ if($('div.banner').length == 0) - return; // not index + return; + if($('#quick-reply').length != 0) + return; $('').appendTo($('head')); + console.log('h'); +}; + +var show_quick_reply = function(){ + if($('div.banner').length == 0) + return; + if($('#quick-reply').length != 0) + return; + + do_css(); + var $postForm = $('form[name="post"]').clone(); $postForm.clone(); @@ -193,7 +206,7 @@ var show_quick_reply = function(){ $postForm.fadeOut(100); else $postForm.fadeIn(100); - }); + }).on('stylesheet', do_css); }; $(window).on('cite', function(e, id, with_link) { diff --git a/templates/main.js b/templates/main.js index a395852a..984b1976 100644 --- a/templates/main.js +++ b/templates/main.js @@ -67,6 +67,9 @@ function changeStyle(styleName, link) { if (link) { link.className = 'selected'; } + + if (typeof $ != 'undefined') + $(window).trigger('stylesheet', styleName); } @@ -198,7 +201,7 @@ function citeReply(id, with_link) { // ??? body.value += '>>' + id + '\n'; } - if ($) { + if (typeof $ != 'undefined') { $(window).trigger('cite', [id, with_link]); $(body).change(); } -- cgit v1.3 From 5d108319eb527ad91d362d8eecc3f24303e31dfa Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Mon, 16 Sep 2013 03:51:36 +1000 Subject: fix some weirdness --- js/quick-reply.js | 19 +++++++++++++------ templates/main.js | 20 +++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'templates') diff --git a/js/quick-reply.js b/js/quick-reply.js index 61832ea7..376c44fd 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -206,20 +206,29 @@ var show_quick_reply = function(){ $postForm.attr('id', 'quick-reply'); $postForm.appendTo($('body')).hide(); + $origPostForm = $('form[name="post"]:first'); // Synchronise body text with original post form - $('#body').bind('change input propertychange', function() { + $origPostForm.find('textarea[name="body"]').bind('change input propertychange', function() { $postForm.find('textarea[name="body"]').val($(this).val()); }); $postForm.find('textarea[name="body"]').bind('change input propertychange', function() { - $('#body').val($(this).val()); + $origPostForm.find('textarea[name="body"]').val($(this).val()); + }); + $postForm.find('textarea[name="body"]').focus(function() { + $origPostForm.find('textarea[name="body"]').removeAttr('id'); + $(this).attr('id', 'body'); + }); + $origPostForm.find('textarea[name="body"]').focus(function() { + $postForm.find('textarea[name="body"]').removeAttr('id'); + $(this).attr('id', 'body'); }); // Synchronise other inputs - $('form[name="post"]:first input[type="text"],select').bind('change input propertychange', function() { + $origPostForm.find('input[type="text"],select').bind('change input propertychange', function() { $postForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val()); }); $postForm.find('input[type="text"],select').bind('change input propertychange', function() { - $('form[name="post"]:first [name="' + $(this).attr('name') + '"]').val($(this).val()); + $origPostForm.find('[name="' + $(this).attr('name') + '"]').val($(this).val()); }); if (typeof $postForm.draggable != 'undefined') { @@ -255,8 +264,6 @@ var show_quick_reply = function(){ $postForm.show(); $(window).trigger('quick-reply'); - - $origPostForm = $('form[name="post"]'); $(window).ready(function() { $(window).scroll(function() { diff --git a/templates/main.js b/templates/main.js index 984b1976..235b52db 100644 --- a/templates/main.js +++ b/templates/main.js @@ -185,25 +185,27 @@ function dopost(form) { } function citeReply(id, with_link) { - var body = document.getElementById('body'); + var textarea = document.getElementById('body'); if (document.selection) { // IE - body.focus(); + textarea.focus(); var sel = document.selection.createRange(); sel.text = '>>' + id + '\n'; - } else if (body.selectionStart || body.selectionStart == '0') { - // Mozilla - var start = body.selectionStart; - var end = body.selectionEnd; - body.value = body.value.substring(0, start) + '>>' + id + '\n' + body.value.substring(end, body.value.length); + } else if (textarea.selectionStart || textarea.selectionStart == '0') { + var start = textarea.selectionStart; + var end = textarea.selectionEnd; + textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length); + + textarea.selectionStart += ('>>' + id).length + 1; + textarea.selectionEnd = textarea.selectionStart; } else { // ??? - body.value += '>>' + id + '\n'; + textarea.value += '>>' + id + '\n'; } if (typeof $ != 'undefined') { $(window).trigger('cite', [id, with_link]); - $(body).change(); + $(textarea).change(); } } -- cgit v1.3 From 3e57bb04d7b8fc62761c0fa50b4d062701b1a82a Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 17 Sep 2013 09:15:24 +1000 Subject: Begin upgrade to much better bans table. DO NOT PULL YET; It won't work. --- inc/config.php | 12 +----- inc/database.php | 2 +- inc/filters.php | 44 +++----------------- inc/functions.php | 66 +++++++++--------------------- inc/mod/ban.php | 99 +-------------------------------------------- inc/mod/config-editor.php | 6 +++ inc/mod/pages.php | 64 +++++++---------------------- install.php | 57 +++++++++++++++++++++++++- js/ajax.js | 21 ++++++++-- templates/banned.html | 2 +- templates/mod/ban_list.html | 12 +++--- templates/mod/view_ip.html | 4 +- 12 files changed, 132 insertions(+), 257 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index e6856341..d7bb8ecc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1052,8 +1052,8 @@ * ==================== */ - // Limit how many bans can be removed via the ban list. Set to -1 for no limit. - $config['mod']['unban_limit'] = -1; + // Limit how many bans can be removed via the ban list. Set to false (or zero) for no limit. + $config['mod']['unban_limit'] = false; // Whether or not to lock moderator sessions to IP addresses. This makes cookie theft ineffective. $config['mod']['lock_ip'] = true; @@ -1098,14 +1098,6 @@ // 'color:red;font-weight:bold' // Change tripcode style; optional //); - // Enable IP range bans (eg. "127.*.0.1", "127.0.0.*", and "12*.0.0.1" all match "127.0.0.1"). Puts a - // little more load on the database - $config['ban_range'] = true; - - // Enable CDIR netmask bans (eg. "10.0.0.0/8" for 10.0.0.0.0 - 10.255.255.255). Useful for stopping - // persistent spammers and ban evaders. Again, a little more database load. - $config['ban_cidr'] = true; - // How often (minimum) to purge the ban list of expired bans (which have been seen). Only works when // $config['cache'] is enabled and working. $config['purge_bans'] = 60 * 60 * 12; // 12 hours diff --git a/inc/database.php b/inc/database.php index 861d4c1e..84a050f2 100644 --- a/inc/database.php +++ b/inc/database.php @@ -22,7 +22,7 @@ class PreparedQueryDebug { if ($config['debug'] && $function == 'execute') { if ($this->explain_query) { - $this->explain_query->execute() or error(db_error($explain_query)); + $this->explain_query->execute() or error(db_error($this->explain_query)); } $start = microtime(true); } diff --git a/inc/filters.php b/inc/filters.php index aa6f9025..f06154ba 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -120,47 +120,13 @@ class Filter { if (!isset($this->reason)) error('The ban action requires a reason.'); - $reason = $this->reason; + $this->expires = isset($this->expires) ? $this->expires : false; + $this->reject = isset($this->reject) ? $this->reject : true; + $this->all_boards = isset($this->all_boards) ? $this->all_boards : false; - if (isset($this->expires)) - $expires = time() + $this->expires; - else - $expires = 0; // Ban indefinitely + Bans::new_ban($_SERVER['REMOTE_ADDR'], $this->reason, $this->expires, $this->all_boards ? false : $board['uri'], -1); - if (isset($this->reject)) - $reject = $this->reject; - else - $reject = true; - - if (isset($this->all_boards)) - $all_boards = $this->all_boards; - else - $all_boards = false; - - $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ip, :mod, :set, :expires, :reason, :board, 0)"); - $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); - $query->bindValue(':mod', -1); - $query->bindValue(':set', time()); - - if ($expires) - $query->bindValue(':expires', $expires); - else - $query->bindValue(':expires', null, PDO::PARAM_NULL); - - if ($reason) - $query->bindValue(':reason', $reason); - else - $query->bindValue(':reason', null, PDO::PARAM_NULL); - - - if ($all_boards) - $query->bindValue(':board', null, PDO::PARAM_NULL); - else - $query->bindValue(':board', $board['uri']); - - $query->execute() or error(db_error($query)); - - if ($reject) { + if ($this->reject) { if (isset($this->message)) error($message); diff --git a/inc/functions.php b/inc/functions.php index 4cbd8625..f7421f68 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -18,6 +18,7 @@ require_once 'inc/template.php'; require_once 'inc/database.php'; require_once 'inc/events.php'; require_once 'inc/api.php'; +require_once 'inc/bans.php'; require_once 'inc/lib/gettext/gettext.inc'; // the user is not currently logged in as a moderator @@ -619,9 +620,7 @@ function displayBan($ban) { global $config; if (!$ban['seen']) { - $query = prepare("UPDATE ``bans`` SET `seen` = 1 WHERE `id` = :id"); - $query->bindValue(':id', $ban['id'], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + Bans::seen($ban['id']); } $ban['ip'] = $_SERVER['REMOTE_ADDR']; @@ -650,62 +649,37 @@ function checkBan($board = false) { if (event('check-ban', $board)) return true; - $query_where = array(); - // Simple ban - $query_where[] = "`ip` = :ip"; - // Range ban - if ($config['ban_range']) - $query_where[] = ":ip LIKE REPLACE(REPLACE(`ip`, '%', '!%'), '*', '%') ESCAPE '!'"; - // Subnet mask ban - if ($config['ban_cidr'] && !isIPv6()) - $query_where[] = "( - `ip` REGEXP '^(\[0-9]+\.\[0-9]+\.\[0-9]+\.\[0-9]+\)\/(\[0-9]+)$' - AND - :iplong >= INET_ATON(SUBSTRING_INDEX(`ip`, '/', 1)) - AND - :iplong < INET_ATON(SUBSTRING_INDEX(`ip`, '/', 1)) + POW(2, 32 - SUBSTRING_INDEX(`ip`, '/', -1)) - )"; - - $query = prepare('SELECT * FROM ``bans`` WHERE (`board` IS NULL' . ($board ? ' OR `board` = :board' : '') . - ') AND (' . implode(' OR ', $query_where) . ') ORDER BY `expires` IS NULL, `expires` DESC'); - if ($board) - $query->bindValue(':board', $board); - $query->bindValue(':ip', $_SERVER['REMOTE_ADDR']); - if ($config['ban_cidr'] && !isIPv6()) - $query->bindValue(':iplong', ip2long($_SERVER['REMOTE_ADDR'])); - $query->execute() or error(db_error($query)); + $bans = Bans::find($_SERVER['REMOTE_ADDR'], $board); - while ($ban = $query->fetch(PDO::FETCH_ASSOC)) { + foreach ($bans as &$ban) { if ($ban['expires'] && $ban['expires'] < time()) { - // Ban expired - $query = prepare("DELETE FROM ``bans`` WHERE `id` = :id"); - $query->bindValue(':id', $ban['id'], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - + Bans::delete($ban['id']); if ($config['require_ban_view'] && !$ban['seen']) { - displayBan($ban); + if (!isset($_POST['json_response'])) { + displayBan($ban); + } else { + header('Content-Type: text/json'); + die(json_encode(array('error' => true, 'banned' => true))); + } } } else { - displayBan($ban); + if (!isset($_POST['json_response'])) { + displayBan($ban); + } else { + header('Content-Type: text/json'); + die(json_encode(array('error' => true, 'banned' => true))); + } } } - // I'm not sure where else to put this. It doesn't really matter where; it just needs to be called every now and then to keep the ban list tidy. - purge_bans(); -} - -// No reason to keep expired bans in the database (except those that haven't been viewed yet) -function purge_bans() { - global $config; - + // I'm not sure where else to put this. It doesn't really matter where; it just needs to be called every + // now and then to keep the ban list tidy. if ($config['cache']['enabled'] && $last_time_purged = cache::get('purged_bans_last')) { if (time() - $last_time_purged < $config['purge_bans'] ) return; } - $query = prepare("DELETE FROM ``bans`` WHERE `expires` IS NOT NULL AND `expires` < :time AND `seen` = 1"); - $query->bindValue(':time', time()); - $query->execute() or error(db_error($query)); + Bans::purge(); if ($config['cache']['enabled']) cache::set('purged_bans_last', time()); diff --git a/inc/mod/ban.php b/inc/mod/ban.php index 71173326..82260585 100644 --- a/inc/mod/ban.php +++ b/inc/mod/ban.php @@ -4,102 +4,7 @@ * Copyright (c) 2010-2013 Tinyboard Development Group */ -if (realpath($_SERVER['SCRIPT_FILENAME']) == str_replace('\\', '/', __FILE__)) { - // You cannot request this file directly. - exit; -} +defined('TINYBOARD') or exit; -function parse_time($str) { - if (empty($str)) - return false; - - if (($time = @strtotime($str)) !== false) - return $time; - - if (!preg_match('/^((\d+)\s?ye?a?r?s?)?\s?+((\d+)\s?mon?t?h?s?)?\s?+((\d+)\s?we?e?k?s?)?\s?+((\d+)\s?da?y?s?)?((\d+)\s?ho?u?r?s?)?\s?+((\d+)\s?mi?n?u?t?e?s?)?\s?+((\d+)\s?se?c?o?n?d?s?)?$/', $str, $matches)) - return false; - - $expire = 0; - - if (isset($matches[2])) { - // Years - $expire += $matches[2]*60*60*24*365; - } - if (isset($matches[4])) { - // Months - $expire += $matches[4]*60*60*24*30; - } - if (isset($matches[6])) { - // Weeks - $expire += $matches[6]*60*60*24*7; - } - if (isset($matches[8])) { - // Days - $expire += $matches[8]*60*60*24; - } - if (isset($matches[10])) { - // Hours - $expire += $matches[10]*60*60; - } - if (isset($matches[12])) { - // Minutes - $expire += $matches[12]*60; - } - if (isset($matches[14])) { - // Seconds - $expire += $matches[14]; - } - - return time() + $expire; -} - -function ban($mask, $reason, $length, $board) { - global $mod, $pdo; - - $query = prepare("INSERT INTO ``bans`` VALUES (NULL, :ip, :mod, :time, :expires, :reason, :board, 0)"); - $query->bindValue(':ip', $mask); - $query->bindValue(':mod', $mod['id']); - $query->bindValue(':time', time()); - if ($reason !== '') { - $reason = escape_markup_modifiers($reason); - markup($reason); - $query->bindValue(':reason', $reason); - } else - $query->bindValue(':reason', null, PDO::PARAM_NULL); - - if ($length > 0) - $query->bindValue(':expires', $length); - else - $query->bindValue(':expires', null, PDO::PARAM_NULL); - - if ($board) - $query->bindValue(':board', $board); - else - $query->bindValue(':board', null, PDO::PARAM_NULL); - - $query->execute() or error(db_error($query)); - - modLog('Created a new ' . - ($length > 0 ? preg_replace('/^(\d+) (\w+?)s?$/', '$1-$2', until($length)) : 'permanent') . - ' ban on ' . - ($board ? '/' . $board . '/' : 'all boards') . - ' for ' . - (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "$mask" : utf8tohtml($mask)) . - ' (#' . $pdo->lastInsertId() . ')' . - ' with ' . ($reason ? 'reason: ' . utf8tohtml($reason) . '' : 'no reason')); -} - -function unban($id) { - $query = prepare("SELECT `ip` FROM ``bans`` WHERE `id` = :id"); - $query->bindValue(':id', $id); - $query->execute() or error(db_error($query)); - $mask = $query->fetchColumn(); - - $query = prepare("DELETE FROM ``bans`` WHERE `id` = :id"); - $query->bindValue(':id', $id); - $query->execute() or error(db_error($query)); - - if ($mask) - modLog("Removed ban #{$id} for " . (filter_var($mask, FILTER_VALIDATE_IP) !== false ? "$mask" : utf8tohtml($mask))); -} +// This file is no longer used. diff --git a/inc/mod/config-editor.php b/inc/mod/config-editor.php index 4493fd2b..0f6dbc9a 100644 --- a/inc/mod/config-editor.php +++ b/inc/mod/config-editor.php @@ -1,5 +1,11 @@ bindValue(':ip', $ip); - $query->execute() or error(db_error($query)); - $args['bans'] = $query->fetchAll(PDO::FETCH_ASSOC); + $args['bans'] = Bans::find($ip, false, true); } if (hasPermission($config['mod']['view_notes'])) { @@ -839,7 +834,7 @@ function mod_ban() { require_once 'inc/mod/ban.php'; - ban($_POST['ip'], $_POST['reason'], parse_time($_POST['length']), $_POST['board'] == '*' ? false : $_POST['board']); + Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board']); if (isset($_POST['redirect'])) header('Location: ' . $_POST['redirect'], true, $config['redirect_http']); @@ -865,58 +860,27 @@ function mod_bans($page_no = 1) { if (preg_match('/^ban_(\d+)$/', $name, $match)) $unban[] = $match[1]; } - if (isset($config['mod']['unban_limit'])){ - if (count($unban) <= $config['mod']['unban_limit'] || $config['mod']['unban_limit'] == -1){ - if (!empty($unban)) { - query('DELETE FROM ``bans`` WHERE `id` = ' . implode(' OR `id` = ', $unban)) or error(db_error()); + if (isset($config['mod']['unban_limit']) && $config['mod']['unban_limit'] && count($unban) > $config['mod']['unban_limit']) + error(sprintf($config['error']['toomanyunban'], $config['mod']['unban_limit'], count($unban))); - foreach ($unban as $id) { - modLog("Removed ban #{$id}"); - } + foreach ($unban as $id) { + Bans::delete($id, true); } - } else { - error(sprintf($config['error']['toomanyunban'], $config['mod']['unban_limit'], count($unban) )); - } - - } else { - - if (!empty($unban)) { - query('DELETE FROM ``bans`` WHERE `id` = ' . implode(' OR `id` = ', $unban)) or error(db_error()); - - foreach ($unban as $id) { - modLog("Removed ban #{$id}"); - } - } - - } header('Location: ?/bans', true, $config['redirect_http']); + return; } - if ($config['mod']['view_banexpired']) { - $query = prepare("SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` ORDER BY (`expires` IS NOT NULL AND `expires` < :time), `set` DESC LIMIT :offset, :limit"); - } else { - // Filter out expired bans - $query = prepare("SELECT ``bans``.*, `username` FROM ``bans`` INNER JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE `expires` = 0 OR `expires` > :time ORDER BY `set` DESC LIMIT :offset, :limit"); - } - $query->bindValue(':time', time(), PDO::PARAM_INT); - $query->bindValue(':limit', $config['mod']['banlist_page'], PDO::PARAM_INT); - $query->bindValue(':offset', ($page_no - 1) * $config['mod']['banlist_page'], PDO::PARAM_INT); - $query->execute() or error(db_error($query)); - $bans = $query->fetchAll(PDO::FETCH_ASSOC); + $bans = Bans::list_all(($page_no - 1) * $config['mod']['banlist_page'], $config['mod']['banlist_page']); if (empty($bans) && $page_no > 1) error($config['error']['404']); - $query = prepare("SELECT COUNT(*) FROM ``bans``"); - $query->execute() or error(db_error($query)); - $count = $query->fetchColumn(); - foreach ($bans as &$ban) { - if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false) - $ban['real_ip'] = true; + if (filter_var($ban['mask'], FILTER_VALIDATE_IP) !== false) + $ban['single_addr'] = true; } - mod_page(_('Ban list'), 'mod/ban_list.html', array('bans' => $bans, 'count' => $count)); + mod_page(_('Ban list'), 'mod/ban_list.html', array('bans' => $bans, 'count' => Bans::count())); } @@ -1217,7 +1181,7 @@ function mod_ban_post($board, $delete, $post, $token = false) { if (isset($_POST['ip'])) $ip = $_POST['ip']; - ban($ip, $_POST['reason'], parse_time($_POST['length']), $_POST['board'] == '*' ? false : $_POST['board']); + Bans::new_ban($_POST['ip'], $_POST['reason'], $_POST['length'], $_POST['board'] == '*' ? false : $_POST['board']); if (isset($_POST['public_message'], $_POST['message'])) { // public ban message diff --git a/install.php b/install.php index 639a90c9..69be6300 100644 --- a/install.php +++ b/install.php @@ -1,7 +1,7 @@ fetch(PDO::FETCH_ASSOC)) { + $query = prepare("INSERT INTO ``bans_new_temp`` VALUES + (NULL, :ipstart, :ipend, :created, :expires, :board, :creator, :reason, :seen, NULL)"); + + $range = Bans::parse_range($ban['ip']); + if ($range === false) { + // Invalid retard ban; just skip it. + continue; + } + + $query->bindValue(':ipstart', $range[0]); + if ($range[1] !== false && $range[1] != $range[0]) + $query->bindValue(':ipend', $range[1]); + else + $query->bindValue(':ipend', null, PDO::PARAM_NULL); + + $query->bindValue(':created', $ban['set']); + + if ($ban['expires']) + $query->bindValue(':expires', $ban['expires']); + else + $query->bindValue(':expires', null, PDO::PARAM_NULL); + + if ($ban['board']) + $query->bindValue(':board', $ban['board']); + else + $query->bindValue(':board', null, PDO::PARAM_NULL); + + $query->bindValue(':creator', $ban['mod']); + + if ($ban['reason']) + $query->bindValue(':reason', $ban['reason']); + else + $query->bindValue(':reason', null, PDO::PARAM_NULL); + + $query->bindValue(':seen', $ban['seen']); + $query->execute() or error(db_error($query)); + } case false: // Update version number file_write($config['has_installed'], VERSION); diff --git a/js/ajax.js b/js/ajax.js index a063890b..74cfe9c0 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -43,9 +43,23 @@ $(window).ready(function() { }, success: function(post_response) { if (post_response.error) { - alert(post_response.error); - $(form).find('input[type="submit"]').val(submit_txt); - $(form).find('input[type="submit"]').removeAttr('disabled'); + if (post_response.banned) { + // You are banned. Must post the form normally so the user can see the ban message. + do_not_ajax = true; + $(form).find('input[type="submit"]').each(function() { + var $replacement = $(''); + $replacement.attr('name', $(this).attr('name')); + $replacement.val(submit_txt); + $(this) + .after($replacement) + .replaceWith($('').val(submit_txt)); + }); + $(form).submit(); + } else { + alert(post_response.error); + $(form).find('input[type="submit"]').val(submit_txt); + $(form).find('input[type="submit"]').removeAttr('disabled'); + } } else if (post_response.redirect && post_response.id) { if (!$(form).find('input[name="thread"]').length) { document.location = post_response.redirect; @@ -84,7 +98,6 @@ $(window).ready(function() { }, error: function(xhr, status, er) { // An error occured - // TODO do_not_ajax = true; $(form).find('input[type="submit"]').each(function() { var $replacement = $(''); diff --git a/templates/banned.html b/templates/banned.html index a4498cf5..065d61e2 100644 --- a/templates/banned.html +++ b/templates/banned.html @@ -30,7 +30,7 @@ {% endif %}

{% trans %}Your ban was filed on{% endtrans %} - {{ ban.set|date(config.ban_date) }} {% trans %}and{% endtrans %} + {{ ban.created|date(config.ban_date) }} {% trans %}and{% endtrans %} {% if ban.expires and time() >= ban.expires %} {% trans %} has since expired. Refresh the page to continue.{% endtrans %} {% elseif ban.expires %} diff --git a/templates/mod/ban_list.html b/templates/mod/ban_list.html index f8826ade..83674544 100644 --- a/templates/mod/ban_list.html +++ b/templates/mod/ban_list.html @@ -17,10 +17,10 @@

- + @@ -124,7 +124,7 @@ - + -- cgit v1.3 From 803f0c8ce1487ea791824197de9d1ee140127838 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Tue, 17 Sep 2013 09:35:13 +1000 Subject: Fix search for new bans table --- inc/mod/pages.php | 7 ++++--- templates/mod/ban_list.html | 2 +- templates/mod/search_results.html | 14 +++++++------- 3 files changed, 12 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 0b9c92a1..c1f35c87 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -289,7 +289,7 @@ function mod_search($type, $search_query_escaped, $page_no = 1) { } if ($type == 'bans') { - $query = 'SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `mod` = ``mods``.`id` WHERE ' . $sql_like . ' ORDER BY (`expires` IS NOT NULL AND `expires` < UNIX_TIMESTAMP()), `created` DESC'; + $query = 'SELECT ``bans``.*, `username` FROM ``bans`` LEFT JOIN ``mods`` ON `creator` = ``mods``.`id` WHERE ' . $sql_like . ' ORDER BY (`expires` IS NOT NULL AND `expires` < UNIX_TIMESTAMP()), `created` DESC'; $sql_table = 'bans'; if (!hasPermission($config['mod']['view_banlist'])) error($config['error']['noaccess']); @@ -317,8 +317,9 @@ function mod_search($type, $search_query_escaped, $page_no = 1) { if ($type == 'bans') { foreach ($results as &$ban) { - if (filter_var($ban['ip'], FILTER_VALIDATE_IP) !== false) - $ban['real_ip'] = true; + $ban['mask'] = Bans::range_to_string(array($ban['ipstart'], $ban['ipend'])); + if (filter_var($ban['mask'], FILTER_VALIDATE_IP) !== false) + $ban['single_addr'] = true; } } diff --git a/templates/mod/ban_list.html b/templates/mod/ban_list.html index 83674544..b41cef28 100644 --- a/templates/mod/ban_list.html +++ b/templates/mod/ban_list.html @@ -46,7 +46,7 @@ {% if ban.expires == 0 %} - {% else %} - {{ (ban.expires - ban.set + time()) | until }} + {{ (ban.expires - ban.created + time()) | until }} {% endif %}
Time
+ {{ post.time | ago }} ago - {{ config.board_abbreviation|sprintf(post.board) }} + + {{ config.board_abbreviation|sprintf(post.board) }} + {% if post.thread %} -- cgit v1.3 From c4a6116722f7798967a8424cb47aad2a319e7a9c Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 00:42:20 +1000 Subject: Optionally show page navigation bar at the top too. --- inc/config.php | 6 ++++++ stylesheets/style.css | 4 ++++ templates/index.html | 22 ++++++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) (limited to 'templates') diff --git a/inc/config.php b/inc/config.php index 897c8a42..90e66a2c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -797,6 +797,12 @@ // Whether or not to put brackets around the whole board list $config['boardlist_wrap_bracket'] = true; + // Show page navigation links at the top as well. + $config['page_nav_top'] = false; + + // Show "Catalog" link in page navigation. Use with the Catalog theme. + // $config['catalog_link'] = 'catalog.html'; + // Board categories. Only used in the "Categories" theme. // $config['categories'] = array( // 'Group Name' => array('a', 'b', 'c'), diff --git a/stylesheets/style.css b/stylesheets/style.css index c1725e35..10ddb8e8 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -319,6 +319,10 @@ div.pages { border-right: 1px solid #B7C5D9; border-bottom: 1px solid #B7C5D9; } +div.pages.top { + display: inline-block; + padding: 4px 8px; +} div.pages a.selected { color: black; font-weight: bolder; diff --git a/templates/index.html b/templates/index.html index d5e6cd18..0b4fed8d 100644 --- a/templates/index.html +++ b/templates/index.html @@ -25,6 +25,17 @@ {% include 'post_form.html' %} + {% if config.page_nav_top %} +
+ {% for page in pages %} + [{{ page.num }}]{% if loop.last %} {% endif %} + {% endfor %} {{ btn.next }} + {% if config.catalog_link %} + | Catalog + {% endif %} +
+ {% endif %} + {% if config.global_message %}
{{ config.global_message }}
{% endif %}
@@ -33,9 +44,16 @@ {{ body }} {% include 'report_delete.html' %}
-
{{ btn.prev }} {% for page in pages %} + +
+ {{ btn.prev }} {% for page in pages %} [{{ page.num }}]{% if loop.last %} {% endif %} - {% endfor %} {{ btn.next }}
+ {% endfor %} {{ btn.next }} + {% if config.catalog_link %} + | Catalog + {% endif %} +
+ {{ boardlist.bottom }}

Powered by Tinyboard {{ config.version }} | Tinyboard Copyright © 2010-2013 Tinyboard Development Group

-- cgit v1.3 From 92550d50848e5873002bfbe5428a568d4f8b6a00 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 00:53:45 +1000 Subject: Better position of top nav bar? Shit css --- stylesheets/style.css | 3 +++ templates/index.html | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) (limited to 'templates') diff --git a/stylesheets/style.css b/stylesheets/style.css index 10ddb8e8..aa5d121e 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -322,6 +322,9 @@ div.pages { div.pages.top { display: inline-block; padding: 4px 8px; + margin-top: 40px; + float: left; + position: absolute; } div.pages a.selected { color: black; diff --git a/templates/index.html b/templates/index.html index 0b4fed8d..b8c5d1ae 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,8 +7,19 @@ {{ boardlist.top }} + + {% if config.page_nav_top %} +
+ {% for page in pages %} + [{{ page.num }}]{% if loop.last %} {% endif %} + {% endfor %} + {{ btn.next }} +
+ {% endif %} + {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %} +

{{ board.url }} - {{ board.title|e }}

@@ -25,17 +36,6 @@ {% include 'post_form.html' %} - {% if config.page_nav_top %} -
- {% for page in pages %} - [{{ page.num }}]{% if loop.last %} {% endif %} - {% endfor %} {{ btn.next }} - {% if config.catalog_link %} - | Catalog - {% endif %} -
- {% endif %} - {% if config.global_message %}
{{ config.global_message }}
{% endif %}
-- cgit v1.3 From 961e3d3fe0e0abb7be956532091372ce7a00bafa Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 05:46:27 +1000 Subject: dock top nav bar in top right corner for now, because it looks shit everywhere else --- stylesheets/style.css | 12 +++++++----- templates/index.html | 18 +++++++++--------- 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'templates') diff --git a/stylesheets/style.css b/stylesheets/style.css index aa5d121e..894fa3e4 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -320,11 +320,13 @@ div.pages { border-bottom: 1px solid #B7C5D9; } div.pages.top { - display: inline-block; - padding: 4px 8px; - margin-top: 40px; - float: left; - position: absolute; + display: block; + padding: 5px 8px; + margin-bottom: 5px; + position: fixed; + top: 0; + right: 0; + opacity: 0.9; } div.pages a.selected { color: black; diff --git a/templates/index.html b/templates/index.html index b8c5d1ae..0458ed5a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -8,15 +8,6 @@ {{ boardlist.top }} - {% if config.page_nav_top %} -
- {% for page in pages %} - [{{ page.num }}]{% if loop.last %} {% endif %} - {% endfor %} - {{ btn.next }} -
- {% endif %} - {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} {% if config.url_banner %}{% endif %} @@ -36,6 +27,15 @@ {% include 'post_form.html' %} + {% if config.page_nav_top %} +
+ {% for page in pages %} + [{{ page.num }}]{% if loop.last %} {% endif %} + {% endfor %} + {{ btn.next }} +
+ {% endif %} + {% if config.global_message %}
{{ config.global_message }}
{% endif %}
-- cgit v1.3 From 9a8cebe4a1c298b3d6ff13332a2daded90506d3c Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 15 Sep 2013 07:17:02 +1000 Subject: add real quick reply (wtf was the other thing?) --- js/quick-reply-old.js | 46 ++++++++++++++ js/quick-reply.js | 168 +++++++++++++++++++++++++++++++++++++++++--------- templates/main.js | 4 ++ 3 files changed, 188 insertions(+), 30 deletions(-) create mode 100644 js/quick-reply-old.js (limited to 'templates') diff --git a/js/quick-reply-old.js b/js/quick-reply-old.js new file mode 100644 index 00000000..ea504b48 --- /dev/null +++ b/js/quick-reply-old.js @@ -0,0 +1,46 @@ +/* + * quick-reply.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/quick-reply.js + * + * Released under the MIT license + * Copyright (c) 2012 Michael Save + * + * Usage: + * $config['quick_reply'] = true; + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/quick-reply.js'; + * + */ + +$(document).ready(function(){ + if($('div.banner').length != 0) + return; // not index + + txt_new_topic = $('form[name=post] input[type=submit]').val(); + txt_new_reply = txt_new_topic == _('Submit') ? txt_new_topic : new_reply_string; + + undo_quick_reply = function() { + $('div.banner').remove(); + $('form[name=post] input[type=submit]').val(txt_new_topic); + $('form[name=post] input[name=quick-reply]').remove(); + } + + $('div.post.op').each(function() { + var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); + $('['+_("Quick reply")+']').insertAfter($(this).children('p.intro').children('a:last')).click(function() { + $('div.banner').remove(); + $('') + .insertBefore('form[name=post]'); + $('form[name=post] input[type=submit]').val(txt_new_reply); + + $('').appendTo($('form[name=post]')); + + $('form[name=post] textarea').select(); + + window.scrollTo(0, 0); + + return false; + }); + }); +}); + diff --git a/js/quick-reply.js b/js/quick-reply.js index ea504b48..3ff6002c 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -3,44 +3,152 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/quick-reply.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save + * Copyright (c) 2013 Michael Save * * Usage: - * $config['quick_reply'] = true; * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/quick-reply.js'; * */ -$(document).ready(function(){ - if($('div.banner').length != 0) +var show_quick_reply = function(){ + if($('div.banner').length == 0) return; // not index + + $('').appendTo($('head')); + + var $postForm = $('form[name="post"]').clone(); + + $postForm.clone(); - txt_new_topic = $('form[name=post] input[type=submit]').val(); - txt_new_reply = txt_new_topic == _('Submit') ? txt_new_topic : new_reply_string; - - undo_quick_reply = function() { - $('div.banner').remove(); - $('form[name=post] input[type=submit]').val(txt_new_topic); - $('form[name=post] input[name=quick-reply]').remove(); - } - - $('div.post.op').each(function() { - var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); - $('['+_("Quick reply")+']').insertAfter($(this).children('p.intro').children('a:last')).click(function() { - $('div.banner').remove(); - $('') - .insertBefore('form[name=post]'); - $('form[name=post] input[type=submit]').val(txt_new_reply); - - $('').appendTo($('form[name=post]')); - - $('form[name=post] textarea').select(); - - window.scrollTo(0, 0); - - return false; - }); + $dummyStuff = $('
').appendTo($postForm); + + $postForm.find('table tr').each(function() { + var $th = $(this).children('th'); + var $td = $(this).children('td'); + if ($th.length && $td.length) { + $td.attr('colspan', 2); + + if ($td.find('input[type="text"]').length) { + // Replace
with input placeholders + $td.find('input[type="text"]') + .removeAttr('size') + .attr('placeholder', $th.clone().children().remove().end().text()); + } + + // Move anti-spam nonsense and remove + $th.contents().appendTo($dummyStuff); + $th.remove(); + + if ($td.find('input[name="password"]').length) { + // Hide password field + $(this).hide(); + } + + // Fix submit button + if ($td.find('input[type="submit"]').length) { + $td.removeAttr('colspan'); + $('
' + _('Quick Reply') + '
- {% if ban.real_ip %} - {{ ban.ip }} + {% if ban.single_addr %} + {{ ban.mask }} {% else %} - {{ ban.ip|e }} + {{ ban.mask }} {% endif %} @@ -38,8 +38,8 @@ {% endif %} - - {{ ban.set|ago }} ago + + {{ ban.created|ago }} ago @@ -77,7 +77,7 @@ {% endif %} {% endif %} - {% elseif ban.mod == -1 %} + {% elseif ban.creator == -1 %} system {% else %} {% trans 'deleted?' %} diff --git a/templates/mod/view_ip.html b/templates/mod/view_ip.html index e2dad7af..f73c5d5a 100644 --- a/templates/mod/view_ip.html +++ b/templates/mod/view_ip.html @@ -100,7 +100,7 @@
{% trans 'IP' %}{{ ban.ip }}{{ ban.mask }}
{% trans 'Reason' %}
{% trans 'Set' %}{{ ban.set|date(config.post_date) }}{{ ban.created|date(config.post_date) }}
{% trans 'Expires' %} diff --git a/templates/mod/search_results.html b/templates/mod/search_results.html index 0c87f75f..0d3c2a10 100644 --- a/templates/mod/search_results.html +++ b/templates/mod/search_results.html @@ -56,10 +56,10 @@ {% for ban in results %} - {% if ban.real_ip %} - {{ ban.ip }} + {% if ban.single_addr %} + {{ ban.mask }} {% else %} - {{ ban.ip|e }} + {{ ban.mask|e }} {% endif %} @@ -77,15 +77,15 @@ {% endif %} - - {{ ban.set|ago }} ago + + {{ ban.created|ago }} ago {% if ban.expires == 0 %} - {% else %} - {{ (ban.expires - ban.set + time()) | until }} + {{ (ban.expires - ban.created + time()) | until }} {% endif %} @@ -116,7 +116,7 @@ {% endif %} {% endif %} - {% elseif ban.mod == -1 %} + {% elseif ban.creator == -1 %} system {% else %} {% trans 'deleted?' %} -- cgit v1.3