From 909e1b81fb8f9c04e7f177c28647dd1c27634b97 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sat, 5 Jan 2013 13:45:21 +0100 Subject: [PATCH 1/7] Embedding: added vocaroo support --- inc/config.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inc/config.php b/inc/config.php index 79ac48cb..a1fa088f 100644 --- a/inc/config.php +++ b/inc/config.php @@ -651,6 +651,10 @@ array( '/^https?:\/\/video\.google\.com\/videoplay\?docid=(\d+)([&#](.+)?)?$/i', '' + ), + array( + '/^https?:\/\/(\w+\.)?vocaroo\.com\/i\/([a-zA-Z0-9]{2,15})$/i', + '' ) ); From b35f7d9e1e0ab4d6682e5c140ae67f0caba24c26 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sun, 6 Jan 2013 09:41:00 +0100 Subject: [PATCH 2/7] refactored head away from templates --- templates/generic_page.html | 31 ++----------------------------- templates/header.html | 28 ++++++++++++++++++++++++++++ templates/index.html | 28 +--------------------------- templates/page.html | 7 +------ 4 files changed, 32 insertions(+), 62 deletions(-) create mode 100644 templates/header.html diff --git a/templates/generic_page.html b/templates/generic_page.html index c50fb5dd..539cfdd3 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -2,35 +2,8 @@ {% block head %} - - {% if config.url_favicon %}{% endif %} - {{ board.url }} - {{ board.name }} - - - {% if config.meta_keywords %}{% endif %} - {% if config.default_stylesheet.1 != '' %}{% endif %} - - {% if not nojavascript %} - - {% if not config.additional_javascript_compile %} - {% for javascript in config.additional_javascript %}{% endfor %} - {% endif %} - {% endif %} - {% if config.recaptcha %}{% endif %} + {% include 'header.html' %} + {{ board.url }} - {{ board.name }} {% endblock %} diff --git a/templates/header.html b/templates/header.html new file mode 100644 index 00000000..95e0bc09 --- /dev/null +++ b/templates/header.html @@ -0,0 +1,28 @@ + + {% if config.url_favicon %}{% endif %} + + + {% if config.meta_keywords %}{% endif %} + {% if config.default_stylesheet.1 != '' %}{% endif %} + + {% if not nojavascript %} + + {% if not config.additional_javascript_compile %} + {% for javascript in config.additional_javascript %}{% endfor %} + {% endif %} + {% endif %} + {% if config.recaptcha %}{% endif %} diff --git a/templates/index.html b/templates/index.html index d7910416..41c47af4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,35 +1,9 @@ + {% include 'header.html' %} - - {% if config.url_favicon %}{% endif %} {{ board.url }} - {{ board.name }} - - {% if config.meta_keywords %}{% endif %} - {% if config.default_stylesheet.1 != '' %}{% endif %} - - {% if not nojavascript %} - - {% if not config.additional_javascript_compile %} - {% for javascript in config.additional_javascript %}{% endfor %} - {% endif %} - {% endif %} - {% if config.recaptcha %}{% endif %} {{ boardlist.top }} diff --git a/templates/page.html b/templates/page.html index 8fbc49cd..457971af 100644 --- a/templates/page.html +++ b/templates/page.html @@ -1,14 +1,9 @@ + {% include 'header.html' %} - - {% if config.url_favicon %}{% endif %} {{ title }} - - {% if config.default_stylesheet.1 != '' %}{% endif %} - - {% if not nojavascript %}{% endif %} {% if pm %}
You have an unread PM{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.

{% endif %} From 60fceb9a2033a6386228b39849488a5b715097a3 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sun, 6 Jan 2013 13:40:33 +0100 Subject: [PATCH 3/7] added Fluttershy recent theme and theme picker --- templates/themes/recent/info.php | 8 ++++ templates/themes/recent/recent_fs.css | 57 +++++++++++++++++++++++++++ templates/themes/recent/theme.php | 2 +- 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 templates/themes/recent/recent_fs.css diff --git a/templates/themes/recent/info.php b/templates/themes/recent/info.php index d4cf1029..58448b3d 100644 --- a/templates/themes/recent/info.php +++ b/templates/themes/recent/info.php @@ -55,6 +55,14 @@ 'default' => 'recent.css', 'comment' => '(eg. "recent.css")' ); + + $theme['config'][] = Array( + 'title' => 'CSS stylesheet name', + 'name' => 'basecss', + 'type' => 'text', + 'default' => 'recent.css', + 'comment' => '(eg. "recent.css" - see templates/themes/recent for details)' + ); // Unique function name for building everything $theme['build_function'] = 'recentposts_build'; diff --git a/templates/themes/recent/recent_fs.css b/templates/themes/recent/recent_fs.css new file mode 100644 index 00000000..26aed668 --- /dev/null +++ b/templates/themes/recent/recent_fs.css @@ -0,0 +1,57 @@ +.box-wrap { + max-width: 670px; + min-width: 332px; + margin: 30px auto; + overflow: auto; + padding: 0; +} +.box { + background: white; + border: 1px solid #98E; + width: 330px; + margin: 8px 0; + padding: 0; +} +.box ul { + padding: 2px 15px; +} +.box ul li { + list-style: none; + margin: 0; +} +.box.left { + background: #FDF6AF; + color: #9E914F; + border: 1px solid #9E914F; + float: left; +} +.box.right { + background: #F2DCE5; + color: #525; + border: 1px solid #CA759E; + float: right; +} + +.box h2 { + padding: 3px 7px; + font-size: 12pt; +} +.box img { + float: none; + margin: 10px auto; +} +.box.left h2 { + background: #FEE78F; + color: #9E914F; +} +.box.right h2 { + background: #EB81B4; + color: #F8F8F8; +} + +body { + background: #F7F8F9; +} +header div.subtitle, h1 { + color: #888A8C; +} diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 986fac6a..b436ab0f 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -18,7 +18,7 @@ global $config, $_theme; if ($action == 'all') { - copy('templates/themes/recent/recent.css', $config['dir']['home'] . $settings['css']); + copy('templates/themes/recent/' . $settings['basecss'], $config['dir']['home'] . $settings['css']); } $this->excluded = explode(' ', $settings['exclude']); From a051ca64ababcf49f4eebf9b768b301c9e8cc06e Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 8 Jan 2013 04:31:09 +0100 Subject: [PATCH 4/7] [EDIT] added dummy page --- inc/mod/pages.php | 12 ++++++++++++ mod.php | 1 + 2 files changed, 13 insertions(+) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 4f1ab73c..fb9f364d 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -985,6 +985,18 @@ function mod_ban_post($board, $delete, $post, $token = false) { mod_page(_('New ban'), 'mod/ban_form.html', $args); } +function mod_edit_post($board, $post) { + global $config, $mod; + + if (!openBoard($board)) + error($config['error']['noboard']); + + if (!hasPermission($config['mod']['editpost'], $board)) + error($config['error']['noaccess']); + + error("Unimplemented!"); +} + function mod_delete($board, $post) { global $config, $mod; diff --git a/mod.php b/mod.php index 8f3a5001..01b3460a 100644 --- a/mod.php +++ b/mod.php @@ -65,6 +65,7 @@ $pages = array( '/(\w+)/deletefile/(\d+)' => 'secure deletefile', // delete file from post '/(\w+)/deletebyip/(\d+)(/global)?' => 'secure deletebyip', // delete all posts by IP address '/(\w+)/(un)?lock/(\d+)' => 'secure lock', // lock thread + '/(\w+)/edit/(\d+)' => 'secure edit_post', // edit post '/(\w+)/(un)?sticky/(\d+)' => 'secure sticky', // sticky thread '/(\w+)/bump(un)?lock/(\d+)' => 'secure bumplock', // "bumplock" thread From 1a2c859996e5827581a0440da8fb97ec09fd70b7 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 8 Jan 2013 04:35:22 +0100 Subject: [PATCH 5/7] [EDIT] added dummy form --- inc/mod/pages.php | 6 +++- templates/mod/edit_post_form.html | 55 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 templates/mod/edit_post_form.html diff --git a/inc/mod/pages.php b/inc/mod/pages.php index fb9f364d..75f7ffb4 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -994,7 +994,11 @@ function mod_edit_post($board, $post) { if (!hasPermission($config['mod']['editpost'], $board)) error($config['error']['noaccess']); - error("Unimplemented!"); + // error("Unimplemented!"); + $args = array( + 'test' => 1 + ); + mod_page(_('Edit post'), 'mod/edit_post_form.html', $args); } function mod_delete($board, $post) { diff --git a/templates/mod/edit_post_form.html b/templates/mod/edit_post_form.html new file mode 100644 index 00000000..ac7e207f --- /dev/null +++ b/templates/mod/edit_post_form.html @@ -0,0 +1,55 @@ +
+ + {% if not config.field_disable_name or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %} + + + {% endif %} + {% if not config.field_disable_email or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %} + + + {% endif %} + + + + + + + + + + + + +
+ {% trans %}Name{% endtrans %} + + +
+ {% trans %}Email{% endtrans %} + + +
+ {% trans %}Subject{% endtrans %} + + +
+ {% trans %}Comment{% endtrans %} + + +
+ {% trans %}Flags{% endtrans %} + + {% if not id and post.mod|hasPermission(config.mod.sticky, board.uri) %}
+ +
+
{% endif %} + {% if not id and post.mod|hasPermission(config.mod.lock, board.uri) %}
+
+ +
{% endif %} + {% if post.mod|hasPermission(config.mod.rawhtml, board.uri) %}
+
+ +
{% endif %} +
+
From 9fec3646fa5ef5ec856f0a0b3a7bc9bba03de7fc Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 8 Jan 2013 07:52:13 +0100 Subject: [PATCH 6/7] [EDIT] basic edit support --- inc/config.php | 2 +- inc/mod/pages.php | 37 ++++++++++++++++++++++++++----- templates/mod/edit_post_form.html | 35 +++++++++-------------------- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/inc/config.php b/inc/config.php index a1fa088f..a6f78053 100644 --- a/inc/config.php +++ b/inc/config.php @@ -953,7 +953,7 @@ // View whether a thread has been bumplocked ("-1" to allow non-mods to see too) $config['mod']['view_bumplock'] = MOD; // Edit posts (EXPERIMENTAL) - $config['mod']['editpost'] = DISABLED; + $config['mod']['editpost'] = MOD; // "Move" a thread to another board (EXPERIMENTAL; has some known bugs) $config['mod']['move'] = DISABLED; // Bypass "field_disable_*" (forced anonymity, etc.) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 75f7ffb4..8cabae6d 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -994,11 +994,38 @@ function mod_edit_post($board, $post) { if (!hasPermission($config['mod']['editpost'], $board)) error($config['error']['noaccess']); - // error("Unimplemented!"); - $args = array( - 'test' => 1 - ); - mod_page(_('Edit post'), 'mod/edit_post_form.html', $args); + $security_token = make_secure_link_token($board . '/ban/' . $post); + + $query = prepare(sprintf('SELECT * FROM `posts_%s` WHERE `id` = :id', $board)); + $query->bindValue(':id', $post); + $query->execute() or error(db_error($query)); + + if (!$_post = $query->fetch(PDO::FETCH_ASSOC)) + error($config['error']['404']); + + if(isset($_POST['mode']) && $_POST['mode'] == "edit") + { + $query = prepare(sprintf("UPDATE `posts_%s` SET `name` = :name,`email` = :email,`subject` = :subject,`body` = :body WHERE `id` = :id",$board)); + $query->bindValue(':id', $post); + $query->bindValue('name', $_POST['name']); + $query->bindValue(':email', $_POST['email']); + $query->bindValue(':subject', $_POST['subject']); + $query->bindValue(':body', $_POST['body']); + $query->execute() or error(db_error($query)); + + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); + } else { + $args = array( + 'token' => $security_token, + 'name' => $_post['name'], + 'email' => $_post['email'], + 'subject' => $_post['subject'], + 'body' => $_post['body'], + 'mode' => "edit" + ); + + mod_page(_('Edit post'), 'mod/edit_post_form.html', $args); + } } function mod_delete($board, $post) { diff --git a/templates/mod/edit_post_form.html b/templates/mod/edit_post_form.html index ac7e207f..6748435e 100644 --- a/templates/mod/edit_post_form.html +++ b/templates/mod/edit_post_form.html @@ -1,27 +1,27 @@
- {% if not config.field_disable_name or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %} + - {% endif %} - {% if not config.field_disable_email or (mod and post.mod|hasPermission(config.mod.bypass_field_disable, board.uri)) %} + + - {% endif %} + @@ -29,27 +29,12 @@ {% trans %}Comment{% endtrans %} - - + +
{% trans %}Name{% endtrans %} - +
{% trans %}Email{% endtrans %} - +
{% trans %}Subject{% endtrans %} - +
- +
- {% trans %}Flags{% endtrans %} - - {% if not id and post.mod|hasPermission(config.mod.sticky, board.uri) %}
- -
-
{% endif %} - {% if not id and post.mod|hasPermission(config.mod.lock, board.uri) %}
-
- -
{% endif %} - {% if post.mod|hasPermission(config.mod.rawhtml, board.uri) %}
-
- -
{% endif %} -
From e145a0ea890f6973f349d8fb342e38a9be4c649b Mon Sep 17 00:00:00 2001 From: asiekierka Date: Tue, 8 Jan 2013 07:57:21 +0100 Subject: [PATCH 7/7] edit bugfixes --- inc/mod/pages.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 8cabae6d..e96a4640 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1013,6 +1013,11 @@ function mod_edit_post($board, $post) { $query->bindValue(':body', $_POST['body']); $query->execute() or error(db_error($query)); + $thread = $_post['thread']; + buildThread($thread ? $thread : $post); + modLog("Edited post #{$post}"); + buildIndex(); + header('Location: ?/' . sprintf($config['board_path'], $board) . $config['file_index'], true, $config['redirect_http']); } else { $args = array(