From 9070b061ee6c3ccd2ee8fa4988e57f63acc0f5fc Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sat, 20 Sep 2014 15:20:00 +0000 Subject: [PATCH 1/4] Bug fix: users were banned from /0/ if they had a ban anywhere else Conflicts: inc/bans.php --- inc/bans.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/inc/bans.php b/inc/bans.php index d5225e95..c5132ef3 100644 --- a/inc/bans.php +++ b/inc/bans.php @@ -122,13 +122,13 @@ class Bans { $query = prepare('SELECT ``bans``.*' . ($get_mod_info ? ', `username`' : '') . ' FROM ``bans`` ' . ($get_mod_info ? 'LEFT JOIN ``mods`` ON ``mods``.`id` = `creator`' : '') . ' - WHERE - (' . ($board ? '(`board` IS NULL OR `board` = :board) AND' : '') . ' - (`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`))) + WHERE ' . ($id ? 'id = :id' : ' + (' . ($board !== false ? '(`board` IS NULL OR `board` = :board) AND' : '') . ' + (`ipstart` = :ip OR (:ip >= `ipstart` AND :ip <= `ipend`)))') . ' ORDER BY `expires` IS NULL, `expires` DESC'); - if ($board) - $query->bindValue(':board', $board); + if ($board !== false) + $query->bindValue(':board', $board, PDO::PARAM_STR); $query->bindValue(':ip', inet_pton($ip)); $query->execute() or error(db_error($query)); From 1ce9fb8174cd7f5fb39f87b83095caf6a47258f1 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sat, 20 Sep 2014 15:27:26 +0000 Subject: [PATCH 2/4] Allow users to choose their favorite boards for sites w/too many to put in bar --- js/favorites.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 js/favorites.js diff --git a/js/favorites.js b/js/favorites.js new file mode 100644 index 00000000..30bf12d0 --- /dev/null +++ b/js/favorites.js @@ -0,0 +1,75 @@ +/* + * favorites.js - Allow user to favorite boards and put them in the bar + * + * Copyright (c) 2014 Fredrick Brennan + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/favorites.js'; + */ + +if (!localStorage.favorites) { + localStorage.favorites = '[]'; +} + +function favorite(board) { + var favorites = JSON.parse(localStorage.favorites); + favorites.push(board); + localStorage.favorites = JSON.stringify(favorites); +}; + +function unfavorite(board) { + var favorites = JSON.parse(localStorage.favorites); + var index = $.inArray(board, favorites); + if (~index) { + favorites.splice(index, 1); + } + localStorage.favorites = JSON.stringify(favorites); +}; + +function handle_boards(data) { + var boards = new Array(); + data = JSON.parse(data); + + $.each(data, function(k, v) { + boards.push(''+v+''); + }) + + if (boards[0]) { + return $('').append(' [ '+boards.slice(0,10).join(" / ")+' ] '); + } +} + +function add_favorites() { + $('.favorite-boards').remove(); + + var boards = handle_boards(localStorage.favorites); + + $('.boardlist').append(boards); +}; + +if (active_page == 'thread' || active_page == 'index') { + $(document).ready(function(){ + var favorites = JSON.parse(localStorage.favorites); + var is_board_favorite = ~$.inArray(board_name, favorites); + console.log(is_board_favorite); + + $('header>h1').append('\u2605'); + add_favorites(); + + $('#favorite-star').on('click', function(e) { + e.preventDefault(); + if (!$(this).data('active')) { + favorite(board_name); + add_favorites(); + $(this).css('color', 'yellow'); + $(this).data('active', true); + } else { + unfavorite(board_name); + add_favorites(); + $(this).css('color', 'grey'); + $(this).data('active', false); + } + }); + }); +} From 23c73ca83943fb720addebe461286bc4ff3679b9 Mon Sep 17 00:00:00 2001 From: Fredrick Brennan Date: Sat, 20 Sep 2014 15:21:50 +0000 Subject: [PATCH 3/4] Allow the user to decide whether or not he wants to display his country --- inc/config.php | 4 ++++ js/quick-reply.js | 2 ++ post.php | 2 +- templates/post_form.html | 2 +- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/config.php b/inc/config.php index 3dd8eb6c..e2cc2ebd 100644 --- a/inc/config.php +++ b/inc/config.php @@ -274,6 +274,7 @@ 'file_url', 'json_response', 'user_flag', + 'no_country' ); // Enable reCaptcha to make spam even harder. Rarely necessary. @@ -531,6 +532,9 @@ // Attach country flags to posts. $config['country_flags'] = false; + // Allow the user to decide whether or not he wants to display his country + $config['allow_no_country'] = false; + // Load all country flags from one file $config['country_flags_condensed'] = true; $config['country_flags_condensed_css'] = 'static/flags/flags.css'; diff --git a/js/quick-reply.js b/js/quick-reply.js index 93cab334..07fe4aef 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -266,6 +266,8 @@ $postForm.find('input[type="file"]').parent() .removeAttr('colspan') .after($('').append(this, ' ', $('