From 3bcc87caf294cd67f221854d1dc13065706f5a81 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Wed, 27 Mar 2013 22:09:39 +0800 Subject: [PATCH 01/11] Fix PM count caching. cache::get() returns null if the key wasn't found (at least when using the Redis cache backend). --- inc/mod/auth.php | 2 +- inc/mod/pages.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/mod/auth.php b/inc/mod/auth.php index f594af4b..d4a2ea1c 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -125,7 +125,7 @@ if (isset($_COOKIE[$config['cookies']['mod']])) { function create_pm_header() { global $mod, $config; - if ($config['cache']['enabled'] && ($header = cache::get('pm_unread_' . $mod['id'])) !== false) { + if ($config['cache']['enabled'] && ($header = cache::get('pm_unread_' . $mod['id'])) != false) { if ($header === true) return false; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index cf06e7d9..726ed735 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -89,7 +89,7 @@ function mod_dashboard() { } } - if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) === false) { + if (!$config['cache']['enabled'] || ($args['unread_pms'] = cache::get('pm_unreadcount_' . $mod['id'])) == false) { $query = prepare('SELECT COUNT(*) FROM `pms` WHERE `to` = :id AND `unread` = 1'); $query->bindValue(':id', $mod['id']); $query->execute() or error(db_error($query)); From 1d4fced75acc7a39abdceaf7ea563c2b5d131839 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 1 Mar 2013 08:42:38 +0800 Subject: [PATCH 02/11] pm_snippet() should probably use mb_substr if it's using mb_strlen. --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/display.php b/inc/display.php index 57110224..6d8cf366 100644 --- a/inc/display.php +++ b/inc/display.php @@ -118,7 +118,7 @@ function pm_snippet($body, $len=null) { // calculate strlen() so we can add "..." after if needed $strlen = mb_strlen($body); - $body = substr($body, 0, $len); + $body = mb_substr($body, 0, $len); // Re-escape the characters. return '' . utf8tohtml($body) . ($strlen > $len ? '…' : '') . ''; From 6fd6b92fe828824dee408614805b35fe29177cd2 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 1 Mar 2013 07:12:17 +0800 Subject: [PATCH 03/11] Fix openBoard and boardTitle functions using same caching keys. Added getBoardInfo function that's used by both of the above functions, and can get a board's info without loading it. --- inc/functions.php | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 16b16901..872c6c23 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -328,11 +328,19 @@ function setupBoard($array) { } function openBoard($uri) { + $board = getBoardInfo($uri); + if ($board) { + setupBoard($board); + return true; + } + return false; +} + +function getBoardInfo($uri) { global $config; if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { - setupBoard($board); - return true; + return $board; } $query = prepare("SELECT * FROM `boards` WHERE `uri` = :uri LIMIT 1"); @@ -342,27 +350,16 @@ function openBoard($uri) { if ($board = $query->fetch()) { if ($config['cache']['enabled']) cache::set('board_' . $uri, $board); - setupBoard($board); - return true; + return $board; } return false; } function boardTitle($uri) { - global $config; - if ($config['cache']['enabled'] && ($board = cache::get('board_' . $uri))) { + $board = getBoardInfo($uri); + if ($board) return $board['title']; - } - - $query = prepare("SELECT `title` FROM `boards` WHERE `uri` = :uri LIMIT 1"); - $query->bindValue(':uri', $uri); - $query->execute() or error(db_error($query)); - - if ($title = $query->fetch()) { - return $title['title']; - } - return false; } From be1e55b9d63bd4cdb910206e9e99ecf83ca7ffde Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Fri, 1 Mar 2013 05:56:44 +0800 Subject: [PATCH 04/11] Fix result page after installing theme getting doubled up. --- inc/mod/pages.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 726ed735..22018d31 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1832,6 +1832,7 @@ function mod_theme_configure($theme_name) { 'result' => $result, 'message' => $message, )); + return; } $settings = themeSettings($theme_name); From b6fc7ca89d8ac0fea48fc4f3b7862cb9ea1e0687 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Mon, 18 Mar 2013 03:14:30 +0800 Subject: [PATCH 05/11] Fix broken entity removal in post truncation. --- inc/display.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/display.php b/inc/display.php index 6d8cf366..90764b43 100644 --- a/inc/display.php +++ b/inc/display.php @@ -204,7 +204,7 @@ function truncate($body, $url, $max_lines = false, $max_chars = false) { } } else { // remove broken HTML entity at the end (if existent) - $body = preg_replace('/&[^;]+$/', '', $body); + $body = preg_replace('/&[^;]*$/', '', $body); } $body .= 'Post too long. Click here to view the full text.'; From fa9c2a0fd1ce4b188361a863208334c8f6b312e5 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Sun, 3 Mar 2013 00:41:00 +0800 Subject: [PATCH 06/11] mod.php: Don't freak out if extra dummy query parameters are added. (Such as for cache-avoidance.) --- mod.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod.php b/mod.php index 9de2c15b..641d2115 100644 --- a/mod.php +++ b/mod.php @@ -105,7 +105,7 @@ $new_pages = array(); foreach ($pages as $key => $callback) { if (preg_match('/^secure /', $callback)) $key .= '(/(?P[a-f0-9]{8}))?'; - $new_pages[@$key[0] == '!' ? $key : "!^$key$!"] = $callback; + $new_pages[@$key[0] == '!' ? $key : '!^' . $key . '(?:&[^&=]+=[^&]*)*$!'] = $callback; } $pages = $new_pages; From 4ad1ce13b1b7743ef13c27ecf425e13c4e4b2a33 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Tue, 11 Jun 2013 10:18:41 -0500 Subject: [PATCH 07/11] Include non-compiled javascript in page.html too. --- templates/page.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templates/page.html b/templates/page.html index e66b3fff..2f3de358 100644 --- a/templates/page.html +++ b/templates/page.html @@ -7,7 +7,12 @@ {{ title }} {% if config.default_stylesheet.1 != '' %}{% endif %} - {% if not nojavascript %}{% endif %} + {% if not nojavascript %} + + {% if not config.additional_javascript_compile %} + {% for javascript in config.additional_javascript %}{% endfor %} + {% endif %} + {% endif %} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} From a5e5cd03e6936e17b91acfb485c7e8a19b4c0b2a Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Tue, 18 Jun 2013 11:58:32 -0500 Subject: [PATCH 08/11] Don't forget secure tripcode that's preceded by a space. Mod capcodes are not remembered in the posting form. --- templates/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/main.js b/templates/main.js index b0a96393..9ec0025f 100644 --- a/templates/main.js +++ b/templates/main.js @@ -105,7 +105,7 @@ function generatePassword() { function dopost(form) { if (form.elements['name']) { - localStorage.name = form.elements['name'].value.replace(/ ##.+$/, ''); + localStorage.name = form.elements['name'].value.replace(/( |^)## .+$/, ''); } if (form.elements['email'] && form.elements['email'].value != 'sage') { localStorage.email = form.elements['email'].value; From b078222ede702b8ecf4b28f5ebd6db5c34b65143 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Sat, 8 Jun 2013 05:55:13 -0500 Subject: [PATCH 09/11] Fix "Undefined index: sticky" and "locked" errors on new thread creation. --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 872c6c23..b83d6c86 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -722,13 +722,13 @@ function post(array $post) { $query->bindValue(':password', $post['password']); $query->bindValue(':ip', isset($post['ip']) ? $post['ip'] : $_SERVER['REMOTE_ADDR']); - if ($post['op'] && $post['mod'] && $post['sticky']) { + if ($post['op'] && $post['mod'] && isset($post['sticky']) && $post['sticky']) { $query->bindValue(':sticky', 1, PDO::PARAM_INT); } else { $query->bindValue(':sticky', 0, PDO::PARAM_INT); } - if ($post['op'] && $post['mod'] && $post['locked']) { + if ($post['op'] && $post['mod'] && isset($post['locked']) && $post['locked']) { $query->bindValue(':locked', 1, PDO::PARAM_INT); } else { $query->bindValue(':locked', 0, PDO::PARAM_INT); From 765e64ee38919c48f840403c4910a37fbce037e9 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Wed, 13 Feb 2013 01:25:56 +0800 Subject: [PATCH 10/11] m and n dash fix --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index b83d6c86..a9afb450 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1362,8 +1362,8 @@ function unicodify($body) { // En and em- dashes are rendered exactly the same in // most monospace fonts (they look the same in code // editors). - $body = str_replace('--', '–', $body); // en dash $body = str_replace('---', '—', $body); // em dash + $body = str_replace('--', '–', $body); // en dash return $body; } From 399aa463b3d046a49c861a2c60c997f39af22561 Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Tue, 18 Jun 2013 12:10:06 -0500 Subject: [PATCH 11/11] Fix #71. --- js/post-hover.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/post-hover.js b/js/post-hover.js index 2f25540b..48f0ed96 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -20,6 +20,8 @@ onready(function(){ if(id = $link.text().match(/^>>(\d+)$/)) { id = id[1]; + } else { + return; } var $post = false;