From c0815ea25aab780402546d04a44f4b3f0dcf2f3a Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 14:42:48 +1000 Subject: [PATCH 1/8] Bugfix: When you hovered over a >>X link, then hid and unhid a thread (js/hide-threads.js) it would fuck up --- js/post-hover.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/post-hover.js b/js/post-hover.js index f4dc9909..263dc9ae 100644 --- a/js/post-hover.js +++ b/js/post-hover.js @@ -73,7 +73,7 @@ onready(function(){ $(document).trigger('new_post', this); if($('#' + $(this).attr('id')).length == 0) - $('div.post:first').prepend($(this).css('display', 'none').addClass('hidden')); + $('body').prepend($(this).css('display', 'none').addClass('hidden')); }); $post = $('div.post#reply_' + id); From cd3e2ef45849af8f3c38397977d3fe9e81c45b34 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 14:54:41 +1000 Subject: [PATCH 2/8] js/expand-all-images.js --- js/expand-all-images.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 js/expand-all-images.js diff --git a/js/expand-all-images.js b/js/expand-all-images.js new file mode 100644 index 00000000..6cca09c8 --- /dev/null +++ b/js/expand-all-images.js @@ -0,0 +1,28 @@ +/* + * expand-all-images.js + * https://github.com/savetheinternet/Tinyboard/blob/master/js/expand-all-images.js + * + * Adds an "Expand all images" button to the top of the page. + * + * Released under the MIT license + * Copyright (c) 2012-2013 Michael Save + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/inline-expanding.js'; + * $config['additional_javascript'][] = 'js/expand-all-images.js'; + * + */ + +onready(function(){ + $('hr:first').before('
'); + $('div#expand-all-images a') + .text(_('Expand all images')) + .click(function() { + $('a img.post-image').each(function() { + if (!$(this).parent()[0].dataset.expanded) + $(this).parent().click(); + }); + $(this).parent().remove(); + }); +}); From e7f25aa480cf30ed901ce72d230cc5e08269179e Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 16:06:45 +1000 Subject: [PATCH 3/8] add delete event --- inc/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 80d67b6b..09933ade 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -949,6 +949,8 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { // Delete posts and maybe replies while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + event('delete', $post); + if (!$post['thread']) { // Delete thread HTML page file_unlink($board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['id'])); From b2d5ec253b53345f46f6e1a246a725167d4ab814 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 17:41:22 +1000 Subject: [PATCH 4/8] escape_markup_modifiers: make it case insensitive --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 09933ade..50937a29 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1631,7 +1631,7 @@ function markup(&$body, $track_cites = false) { } function escape_markup_modifiers($string) { - return preg_replace('@@m', '', $string); + return preg_replace('@@mi', '', $string); } function utf8tohtml($utf8) { From 998002fd3442ad036391293fbb4382552081bf0f Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 17:53:39 +1000 Subject: [PATCH 5/8] better modifier escaping again --- inc/functions.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 50937a29..d1ae2267 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1482,7 +1482,8 @@ function markup(&$body, $track_cites = false) { $modifiers = extract_modifiers($body); - $body = preg_replace('@(.+?)@us', '', $body); + $body = preg_replace('@(.+?)@us', '', $body); + $body = preg_replace('@@i', '', $body); if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') return $body; From 28f366b686d8e8d62bd20160fb085330314601bd Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sat, 17 Aug 2013 17:56:38 +1000 Subject: [PATCH 6/8] keep casing of escape modifiers --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index d1ae2267..3b81cf4c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1483,7 +1483,7 @@ function markup(&$body, $track_cites = false) { $modifiers = extract_modifiers($body); $body = preg_replace('@(.+?)@us', '', $body); - $body = preg_replace('@@i', '', $body); + $body = preg_replace('@<(tinyboard) escape ([\w\s]+)>@i', '<$1 $2>', $body); if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') return $body; @@ -1632,7 +1632,7 @@ function markup(&$body, $track_cites = false) { } function escape_markup_modifiers($string) { - return preg_replace('@@mi', '', $string); + return preg_replace('@<(tinyboard) ([\w\s]+)>@mi', '<$1 escape $2>', $string); } function utf8tohtml($utf8) { From 3a27060503b18815f7eb268bbce3df4c124aa24e Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 18 Aug 2013 01:06:13 +1000 Subject: [PATCH 7/8] GeoIP: Ignore country codes that aren't country codes: ap (Asia/Pacific), EU, etc. --- post.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/post.php b/post.php index 49f569f4..3f8656df 100644 --- a/post.php +++ b/post.php @@ -430,8 +430,9 @@ if (isset($_POST['delete'])) { error('GeoIP not available: ' . geoip_db_filename(GEOIP_COUNTRY_EDITION)); } if ($country_code = @geoip_country_code_by_name($_SERVER['REMOTE_ADDR'])) { - $post['body'] .= "\n" . strtolower($country_code) . "" . - "\n" . @geoip_country_name_by_name($_SERVER['REMOTE_ADDR']) . ""; + if (!in_array(strtolower($country_code), array('eu', 'ap', 'o1', 'a1', 'a2'))) + $post['body'] .= "\n" . strtolower($country_code) . "" . + "\n" . @geoip_country_name_by_name($_SERVER['REMOTE_ADDR']) . ""; } } From cff62b250c90f9fd336ceac5e2c557bf4c448859 Mon Sep 17 00:00:00 2001 From: Michael Foster Date: Sun, 18 Aug 2013 04:49:56 +1000 Subject: [PATCH 8/8] Bugfix: raw html posting --- inc/functions.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 3b81cf4c..259245f3 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -1485,8 +1485,9 @@ function markup(&$body, $track_cites = false) { $body = preg_replace('@(.+?)@us', '', $body); $body = preg_replace('@<(tinyboard) escape ([\w\s]+)>@i', '<$1 $2>', $body); - if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') - return $body; + if (isset($modifiers['raw html']) && $modifiers['raw html'] == '1') { + return array(); + } $body = str_replace("\r", '', $body); $body = utf8tohtml($body);