From d690567b44464962b0f99c9c222ce4530b9b716e Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:13:18 +0100 Subject: ... (minor fix for locales) --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 2a398ae7..846dbdaa 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -358,7 +358,7 @@ function rebuildThemes($action, $boardname = false) { // Reload the locale if ($config['locale'] != $current_locale) { $current_locale = $config['locale']; - init_locale($config['locale'], $error); + init_locale($config['locale']); } if (PHP_SAPI === 'cli') { @@ -379,7 +379,7 @@ function rebuildThemes($action, $boardname = false) { // Reload the locale if ($config['locale'] != $current_locale) { $current_locale = $config['locale']; - init_locale($config['locale'], $error); + init_locale($config['locale']); } } -- cgit v1.3 From 7d92a05bd8b283a79764e8ed5435661b9a8b27f2 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:23:40 +0100 Subject: ... --- templates/themes/catalog/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index b3b7caf7..f8f1146e 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -42,7 +42,7 @@ $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post)); + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\/\/(\w+\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([a-zA-Z0-9\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { -- cgit v1.3 From e999955d08274efa5d78fd9bda410648dfb2ae12 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:28:55 +0100 Subject: ... --- post.php | 1 + 1 file changed, 1 insertion(+) diff --git a/post.php b/post.php index 93592590..87795aa0 100644 --- a/post.php +++ b/post.php @@ -800,6 +800,7 @@ if (isset($_POST['delete'])) { $post['num_files'] = sizeof($post['files']); $post['id'] = $id = post($post); + $post['slug'] = slugify($post); insertFloodPost($post); -- cgit v1.3 From 4aa1d387f8a90d33207d28afc637958759e2ce6e Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:34:02 +0100 Subject: ... --- templates/themes/sitemap/theme.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 1cebcdb6..41a7f304 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -26,7 +26,7 @@ $threads = array(); foreach ($boards as $board) { - $query = query(sprintf("SELECT `id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); } -- cgit v1.3 From 7623de9e2fe8424f35be70cddb9cf68254e49e3e Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:42:10 +0100 Subject: ... (cache) --- inc/functions.php | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 846dbdaa..6880ad44 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2479,16 +2479,25 @@ function link_for($post, $page50 = false, $foreignlink = false, $thread = false) $slug = false; if ($config['slugify'] && isset($post['thread']) && $post['thread']) { + $cvar = "slug_".$b['uri']."_".$id; if (!$thread) { - // Oh fuck, we'd better optimize it ASAP + $slug = Cache::get($cvar); - $query = prepare(sprintf("SELECT `slug` FROM ``posts_%s`` WHERE `id` = :id", $b['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + if ($slug === false) { + $query = prepare(sprintf("SELECT `slug` FROM ``posts_%s`` WHERE `id` = :id", $b['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); - $thread = $query->fetch(PDO::FETCH_ASSOC); + $thread = $query->fetch(PDO::FETCH_ASSOC); + + $slug = $thread['slug']; + + Cache::set($cvar, $slug); + } + } + else { + $slug = $thread['slug']; } - $slug = $thread['slug']; } elseif ($config['slugify']) { $slug = $post['slug']; -- cgit v1.3 From 58b60f0aa4ef14589315a66fcf58d749928483c7 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:46:34 +0100 Subject: ... --- inc/mod/pages.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 79d1bf51..2b7de134 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1224,7 +1224,10 @@ function mod_move($originBoard, $postID) { // create the new thread $newID = post($post); - + + $op = $post; + $op['id'] = $newID; + if ($post['has_file']) { // copy image foreach ($post['files'] as $i => &$file) { @@ -1357,14 +1360,14 @@ function mod_move($originBoard, $postID) { buildIndex(); - header('Location: ?/' . sprintf($config['board_path'], $originBoard) . $config['dir']['res'] . link_for($post, false, $newboard) . + header('Location: ?/' . sprintf($config['board_path'], $originBoard) . $config['dir']['res'] . link_for($op, false, $newboard) . '#' . $botID, true, $config['redirect_http']); } else { deletePost($postID); buildIndex(); openBoard($targetBoard); - header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($post, false, $newboard), true, $config['redirect_http']); + header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($op, false, $newboard), true, $config['redirect_http']); } } -- cgit v1.3 From 2f7aeec53128b08e000e89bc031f25c0501565f3 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:48:33 +0100 Subject: ... --- inc/mod/pages.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 2b7de134..be713f57 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1360,14 +1360,14 @@ function mod_move($originBoard, $postID) { buildIndex(); - header('Location: ?/' . sprintf($config['board_path'], $originBoard) . $config['dir']['res'] . link_for($op, false, $newboard) . + header('Location: ?/' . sprintf($config['board_path'], $newboard['uri']) . $config['dir']['res'] . link_for($op, false, $newboard) . '#' . $botID, true, $config['redirect_http']); } else { deletePost($postID); buildIndex(); openBoard($targetBoard); - header('Location: ?/' . sprintf($config['board_path'], $board['uri']) . $config['dir']['res'] . link_for($op, false, $newboard), true, $config['redirect_http']); + header('Location: ?/' . sprintf($config['board_path'], $newboard['uri']) . $config['dir']['res'] . link_for($op, false, $newboard), true, $config['redirect_http']); } } -- cgit v1.3 From 9f34d334d3d45471ab88fc90a702999cd2cf6bf5 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 13:52:31 +0100 Subject: .. --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 6880ad44..1beb7f6e 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1085,7 +1085,7 @@ function deletePost($id, $error_if_doesnt_exist=true, $rebuild_after=true) { global $board, $config; // Select post and replies (if thread) in one query - $query = prepare(sprintf("SELECT `id`,`thread`,`files` FROM ``posts_%s`` WHERE `id` = :id OR `thread` = :id", $board['uri'])); + $query = prepare(sprintf("SELECT `id`,`thread`,`files`,`slug` FROM ``posts_%s`` WHERE `id` = :id OR `thread` = :id", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); $query->execute() or error(db_error($query)); -- cgit v1.3 From 50b80e9e2452cfffadeb6918150736a4dde7834a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:06:44 +0100 Subject: ... (slug api) --- inc/api.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/api.php b/inc/api.php index c9608f06..351943a3 100644 --- a/inc/api.php +++ b/inc/api.php @@ -33,6 +33,7 @@ class Api { 'sticky' => 'sticky', 'locked' => 'locked', 'bump' => 'last_modified', + 'slug' => 'semantic_url', ); $this->threadsPageFields = array( -- cgit v1.3 From a2544bc596465f9915589a47d112fa1475f54720 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:16:27 +0100 Subject: ... (cites) --- inc/functions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 1beb7f6e..4dc516fc 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1810,7 +1810,7 @@ function markup(&$body, $track_cites = false) { if (isset($cited_posts[$cite])) { $replacement = '' . + link_for(array('id' => $cite)) . '#' . $cite . '">' . '>>' . $cite . ''; @@ -1876,12 +1876,12 @@ function markup(&$body, $track_cites = false) { if (!empty($clauses)) { $cited_posts[$_board] = array(); - $query = query(sprintf('SELECT `thread`, `id` FROM ``posts_%s`` WHERE ' . + $query = query(sprintf('SELECT `thread`, `id`, `slug` FROM ``posts_%s`` WHERE ' . implode(' OR ', $clauses), $board['uri'])) or error(db_error()); while ($cite = $query->fetch(PDO::FETCH_ASSOC)) { $cited_posts[$_board][$cite['id']] = $config['root'] . $board['dir'] . $config['dir']['res'] . - ($cite['thread'] ? $cite['thread'] : $cite['id']) . '.html#' . $cite['id']; + link_for($cite) . '#' . $cite['id']; } } @@ -2478,7 +2478,7 @@ function link_for($post, $page50 = false, $foreignlink = false, $thread = false) $slug = false; - if ($config['slugify'] && isset($post['thread']) && $post['thread']) { + if ($config['slugify'] && ( (isset($post['thread']) && $post['thread']) || !isset ($post['slug']) ) ) { $cvar = "slug_".$b['uri']."_".$id; if (!$thread) { $slug = Cache::get($cvar); -- cgit v1.3 From 4bf525599e7c596e7aec7f483664a091ef0db57b Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:19:36 +0100 Subject: ... --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index 4dc516fc..704c6600 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1810,7 +1810,7 @@ function markup(&$body, $track_cites = false) { if (isset($cited_posts[$cite])) { $replacement = '' . + link_for(array('id' => $cite, 'thread' => $cited_posts[$cite])) . '#' . $cite . '">' . '>>' . $cite . ''; -- cgit v1.3 From 6c4d3941fa729558f4a5313081c85b0a06202e54 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:22:29 +0100 Subject: api fix --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index c9608f06..661ee109 100644 --- a/inc/api.php +++ b/inc/api.php @@ -109,7 +109,7 @@ class Api { if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = substr($file->name, 0, strrpos($file->name, '.')); + $apiPost['filename'] = isset($file->name) ? substr($file->name, 0, strrpos($file->name, '.')) : ""; $dotPos = strrpos($file->file, '.'); $apiPost['ext'] = substr($file->file, $dotPos); $apiPost['tim'] = substr($file->file, 0, $dotPos); -- cgit v1.3 From dbaaa0c40a7a96306185f9431b008a72bc153dd5 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 10 Mar 2015 14:52:44 +0100 Subject: watch.js & slugify fix --- js/watch.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/watch.js b/js/watch.js index a202130f..8ac026a7 100644 --- a/js/watch.js +++ b/js/watch.js @@ -98,6 +98,9 @@ $(function(){ else { bc.threads = bc.threads || {}; bc.threads[thread] = Date.now(); + + bc.slugs = bc.slugs || {}; + bc.slugs[thread] = document.location.pathname + document.location.search; } st[board] = bc; storage_save(st); @@ -121,7 +124,7 @@ $(function(){ var tag; if (variant == 'desktop') { - tag = $("#"+tid+""+newposts+""); + tag = $("#"+tid+""+newposts+""); tag.find(".watch-remove").mouseenter(function() { this.oldval = $(this).html(); $(this).css("min-width", $(this).width()); @@ -132,7 +135,7 @@ $(function(){ }) } else if (variant == 'mobile') { - tag = $("#"+tid+""+newposts+"" + tag = $("#"+tid+""+newposts+"" +""); } -- cgit v1.3 From e7d3097e5a0b8a07f726bd9540d678523ff2d8eb Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Wed, 11 Mar 2015 16:35:49 -0400 Subject: Removed extra space for some options --- js/forced-anon.js | 2 +- js/no-animated-gif.js | 2 +- js/toggle-images.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/js/forced-anon.js b/js/forced-anon.js index 5ea68199..11327ec9 100644 --- a/js/forced-anon.js +++ b/js/forced-anon.js @@ -64,7 +64,7 @@ $(document).ready(function() { if (window.Options && Options.get_tab('general')) { selector = '#forced-anon'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#forced-anon'; diff --git a/js/no-animated-gif.js b/js/no-animated-gif.js index 45a55f97..a10a6497 100644 --- a/js/no-animated-gif.js +++ b/js/no-animated-gif.js @@ -57,7 +57,7 @@ if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko' | if (window.Options && Options.get_tab('general')) { selector = '#no-animated-gif>input'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#no-animated-gif'; diff --git a/js/toggle-images.js b/js/toggle-images.js index 20940ccf..b8940252 100644 --- a/js/toggle-images.js +++ b/js/toggle-images.js @@ -60,7 +60,7 @@ $(document).ready(function(){ if (window.Options && Options.get_tab('general')) { selector = '#toggle-images>input'; event = 'change'; - Options.extend_tab("general", ""); + Options.extend_tab("general", ""); } else { selector = '#toggle-images a'; -- cgit v1.3 From 10a82199656aa5a9f5b81afda1a2f3512f46efe2 Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Thu, 12 Mar 2015 00:00:59 +0100 Subject: enable a `basic` cache by default; notify me if it breaks your chan --- inc/config.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index ac4acaa4..42e1c32b 100644 --- a/inc/config.php +++ b/inc/config.php @@ -115,7 +115,7 @@ * http://tinyboard.org/docs/index.php?p=Config/Cache */ - $config['cache']['enabled'] = false; + $config['cache']['enabled'] = 'php'; // $config['cache']['enabled'] = 'xcache'; // $config['cache']['enabled'] = 'apc'; // $config['cache']['enabled'] = 'memcached'; @@ -570,6 +570,9 @@ // Use semantic URLs for threads, like /b/res/12345/daily-programming-thread.html $config['slugify'] = false; + // Max size for slugs + $config['slug_max_size'] = 80; + /* * ==================== * Ban settings -- cgit v1.3 From 3851087dce99d3f7368f501a1599564304b62bea Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 12 Mar 2015 00:03:22 +0100 Subject: slug size should be configurable --- inc/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 704c6600..ca918e0a 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2432,6 +2432,8 @@ function diceRoller($post) { } function slugify($post) { + global $config; + $slug = ""; if (isset($post['subject']) && $post['subject']) @@ -2459,8 +2461,8 @@ function slugify($post) { // Strip dashes at the beginning and at the end $slug = preg_replace('/^-|-$/', '', $slug); - // Slug should be 200 characters long, at max - $slug = substr($slug, 0, 200); + // Slug should be X characters long, at max (80?) + $slug = substr($slug, 0, $config['slug_max_size']); // Slug is now ready return $slug; -- cgit v1.3 From d863bf09fa188d89f8ecd63da24914287978bbc7 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 12 Mar 2015 17:13:04 +0100 Subject: update readme --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 06efae0a..e47dd597 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ About vichan is a free light-weight, fast, highly configurable and user-friendly imageboard software package. It is written in PHP and has few dependencies. -vichan is a fork of [Tinyboard](http://tinyboard.org/), a great imageboard package, actively -building on it and adding a lot of features and other improvements. +vichan is a fork of (now defunc'd) [Tinyboard](http://github.com/savetheinternet/Tinyboard), +a great imageboard package, actively building on it and adding a lot of features and other +improvements. Support and announcements: https://int.vichan.net/devel/ @@ -64,7 +65,7 @@ backup your ```inc/instance-config.php```, replace all your files in place (don't remove boards etc.), then put ```inc/instance-config.php``` back and finally run ```install.php```. -To migrate from a Kusaba X board: +To migrate from a Kusaba X board, use http://github.com/vichan-devel/Tinyboard-Migration Support -------- @@ -84,10 +85,7 @@ find support from a variety of sources: vichan is based on a Tinyboard, so both engines have very much in common. These links may be helpful for you as well: -* Tinyboard documentation can be found [here](http://tinyboard.org/docs/). -* You can join Tinyboard's IRC channel for support and general queries: - [irc.datnode.net #tinyboard](irc://irc.datnode.net/tinyboard). -* You may find help at [tinyboard.org](http://tinyboard.org/#help). +* Tinyboard documentation can be found [here](https://web.archive.org/web/20121016074303/http://tinyboard.org/docs/?p=Main_Page). Donations --------- -- cgit v1.3 From d6e91ec62f0364c0ea430bd872c5eec3c7169bdb Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Thu, 19 Mar 2015 19:35:28 -0400 Subject: Added space after Google image search link --- templates/post/image_identification.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/post/image_identification.html b/templates/post/image_identification.html index fa2f30b3..cd37b901 100644 --- a/templates/post/image_identification.html +++ b/templates/post/image_identification.html @@ -8,7 +8,7 @@ Exif {% endif %} {% if config.image_identification_google %} - Google + Google {% endif %} {% if config.image_identification_iqdb %} iqdb -- cgit v1.3 From 1283e51ca50c9085a0f1b763fa4928c91b7c8e69 Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Thu, 19 Mar 2015 21:49:57 -0400 Subject: Fixed and re-enabled active content stat for recent theme --- templates/themes/recent/theme.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 2ea6a7b9..9307c6a9 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -125,15 +125,18 @@ $stats['unique_posters'] = number_format($query->fetchColumn()); // Active content - /*$query = 'SELECT SUM(`filesize`) FROM ('; + $query = 'SELECT `files` FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; - $query .= sprintf("SELECT `filesize` FROM ``posts_%s`` UNION ALL ", $_board['uri']); + $query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']); } - $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query); $query = query($query) or error(db_error()); - $stats['active_content'] = $query->fetchColumn();*/ + $files = $query->fetchAll(); + $stats['active_content'] = 0; + foreach ($files as &$file) + $stats['active_content'] += intval(preg_replace('/.*"size":([0-9]*).*/', '$1', $file[0])); return Element('themes/recent/recent.html', Array( 'settings' => $settings, -- cgit v1.3 From 034b288a1317a940c3a5722c6d2864d1ea08f5db Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Fri, 20 Mar 2015 09:47:40 -0400 Subject: Fixed to work with multiple images --- templates/themes/recent/theme.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index 9307c6a9..ce64c80e 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -125,7 +125,7 @@ $stats['unique_posters'] = number_format($query->fetchColumn()); // Active content - $query = 'SELECT `files` FROM ('; + $query = 'SELECT DISTINCT(`files`) FROM ('; foreach ($boards as &$_board) { if (in_array($_board['uri'], $this->excluded)) continue; @@ -135,8 +135,10 @@ $query = query($query) or error(db_error()); $files = $query->fetchAll(); $stats['active_content'] = 0; - foreach ($files as &$file) - $stats['active_content'] += intval(preg_replace('/.*"size":([0-9]*).*/', '$1', $file[0])); + foreach ($files as &$file) { + preg_match_all('/"size":([0-9]*)/', $file[0], $matches); + $stats['active_content'] += array_sum($matches[1]); + } return Element('themes/recent/recent.html', Array( 'settings' => $settings, -- cgit v1.3 From 158371dc64676abdffe659f9d4763745d0b77300 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 00:33:19 +0100 Subject: switch to hotwheels' wPaint branch --- js/wPaint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/wPaint b/js/wPaint index 2c272dff..f1122003 160000 --- a/js/wPaint +++ b/js/wPaint @@ -1 +1 @@ -Subproject commit 2c272dffca0f3d7b7163bd82ba15629f54409278 +Subproject commit f11220032e7edb8349516d3751d3aaee0fd0de68 -- cgit v1.3 From 81afc17b671e16cd95923c1b2461509a5fc4aa81 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 00:35:13 +0100 Subject: image identification: url encode --- templates/post/image_identification.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/post/image_identification.html b/templates/post/image_identification.html index fa2f30b3..408a338c 100644 --- a/templates/post/image_identification.html +++ b/templates/post/image_identification.html @@ -8,7 +8,7 @@ Exif {% endif %} {% if config.image_identification_google %} - Google + Google {% endif %} {% if config.image_identification_iqdb %} iqdb -- cgit v1.3 From 9fa320838b19506d2bfd45f995298e75766530d9 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 23 Mar 2015 01:09:16 +0100 Subject: wpaint has new dependencies – important! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/wpaint.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/wpaint.js b/js/wpaint.js index 9c619070..67d58fc2 100644 --- a/js/wpaint.js +++ b/js/wpaint.js @@ -13,12 +13,7 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/jquery-ui.custom.min.js'; * $config['additional_javascript'][] = 'js/ajax.js'; - * $config['additional_javascript'][] = 'js/wPaint/lib/wColorPicker.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/wPaint.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/main/wPaint.menu.main.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/text/wPaint.menu.text.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/shapes/wPaint.menu.main.shapes.min.js'; - * $config['additional_javascript'][] = 'js/wPaint/plugins/file/wPaint.menu.main.file.min.js'; + * $config['additional_javascript'][] = 'js/wPaint/8ch.js'; * $config['additional_javascript'][] = 'js/wpaint.js'; * $config['additional_javascript'][] = 'js/upload-selection.js'; * -- cgit v1.3 From 10f93d0d4367ade293c7a8733989cedcd7ca791a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 24 Mar 2015 05:19:25 +0100 Subject: implement a protection against transparent proxies --- inc/config.php | 6 ++++++ inc/functions.php | 34 ++++++++++++++++++++++------------ post.php | 7 ++++++- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/inc/config.php b/inc/config.php index 42e1c32b..0ba1952b 100644 --- a/inc/config.php +++ b/inc/config.php @@ -290,6 +290,12 @@ // Ability to lock a board for normal users and still allow mods to post. Could also be useful for making an archive board $config['board_locked'] = false; + // If poster's proxy supplies X-Forwarded-For header, check if poster's real IP is banned. + $config['proxy_check'] = false; + + // If poster's proxy supplies X-Forwarded-For header, save it for further inspection and/or filtering. + $config['proxy_save'] = false; + /* * Custom filters detect certain posts and reject/ban accordingly. They are made up of a condition and an * action (for when ALL conditions are met). As every single post has to be put through each filter, diff --git a/inc/functions.php b/inc/functions.php index ca918e0a..0f70d447 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -810,12 +810,29 @@ function checkBan($board = false) { if (event('check-ban', $board)) return true; - $bans = Bans::find($_SERVER['REMOTE_ADDR'], $board, $config['show_modname']); + $ips = array(); + + $ips[] = $_SERVER['REMOTE_ADDR']; + + if ($config['proxy_check'] && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $ips = array_merge($ips, explode(", ", $_SERVER['HTTP_X_FORWARDED_FOR'])); + } + + foreach ($ips as $ip) { + $bans = Bans::find($_SERVER['REMOTE_ADDR'], $board, $config['show_modname']); - foreach ($bans as &$ban) { - if ($ban['expires'] && $ban['expires'] < time()) { - Bans::delete($ban['id']); - if ($config['require_ban_view'] && !$ban['seen']) { + foreach ($bans as &$ban) { + if ($ban['expires'] && $ban['expires'] < time()) { + Bans::delete($ban['id']); + if ($config['require_ban_view'] && !$ban['seen']) { + if (!isset($_POST['json_response'])) { + displayBan($ban); + } else { + header('Content-Type: text/json'); + die(json_encode(array('error' => true, 'banned' => true))); + } + } + } else { if (!isset($_POST['json_response'])) { displayBan($ban); } else { @@ -823,13 +840,6 @@ function checkBan($board = false) { die(json_encode(array('error' => true, 'banned' => true))); } } - } else { - if (!isset($_POST['json_response'])) { - displayBan($ban); - } else { - header('Content-Type: text/json'); - die(json_encode(array('error' => true, 'banned' => true))); - } } } diff --git a/post.php b/post.php index 87795aa0..100c3efb 100644 --- a/post.php +++ b/post.php @@ -516,7 +516,7 @@ if (isset($_POST['delete'])) { "\n".geoip\geoip_country_name_by_addr_v6($gi, ipv4to6($_SERVER['REMOTE_ADDR'])).""; } } - + if ($config['user_flag'] && isset($_POST['user_flag'])) if (!empty($_POST['user_flag']) ){ @@ -530,6 +530,11 @@ if (isset($_POST['delete'])) { $post['body'] .= "\n" . strtolower($user_flag) . "" . "\n" . $flag_alt . ""; } + + if ($config['proxy_save'] && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { + $proxy = preg_replace("/[^0-9a-fA-F.,: ]/", '', $_SERVER['HTTP_X_FORWARDED_FOR']); + $post['body'] .= "\n".$proxy.""; + } if (mysql_version() >= 50503) { $post['body_nomarkup'] = $post['body']; // Assume we're using the utf8mb4 charset -- cgit v1.3 From 25c2a18a71e76bc70b0b04e3e7e3aaa3738a623d Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Sun, 29 Mar 2015 22:31:38 -0400 Subject: Made quick-reply box resizable horizontally --- js/quick-reply.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/quick-reply.js b/js/quick-reply.js index 07fe4aef..6661501c 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -83,11 +83,12 @@ }\ #quick-reply textarea {\ width: 100%;\ + min-width: 100%;\ box-sizing: border-box;\ -webkit-box-sizing:border-box;\ -moz-box-sizing: border-box;\ font-size: 10pt;\ - resize: vertical;\ + resize: vertical horizontal;\ }\ #quick-reply input, #quick-reply select, #quick-reply textarea {\ margin: 0 0 1px 0;\ -- cgit v1.3 From 5d8e023fc4ba7692eb81bf690c8a04dac9d561ee Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 30 Mar 2015 06:26:53 +0200 Subject: remove tinyboard special markup from slugs; thanks stigma for reporting --- inc/functions.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 0f70d447..ab55d214 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2459,6 +2459,9 @@ function slugify($post) { // Transliterate local characters like ü, I wonder how would it work for weird alphabets :^) $slug = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", $slug); + // Remove Tinyboard custom markup + $slug = preg_replace("/]+>.*?<\/tinyboard>/s", '', $slug); + // Downcase everything $slug = strtolower($slug); -- cgit v1.3 From 300e9e7e71bb9a3e095dca425e944e2fbf6e5117 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 05:20:00 +0200 Subject: fix some png images being discarded --- inc/image.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/image.php b/inc/image.php index 7a68605d..291f3e2a 100644 --- a/inc/image.php +++ b/inc/image.php @@ -363,9 +363,10 @@ class ImageConvert extends ImageBase { $this->height, escapeshellarg($this->temp)))) || !file_exists($this->temp)) { - if (strpos($error, "known incorrect sRGB profile") === false) { + if (strpos($error, "known incorrect sRGB profile") === false && + strpos($error, "iCCP: Not recognizing known sRGB profile that has been edited") === false) { $this->destroy(); - error('Failed to resize image!', null, array('convert_error' => $error)); + error(_('Failed to resize image!')." "._('Details: ').nl2br(htmlspecialchars($error)), null, array('convert_error' => $error)); } if (!file_exists($this->temp)) { $this->destroy(); -- cgit v1.3 From 4a22ee9245b81e9a94bcc18128cf9ad10d19d901 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 30 Oct 2014 05:33:01 -0700 Subject: Extra files and IDs in API Conflicts: inc/api.php --- inc/api.php | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/inc/api.php b/inc/api.php index ac3b1325..eb99d3fb 100644 --- a/inc/api.php +++ b/inc/api.php @@ -86,11 +86,22 @@ class Api { } } + private function translateFile($file, $post, &$apiPost) { + $this->translateFields($this->fileFields, $file, $apiPost); + $apiPost['filename'] = @substr($file->name, 0, strrpos($file->name, '.')); + $dotPos = strrpos($file->file, '.'); + $apiPost['ext'] = substr($file->file, $dotPos); + $apiPost['tim'] = substr($file->file, 0, $dotPos); + $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); + } + private function translatePost($post, $threadsPage = false) { + global $config, $board; $apiPost = array(); $fields = $threadsPage ? $this->threadsPageFields : $this->postFields; $this->translateFields($fields, $post, $apiPost); + if (isset($config['poster_ids'])) $apiPost['id'] = poster_id($post->ip, $post->thread, $board['uri']); if ($threadsPage) return $apiPost; // Handle country field @@ -109,12 +120,19 @@ class Api { // Note: 4chan only supports one file, so only the first file is taken into account for 4chan-compatible API. if (isset($post->files) && $post->files && !$threadsPage) { $file = $post->files[0]; - $this->translateFields($this->fileFields, $file, $apiPost); - $apiPost['filename'] = isset($file->name) ? substr($file->name, 0, strrpos($file->name, '.')) : ""; - $dotPos = strrpos($file->file, '.'); - $apiPost['ext'] = substr($file->file, $dotPos); - $apiPost['tim'] = substr($file->file, 0, $dotPos); - $apiPost['md5'] = base64_encode(hex2bin($post->filehash)); + $this->translateFile($file, $post, $apiPost); + if (sizeof($post->files) > 1) { + $extra_files = array(); + foreach ($post->files as $i => $f) { + if ($i == 0) continue; + + $extra_file = array(); + $this->translateFile($f, $post, $extra_file); + + $extra_files[] = $extra_file; + } + $apiPost['extra_files'] = $extra_files; + } } return $apiPost; -- cgit v1.3 From e35d261ff48e38ea109e29feeed7f8edaaf82b4a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 05:32:38 +0200 Subject: enable embed field for api --- inc/api.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index eb99d3fb..f8f2a71c 100644 --- a/inc/api.php +++ b/inc/api.php @@ -1,4 +1,4 @@ - 'sticky', 'locked' => 'locked', 'bump' => 'last_modified', + 'embed' => 'embed', 'slug' => 'semantic_url', ); -- cgit v1.3 From 61371f77ceed2184aef4e1494d2b9e625afd9e90 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 19 Feb 2015 19:14:24 -0800 Subject: rebuild2 - multithreaded rebuild script --- tools/rebuild2.php | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 tools/rebuild2.php diff --git a/tools/rebuild2.php b/tools/rebuild2.php new file mode 100755 index 00000000..2945460c --- /dev/null +++ b/tools/rebuild2.php @@ -0,0 +1,140 @@ +#!/usr/bin/php +clearCacheFiles(); +} + +if($options['themes']) { + echo "Regenerating theme files...\n"; + rebuildThemes('all'); +} + +if($options['js']) { + echo "Generating Javascript file...\n"; + buildJavascript(); +} + +$main_js = $config['file_script']; + +$boards = listBoards(); +//$boards = array(array('uri'=>'test'), array('uri'=>'tester'), array('uri'=>'testing')); +$boards_m = array_chunk($boards, floor(sizeof($boards)/$options['processes'])); + +function doboard($board) { + global $global_locale, $config, $main_js, $options; + $config['mask_db_error'] = false; + if (!$options['api']) $config['api']['enabled'] = false; + + echo "Opening board /{$board['uri']}/...\n"; + // Reset locale to global locale + $config['locale'] = $global_locale; + init_locale($config['locale'], 'error'); + openBoard($board['uri']); + $config['try_smarter'] = false; + + if($config['file_script'] != $main_js && $options['js']) { + // different javascript file + echo "(/{$board['uri']}/) Generating Javascript file...\n"; + buildJavascript(); + } + + + if ($options['indexes']) { + echo "(/{$board['uri']}/) Creating index pages...\n"; + buildIndex(); + } + + if($options['postmarkup']) { + $query = query(sprintf("SELECT `id` FROM ``posts_%s``", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; + rebuildPost($post['id']); + } + } + + if ($options['threads']) { + $query = query(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `thread` IS NULL", $board['uri'])) or error(db_error()); + while($post = $query->fetch()) { + echo "(/{$board['uri']}/) Rebuilding #{$post['id']}...\n"; + @buildThread($post['id']); + } + } +} + +$children = array(); +foreach ($boards_m as $i => $bb) { + $pid = pcntl_fork(); + + if ($pid == -1) { + die('Fork failed?'); + } else if ($pid) { + echo "Started PID #$pid...\n"; + $children[] = $pid; + } else { + unset($pdo); + $i = 0; + $total = sizeof($bb); + sql_open(); + foreach ($bb as $i => $b) { + $i++; + doboard($b); + echo "I'm on board $i/$total\n"; + } + break; + } +} + + +printf("Complete! Took %g seconds\n", microtime(true) - $start); + +unset($board); + +foreach ($children as $child) { + pcntl_waitpid($child, $status); + unset($children[$child]); +} + +//modLog('Rebuilt everything using tools/rebuild.php'); -- cgit v1.3 From 4083c92dbe641f81c1b92fa33dd111199d5654b0 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 8 Nov 2014 16:56:41 -0800 Subject: Stop double posting AJAX bug --- js/ajax.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/ajax.js b/js/ajax.js index 61d83df2..663f4426 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -141,6 +141,7 @@ $(window).ready(function() { }; setup_form($('form[name="post"]')); $(window).on('quick-reply', function() { + $('form#quick-reply').off('submit'); setup_form($('form#quick-reply')); }); }); -- cgit v1.3 From d3cc27ff5cf598ead9d0045077f69ec73bb470c6 Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 17 Nov 2014 05:23:41 -0800 Subject: Handle XHR errors better --- js/ajax.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/js/ajax.js b/js/ajax.js index 663f4426..1b2bf2c0 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -115,17 +115,7 @@ $(window).ready(function() { } }, error: function(xhr, status, er) { - // An error occured - 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(); + alert(_('The server returned an error or truncated response -- your post was probably still submitted. If it wasn\'t, 8chan.co might be experiencing issues right now -- please try your post again later.')); }, data: formData, cache: false, -- cgit v1.3 From 0f1d506586c2553852cb88204a3e529abace6f78 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 11 Mar 2015 02:58:03 -0700 Subject: Change this message again Conflicts: js/ajax.js --- js/ajax.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/ajax.js b/js/ajax.js index 1b2bf2c0..56f0df5c 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -115,7 +115,10 @@ $(window).ready(function() { } }, error: function(xhr, status, er) { - alert(_('The server returned an error or truncated response -- your post was probably still submitted. If it wasn\'t, 8chan.co might be experiencing issues right now -- please try your post again later.')); + console.log(xhr); + alert(_('The server took too long to submit your post. Your post was probably still submitted. If it wasn\'t, we might be experiencing issues right now -- please try your post again later. Error information: ') + "
"); + $(form).find('input[type="submit"]').val(submit_txt); + $(form).find('input[type="submit"]').removeAttr('disabled'); }, data: formData, cache: false, -- cgit v1.3 From 48cd7438a1ca7309386a44be78cb460f4e729e01 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 15 Mar 2015 22:18:58 +0800 Subject: initial commit file-selector.js --- js/file-selector.js | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100644 js/file-selector.js diff --git a/js/file-selector.js b/js/file-selector.js new file mode 100644 index 00000000..437e1d4a --- /dev/null +++ b/js/file-selector.js @@ -0,0 +1,187 @@ +/* + * file-selector.js - Add support for drag and drop file selection, and paste from clipbboard on supported browsers. + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/file-selector.js'; + */ + +onready(function () { + +// add options panel item +$(document).ready(function () { + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); + + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); + +// disabled by user, or incompatible browser. +// fallback to old +if (localStorage.file_dragdrop == 'false' || !(window.FileReader || window.File)) { + $('.dropzone-wrap').remove(); + $('#upload_file').show(); + + return; +} + +// multipost not enabled +if (typeof max_images == 'undefined') { + var max_images = 1; +} + +var files = []; + +function addFile(file) { + if (files.length == max_images) + return; + + files.push(file); + addThumb(file); +} + +function removeFile(file) { + files.splice(files.indexOf(file), 1); +} + +function getThumbElement(file) { + return $('.tmb-container').filter(function(){return($(this).data('file-ref')==file);}); +} + +function addThumb(file) { + + var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; + var fileType = file.type.split('/')[0]; + var fileExt = file.type.split('/')[1]; + var $fileThumb; + + $('.file-thumbs').append($('
') + .addClass('tmb-container') + .data('file-ref', file) + .append( + $('
').addClass('remove-btn').html('✖'), + $('
').addClass('file-tmb'), + $('
').addClass('tmb-filename').html(fileName) + ) + ); + + if (fileType == 'image') { + // if image file, generate thumbnail + var reader = new FileReader(); + + reader.onloadend = function () { + var dataURL = reader.result; + var $fileThumb = getThumbElement(file).find('.file-tmb'); + $fileThumb.css('background-image', 'url('+ dataURL +')'); + }; + + reader.readAsDataURL(file); + } else { + $fileThumb = getThumbElement(file).find('.file-tmb'); + $fileThumb.html('' + fileExt.toUpperCase() + ''); + } +} + +$(document).on('ajax_before_post', function (e, formData) { + var i; + + for (i=0; i 0) key += i + 1; + formData.append(key, files[i]); + } + + // clear file queue and UI + files = []; + $('.file-thumbs').empty(); +}); + +var dragCounter = 0; +var dropHandlers = { + dragenter: function (e) { + e.stopPropagation(); + e.preventDefault(); + + if (dragCounter === 0) $(this).addClass('dragover'); + dragCounter++; + }, + dragover: function (e) { + // needed for webkit to work + e.stopPropagation(); + e.preventDefault(); + }, + dragleave: function (e) { + e.stopPropagation(); + e.preventDefault(); + + dragCounter--; + if (dragCounter === 0) $(this).removeClass('dragover'); + }, + drop: function (e) { + e.stopPropagation(); + e.preventDefault(); + + $(this).removeClass('dragover'); + dragCounter = 0; + + var fileList = e.originalEvent.dataTransfer.files; + for (var i=0; i'); + + $fileSelector.on('change', function (e) { + if (this.files.length > 0) { + for (var i=0; i Date: Tue, 31 Mar 2015 05:50:52 +0200 Subject: better slugify support for api --- inc/api.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index f8f2a71c..a057f4ed 100644 --- a/inc/api.php +++ b/inc/api.php @@ -34,7 +34,6 @@ class Api { 'locked' => 'locked', 'bump' => 'last_modified', 'embed' => 'embed', - 'slug' => 'semantic_url', ); $this->threadsPageFields = array( @@ -117,6 +116,10 @@ class Api { } } + if ($config['slugify'] && !$post->thread) { + $apiPost['semantic_url'] = $post->slug; + } + // Handle files // Note: 4chan only supports one file, so only the first file is taken into account for 4chan-compatible API. if (isset($post->files) && $post->files && !$threadsPage) { -- cgit v1.3 From d7f82c58fdcae697d41330085b86cc39a60bf1d9 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 15 Mar 2015 23:32:53 +0800 Subject: Run on index and thread Clear file queue after upload success corrected fallback detection --- js/file-selector.js | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index 437e1d4a..c820db48 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -6,29 +6,28 @@ * $config['additional_javascript'][] = 'js/file-selector.js'; */ -onready(function () { +if (active_page == 'index' || active_page == 'thread') { +$(document).ready(function () { // add options panel item -$(document).ready(function () { - if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); +if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); - if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); - } -}); + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); +} // disabled by user, or incompatible browser. // fallback to old -if (localStorage.file_dragdrop == 'false' || !(window.FileReader || window.File)) { +if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) { $('.dropzone-wrap').remove(); $('#upload_file').show(); @@ -93,15 +92,15 @@ function addThumb(file) { } $(document).on('ajax_before_post', function (e, formData) { - var i; - - for (i=0; i 0) key += i + 1; formData.append(key, files[i]); } +}); - // clear file queue and UI +// clear file queue and UI on success +$(document).on('ajax_after_post', function () { files = []; $('.file-thumbs').empty(); }); @@ -185,3 +184,4 @@ $(document).on('paste', function (e) { }); }); +} -- cgit v1.3 From 3bd7f94861e9a2a8b9a7f8f972f04eb6eaa45453 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 18:44:47 +0800 Subject: Fallback for browsers that disables javascript Conflicts: stylesheets/style.css templates/post_form.html --- js/file-selector.js | 3 +- stylesheets/style.css | 81 ++++++++++++++++++++++++++++++++++++++++++++++++ templates/post_form.html | 8 +++++ 3 files changed, 91 insertions(+), 1 deletion(-) diff --git a/js/file-selector.js b/js/file-selector.js index c820db48..ddae2d09 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -140,7 +140,8 @@ var dropHandlers = { } }; -$('.dropzone').css('user-select', 'none') // let jquery add browser specific prefix +$('#upload input[type=file]').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); diff --git a/stylesheets/style.css b/stylesheets/style.css index e0ce08c5..56140561 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -959,3 +959,84 @@ span.pln { cursor: pointer; } +#youtube-size input { + width: 50px; +} + +/* File selector */ +.dropzone { + color: #000; + cursor: default; + margin: auto; + padding: 0px 4px; + text-align: center; + min-height: 50px; + max-height: 140px; + transition: 0.2s; + background-color: rgba(200, 200, 200, 0.5); + overflow-y: auto; +} +.dropzone-wrap { + width: 100%; +} +.dropzone .file-hint { + color: rgba(0, 0, 0, 0.5); + cursor: pointer; + position: relative; + margin-bottom: 5px; + padding: 10px 0px; + top: 5px; + transition: 0.2s; + border: 2px dashed rgba(125, 125, 125, 0.4); +} +.file-hint:hover, .dropzone.dragover .file-hint { + color: rgba(0, 0, 0, 1); + border-color: rgba(125, 125, 125, 0.8); +} +.dropzone.dragover { + background-color: rgba(200, 200, 200, 1); +} +.dropzone .file-thumbs { + text-align: left; + width: 100%; +} +.dropzone .tmb-container { + padding: 3px; + overflow-x: hidden; + white-space: nowrap; +} +.dropzone .file-tmb { + height: 40px; + width: 70px; + cursor: pointer; + display: inline-block; + text-align: center; + background-color: rgba(187, 187, 187, 0.5); + background-size: cover; + background-position: center; +} +.dropzone .file-tmb span { + font-weight: 600; + position: relative; + top: 13px; +} +.dropzone .tmb-filename { + display: inline-block; + vertical-align: bottom; + bottom: 12px; + position: relative; + margin-left: 5px; +} +.dropzone .remove-btn { + cursor: pointer; + color: rgba(125, 125, 125, 0.5); + display: inline-block; + vertical-align: bottom; + bottom: 10px; + position: relative; + margin-right: 5px; + font-size: 20px +} +.dropzone .remove-btn:hover { + color: rgba(125, 125, 125, 1); +} diff --git a/templates/post_form.html b/templates/post_form.html index 1846adb5..9596ee6b 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -98,6 +98,14 @@ + + + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 0005f11098890ad76c1b9963792cd686493649a9 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Wed, 18 Mar 2015 21:35:58 +0800 Subject: initialize file selector soon as it's loaded Conflicts: templates/post_form.html --- js/file-selector.js | 44 +++++++++++++++++++------------------------- templates/post_form.html | 2 ++ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index ddae2d09..b4589706 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -5,34 +5,29 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/file-selector.js'; */ +function init_file_selector() { -if (active_page == 'index' || active_page == 'thread') { $(document).ready(function () { + // add options panel item + if (window.Options && Options.get_tab('general')) { + Options.extend_tab('general', ''); + + $('#file-drag-drop>input').on('click', function() { + if ($('#file-drag-drop>input').is(':checked')) { + localStorage.file_dragdrop = 'true'; + } else { + localStorage.file_dragdrop = 'false'; + } + }); -// add options panel item -if (window.Options && Options.get_tab('general')) { - Options.extend_tab('general', ''); - - $('#file-drag-drop>input').on('click', function() { - if ($('#file-drag-drop>input').is(':checked')) { - localStorage.file_dragdrop = 'true'; - } else { - localStorage.file_dragdrop = 'false'; - } - }); - - if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; - if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); -} + if (localStorage.file_dragdrop === 'undefined') localStorage.file_dragdrop = 'true'; + if (localStorage.file_dragdrop === 'true') $('#file-drag-drop>input').prop('checked', true); + } +}); // disabled by user, or incompatible browser. -// fallback to old -if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) { - $('.dropzone-wrap').remove(); - $('#upload_file').show(); - +if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) return; -} // multipost not enabled if (typeof max_images == 'undefined') { @@ -40,6 +35,8 @@ if (typeof max_images == 'undefined') { } var files = []; +$('#upload_file').hide(); // hide the original file selector +$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { if (files.length == max_images) @@ -140,8 +137,6 @@ var dropHandlers = { } }; -$('#upload input[type=file]').hide(); // hide the original file selector -$('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix // attach handlers $(document).on(dropHandlers, '.dropzone'); @@ -184,5 +179,4 @@ $(document).on('paste', function (e) { } }); -}); } diff --git a/templates/post_form.html b/templates/post_form.html index 9596ee6b..809230f0 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -106,6 +106,8 @@
+ + {% if config.allow_upload_by_url %}
: -- cgit v1.3 From 4da073b6e85aae15b8eed227b3b3b16798d2a99e Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Thu, 19 Mar 2015 19:29:48 +0800 Subject: Keep quick-reply and main form in sync Use object-url instead of data-url due to shorter length --- js/file-selector.js | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index b4589706..e5451f1a 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -26,7 +26,7 @@ $(document).ready(function () { }); // disabled by user, or incompatible browser. -if (localStorage.file_dragdrop == 'false' || !(window.FileReader && window.File)) +if (localStorage.file_dragdrop == 'false' || !(window.URL.createObjectURL && window.File)) return; // multipost not enabled @@ -59,9 +59,9 @@ function addThumb(file) { var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; var fileType = file.type.split('/')[0]; var fileExt = file.type.split('/')[1]; - var $fileThumb; + var $container = $('
'); - $('.file-thumbs').append($('
') + $container .addClass('tmb-container') .data('file-ref', file) .append( @@ -69,21 +69,14 @@ function addThumb(file) { $('
').addClass('file-tmb'), $('
').addClass('tmb-filename').html(fileName) ) - ); + .appendTo($('.file-thumbs')); + var $fileThumb = $container.find('.file-tmb'); if (fileType == 'image') { // if image file, generate thumbnail - var reader = new FileReader(); - - reader.onloadend = function () { - var dataURL = reader.result; - var $fileThumb = getThumbElement(file).find('.file-tmb'); - $fileThumb.css('background-image', 'url('+ dataURL +')'); - }; - - reader.readAsDataURL(file); + var objURL = window.URL.createObjectURL(file); + $fileThumb.css('background-image', 'url('+ objURL +')'); } else { - $fileThumb = getThumbElement(file).find('.file-tmb'); $fileThumb.html('' + fileExt.toUpperCase() + ''); } } @@ -144,8 +137,8 @@ $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { var file = $(e.target).parent().data('file-ref'); + getThumbElement(file).remove(); removeFile(file); - $(e.target).parent().remove(); }); $(document).on('click', '.dropzone .file-hint', function (e) { -- cgit v1.3 From 6e84a25f9a882bc4c2cbd1e376416ac34ca9943b Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 08:53:57 +0800 Subject: Adds keyboard focus to file selector --- js/file-selector.js | 10 +++++++++- templates/post_form.html | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index e5451f1a..dbe8ea82 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -135,13 +135,21 @@ var dropHandlers = { $(document).on(dropHandlers, '.dropzone'); $(document).on('click', '.dropzone .remove-btn', function (e) { + e.stopPropagation(); + var file = $(e.target).parent().data('file-ref'); getThumbElement(file).remove(); removeFile(file); }); -$(document).on('click', '.dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { + e.stopPropagation(); + + // accept mosue click or Enter + if (e.which != 1 || e.which != 13) + return; + var $fileSelector = $(''); $fileSelector.on('change', function (e) { diff --git a/templates/post_form.html b/templates/post_form.html index 809230f0..7cdcc7d3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -100,7 +100,7 @@ - + {% if config.allow_upload_by_url %}
-- cgit v1.3 From 419d69b4eea23b1ec92762d2ba2771ac0b46a315 Mon Sep 17 00:00:00 2001 From: 8chan Date: Thu, 19 Mar 2015 20:34:54 -0700 Subject: ayylmao @marktaiwan --- js/file-selector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/file-selector.js b/js/file-selector.js index 687920d0..6a7e6773 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -147,7 +147,7 @@ $(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) e.stopPropagation(); // accept mosue click or Enter - if (e.which != 1 || e.which != 13) + if (e.which != 1 && e.which != 13) return; var $fileSelector = $(''); -- cgit v1.3 From e42ffb27684e159473320c512052246f081d04f0 Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Fri, 20 Mar 2015 12:48:32 +0800 Subject: fix file selector element reference fix thumbnail image not applying to main form with quick reply open --- js/file-selector.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index 6a7e6773..9869e347 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -59,9 +59,7 @@ function addThumb(file) { var fileName = (file.name.length < 24) ? file.name : file.name.substr(0, 22) + '…'; var fileType = file.type.split('/')[0]; var fileExt = file.type.split('/')[1]; - var $container = $('
'); - - $container + var $container = $('
') .addClass('tmb-container') .data('file-ref', file) .append( @@ -69,7 +67,7 @@ function addThumb(file) { $('
').addClass('file-tmb'), $('
').addClass('tmb-filename').html(fileName) ) - .appendTo($('.file-thumbs')); + .appendTo('.file-thumbs'); var $fileThumb = $container.find('.file-tmb'); if (fileType == 'image') { -- cgit v1.3 From 6f94a0658603f3f39032655b3cebe738c2bced0d Mon Sep 17 00:00:00 2001 From: marktaiwan Date: Sun, 22 Mar 2015 22:15:43 +0800 Subject: file selector: correct typo, click event target --- js/file-selector.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index 9869e347..fc9c83e2 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -141,11 +141,12 @@ $(document).on('click', '.dropzone .remove-btn', function (e) { removeFile(file); }); -$(document).on('keypress click', '.dropzone, .dropzone .file-hint', function (e) { +$(document).on('keypress click', '.dropzone', function (e) { e.stopPropagation(); - // accept mosue click or Enter - if (e.which != 1 && e.which != 13) + // accept mouse click or Enter + if ((e.which != 1 || e.target.className != 'file-hint') && + e.which != 13) return; var $fileSelector = $(''); -- cgit v1.3 From 765dea599bd010bc00a3a40df58953b239ec0e9d Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 06:50:05 +0200 Subject: trivial fixes to file-selector.js --- js/file-selector.js | 11 ++++++++++- js/upload-selection.js | 2 ++ templates/post_form.html | 7 ------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index fc9c83e2..6aad9382 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -34,8 +34,16 @@ if (typeof max_images == 'undefined') { var max_images = 1; } +$(''+ +'
').prependTo('#upload td'); + var files = []; -$('#upload_file').hide(); // hide the original file selector +$('#upload_file').remove(); // remove the original file selector $('.dropzone-wrap').css('user-select', 'none').show(); // let jquery add browser specific prefix function addFile(file) { @@ -83,6 +91,7 @@ $(document).on('ajax_before_post', function (e, formData) { for (var i=0; i 0) key += i + 1; + if (typeof files[i] === 'undefined') break; formData.append(key, files[i]); } }); diff --git a/js/upload-selection.js b/js/upload-selection.js index e2032748..b342a134 100644 --- a/js/upload-selection.js +++ b/js/upload-selection.js @@ -25,6 +25,7 @@ $(function(){ $("#upload_url").hide(); $("#upload_embed").hide(); $(".add_image").hide(); + $(".dropzone-wrap").hide(); $('[id^=upload_file]').each(function(i, v) { $(v).val(''); @@ -40,6 +41,7 @@ $(function(){ enable_file = function() { disable_all(); $("#upload").show(); + $(".dropzone-wrap").show(); $(".file_separator").show(); $("[id^=upload_file]").show(); $(".add_image").show(); diff --git a/templates/post_form.html b/templates/post_form.html index 00390daf..d6a77452 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -99,13 +99,6 @@ - - {% if config.allow_upload_by_url %} -- cgit v1.3 From 388e87746ef936d6ce6ec04f7e09bbcd17d8e4fc Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 06:55:29 +0200 Subject: small tweaks to stylesheet --- stylesheets/style.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/stylesheets/style.css b/stylesheets/style.css index 56140561..2565ba4f 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -93,13 +93,17 @@ input[type="text"],input[type="password"],textarea { text-shadow: none; text-transform: none; word-spacing: normal; - max-width: 75%; + max-width: 100%; } #quick-reply input[type="text"], input[type="password"], #quick-reply textarea { max-width: 100%; } +textarea { + width: 100%; +} + form table tr td { text-align: left; margin: 0; -- cgit v1.3 From c74fc6cefb69e751ee3a8b6c65eeb22f6e499753 Mon Sep 17 00:00:00 2001 From: anonish Date: Thu, 29 Jan 2015 21:44:11 -0600 Subject: QR fix for tablet (portrait) mode in laptops Quick reply will now show up on tablets in portrait mode where width can be < 800px as originally coded (mainly 768x1280 and 800x1280) --- js/quick-reply.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/quick-reply.js b/js/quick-reply.js index 6661501c..a8145607 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -116,7 +116,7 @@ #quick-reply td.recaptcha-response {\ padding: 0 0 1px 0;\ }\ - @media screen and (max-width: 800px) {\ + @media screen and (max-width: 600px) {\ #quick-reply {\ display: none !important;\ }\ @@ -364,7 +364,7 @@ $(window).ready(function() { if (settings.get('hide_at_top', true)) { $(window).scroll(function() { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100) $postForm.fadeOut(100); @@ -385,7 +385,7 @@ }; $(window).on('cite', function(e, id, with_link) { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; show_quick_reply(); if (with_link) { @@ -440,7 +440,7 @@ $('.quick-reply-btn').hide(); $(window).scroll(function() { - if ($(this).width() <= 800) + if ($(this).width() <= 600) return; if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100) $('.quick-reply-btn').fadeOut(100); -- cgit v1.3 From d3d54b8c764b779c6d3cf1d2a6cd49f204d60387 Mon Sep 17 00:00:00 2001 From: Anonish Date: Fri, 6 Feb 2015 20:42:13 -0600 Subject: Update quick-reply.js apparently 600 was still not allowing QR to load on portrait mode. 400 seems to work fine --- js/quick-reply.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/quick-reply.js b/js/quick-reply.js index a8145607..12cca366 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -116,7 +116,7 @@ #quick-reply td.recaptcha-response {\ padding: 0 0 1px 0;\ }\ - @media screen and (max-width: 600px) {\ + @media screen and (max-width: 400px) {\ #quick-reply {\ display: none !important;\ }\ @@ -364,7 +364,7 @@ $(window).ready(function() { if (settings.get('hide_at_top', true)) { $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $origPostForm.offset().top + $origPostForm.height() - 100) $postForm.fadeOut(100); @@ -385,7 +385,7 @@ }; $(window).on('cite', function(e, id, with_link) { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; show_quick_reply(); if (with_link) { @@ -440,7 +440,7 @@ $('.quick-reply-btn').hide(); $(window).scroll(function() { - if ($(this).width() <= 600) + if ($(this).width() <= 400) return; if ($(this).scrollTop() < $('form[name="post"]:first').offset().top + $('form[name="post"]:first').height() - 100) $('.quick-reply-btn').fadeOut(100); -- cgit v1.3 From 745bdc2b6cf5af863a7ae86f5b95b14746f5f2e4 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:01:51 +0200 Subject: password is text nao, fuck you chrome --- templates/post_form.html | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/templates/post_form.html b/templates/post_form.html index d6a77452..d2e644b3 100644 --- a/templates/post_form.html +++ b/templates/post_form.html @@ -146,14 +146,9 @@ {% trans %}Password{% endtrans %} {{ antibot.html() }} - - - - - - + {% trans %}(For file deletion.){% endtrans %} {{ antibot.html() }} -- cgit v1.3 From 0e805c25d8f3044a2c6640a1e8818d3774a0ff07 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:20:53 +0200 Subject: file-selector.js: allow file dropping anywhere --- js/file-selector.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/file-selector.js b/js/file-selector.js index 6aad9382..207a5ae9 100644 --- a/js/file-selector.js +++ b/js/file-selector.js @@ -108,7 +108,7 @@ var dropHandlers = { e.stopPropagation(); e.preventDefault(); - if (dragCounter === 0) $(this).addClass('dragover'); + if (dragCounter === 0) $('.dropzone').addClass('dragover'); dragCounter++; }, dragover: function (e) { @@ -121,13 +121,13 @@ var dropHandlers = { e.preventDefault(); dragCounter--; - if (dragCounter === 0) $(this).removeClass('dragover'); + if (dragCounter === 0) $('.dropzone').removeClass('dragover'); }, drop: function (e) { e.stopPropagation(); e.preventDefault(); - $(this).removeClass('dragover'); + $('.dropzone').removeClass('dragover'); dragCounter = 0; var fileList = e.originalEvent.dataTransfer.files; @@ -139,7 +139,7 @@ var dropHandlers = { // attach handlers -$(document).on(dropHandlers, '.dropzone'); +$(document).on(dropHandlers); $(document).on('click', '.dropzone .remove-btn', function (e) { e.stopPropagation(); -- cgit v1.3 From de1a9fe568f21e88f326f5e645973c41d11b3211 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:27:22 +0200 Subject: futaba+vichan.css: do proper styling --- stylesheets/futaba+vichan.css | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/stylesheets/futaba+vichan.css b/stylesheets/futaba+vichan.css index 5f7d742b..c67fc93a 100644 --- a/stylesheets/futaba+vichan.css +++ b/stylesheets/futaba+vichan.css @@ -83,15 +83,12 @@ div.boardlist a { table.modlog tr th { background: #EA8; } -div.boardlist { - background-color: rgba(90%,90%,90%,0.2); +.desktop-style div.boardlist:nth-child(1), .desktop-style div.boardlist:nth-child(1):hover { + background-color: #f0e0d6; } div.boardlist .sub { background: none; } -div.boardlist.bottom { - background-color:transparent; -} .desktop-style div.boardlist:nth-child(1) { text-shadow: #fff 1px 1px 1px, #fff -1px -1px 1px; @@ -116,3 +113,8 @@ div.boardlist.bottom { border-color: #d9bfb7; border-width: 1px 0px 0px 1px; } + +.dropzone { + background-color: white; + border: 1px solid #a9a9a9; +} -- cgit v1.3 From a8982ce0a9182466c72ee54d59e0576e914dd221 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:29:52 +0200 Subject: f+v.css ... --- stylesheets/futaba+vichan.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/stylesheets/futaba+vichan.css b/stylesheets/futaba+vichan.css index c67fc93a..f00dc9b7 100644 --- a/stylesheets/futaba+vichan.css +++ b/stylesheets/futaba+vichan.css @@ -93,9 +93,6 @@ div.boardlist .sub { .desktop-style div.boardlist:nth-child(1) { text-shadow: #fff 1px 1px 1px, #fff -1px -1px 1px; } -.desktop-style div.boardlist:nth-child(1):hover, .desktop-style div.boardlist:nth-child(1).cb-menu { - background-color: rgba(90%, 90%, 90%, 0.55); -} /* options.js */ #options_div, #alert_div { -- cgit v1.3 From 2f7127a3cb23d88d1b1727fc61c5c44389cc9caf Mon Sep 17 00:00:00 2001 From: Markerov Date: Sun, 2 Nov 2014 22:55:35 +0800 Subject: Catalog Search --- js/catalog-search.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 js/catalog-search.js diff --git a/js/catalog-search.js b/js/catalog-search.js new file mode 100644 index 00000000..97121e3b --- /dev/null +++ b/js/catalog-search.js @@ -0,0 +1,82 @@ +/* + * catalog-search.js + * - Search and filters threads when on catalog view + * - Optional shortcuts 's' and 'esc' to open and close the search. + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/comment-toolbar.js'; + */ +if (active_page == 'catalog') { + $(document).ready(function () { + 'use strict'; + + // 'true' = enable shortcuts + var useKeybinds = true; + + // trigger the search 400ms after last keystroke + var delay = 400; + var timeoutHandle; + + //search and hide none matching threads + function filter(search_term) { + $('.replies').each(function () { + var subject = $(this).children('.intro').text().toLowerCase(); + var comment = $(this).clone().children().remove(':lt(2)').end().text().trim().toLowerCase(); + search_term = search_term.toLowerCase(); + + if (subject.indexOf(search_term) == -1 && comment.indexOf(search_term) == -1) { + $(this).parents('div[id="Grid"]>.mix').css('display', 'none'); + } else { + $(this).parents('div[id="Grid"]>.mix').css('display', 'inline-block'); + } + }); + } + + function searchToggle() { + var button = $('#catalog_search_button')[0]; + + if (!button.dataset.expanded) { + button.dataset.expanded = '1'; + button.innerText = 'Close'; + $('.catalog_search').append(' '); + $('#search_field').focus(); + } else { + delete button.dataset.expanded; + button.innerText = 'Search'; + $('.catalog_search').children().last().remove(); + $('div[id="Grid"]>.mix').each(function () { $(this).css('display', 'inline-block'); }); + } + } + + $('.threads').before('[]'); + $('#catalog_search_button').text('Search'); + + $('#catalog_search_button').on('click', searchToggle); + $('.catalog_search').on('keyup', 'input#search_field', function (e) { + window.clearTimeout(timeoutHandle); + timeoutHandle = window.setTimeout(filter, 400, e.target.value); + }); + + if (useKeybinds) { + // 's' + $('body').on('keydown', function (e) { + if (e.which === 83 && e.target.tagName === 'BODY' && !(e.ctrlKey || e.altKey || e.shiftKey)) { + e.preventDefault(); + if ($('#search_field').length !== 0) { + $('#search_field').focus(); + } else { + searchToggle(); + } + } + }); + // 'esc' + $('.catalog_search').on('keydown', 'input#search_field', function (e) { + if (e.which === 27 && !(e.ctrlKey || e.altKey || e.shiftKey)) { + window.clearTimeout(timeoutHandle); + searchToggle(); + } + }); + } + }); +} -- cgit v1.3 From 6363d8d24721d1c3138cf3d1574f6795efe91c91 Mon Sep 17 00:00:00 2001 From: Markerov Date: Fri, 2 Jan 2015 17:13:29 +0800 Subject: change to use onready() --- js/catalog-search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/catalog-search.js b/js/catalog-search.js index 97121e3b..17a8edac 100644 --- a/js/catalog-search.js +++ b/js/catalog-search.js @@ -8,7 +8,7 @@ * $config['additional_javascript'][] = 'js/comment-toolbar.js'; */ if (active_page == 'catalog') { - $(document).ready(function () { + onready(function () { 'use strict'; // 'true' = enable shortcuts -- cgit v1.3 From 960053af750a9e8ce196a3855c9fbee69f9ec0ba Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 07:48:03 +0200 Subject: catalog: fix for embed youtube on https --- templates/themes/catalog/catalog.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/themes/catalog/catalog.html b/templates/themes/catalog/catalog.html index aef6c139..acf538f0 100644 --- a/templates/themes/catalog/catalog.html +++ b/templates/themes/catalog/catalog.html @@ -48,7 +48,7 @@
{% if post.youtube %} - Date: Wed, 26 Nov 2014 21:10:27 +0000 Subject: add global option for tree view --- js/treeview.js | 71 ++++++++++++++++++++++++++++++++------------------- stylesheets/style.css | 3 ++- 2 files changed, 47 insertions(+), 27 deletions(-) diff --git a/js/treeview.js b/js/treeview.js index 78ad620b..c9bd55f8 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -11,35 +11,54 @@ * */ +if (active_page == 'thread' || active_page == 'ukko' || active_page == 'index') +$(function() { + if (window.Options && Options.get_tab('general')) { + var selector = '#treeview-global>input'; + Options.extend_tab("general", ""); + } + $(selector).on('change', function () { + if (localStorage.treeview === 'true') { + localStorage.treeview = 'false'; + } else { + localStorage.treeview = 'true'; + } + }); + if (localStorage.treeview === 'true') { + $(selector).attr('checked', 'checked'); + } +}); + if (active_page == 'thread') $(function() { + var treeview = function() { + $('.post.reply').each(function(){ + var references = []; + $(this).find('.body a').each(function(){ + if ($(this).html().match('^>>[0-9]+$')) { + references.push(parseInt($(this).html().replace('>>', ''))); + } + }); + var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); + + var parent_post = $("#reply_"+maxref); + if (parent_post.length == 0) return; + + var margin = parseInt(parent_post.css("margin-left"))+32; + + var post = $(this); + var br = post.next(); + + post.detach().css("margin-left", margin).insertAfter(parent_post.next()); + br.detach().insertAfter(post); + }); + } + if (localStorage.treeview === 'true') { + treeview(); + } + $('hr:first').before('
'); $('div#treeview a') .text(_('Tree view')) - .click(function(e) { - e.preventDefault(); - - $('.post.reply').each(function(){ - var references = []; - $(this).find('.body a').each(function(){ - if ($(this).html().match('^>>[0-9]+$')) { - references.push(parseInt($(this).html().replace('>>', ''))); - } - }); - - var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); - - var parent_post = $("#reply_"+maxref); - if (parent_post.length == 0) return; - - var margin = parseInt(parent_post.css("margin-left"))+32; - - var post = $(this); - var br = post.next(); - - post.detach().css("margin-left", margin).insertAfter(parent_post.next()); - br.detach().insertAfter(post); - - }); - }); + .click(function(e) { treeview(); e.preventDefault(); }); }); diff --git a/stylesheets/style.css b/stylesheets/style.css index 2565ba4f..d2cc0572 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -825,7 +825,7 @@ div.thread:hover { #options_div { width: 600px; - height: 300px; + height: 320px; } #alert_div { @@ -892,6 +892,7 @@ div.thread:hover { right: 0px; text-align: left; font-size: 12px; + overflow-y: auto; } .options_tab h2 { -- cgit v1.3 From d67351534a4d54af65b0b9d6515587c49c772934 Mon Sep 17 00:00:00 2001 From: topkek Date: Wed, 26 Nov 2014 22:48:54 +0000 Subject: toggle tree view --- js/treeview.js | 52 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/js/treeview.js b/js/treeview.js index c9bd55f8..937ea6ff 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -31,27 +31,41 @@ $(function() { if (active_page == 'thread') $(function() { + var treeview_on = false; var treeview = function() { - $('.post.reply').each(function(){ - var references = []; - $(this).find('.body a').each(function(){ - if ($(this).html().match('^>>[0-9]+$')) { - references.push(parseInt($(this).html().replace('>>', ''))); - } - }); - var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); - - var parent_post = $("#reply_"+maxref); - if (parent_post.length == 0) return; - - var margin = parseInt(parent_post.css("margin-left"))+32; - - var post = $(this); - var br = post.next(); + if (!treeview_on) { + treeview_on = true; + $('.post.reply').each(function(){ + var references = []; + $(this).find('.body a').each(function(){ + if ($(this).html().match('^>>[0-9]+$')) { + references.push(parseInt($(this).html().replace('>>', ''))); + } + }); + var maxref = references.reduce(function(a,b) { return a > b ? a : b; }, 0); + + var parent_post = $("#reply_"+maxref); + if (parent_post.length == 0) return; + + var margin = parseInt(parent_post.css("margin-left"))+32; - post.detach().css("margin-left", margin).insertAfter(parent_post.next()); - br.detach().insertAfter(post); - }); + var post = $(this); + var br = post.next(); + + post.detach().css("margin-left", margin).insertAfter(parent_post.next()); + br.detach().insertAfter(post); + }); + } else { + treeview_on = false; + $('.post.reply').sort(function(a,b) { + return parseInt(a.id.replace('reply_', '')) > parseInt(b.id.replace('reply_', '')); + }).each(function () { + var post = $(this); + var br = post.next(); + post.detach().css('margin-left', '0').appendTo('.thread'); + br.detach().insertAfter(post); + }); + } } if (localStorage.treeview === 'true') { treeview(); -- cgit v1.3 From 1888e174b3d6ea6a506c62cc1c75c9d6acf6ff72 Mon Sep 17 00:00:00 2001 From: topkek Date: Thu, 27 Nov 2014 00:36:51 +0000 Subject: chrome fix --- js/treeview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/treeview.js b/js/treeview.js index 937ea6ff..046a9796 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -58,7 +58,7 @@ $(function() { } else { treeview_on = false; $('.post.reply').sort(function(a,b) { - return parseInt(a.id.replace('reply_', '')) > parseInt(b.id.replace('reply_', '')); + return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', '')); }).each(function () { var post = $(this); var br = post.next(); -- cgit v1.3 From 8de9b68f5f5386265a624678bf95214e44f9bc21 Mon Sep 17 00:00:00 2001 From: topkek Date: Fri, 28 Nov 2014 01:15:10 +0000 Subject: checkbox for tree view Conflicts: js/post-hover.js --- js/favorites.js | 1 - js/treeview.js | 21 +++++++++------------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/js/favorites.js b/js/favorites.js index e325e110..daf7b732 100644 --- a/js/favorites.js +++ b/js/favorites.js @@ -54,7 +54,6 @@ 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(); diff --git a/js/treeview.js b/js/treeview.js index 046a9796..dcd87e1e 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -31,10 +31,8 @@ $(function() { if (active_page == 'thread') $(function() { - var treeview_on = false; - var treeview = function() { - if (!treeview_on) { - treeview_on = true; + var treeview = function(enable) { + if (enable === true) { $('.post.reply').each(function(){ var references = []; $(this).find('.body a').each(function(){ @@ -56,23 +54,22 @@ $(function() { br.detach().insertAfter(post); }); } else { - treeview_on = false; $('.post.reply').sort(function(a,b) { return parseInt(a.id.replace('reply_', '')) - parseInt(b.id.replace('reply_', '')); }).each(function () { var post = $(this); var br = post.next(); - post.detach().css('margin-left', '0').appendTo('.thread'); + post.detach().css('margin-left', '').appendTo('.thread'); br.detach().insertAfter(post); }); } } + + $('hr:first').before('
'); + $('input#treeview').on('change', function(e) { treeview($(this).is(':checked')); }); + if (localStorage.treeview === 'true') { - treeview(); + treeview(true); + $('input#treeview').attr('checked', true); } - - $('hr:first').before('
'); - $('div#treeview a') - .text(_('Tree view')) - .click(function(e) { treeview(); e.preventDefault(); }); }); -- cgit v1.3 From e6da7b4682a80b63008b6f2bb550515d5c90d774 Mon Sep 17 00:00:00 2001 From: topkek Date: Fri, 28 Nov 2014 21:59:05 +0000 Subject: clean up options code --- js/treeview.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/js/treeview.js b/js/treeview.js index dcd87e1e..1709debb 100644 --- a/js/treeview.js +++ b/js/treeview.js @@ -16,16 +16,16 @@ $(function() { if (window.Options && Options.get_tab('general')) { var selector = '#treeview-global>input'; Options.extend_tab("general", ""); - } - $(selector).on('change', function () { + $(selector).on('change', function() { + if (localStorage.treeview === 'true') { + localStorage.treeview = 'false'; + } else { + localStorage.treeview = 'true'; + } + }); if (localStorage.treeview === 'true') { - localStorage.treeview = 'false'; - } else { - localStorage.treeview = 'true'; + $(selector).attr('checked', 'checked'); } - }); - if (localStorage.treeview === 'true') { - $(selector).attr('checked', 'checked'); } }); -- cgit v1.3 From d94143b6c67e1c48fee2f6ecb549fd3197a66378 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 08:58:54 +0200 Subject: fix wpaint & file-selection interaction --- js/wpaint.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/wpaint.js b/js/wpaint.js index 67d58fc2..a245a22b 100644 --- a/js/wpaint.js +++ b/js/wpaint.js @@ -44,7 +44,7 @@ oekaki.init = function() { var oekaki_form = 'Oekaki
'; // Add oekaki after the file input - $('form[name="post"]:not(#quick-reply) input[type="file"]').parent().parent().after(oekaki_form); + $('form[name="post"]:not(#quick-reply) [id="upload"]').after(oekaki_form); $('').appendTo($("head")); $('').appendTo($("head")); -- cgit v1.3 From 6cbd51b83c46b103624690ebe14846c02f542d68 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 31 Mar 2015 09:17:22 +0200 Subject: for fastcgi users: rearrange post.php, sort of, so that posts are created faster, and we can leave php to generate themes in the background same for post deletion --- post.php | 51 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/post.php b/post.php index 100c3efb..09a5f53f 100644 --- a/post.php +++ b/post.php @@ -92,18 +92,22 @@ if (isset($_POST['delete'])) { buildIndex(); - - rebuildThemes('post-delete', $board['uri']); - $is_mod = isset($_POST['mod']) && $_POST['mod']; $root = $is_mod ? $config['root'] . $config['file_mod'] . '?/' : $config['root']; - + if (!isset($_POST['json_response'])) { header('Location: ' . $root . $board['dir'] . $config['file_index'], true, $config['redirect_http']); } else { header('Content-Type: text/json'); echo json_encode(array('success' => true)); } + + // We are already done, let's continue our heavy-lifting work in the background (if we run off FastCGI) + if (function_exists('fastcgi_finish_request')) + @fastcgi_finish_request(); + + rebuildThemes('post-delete', $board['uri']); + } elseif (isset($_POST['report'])) { if (!isset($_POST['board'], $_POST['reason'])) error($config['error']['bot']); @@ -827,18 +831,6 @@ if (isset($_POST['delete'])) { bumpThread($post['thread']); } - buildThread($post['op'] ? $id : $post['thread']); - - if ($config['try_smarter'] && $post['op']) - $build_pages = range(1, $config['max_pages']); - - if ($post['op']) - clean(); - - event('post-after', $post); - - buildIndex(); - if (isset($_SERVER['HTTP_REFERER'])) { // Tell Javascript that we posted successfully if (isset($_COOKIE[$config['cookies']['js']])) @@ -875,6 +867,8 @@ if (isset($_POST['delete'])) { $redirect = $root . $board['dir'] . $config['file_index']; } + + buildThread($post['op'] ? $id : $post['thread']); if ($config['syslog']) _syslog(LOG_INFO, 'New post: /' . $board['dir'] . $config['dir']['res'] . @@ -882,11 +876,6 @@ if (isset($_POST['delete'])) { if (!$post['mod']) header('X-Associated-Content: "' . $redirect . '"'); - if ($post['op']) - rebuildThemes('post-thread', $board['uri']); - else - rebuildThemes('post', $board['uri']); - if (!isset($_POST['json_response'])) { header('Location: ' . $redirect, true, $config['redirect_http']); } else { @@ -897,6 +886,26 @@ if (isset($_POST['delete'])) { 'id' => $id )); } + + if ($config['try_smarter'] && $post['op']) + $build_pages = range(1, $config['max_pages']); + + if ($post['op']) + clean(); + + event('post-after', $post); + + buildIndex(); + + // We are already done, let's continue our heavy-lifting work in the background (if we run off FastCGI) + if (function_exists('fastcgi_finish_request')) + @fastcgi_finish_request(); + + if ($post['op']) + rebuildThemes('post-thread', $board['uri']); + else + rebuildThemes('post', $board['uri']); + } elseif (isset($_POST['appeal'])) { if (!isset($_POST['ban_id'])) error($config['error']['bot']); -- cgit v1.3 From 7fd8c75450200c18c5cf42a839183a55a924cb1e Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 16:53:28 +0200 Subject: don`t rebuild a page, when not needed, even if it doesn`t exist --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index ab55d214..7df75ef2 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1494,7 +1494,7 @@ function buildIndex() { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); if (!$config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) - && !in_array($page, $build_pages) && is_file($filename)) + && !in_array($page, $build_pages) ) continue; $content = index($page); if (!$content) @@ -1511,7 +1511,7 @@ function buildIndex() { } if ($config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) - && !in_array($page, $build_pages) && is_file($filename)) + && !in_array($page, $build_pages) ) continue; if ($config['try_smarter']) { -- cgit v1.3 From deefe8299b10cef01db1ef782f09e6cf44e6a773 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 16:56:17 +0200 Subject: unlink a .gz version of a file if it exists --- inc/functions.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 7df75ef2..bdc03535 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -636,6 +636,13 @@ function file_unlink($path) { } $ret = @unlink($path); + + if ($config['gzip_static']) { + $gzpath = "$path.gz"; + + @unlink($gzpath); + } + if (isset($config['purge']) && $path[0] != '/' && isset($_SERVER['HTTP_HOST'])) { // Purge cache if (basename($path) == $config['file_index']) { -- cgit v1.3 From 4030c42bb49ae3d71c6e252861699cbea30496ba Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 17:07:24 +0200 Subject: add a global_api variable for buildIndex --- inc/functions.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index bdc03535..eedccae0 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1485,7 +1485,7 @@ function checkMute() { } } -function buildIndex() { +function buildIndex($global_api = "yes") { global $board, $config, $build_pages; $pages = getPages(); @@ -1500,8 +1500,8 @@ function buildIndex() { for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); - if (!$config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) - && !in_array($page, $build_pages) ) + if (!$config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) continue; $content = index($page); if (!$content) @@ -1517,8 +1517,8 @@ function buildIndex() { $catalog[$page-1] = $threads; } - if ($config['api']['enabled'] && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) - && !in_array($page, $build_pages) ) + if ($config['api']['enabled'] && $global_api == "skip" && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) continue; if ($config['try_smarter']) { @@ -1547,7 +1547,7 @@ function buildIndex() { } // json api catalog - if ($config['api']['enabled']) { + if ($config['api']['enabled'] && $global_api != "skip") { $json = json_encode($api->translateCatalog($catalog)); $jsonFilename = $board['dir'] . 'catalog.json'; file_write($jsonFilename, $json); -- cgit v1.3 From e4e01e45733488a756f457f0681dc90b28f6fa1b Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 17:16:30 +0200 Subject: smart build: define configuration variables --- inc/config.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/inc/config.php b/inc/config.php index 0ba1952b..be1bb8e1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1181,9 +1181,20 @@ // Website favicon. // $config['url_favicon'] = '/favicon.gif'; - // EXPERIMENTAL: Try not to build pages when we shouldn't have to. + // Try not to build pages when we shouldn't have to. $config['try_smarter'] = true; + // EXPERIMENTAL: Defer static HTML building to a moment, when a given file is actually accessed. + // Warning: This option won't run out of the box. You need to tell your webserver, that a file + // for serving 403 and 404 pages is /smart_build.php. Also, you need to turn off indexes. + $config['smart_build'] = false; + + // Smart build related: when a file doesn't exist, where should we redirect? + $config['page_404'] = '/404.html'; + + // Smart build related: extra entrypoints. + $config['smart_build_entrypoints'] = array(); + /* * ==================== * Mod settings -- cgit v1.3 From d4892aca123df1bc04287b0ce37fafb7e71f1f2a Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 17:30:06 +0200 Subject: fix one of the previous commits: fix api_global --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index eedccae0..6f736310 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1500,7 +1500,7 @@ function buildIndex($global_api = "yes") { for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); - if (!$config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) + if ((!$config['api']['enabled'] || $global_api == "skip") && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) continue; $content = index($page); @@ -1517,7 +1517,7 @@ function buildIndex($global_api = "yes") { $catalog[$page-1] = $threads; } - if ($config['api']['enabled'] && $global_api == "skip" && $config['try_smarter'] && isset($build_pages) + if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) continue; -- cgit v1.3 From ed07404f08eafa267a4bca13fdfbfacf5f19975f Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 17:50:59 +0200 Subject: smart_build.php: initial release --- smart_build.php | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 smart_build.php diff --git a/smart_build.php b/smart_build.php new file mode 100644 index 00000000..6621238e --- /dev/null +++ b/smart_build.php @@ -0,0 +1,139 @@ + $config['max_pages']) return false; + $config['try_smarter'] = true; + $build_pages = array($page); + buildIndex("skip"); + return true; +} + +function sb_api_board($b, $page = 0) { $page = (int)$page; + return sb_board($b, $page + 1); +} + +function sb_thread($b, $thread) { global $config; $thread = (int)$thread; + if (!openBoard($b)) return false; + buildThread($thread); + return true; +} + +function sb_api($b) { global $config; + if (!openBoard($b)) return false; + $config['try_smarter'] = true; + $build_pages = array(-1); + buildIndex(); + return true; +} + +function sb_ukko() { + rebuildTheme("ukko", "post-thread"); + return true; +} + +function sb_catalog($b) { + rebuildTheme("catalog", "post-thread", $b); + return true; +} + +function sb_recent() { + rebuildTheme("recent", "post-thread"); + return true; +} + +$entrypoints = array(); + +$entrypoints['/%b/'] = 'sb_board'; +$entrypoints['/%b/'.$config['file_index']] = 'sb_board'; +$entrypoints['/%b/'.$config['file_page']] = 'sb_board'; +$entrypoints['/%b/%d.json'] = 'sb_api_board'; +if ($config['api']['enabled']) { + $entrypoints['/%b/threads.json'] = 'sb_api'; + $entrypoints['/%b/catalog.json'] = 'sb_api'; +} + +$entrypoints['/%b/'.$config['dir']['res'].$config['file_page']] = 'sb_thread'; +$entrypoints['/%b/'.$config['dir']['res'].$config['file_page50']] = 'sb_thread'; +if ($config['slugify']) { + $entrypoints['/%b/'.$config['dir']['res'].$config['file_page_slug']] = 'sb_thread'; + $entrypoints['/%b/'.$config['dir']['res'].$config['file_page50_slug']] = 'sb_thread'; +} +if ($config['api']['enabled']) { + $entrypoints['/%b/'.$config['dir']['res'].'%d.json'] = 'sb_thread'; +} + +$entrypoints['/*/'] = 'sb_ukko'; +$entrypoints['/*/index.html'] = 'sb_ukko'; +$entrypoints['/recent.html'] = 'sb_recent'; +$entrypoints['/%b/catalog.html'] = 'sb_catalog'; + +$reached = false; + +$request = $_SERVER['REQUEST_URI']; + +foreach ($entrypoints as $id => $fun) { + $id = '@^' . preg_quote($id, '@') . '$@u'; + + $id = str_replace('%b', '('.$config['board_regex'].')', $id); + $id = str_replace('%d', '([0-9]+)', $id); + $id = str_replace('%s', '[a-zA-Z0-9-]+', $id); + + $matches = null; + + if (preg_match ($id, $request, $matches)) { + array_shift($matches); + + $reached = call_user_func_array($fun, $matches); + + break; + } +} + +if ($reached) { + if ($request[strlen($request)-1] == '/') { + $request .= 'index.html'; + } + $request = '.'.$request; + + if (!file_exists($request)) { + header("Location: ".$config['page_404']); + die(); + } + + header("HTTP/1.1 200 OK"); + header("Status: 200 OK"); + if (preg_match('/\.json$/', $request)) { + header("Content-Type", "application/json"); + } + elseif (preg_match('/\.js$/', $request)) { + header("Content-Type", "text/javascript; charset=utf-8"); + } + else { + header("Content-Type", "text/html; charset=utf-8"); + } + header("Cache-Control: public, nocache, no-cache, max-age=0, must-revalidate"); + header("Expires: Fri, 22 Feb 1991 06:00:00 GMT"); + header("Last-Modified: ".date('r', filemtime($request))); + + //if (isset ($_SERVER['HTTP_ACCEPT_ENCODING']) && preg_match('/gzip/', $_SERVER['HTTP_ACCEPT_ENCODING']) && file_exists($request.".gz")) { + // header("Content-Encoding: gzip"); + // $file = fopen($request.".gz", 'r'); + //} + //else { + $file = fopen($request, 'r'); + //} + fpassthru($file); + fclose($file); +} +else { + header("Location: ".$config['page_404']); +} -- cgit v1.3 From 55277ce3835fecf44bb1a0cc1ba0b02d23846848 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 18:11:08 +0200 Subject: smart_build for buildIndex --- inc/functions.php | 95 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 6f736310..568b7f0a 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1488,53 +1488,62 @@ function checkMute() { function buildIndex($global_api = "yes") { global $board, $config, $build_pages; - $pages = getPages(); - if (!$config['try_smarter']) - $antibot = create_antibot($board['uri']); + if (!$config['smart_build']) { + $pages = getPages(); + if (!$config['try_smarter']) + $antibot = create_antibot($board['uri']); - if ($config['api']['enabled']) { - $api = new Api(); - $catalog = array(); + if ($config['api']['enabled']) { + $api = new Api(); + $catalog = array(); + } } for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); + $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - if ((!$config['api']['enabled'] || $global_api == "skip") && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) + if ((!$config['api']['enabled'] || $global_api == "skip" || $config['smart_build']) && $config['try_smarter'] + && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) continue; - $content = index($page); - if (!$content) - break; - // json api - if ($config['api']['enabled']) { - $threads = $content['threads']; - $json = json_encode($api->translatePage($threads)); - $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - file_write($jsonFilename, $json); + if (!$config['smart_build']) { + $content = index($page); + if (!$content) + break; - $catalog[$page-1] = $threads; - } + // json api + if ($config['api']['enabled']) { + $threads = $content['threads']; + $json = json_encode($api->translatePage($threads)); + file_write($jsonFilename, $json); - if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) - continue; + $catalog[$page-1] = $threads; + } - if ($config['try_smarter']) { - $antibot = create_antibot($board['uri'], 0 - $page); - $content['current_page'] = $page; - } - $antibot->reset(); - $content['pages'] = $pages; - $content['pages'][$page-1]['selected'] = true; - $content['btn'] = getPageButtons($content['pages']); - $content['antibot'] = $antibot; + if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) + continue; - file_write($filename, Element('index.html', $content)); + if ($config['try_smarter']) { + $antibot = create_antibot($board['uri'], 0 - $page); + $content['current_page'] = $page; + } + $antibot->reset(); + $content['pages'] = $pages; + $content['pages'][$page-1]['selected'] = true; + $content['btn'] = getPageButtons($content['pages']); + $content['antibot'] = $antibot; + + file_write($filename, Element('index.html', $content)); + } + else { + file_unlink($filename); + file_unlink($jsonFilename); + } } - if ($page < $config['max_pages']) { + if (!$config['smart_build'] && $page < $config['max_pages']) { for (;$page<=$config['max_pages'];$page++) { $filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page)); file_unlink($filename); @@ -1548,13 +1557,21 @@ function buildIndex($global_api = "yes") { // json api catalog if ($config['api']['enabled'] && $global_api != "skip") { - $json = json_encode($api->translateCatalog($catalog)); - $jsonFilename = $board['dir'] . 'catalog.json'; - file_write($jsonFilename, $json); + if ($config['smart_build']) { + $jsonFilename = $board['dir'] . 'catalog.json'; + file_unlink($jsonFilename); + $jsonFilename = $board['dir'] . 'threads.json'; + file_unlink($jsonFilename); + } + else { + $json = json_encode($api->translateCatalog($catalog)); + $jsonFilename = $board['dir'] . 'catalog.json'; + file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); - $jsonFilename = $board['dir'] . 'threads.json'; - file_write($jsonFilename, $json); + $json = json_encode($api->translateCatalog($catalog, true)); + $jsonFilename = $board['dir'] . 'threads.json'; + file_write($jsonFilename, $json); + } } if ($config['try_smarter']) -- cgit v1.3 From 14671e05353c11b44231c08cebea9a1777d55565 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 18:13:32 +0200 Subject: functions.php fix: after_open_board support; so that we may disable smart_build immediately after open_board --- inc/functions.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 568b7f0a..1c60393c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -475,6 +475,11 @@ function openBoard($uri) { $board = getBoardInfo($uri); if ($board) { setupBoard($board); + + if (function_exists('after_open_board')) { + after_open_board(); + } + return true; } return false; -- cgit v1.3 From f2a74812f0a135370969bcdedea8a8c9c3f96aed Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 18:43:48 +0200 Subject: smart_build: buildThread --- inc/functions.php | 85 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 1c60393c..7ed3af5a 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2068,51 +2068,62 @@ function buildThread($id, $return = false, $mod = false) { cache::delete("thread_{$board['uri']}_{$id}"); } - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + if (!$config['smart_build'] || $return || $mod) { + $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); - while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - if (!isset($thread)) { - $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); - } else { - $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + if (!isset($thread)) { + $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); + } else { + $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); + } } - } - // Check if any posts were found - if (!isset($thread)) - error($config['error']['nonexistant']); + // Check if any posts were found + if (!isset($thread)) + error($config['error']['nonexistant']); - $hasnoko50 = $thread->postCount() >= $config['noko50_min']; - $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); - - $body = Element('thread.html', array( - 'board' => $board, - 'thread' => $thread, - 'body' => $thread->build(), - 'config' => $config, - 'id' => $id, - 'mod' => $mod, - 'hasnoko50' => $hasnoko50, - 'isnoko50' => false, - 'antibot' => $antibot, - 'boardlist' => createBoardlist($mod), - 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) - )); - - if ($config['try_smarter'] && !$mod) - $build_pages[] = thread_find_page($id); + $hasnoko50 = $thread->postCount() >= $config['noko50_min']; + $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); - // json api - if ($config['api']['enabled']) { - $api = new Api(); - $json = json_encode($api->translateThread($thread)); + $body = Element('thread.html', array( + 'board' => $board, + 'thread' => $thread, + 'body' => $thread->build(), + 'config' => $config, + 'id' => $id, + 'mod' => $mod, + 'hasnoko50' => $hasnoko50, + 'isnoko50' => false, + 'antibot' => $antibot, + 'boardlist' => createBoardlist($mod), + 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) + )); + + if ($config['try_smarter'] && !$mod) + $build_pages[] = thread_find_page($id); + + // json api + if ($config['api']['enabled']) { + $api = new Api(); + $json = json_encode($api->translateThread($thread)); + $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; + file_write($jsonFilename, $json); + } + } + else { $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; - file_write($jsonFilename, $json); + file_unlink($jsonFilename); } - if ($return) { + if ($config['smart_build'] && !$return && !$mod) { + $noko50fn = $board['dir'] . $config['dir']['res'] . link_for(array('id' => $id), true); + file_unlink($noko50fn); + + file_unlink($board['dir'] . $config['dir']['res'] . link_for(array('id' => $id))); + } else if ($return) { return $body; } else { $noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true); -- cgit v1.3 From b246daa191ed6495ce7a73a369c645599eea610e Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 18:44:01 +0200 Subject: Revert "smart_build: buildThread" (for a moment, something b0rks) This reverts commit f2a74812f0a135370969bcdedea8a8c9c3f96aed. --- inc/functions.php | 85 ++++++++++++++++++++++++------------------------------- 1 file changed, 37 insertions(+), 48 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7ed3af5a..1c60393c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2068,62 +2068,51 @@ function buildThread($id, $return = false, $mod = false) { cache::delete("thread_{$board['uri']}_{$id}"); } - if (!$config['smart_build'] || $return || $mod) { - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); - while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - if (!isset($thread)) { - $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); - } else { - $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); - } + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + if (!isset($thread)) { + $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); + } else { + $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); } + } - // Check if any posts were found - if (!isset($thread)) - error($config['error']['nonexistant']); + // Check if any posts were found + if (!isset($thread)) + error($config['error']['nonexistant']); - $hasnoko50 = $thread->postCount() >= $config['noko50_min']; - $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); + $hasnoko50 = $thread->postCount() >= $config['noko50_min']; + $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); - $body = Element('thread.html', array( - 'board' => $board, - 'thread' => $thread, - 'body' => $thread->build(), - 'config' => $config, - 'id' => $id, - 'mod' => $mod, - 'hasnoko50' => $hasnoko50, - 'isnoko50' => false, - 'antibot' => $antibot, - 'boardlist' => createBoardlist($mod), - 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) - )); - - if ($config['try_smarter'] && !$mod) - $build_pages[] = thread_find_page($id); - - // json api - if ($config['api']['enabled']) { - $api = new Api(); - $json = json_encode($api->translateThread($thread)); - $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; - file_write($jsonFilename, $json); - } - } - else { + $body = Element('thread.html', array( + 'board' => $board, + 'thread' => $thread, + 'body' => $thread->build(), + 'config' => $config, + 'id' => $id, + 'mod' => $mod, + 'hasnoko50' => $hasnoko50, + 'isnoko50' => false, + 'antibot' => $antibot, + 'boardlist' => createBoardlist($mod), + 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) + )); + + if ($config['try_smarter'] && !$mod) + $build_pages[] = thread_find_page($id); + + // json api + if ($config['api']['enabled']) { + $api = new Api(); + $json = json_encode($api->translateThread($thread)); $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; - file_unlink($jsonFilename); + file_write($jsonFilename, $json); } - if ($config['smart_build'] && !$return && !$mod) { - $noko50fn = $board['dir'] . $config['dir']['res'] . link_for(array('id' => $id), true); - file_unlink($noko50fn); - - file_unlink($board['dir'] . $config['dir']['res'] . link_for(array('id' => $id))); - } else if ($return) { + if ($return) { return $body; } else { $noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true); -- cgit v1.3 From a19853dbe82f10fa9a3c7c69f3da6662fd0fc589 Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 18:46:48 +0200 Subject: smart_build.php: misc fixes --- smart_build.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/smart_build.php b/smart_build.php index 6621238e..d937241b 100644 --- a/smart_build.php +++ b/smart_build.php @@ -7,8 +7,12 @@ if (!$config['smart_build']) { $config['smart_build'] = false; // Let's disable it, so we can build the page for real +function after_open_board() { global $config; + $config['smart_build'] = false; +}; + function sb_board($b, $page = 1) { global $config, $build_pages; $page = (int)$page; - if ($page < 1 && $page != -1) return false; + if ($page < 1) return false; if (!openBoard($b)) return false; if ($page > $config['max_pages']) return false; $config['try_smarter'] = true; @@ -46,7 +50,7 @@ function sb_catalog($b) { } function sb_recent() { - rebuildTheme("recent", "post-thread"); + rebuildTheme("recent", "post-thread"); return true; } -- cgit v1.3 From e9e5ceaf908ccac1b90e939f455b3a861b67f88e Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 1 Apr 2015 19:37:06 +0200 Subject: main.js vs new file uploader --- templates/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/main.js b/templates/main.js index e948fd82..59a632d7 100644 --- a/templates/main.js +++ b/templates/main.js @@ -254,7 +254,7 @@ function dopost(form) { saved[document.location] = form.elements['body'].value; sessionStorage.body = JSON.stringify(saved); - return form.elements['body'].value != "" || form.elements['file'].value != "" || (form.elements.file_url && form.elements['file_url'].value != ""); + return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != ""); } function citeReply(id, with_link) { -- cgit v1.3 From cfb2f55b7a6ae314fa03b516192df34bd9849726 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 19:36:55 +0200 Subject: Revert "smart_build for buildIndex" This reverts commit 55277ce3835fecf44bb1a0cc1ba0b02d23846848. --- inc/functions.php | 95 +++++++++++++++++++++++-------------------------------- 1 file changed, 39 insertions(+), 56 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 1c60393c..f5fb6360 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1493,62 +1493,53 @@ function checkMute() { function buildIndex($global_api = "yes") { global $board, $config, $build_pages; - if (!$config['smart_build']) { - $pages = getPages(); - if (!$config['try_smarter']) - $antibot = create_antibot($board['uri']); + $pages = getPages(); + if (!$config['try_smarter']) + $antibot = create_antibot($board['uri']); - if ($config['api']['enabled']) { - $api = new Api(); - $catalog = array(); - } + if ($config['api']['enabled']) { + $api = new Api(); + $catalog = array(); } for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); - $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - if ((!$config['api']['enabled'] || $global_api == "skip" || $config['smart_build']) && $config['try_smarter'] - && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) + if ((!$config['api']['enabled'] || $global_api == "skip") && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) continue; + $content = index($page); + if (!$content) + break; - if (!$config['smart_build']) { - $content = index($page); - if (!$content) - break; - - // json api - if ($config['api']['enabled']) { - $threads = $content['threads']; - $json = json_encode($api->translatePage($threads)); - file_write($jsonFilename, $json); - - $catalog[$page-1] = $threads; - } + // json api + if ($config['api']['enabled']) { + $threads = $content['threads']; + $json = json_encode($api->translatePage($threads)); + $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 + file_write($jsonFilename, $json); - if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) - continue; + $catalog[$page-1] = $threads; + } - if ($config['try_smarter']) { - $antibot = create_antibot($board['uri'], 0 - $page); - $content['current_page'] = $page; - } - $antibot->reset(); - $content['pages'] = $pages; - $content['pages'][$page-1]['selected'] = true; - $content['btn'] = getPageButtons($content['pages']); - $content['antibot'] = $antibot; + if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) + continue; - file_write($filename, Element('index.html', $content)); - } - else { - file_unlink($filename); - file_unlink($jsonFilename); + if ($config['try_smarter']) { + $antibot = create_antibot($board['uri'], 0 - $page); + $content['current_page'] = $page; } + $antibot->reset(); + $content['pages'] = $pages; + $content['pages'][$page-1]['selected'] = true; + $content['btn'] = getPageButtons($content['pages']); + $content['antibot'] = $antibot; + + file_write($filename, Element('index.html', $content)); } - if (!$config['smart_build'] && $page < $config['max_pages']) { + if ($page < $config['max_pages']) { for (;$page<=$config['max_pages'];$page++) { $filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page)); file_unlink($filename); @@ -1562,21 +1553,13 @@ function buildIndex($global_api = "yes") { // json api catalog if ($config['api']['enabled'] && $global_api != "skip") { - if ($config['smart_build']) { - $jsonFilename = $board['dir'] . 'catalog.json'; - file_unlink($jsonFilename); - $jsonFilename = $board['dir'] . 'threads.json'; - file_unlink($jsonFilename); - } - else { - $json = json_encode($api->translateCatalog($catalog)); - $jsonFilename = $board['dir'] . 'catalog.json'; - file_write($jsonFilename, $json); + $json = json_encode($api->translateCatalog($catalog)); + $jsonFilename = $board['dir'] . 'catalog.json'; + file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); - $jsonFilename = $board['dir'] . 'threads.json'; - file_write($jsonFilename, $json); - } + $json = json_encode($api->translateCatalog($catalog, true)); + $jsonFilename = $board['dir'] . 'threads.json'; + file_write($jsonFilename, $json); } if ($config['try_smarter']) -- cgit v1.3 From 0870acb88e9f872071c8891fbec49e0e673beaea Mon Sep 17 00:00:00 2001 From: Marcin Łabanowski Date: Thu, 2 Apr 2015 20:27:10 +0200 Subject: smart_build.php: optimizations, guards, also a functionality to correct slugs --- smart_build.php | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/smart_build.php b/smart_build.php index d937241b..56299aee 100644 --- a/smart_build.php +++ b/smart_build.php @@ -25,12 +25,53 @@ function sb_api_board($b, $page = 0) { $page = (int)$page; return sb_board($b, $page + 1); } -function sb_thread($b, $thread) { global $config; $thread = (int)$thread; +function sb_thread($b, $thread, $slugcheck = false) { global $config; $thread = (int)$thread; + if ($thread < 1) return false; + + if (!preg_match('/^'.$config['board_regex'].'$/u', $b)) return false; + + if (Cache::get("thread_exists_".$b."_".$thread) == "no") return false; + + $query = prepare(sprintf("SELECT MAX(`id`) AS `max` FROM ``posts_%s``", $b)); + if (!$query->execute()) return false; + + $s = $query->fetch(PDO::FETCH_ASSOC); + $max = $s['max']; + + if ($thread > $max) return false; + + $query = prepare(sprintf("SELECT `id` FROM ``posts_%s`` WHERE `id` = :id AND `thread` IS NULL", $b)); + $query->bindValue(':id', $thread); + + if (!$query->execute() || !$query->fetch(PDO::FETCH_ASSOC) ) { + Cache::set("thread_exists_".$b."_".$thread, "no"); + return false; + } + + if ($slugcheck && $config['slugify']) { + global $request; + + $link = link_for(array("id" => $thread), $slugcheck === 50, array("uri" => $b)); + $link = "/".$b."/".$config['dir']['res'].$link; + + if ($link != $request) { + header("Location: $link", true, 301); + die(); + } + } + if (!openBoard($b)) return false; buildThread($thread); return true; } +function sb_thread_slugcheck($b, $thread) { + return sb_thread($b, $thread, true); +} +function sb_thread_slugcheck50($b, $thread) { + return sb_thread($b, $thread, 50); +} + function sb_api($b) { global $config; if (!openBoard($b)) return false; $config['try_smarter'] = true; @@ -65,11 +106,11 @@ if ($config['api']['enabled']) { $entrypoints['/%b/catalog.json'] = 'sb_api'; } -$entrypoints['/%b/'.$config['dir']['res'].$config['file_page']] = 'sb_thread'; -$entrypoints['/%b/'.$config['dir']['res'].$config['file_page50']] = 'sb_thread'; +$entrypoints['/%b/'.$config['dir']['res'].$config['file_page']] = 'sb_thread_slugcheck'; +$entrypoints['/%b/'.$config['dir']['res'].$config['file_page50']] = 'sb_thread_slugcheck50'; if ($config['slugify']) { - $entrypoints['/%b/'.$config['dir']['res'].$config['file_page_slug']] = 'sb_thread'; - $entrypoints['/%b/'.$config['dir']['res'].$config['file_page50_slug']] = 'sb_thread'; + $entrypoints['/%b/'.$config['dir']['res'].$config['file_page_slug']] = 'sb_thread_slugcheck'; + $entrypoints['/%b/'.$config['dir']['res'].$config['file_page50_slug']] = 'sb_thread_slugcheck50'; } if ($config['api']['enabled']) { $entrypoints['/%b/'.$config['dir']['res'].'%d.json'] = 'sb_thread'; @@ -102,6 +143,18 @@ foreach ($entrypoints as $id => $fun) { } } +function die_404() { global $config; + if (!$config['page_404']) { + header("HTTP/1.1 404 Not Exists"); + header("Status: 404 Not Exists"); + echo "

404 Not Exists

Page doesn't exist


vichan
"; + } + else { + header("Location: ".$config['page_404']); + } + die(); +} + if ($reached) { if ($request[strlen($request)-1] == '/') { $request .= 'index.html'; @@ -109,8 +162,7 @@ if ($reached) { $request = '.'.$request; if (!file_exists($request)) { - header("Location: ".$config['page_404']); - die(); + die_404(); } header("HTTP/1.1 200 OK"); @@ -139,5 +191,5 @@ if ($reached) { fclose($file); } else { - header("Location: ".$config['page_404']); + die_404(); } -- cgit v1.3 From 99706835c228152fdd42adc20724fb7f4c05488a Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:29:43 +0200 Subject: Revert "Revert "smart_build for buildIndex"" This reverts commit cfb2f55b7a6ae314fa03b516192df34bd9849726. --- inc/functions.php | 95 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index f5fb6360..1c60393c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1493,53 +1493,62 @@ function checkMute() { function buildIndex($global_api = "yes") { global $board, $config, $build_pages; - $pages = getPages(); - if (!$config['try_smarter']) - $antibot = create_antibot($board['uri']); + if (!$config['smart_build']) { + $pages = getPages(); + if (!$config['try_smarter']) + $antibot = create_antibot($board['uri']); - if ($config['api']['enabled']) { - $api = new Api(); - $catalog = array(); + if ($config['api']['enabled']) { + $api = new Api(); + $catalog = array(); + } } for ($page = 1; $page <= $config['max_pages']; $page++) { $filename = $board['dir'] . ($page == 1 ? $config['file_index'] : sprintf($config['file_page'], $page)); + $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - if ((!$config['api']['enabled'] || $global_api == "skip") && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) + if ((!$config['api']['enabled'] || $global_api == "skip" || $config['smart_build']) && $config['try_smarter'] + && isset($build_pages) && !empty($build_pages) && !in_array($page, $build_pages) ) continue; - $content = index($page); - if (!$content) - break; - // json api - if ($config['api']['enabled']) { - $threads = $content['threads']; - $json = json_encode($api->translatePage($threads)); - $jsonFilename = $board['dir'] . ($page - 1) . '.json'; // pages should start from 0 - file_write($jsonFilename, $json); + if (!$config['smart_build']) { + $content = index($page); + if (!$content) + break; - $catalog[$page-1] = $threads; - } + // json api + if ($config['api']['enabled']) { + $threads = $content['threads']; + $json = json_encode($api->translatePage($threads)); + file_write($jsonFilename, $json); - if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) - && !empty($build_pages) && !in_array($page, $build_pages) ) - continue; + $catalog[$page-1] = $threads; + } - if ($config['try_smarter']) { - $antibot = create_antibot($board['uri'], 0 - $page); - $content['current_page'] = $page; - } - $antibot->reset(); - $content['pages'] = $pages; - $content['pages'][$page-1]['selected'] = true; - $content['btn'] = getPageButtons($content['pages']); - $content['antibot'] = $antibot; + if ($config['api']['enabled'] && $global_api != "skip" && $config['try_smarter'] && isset($build_pages) + && !empty($build_pages) && !in_array($page, $build_pages) ) + continue; - file_write($filename, Element('index.html', $content)); + if ($config['try_smarter']) { + $antibot = create_antibot($board['uri'], 0 - $page); + $content['current_page'] = $page; + } + $antibot->reset(); + $content['pages'] = $pages; + $content['pages'][$page-1]['selected'] = true; + $content['btn'] = getPageButtons($content['pages']); + $content['antibot'] = $antibot; + + file_write($filename, Element('index.html', $content)); + } + else { + file_unlink($filename); + file_unlink($jsonFilename); + } } - if ($page < $config['max_pages']) { + if (!$config['smart_build'] && $page < $config['max_pages']) { for (;$page<=$config['max_pages'];$page++) { $filename = $board['dir'] . ($page==1 ? $config['file_index'] : sprintf($config['file_page'], $page)); file_unlink($filename); @@ -1553,13 +1562,21 @@ function buildIndex($global_api = "yes") { // json api catalog if ($config['api']['enabled'] && $global_api != "skip") { - $json = json_encode($api->translateCatalog($catalog)); - $jsonFilename = $board['dir'] . 'catalog.json'; - file_write($jsonFilename, $json); + if ($config['smart_build']) { + $jsonFilename = $board['dir'] . 'catalog.json'; + file_unlink($jsonFilename); + $jsonFilename = $board['dir'] . 'threads.json'; + file_unlink($jsonFilename); + } + else { + $json = json_encode($api->translateCatalog($catalog)); + $jsonFilename = $board['dir'] . 'catalog.json'; + file_write($jsonFilename, $json); - $json = json_encode($api->translateCatalog($catalog, true)); - $jsonFilename = $board['dir'] . 'threads.json'; - file_write($jsonFilename, $json); + $json = json_encode($api->translateCatalog($catalog, true)); + $jsonFilename = $board['dir'] . 'threads.json'; + file_write($jsonFilename, $json); + } } if ($config['try_smarter']) -- cgit v1.3 From 67db118f1e77f864aa42fc6e81e2a8a2bf7bbcd4 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:30:57 +0200 Subject: Revert "Revert "smart_build: buildThread" (for a moment, something b0rks)" This reverts commit b246daa191ed6495ce7a73a369c645599eea610e. --- inc/functions.php | 85 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 37 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 1c60393c..7ed3af5a 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2068,51 +2068,62 @@ function buildThread($id, $return = false, $mod = false) { cache::delete("thread_{$board['uri']}_{$id}"); } - $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); - $query->bindValue(':id', $id, PDO::PARAM_INT); - $query->execute() or error(db_error($query)); + if (!$config['smart_build'] || $return || $mod) { + $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); + $query->bindValue(':id', $id, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); - while ($post = $query->fetch(PDO::FETCH_ASSOC)) { - if (!isset($thread)) { - $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); - } else { - $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); + while ($post = $query->fetch(PDO::FETCH_ASSOC)) { + if (!isset($thread)) { + $thread = new Thread($post, $mod ? '?/' : $config['root'], $mod); + } else { + $thread->add(new Post($post, $mod ? '?/' : $config['root'], $mod)); + } } - } - // Check if any posts were found - if (!isset($thread)) - error($config['error']['nonexistant']); + // Check if any posts were found + if (!isset($thread)) + error($config['error']['nonexistant']); - $hasnoko50 = $thread->postCount() >= $config['noko50_min']; - $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); - - $body = Element('thread.html', array( - 'board' => $board, - 'thread' => $thread, - 'body' => $thread->build(), - 'config' => $config, - 'id' => $id, - 'mod' => $mod, - 'hasnoko50' => $hasnoko50, - 'isnoko50' => false, - 'antibot' => $antibot, - 'boardlist' => createBoardlist($mod), - 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) - )); - - if ($config['try_smarter'] && !$mod) - $build_pages[] = thread_find_page($id); + $hasnoko50 = $thread->postCount() >= $config['noko50_min']; + $antibot = $mod || $return ? false : create_antibot($board['uri'], $id); - // json api - if ($config['api']['enabled']) { - $api = new Api(); - $json = json_encode($api->translateThread($thread)); + $body = Element('thread.html', array( + 'board' => $board, + 'thread' => $thread, + 'body' => $thread->build(), + 'config' => $config, + 'id' => $id, + 'mod' => $mod, + 'hasnoko50' => $hasnoko50, + 'isnoko50' => false, + 'antibot' => $antibot, + 'boardlist' => createBoardlist($mod), + 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) + )); + + if ($config['try_smarter'] && !$mod) + $build_pages[] = thread_find_page($id); + + // json api + if ($config['api']['enabled']) { + $api = new Api(); + $json = json_encode($api->translateThread($thread)); + $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; + file_write($jsonFilename, $json); + } + } + else { $jsonFilename = $board['dir'] . $config['dir']['res'] . $id . '.json'; - file_write($jsonFilename, $json); + file_unlink($jsonFilename); } - if ($return) { + if ($config['smart_build'] && !$return && !$mod) { + $noko50fn = $board['dir'] . $config['dir']['res'] . link_for(array('id' => $id), true); + file_unlink($noko50fn); + + file_unlink($board['dir'] . $config['dir']['res'] . link_for(array('id' => $id))); + } else if ($return) { return $body; } else { $noko50fn = $board['dir'] . $config['dir']['res'] . link_for($thread, true); -- cgit v1.3 From 018ec3b605091af93b58a48d563410976212d470 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:35:17 +0200 Subject: smart_build.php: additional fixes --- smart_build.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/smart_build.php b/smart_build.php index 56299aee..d8352621 100644 --- a/smart_build.php +++ b/smart_build.php @@ -124,6 +124,7 @@ $entrypoints['/%b/catalog.html'] = 'sb_catalog'; $reached = false; $request = $_SERVER['REQUEST_URI']; +list($request) = explode('?', $request); foreach ($entrypoints as $id => $fun) { $id = '@^' . preg_quote($id, '@') . '$@u'; @@ -145,13 +146,14 @@ foreach ($entrypoints as $id => $fun) { function die_404() { global $config; if (!$config['page_404']) { - header("HTTP/1.1 404 Not Exists"); - header("Status: 404 Not Exists"); - echo "

404 Not Exists

Page doesn't exist


vichan
"; + header("HTTP/1.1 404 Not Found"); + header("Status: 404 Not Found"); + echo "

404 Not Found

Page doesn't exist


vichan
"; } else { header("Location: ".$config['page_404']); } + die(); } -- cgit v1.3 From fd0f3195b2ae36cbe2b4d599734cf00b80e3a1f0 Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:43:06 +0200 Subject: smart_build.php: add a protection for +50; maybe we don`t need to rebuild after all? --- smart_build.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/smart_build.php b/smart_build.php index d8352621..dd9450ae 100644 --- a/smart_build.php +++ b/smart_build.php @@ -59,6 +59,14 @@ function sb_thread($b, $thread, $slugcheck = false) { global $config; $thread = die(); } } + + if ($slugcheck == 50) { // Should we really generate +50 page? Maybe there are not enough posts anyway + global $request; + $r = str_replace("+50", "", $request); + $r = substr($r, 1); // Cut the slash + + if (file_exists($r)) return false; + } if (!openBoard($b)) return false; buildThread($thread); -- cgit v1.3 From e1a8c4aa7dc62186e7c74436db9fe89071647b3d Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:53:50 +0200 Subject: smart_build.php: a small fix to catalog handling --- smart_build.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/smart_build.php b/smart_build.php index dd9450ae..fb467233 100644 --- a/smart_build.php +++ b/smart_build.php @@ -94,6 +94,8 @@ function sb_ukko() { } function sb_catalog($b) { + if (!openBoard($b)) return false; + rebuildTheme("catalog", "post-thread", $b); return true; } -- cgit v1.3 From 61d2729a40e8249fef8b3c0c584a9b5f7ae0777c Mon Sep 17 00:00:00 2001 From: czaks Date: Thu, 2 Apr 2015 20:54:28 +0200 Subject: themes can use smart_build now --- templates/themes/catalog/theme.php | 23 +++++++++++++++++++---- templates/themes/recent/theme.php | 10 ++++++++-- templates/themes/ukko/theme.php | 10 +++++++++- 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/templates/themes/catalog/theme.php b/templates/themes/catalog/theme.php index f8f1146e..34b28e48 100644 --- a/templates/themes/catalog/theme.php +++ b/templates/themes/catalog/theme.php @@ -16,11 +16,22 @@ if ($action == 'all') { foreach ($boards as $board) { $b = new Catalog(); - $b->build($settings, $board); + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $b->build($settings, $board); + } } } elseif ($action == 'post-thread' || ($settings['update_on_posts'] && $action == 'post') || ($settings['update_on_posts'] && $action == 'post-delete') && in_array($board, $boards)) { $b = new Catalog(); - $b->build($settings, $board); + + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $board . '/catalog.html'); + } + else { + $b->build($settings, $board); + } } } @@ -28,8 +39,12 @@ class Catalog { public function build($settings, $board_name) { global $config, $board; - - openBoard($board_name); + + if ($board['uri'] != $board_name) { + if (!openBoard($board_name)) { + error(sprintf(_("Board %s doesn't exist"), $board_name)); + } + } $recent_images = array(); $recent_posts = array(); diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ce64c80e..f44e2529 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -24,8 +24,14 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $settings['html']); + } + else { + file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + } + } } // Build news page diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index 058fc77b..e1fa0a3f 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -2,6 +2,8 @@ require 'info.php'; function ukko_build($action, $settings) { + global $config; + $ukko = new ukko(); $ukko->settings = $settings; @@ -9,7 +11,13 @@ return; } - file_write($settings['uri'] . '/index.html', $ukko->build()); + if ($config['smart_build']) { + file_unlink($settings['uri'] . '/index.html'); + } + else { + file_write($settings['uri'] . '/index.html', $ukko->build()); + } + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } -- cgit v1.3 From e2731113404bda42ee506e29b6927165b7576f61 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 3 Apr 2015 05:57:39 +0200 Subject: sitemap theme for smart_build --- smart_build.php | 9 ++++++++ templates/themes/sitemap/theme.php | 47 ++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 20 deletions(-) diff --git a/smart_build.php b/smart_build.php index fb467233..43734e4f 100644 --- a/smart_build.php +++ b/smart_build.php @@ -105,6 +105,11 @@ function sb_recent() { return true; } +function sb_sitemap() { + rebuildTheme("sitemap", "all"); + return true; +} + $entrypoints = array(); $entrypoints['/%b/'] = 'sb_board'; @@ -130,6 +135,7 @@ $entrypoints['/*/'] = 'sb_ukko'; $entrypoints['/*/index.html'] = 'sb_ukko'; $entrypoints['/recent.html'] = 'sb_recent'; $entrypoints['/%b/catalog.html'] = 'sb_catalog'; +$entrypoints['/sitemap.xml'] = 'sb_sitemap'; $reached = false; @@ -185,6 +191,9 @@ if ($reached) { elseif (preg_match('/\.js$/', $request)) { header("Content-Type", "text/javascript; charset=utf-8"); } + elseif (preg_match('/\.xml$/', $request)) { + header("Content-Type", "application/xml"); + } else { header("Content-Type", "text/html; charset=utf-8"); } diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php index 41a7f304..52779d53 100644 --- a/templates/themes/sitemap/theme.php +++ b/templates/themes/sitemap/theme.php @@ -10,30 +10,37 @@ // - boards (board list changed) // - post (a post has been made) // - thread (a thread has been made) + + if ($action != 'all') { + if ($action != 'post-thread' && $action != 'post-delete') + return; - if ($action != 'post-thread' && $action != 'post-delete') - return; - - if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { - if ($last_gen = @filemtime($settings['path'])) { - if (time() - $last_gen < (int)$settings['regen_time']) - return; // Too soon + if (isset($settings['regen_time']) && $settings['regen_time'] > 0) { + if ($last_gen = @filemtime($settings['path'])) { + if (time() - $last_gen < (int)$settings['regen_time']) + return; // Too soon + } } } + + if ($config['smart_build']) { + file_unlink($settings['path']); + } + else { + $boards = explode(' ', $settings['boards']); - $boards = explode(' ', $settings['boards']); - - $threads = array(); + $threads = array(); - foreach ($boards as $board) { - $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); - $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); - } + foreach ($boards as $board) { + $query = query(sprintf("SELECT `id`, `id` AS `thread_id`, `slug`, (SELECT `time` FROM ``posts_%s`` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM ``posts_%s`` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); + } - file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( - 'settings' => $settings, - 'config' => $config, - 'threads' => $threads, - 'boards' => $boards, - ))); + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'threads' => $threads, + 'boards' => $boards, + ))); + } } -- cgit v1.3 From 8cf28682e74baf592df8b0949e76922fa76de08e Mon Sep 17 00:00:00 2001 From: Jason Puglisi Date: Fri, 3 Apr 2015 08:03:15 -0400 Subject: Removed tab at start of api.php to fix ban list and possibly other stuff --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index a057f4ed..b77fa3f8 100644 --- a/inc/api.php +++ b/inc/api.php @@ -1,4 +1,4 @@ - Date: Sun, 5 Apr 2015 20:14:58 +0930 Subject: made the define_groups function play nice on hhvm --- inc/functions.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7ed3af5a..e1d54590 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -328,8 +328,12 @@ function verbose_error_handler($errno, $errstr, $errfile, $errline) { function define_groups() { global $config; - foreach ($config['mod']['groups'] as $group_value => $group_name) - defined($group_name) or define($group_name, $group_value, true); + foreach ($config['mod']['groups'] as $group_value => $group_name) { + $group_name = strtoupper($group_name); + if(!defined($group_name)) { + define($group_name, $group_value, true); + } + } ksort($config['mod']['groups']); } -- cgit v1.3 From 1f9e36868e82fe563028f8c35aaee3c9ba21fa23 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:20:59 +0200 Subject: ukko: small optimization: move js creation to install time --- templates/themes/ukko/info.php | 1 + templates/themes/ukko/theme.php | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/templates/themes/ukko/info.php b/templates/themes/ukko/info.php index 45a687fc..9a0a53e6 100644 --- a/templates/themes/ukko/info.php +++ b/templates/themes/ukko/info.php @@ -49,6 +49,7 @@ function ukko_install($settings) { if (!file_exists($settings['uri'])) @mkdir($settings['uri'], 0777) or error("Couldn't create " . $settings['uri'] . ". Check permissions.", true); + file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } } diff --git a/templates/themes/ukko/theme.php b/templates/themes/ukko/theme.php index e1fa0a3f..d6fc303c 100644 --- a/templates/themes/ukko/theme.php +++ b/templates/themes/ukko/theme.php @@ -17,8 +17,6 @@ else { file_write($settings['uri'] . '/index.html', $ukko->build()); } - - file_write($settings['uri'] . '/ukko.js', Element('themes/ukko/ukko.js', array())); } class ukko { -- cgit v1.3 From cbbebcd20ced5874b97452babbffdbc6d2278d58 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:26:32 +0200 Subject: optimization: if gettext.so is loaded, we don`t need the fallback implementation --- inc/functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7ed3af5a..76b1d9a8 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -19,7 +19,9 @@ 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'; +if (!extension_loaded('gettext')) { + require_once 'inc/lib/gettext/gettext.inc'; +} // the user is not currently logged in as a moderator $mod = false; @@ -29,14 +31,17 @@ mb_internal_encoding('UTF-8'); loadConfig(); function init_locale($locale, $error='error') { - if (_setlocale(LC_ALL, $locale) === false) { - $error('The specified locale (' . $locale . ') does not exist on your platform!'); - } if (extension_loaded('gettext')) { + if (setlocale(LC_ALL, $locale) === false) { + $error('The specified locale (' . $locale . ') does not exist on your platform!'); + } bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); textdomain('tinyboard'); } else { + if (_setlocale(LC_ALL, $locale) === false) { + $error('The specified locale (' . $locale . ') does not exist on your platform!'); + } _bindtextdomain('tinyboard', './inc/locale'); _bind_textdomain_codeset('tinyboard', 'UTF-8'); _textdomain('tinyboard'); -- cgit v1.3 From 34eeaccea9f3809fdfa465e9910c8fa84f836011 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:31:20 +0200 Subject: optimization: we don`t need bans.php most of the time and bans.php has big dependencies --- inc/functions.php | 1 - mod.php | 7 ++++--- post.php | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 76b1d9a8..b1b1b042 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -18,7 +18,6 @@ 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'; if (!extension_loaded('gettext')) { require_once 'inc/lib/gettext/gettext.inc'; } diff --git a/mod.php b/mod.php index e06d5db6..5697e2b5 100644 --- a/mod.php +++ b/mod.php @@ -4,9 +4,10 @@ * Copyright (c) 2010-2014 Tinyboard Development Group */ -require 'inc/functions.php'; -require 'inc/mod/pages.php'; -require 'inc/mod/auth.php'; +require_once 'inc/functions.php'; +require_once 'inc/bans.php'; +require_once 'inc/mod/pages.php'; +require_once 'inc/mod/auth.php'; if ($config['debug']) $parse_start_time = microtime(true); diff --git a/post.php b/post.php index 09a5f53f..2b903b1c 100644 --- a/post.php +++ b/post.php @@ -3,8 +3,9 @@ * Copyright (c) 2010-2014 Tinyboard Development Group */ -require 'inc/functions.php'; -require 'inc/anti-bot.php'; +require_once 'inc/functions.php'; +require_once 'inc/anti-bot.php'; +require_once 'inc/bans.php'; // Fix for magic quotes if (get_magic_quotes_gpc()) { -- cgit v1.3 From 71ef3430fc3385f343b9e2c3eb4d05eaeca8607a Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:38:16 +0200 Subject: optimization: get rid of one more sql query related to installed themes --- inc/functions.php | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index b1b1b042..8a98659b 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -352,9 +352,22 @@ function rebuildThemes($action, $boardname = false) { $_board = $board; // List themes - $query = query("SELECT `theme` FROM ``theme_settings`` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error()); + if ($themes = Cache::get("themes")) { + // OK, we already have themes loaded + } + else { + $query = query("SELECT `theme` FROM ``theme_settings`` WHERE `name` IS NULL AND `value` IS NULL") or error(db_error()); + + $themes = array(); + + while ($theme = $query->fetch(PDO::FETCH_ASSOC)) { + $themes[] = $theme; + } - while ($theme = $query->fetch(PDO::FETCH_ASSOC)) { + Cache::set("themes", $themes); + } + + foreach ($themes as $theme) { // Restore them $config = $_config; $board = $_board; @@ -415,6 +428,10 @@ function rebuildTheme($theme, $action, $board = false) { function themeSettings($theme) { + if ($settings = Cache::get("theme_settings_".$theme)) { + return $settings; + } + $query = prepare("SELECT `name`, `value` FROM ``theme_settings`` WHERE `theme` = :theme AND `name` IS NOT NULL"); $query->bindValue(':theme', $theme); $query->execute() or error(db_error($query)); @@ -424,6 +441,8 @@ function themeSettings($theme) { $settings[$s['name']] = $s['value']; } + Cache::set("theme_settings_".$theme, $settings); + return $settings; } -- cgit v1.3 From e997357084fb9630e6c5098a912b6122aa0f2b56 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:45:51 +0200 Subject: add tmp subdirectory (a filesystem used for further optimizations) --- tmp/cache/.gitkeep | 0 tmp/locks/.gitkeep | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 tmp/cache/.gitkeep create mode 100644 tmp/locks/.gitkeep diff --git a/tmp/cache/.gitkeep b/tmp/cache/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/tmp/locks/.gitkeep b/tmp/locks/.gitkeep new file mode 100644 index 00000000..e69de29b -- cgit v1.3 From 758cb94e01945b16f730c08775666d3f5e65eb86 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:52:35 +0200 Subject: optimization: locale caching, so we don`t have to reparse instance-config every single time --- inc/functions.php | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 8a98659b..fc22e6ce 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -96,18 +96,28 @@ function loadConfig() { // Initialize locale as early as possible - $config['locale'] = 'en'; + // Those calls are expensive. Unfortunately, our cache system is not initialized at this point. + // So, we may store the locale in a tmp/ filesystem. - $configstr = file_get_contents('inc/instance-config.php'); + if (file_exists($fn = 'tmp/cache/locale_' . ( isset($board['uri']) ? $board['uri'] : '' ) ) ) { + $config['locale'] = file_get_contents($fn); + } + else { + $config['locale'] = 'en'; + + $configstr = file_get_contents('inc/instance-config.php'); if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { - $configstr .= file_get_contents($board['dir'] . '/config.php'); + $configstr .= file_get_contents($board['dir'] . '/config.php'); } - $matches = array(); - preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); - if ($matches && isset ($matches[2]) && $matches[2]) { - $matches = $matches[2]; - $config['locale'] = $matches[count($matches)-1]; + $matches = array(); + preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); + if ($matches && isset ($matches[2]) && $matches[2]) { + $matches = $matches[2]; + $config['locale'] = $matches[count($matches)-1]; + } + + file_put_contents($fn, $config['locale']); } if ($config['locale'] != $current_locale) { -- cgit v1.3 From b78b3db0105c832f3e5b1f5cca019bb41a137662 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 16:59:04 +0200 Subject: uncache themes on settings change --- inc/mod/pages.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index be713f57..969c570e 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2501,10 +2501,14 @@ function mod_theme_configure($theme_name) { $query->bindValue(':value', $_POST[$conf['name']]); $query->execute() or error(db_error($query)); } - + $query = prepare("INSERT INTO ``theme_settings`` VALUES(:theme, NULL, NULL)"); $query->bindValue(':theme', $theme_name); $query->execute() or error(db_error($query)); + + // Clean cache + Cache::delete("themes"); + Cache::delete("theme_settings_".$theme); $result = true; $message = false; @@ -2552,11 +2556,15 @@ function mod_theme_uninstall($theme_name) { if (!hasPermission($config['mod']['themes'])) error($config['error']['noaccess']); - + $query = prepare("DELETE FROM ``theme_settings`` WHERE `theme` = :theme"); $query->bindValue(':theme', $theme_name); $query->execute() or error(db_error($query)); + // Clean cache + Cache::delete("themes"); + Cache::delete("theme_settings_".$theme); + header('Location: ?/themes', true, $config['redirect_http']); } -- cgit v1.3 From 1d28b4be4daac42164cf52c262f923856fbeeb28 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 17:13:55 +0200 Subject: cache.php: fs cache --- inc/cache.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/inc/cache.php b/inc/cache.php index d1200919..d6bc9211 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -50,6 +50,17 @@ class Cache { case 'php': $data = isset(self::$cache[$key]) ? self::$cache[$key] : false; break; + case 'fs': + $key = str_replace('/', '::', $key); + $key = str_replace("\0", '', $key); + if (!file_exists('tmp/cache/'.$key)) { + $data = false; + } + else { + $data = file_get_contents('tmp/cache/'.$key); + $data = json_decode($data, true); + } + break; case 'redis': if (!self::$cache) self::init(); @@ -87,6 +98,11 @@ class Cache { case 'xcache': xcache_set($key, $value, $expires); break; + case 'fs': + $key = str_replace('/', '::', $key); + $key = str_replace("\0", '', $key); + file_put_contents('tmp/cache/'.$key, json_encode($value)); + break; case 'php': self::$cache[$key] = $value; break; @@ -113,6 +129,11 @@ class Cache { case 'xcache': xcache_unset($key); break; + case 'fs': + $key = str_replace('/', '::', $key); + $key = str_replace("\0", '', $key); + unlink('tmp/cache/'.$key); + break; case 'php': unset(self::$cache[$key]); break; @@ -134,6 +155,12 @@ class Cache { case 'php': self::$cache = array(); break; + case 'fs': + $files = glob('tmp/cache/*'); + foreach ($files as $file) { + unlink($file); + } + break; case 'redis': if (!self::$cache) self::init(); -- cgit v1.3 From b8fe93fd8fa29b3c7793f035b7daf1783c352c05 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 18:46:45 +0200 Subject: update gitignore --- .gitignore | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitignore b/.gitignore index 69317f82..281515e9 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,12 @@ Thumbs.db *.orig *~ +# tmp filesystem +/tmp/cache/* +/tmp/locks/* +!/tmp/cache/.gitkeep +!/tmp/locks/.gitkeep + #vichan custom favicon.ico /static/spoiler.png -- cgit v1.3 From dc2928a14dcd29bf8502b6a9dc1357ad0e624251 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 18:48:53 +0200 Subject: cache_config preliminary release --- inc/config.php | 5 ++++ inc/functions.php | 71 +++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 61 insertions(+), 15 deletions(-) diff --git a/inc/config.php b/inc/config.php index be1bb8e1..3a63054c 100644 --- a/inc/config.php +++ b/inc/config.php @@ -137,6 +137,11 @@ // Tinyboard to use. $config['cache']['redis'] = array('localhost', 6379, '', 1); + // EXPERIMENTAL: Should we cache configs? Warning: this changes board behaviour, i'd say, a lot. + // If you have any lambdas/includes present in your config, you should move them to instance-functions.php + // (this file will be explicitly loaded during cache hit, but not during cache miss). + $config['cache_config'] = false; + /* * ==================== * Cookie settings diff --git a/inc/functions.php b/inc/functions.php index fc22e6ce..7b4dde7e 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -50,15 +50,40 @@ $current_locale = 'en'; function loadConfig() { - global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale; + global $board, $config, $__ip, $debug, $__version, $microtime_start, $current_locale, $events; $error = function_exists('error') ? 'error' : 'basic_error_function_because_the_other_isnt_loaded_yet'; - reset_events(); + $boardsuffix = isset($board['uri']) ? $board['uri'] : ''; if (!isset($_SERVER['REMOTE_ADDR'])) $_SERVER['REMOTE_ADDR'] = '0.0.0.0'; + if (file_exists('tmp/cache/cache_config.php')) { + require_once('tmp/cache/cache_config.php'); + } + + + if (isset($config['cache_config']) && + $config['cache_config'] && + $config = Cache::get('config_' . $boardsuffix ) ) { + $events = Cache::get('events_' . $boardsuffix ); + + if (file_exists('inc/instance-functions.php')) { + require_once('inc/instance-functions.php'); + } + + if ($config['locale'] != $current_locale) { + $current_locale = $config['locale']; + init_locale($config['locale'], $error); + } + } + else { + $config = array(); + // We will indent that later. + + reset_events(); + $arrays = array( 'db', 'api', @@ -86,7 +111,6 @@ function loadConfig() { 'dashboard_links' ); - $config = array(); foreach ($arrays as $key) { $config[$key] = array(); } @@ -99,7 +123,7 @@ function loadConfig() { // Those calls are expensive. Unfortunately, our cache system is not initialized at this point. // So, we may store the locale in a tmp/ filesystem. - if (file_exists($fn = 'tmp/cache/locale_' . ( isset($board['uri']) ? $board['uri'] : '' ) ) ) { + if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix ) ) { $config['locale'] = file_get_contents($fn); } else { @@ -138,8 +162,6 @@ function loadConfig() { init_locale($config['locale'], $error); } - date_default_timezone_set($config['timezone']); - if (!isset($config['global_message'])) $config['global_message'] = false; @@ -219,8 +241,22 @@ function loadConfig() { if (!isset($config['user_flags'])) $config['user_flags'] = array(); + if (!isset($__version)) + $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; + $config['version'] = $__version; + + if ($config['allow_roll']) + event_handler('post', 'diceRoller'); + + if (is_array($config['anonymous'])) + $config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; + + + } // Effectful config processing below: + date_default_timezone_set($config['timezone']); + if ($config['root_file']) { chdir($config['root_file']); } @@ -233,10 +269,6 @@ function loadConfig() { if (preg_match('/^\:\:(ffff\:)?(\d+\.\d+\.\d+\.\d+)$/', $__ip, $m)) $_SERVER['REMOTE_ADDR'] = $m[2]; - if (!isset($__version)) - $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; - $config['version'] = $__version; - if ($config['verbose_errors']) { set_error_handler('verbose_error_handler'); error_reporting(E_ALL); @@ -260,13 +292,22 @@ function loadConfig() { event_handler('post', 'postHandler'); } - if (is_array($config['anonymous'])) - $config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; + event('load-config'); - if ($config['allow_roll']) - event_handler('post', 'diceRoller'); + if ($config['cache_config'] && !isset ($config['cache_config_loaded'])) { + file_put_contents('tmp/cache/cache_config.php', ' Date: Sun, 5 Apr 2015 18:50:16 +0200 Subject: tools/rebuild.php: fix for bans.php not included by default and public_banlist --- tools/rebuild.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/rebuild.php b/tools/rebuild.php index 82df3e19..289523a1 100755 --- a/tools/rebuild.php +++ b/tools/rebuild.php @@ -21,6 +21,8 @@ require dirname(__FILE__) . '/inc/cli.php'; +require_once("inc/bans.php"); + $start = microtime(true); // parse command line -- cgit v1.3 From 45f11d1d782ca51b43a7d5f0ddd035dcfdd4f9cd Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 19:12:41 +0200 Subject: indent the file (inc/functions.php) after the latest changes --- inc/functions.php | 312 +++++++++++++++++++++++++++--------------------------- 1 file changed, 155 insertions(+), 157 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 7b4dde7e..12135983 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -80,177 +80,175 @@ function loadConfig() { } else { $config = array(); - // We will indent that later. - - reset_events(); - - $arrays = array( - 'db', - 'api', - 'cache', - 'cookies', - 'error', - 'dir', - 'mod', - 'spam', - 'filters', - 'wordfilters', - 'custom_capcode', - 'custom_tripcode', - 'dnsbl', - 'dnsbl_exceptions', - 'remote', - 'allowed_ext', - 'allowed_ext_files', - 'file_icons', - 'footer', - 'stylesheets', - 'additional_javascript', - 'markup', - 'custom_pages', - 'dashboard_links' - ); - - foreach ($arrays as $key) { - $config[$key] = array(); - } - if (!file_exists('inc/instance-config.php')) - $error('Tinyboard is not configured! Create inc/instance-config.php.'); + reset_events(); + + $arrays = array( + 'db', + 'api', + 'cache', + 'cookies', + 'error', + 'dir', + 'mod', + 'spam', + 'filters', + 'wordfilters', + 'custom_capcode', + 'custom_tripcode', + 'dnsbl', + 'dnsbl_exceptions', + 'remote', + 'allowed_ext', + 'allowed_ext_files', + 'file_icons', + 'footer', + 'stylesheets', + 'additional_javascript', + 'markup', + 'custom_pages', + 'dashboard_links' + ); - // Initialize locale as early as possible + foreach ($arrays as $key) { + $config[$key] = array(); + } - // Those calls are expensive. Unfortunately, our cache system is not initialized at this point. - // So, we may store the locale in a tmp/ filesystem. + if (!file_exists('inc/instance-config.php')) + $error('Tinyboard is not configured! Create inc/instance-config.php.'); - if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix ) ) { - $config['locale'] = file_get_contents($fn); - } - else { - $config['locale'] = 'en'; + // Initialize locale as early as possible - $configstr = file_get_contents('inc/instance-config.php'); + // Those calls are expensive. Unfortunately, our cache system is not initialized at this point. + // So, we may store the locale in a tmp/ filesystem. - if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { - $configstr .= file_get_contents($board['dir'] . '/config.php'); - } - $matches = array(); - preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); - if ($matches && isset ($matches[2]) && $matches[2]) { - $matches = $matches[2]; - $config['locale'] = $matches[count($matches)-1]; + if (file_exists($fn = 'tmp/cache/locale_' . $boardsuffix ) ) { + $config['locale'] = file_get_contents($fn); } + else { + $config['locale'] = 'en'; - file_put_contents($fn, $config['locale']); - } + $configstr = file_get_contents('inc/instance-config.php'); - if ($config['locale'] != $current_locale) { - $current_locale = $config['locale']; - init_locale($config['locale'], $error); - } + if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { + $configstr .= file_get_contents($board['dir'] . '/config.php'); + } + $matches = array(); + preg_match_all('/[^\/*#]\$config\s*\[\s*[\'"]locale[\'"]\s*\]\s*=\s*([\'"])(.*?)\1/', $configstr, $matches); + if ($matches && isset ($matches[2]) && $matches[2]) { + $matches = $matches[2]; + $config['locale'] = $matches[count($matches)-1]; + } - require 'inc/config.php'; + file_put_contents($fn, $config['locale']); + } - require 'inc/instance-config.php'; + if ($config['locale'] != $current_locale) { + $current_locale = $config['locale']; + init_locale($config['locale'], $error); + } - if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { - require $board['dir'] . '/config.php'; - } + require 'inc/config.php'; - if ($config['locale'] != $current_locale) { - $current_locale = $config['locale']; - init_locale($config['locale'], $error); - } - - if (!isset($config['global_message'])) - $config['global_message'] = false; - - if (!isset($config['post_url'])) - $config['post_url'] = $config['root'] . $config['file_post']; - - - if (!isset($config['referer_match'])) - if (isset($_SERVER['HTTP_HOST'])) { - $config['referer_match'] = '/^' . - (preg_match('@^https?://@', $config['root']) ? '' : - 'https?:\/\/' . $_SERVER['HTTP_HOST']) . - preg_quote($config['root'], '/') . - '(' . - str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . - '(' . - preg_quote($config['file_index'], '/') . '|' . - str_replace('%d', '\d+', preg_quote($config['file_page'])) . - ')?' . - '|' . - str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . - preg_quote($config['dir']['res'], '/') . - '(' . - str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . '|' . - str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . '|' . - str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '/')) . '|' . - str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) . - ')' . - '|' . - preg_quote($config['file_mod'], '/') . '\?\/.+' . - ')([#?](.+)?)?$/ui'; - } else { - // CLI mode - $config['referer_match'] = '//'; - } - if (!isset($config['cookies']['path'])) - $config['cookies']['path'] = &$config['root']; - - if (!isset($config['dir']['static'])) - $config['dir']['static'] = $config['root'] . 'static/'; - - if (!isset($config['image_blank'])) - $config['image_blank'] = $config['dir']['static'] . 'blank.gif'; - - if (!isset($config['image_sticky'])) - $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; - if (!isset($config['image_locked'])) - $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; - if (!isset($config['image_bumplocked'])) - $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; - if (!isset($config['image_deleted'])) - $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; - - if (!isset($config['uri_thumb'])) - $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; - elseif (isset($board['dir'])) - $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); - - if (!isset($config['uri_img'])) - $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; - elseif (isset($board['dir'])) - $config['uri_img'] = sprintf($config['uri_img'], $board['dir']); - - if (!isset($config['uri_stylesheets'])) - $config['uri_stylesheets'] = $config['root'] . 'stylesheets/'; - - if (!isset($config['url_stylesheet'])) - $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; - if (!isset($config['url_javascript'])) - $config['url_javascript'] = $config['root'] . $config['file_script']; - if (!isset($config['additional_javascript_url'])) - $config['additional_javascript_url'] = $config['root']; - if (!isset($config['uri_flags'])) - $config['uri_flags'] = $config['root'] . 'static/flags/%s.png'; - if (!isset($config['user_flag'])) - $config['user_flag'] = false; - if (!isset($config['user_flags'])) - $config['user_flags'] = array(); - - if (!isset($__version)) - $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; - $config['version'] = $__version; - - if ($config['allow_roll']) - event_handler('post', 'diceRoller'); - - if (is_array($config['anonymous'])) - $config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; + require 'inc/instance-config.php'; + if (isset($board['dir']) && file_exists($board['dir'] . '/config.php')) { + require $board['dir'] . '/config.php'; + } + + if ($config['locale'] != $current_locale) { + $current_locale = $config['locale']; + init_locale($config['locale'], $error); + } + + if (!isset($config['global_message'])) + $config['global_message'] = false; + + if (!isset($config['post_url'])) + $config['post_url'] = $config['root'] . $config['file_post']; + + + if (!isset($config['referer_match'])) + if (isset($_SERVER['HTTP_HOST'])) { + $config['referer_match'] = '/^' . + (preg_match('@^https?://@', $config['root']) ? '' : + 'https?:\/\/' . $_SERVER['HTTP_HOST']) . + preg_quote($config['root'], '/') . + '(' . + str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . + '(' . + preg_quote($config['file_index'], '/') . '|' . + str_replace('%d', '\d+', preg_quote($config['file_page'])) . + ')?' . + '|' . + str_replace('%s', $config['board_regex'], preg_quote($config['board_path'], '/')) . + preg_quote($config['dir']['res'], '/') . + '(' . + str_replace('%d', '\d+', preg_quote($config['file_page'], '/')) . '|' . + str_replace('%d', '\d+', preg_quote($config['file_page50'], '/')) . '|' . + str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page_slug'], '/')) . '|' . + str_replace(array('%d', '%s'), array('\d+', '[a-z0-9-]+'), preg_quote($config['file_page50_slug'], '/')) . + ')' . + '|' . + preg_quote($config['file_mod'], '/') . '\?\/.+' . + ')([#?](.+)?)?$/ui'; + } else { + // CLI mode + $config['referer_match'] = '//'; + } + if (!isset($config['cookies']['path'])) + $config['cookies']['path'] = &$config['root']; + + if (!isset($config['dir']['static'])) + $config['dir']['static'] = $config['root'] . 'static/'; + + if (!isset($config['image_blank'])) + $config['image_blank'] = $config['dir']['static'] . 'blank.gif'; + + if (!isset($config['image_sticky'])) + $config['image_sticky'] = $config['dir']['static'] . 'sticky.gif'; + if (!isset($config['image_locked'])) + $config['image_locked'] = $config['dir']['static'] . 'locked.gif'; + if (!isset($config['image_bumplocked'])) + $config['image_bumplocked'] = $config['dir']['static'] . 'sage.gif'; + if (!isset($config['image_deleted'])) + $config['image_deleted'] = $config['dir']['static'] . 'deleted.png'; + + if (!isset($config['uri_thumb'])) + $config['uri_thumb'] = $config['root'] . $board['dir'] . $config['dir']['thumb']; + elseif (isset($board['dir'])) + $config['uri_thumb'] = sprintf($config['uri_thumb'], $board['dir']); + + if (!isset($config['uri_img'])) + $config['uri_img'] = $config['root'] . $board['dir'] . $config['dir']['img']; + elseif (isset($board['dir'])) + $config['uri_img'] = sprintf($config['uri_img'], $board['dir']); + + if (!isset($config['uri_stylesheets'])) + $config['uri_stylesheets'] = $config['root'] . 'stylesheets/'; + + if (!isset($config['url_stylesheet'])) + $config['url_stylesheet'] = $config['uri_stylesheets'] . 'style.css'; + if (!isset($config['url_javascript'])) + $config['url_javascript'] = $config['root'] . $config['file_script']; + if (!isset($config['additional_javascript_url'])) + $config['additional_javascript_url'] = $config['root']; + if (!isset($config['uri_flags'])) + $config['uri_flags'] = $config['root'] . 'static/flags/%s.png'; + if (!isset($config['user_flag'])) + $config['user_flag'] = false; + if (!isset($config['user_flags'])) + $config['user_flags'] = array(); + + if (!isset($__version)) + $__version = file_exists('.installed') ? trim(file_get_contents('.installed')) : false; + $config['version'] = $__version; + + if ($config['allow_roll']) + event_handler('post', 'diceRoller'); + + if (is_array($config['anonymous'])) + $config['anonymous'] = $config['anonymous'][array_rand($config['anonymous'])]; } // Effectful config processing below: -- cgit v1.3 From f053450edfc137e369839fe7203d50315d76fccf Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 20:04:27 +0200 Subject: cache_config: fix debug notice --- inc/functions.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 12135983..a9e912bd 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -295,9 +295,9 @@ function loadConfig() { if ($config['cache_config'] && !isset ($config['cache_config_loaded'])) { file_put_contents('tmp/cache/cache_config.php', ' Date: Sun, 5 Apr 2015 20:23:57 +0200 Subject: fix a locale issue --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index a9e912bd..147d269e 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -32,7 +32,7 @@ loadConfig(); function init_locale($locale, $error='error') { if (extension_loaded('gettext')) { if (setlocale(LC_ALL, $locale) === false) { - $error('The specified locale (' . $locale . ') does not exist on your platform!'); + //$error('The specified locale (' . $locale . ') does not exist on your platform!'); } bindtextdomain('tinyboard', './inc/locale'); bind_textdomain_codeset('tinyboard', 'UTF-8'); -- cgit v1.3 From 9831b582fa4c8fa0581ad8c6ea95ae28bbba8654 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 5 Apr 2015 20:25:57 +0200 Subject: groups were not defined --- inc/functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/inc/functions.php b/inc/functions.php index 147d269e..2bd7fd93 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -69,6 +69,8 @@ function loadConfig() { $config = Cache::get('config_' . $boardsuffix ) ) { $events = Cache::get('events_' . $boardsuffix ); + define_groups(); + if (file_exists('inc/instance-functions.php')) { require_once('inc/instance-functions.php'); } -- cgit v1.3 From 64a0b486f2dd49a749104eb200127208f7b592df Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 6 Apr 2015 18:42:23 +0200 Subject: smart_build.php: nginx – cache 404 replies for 120s MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- smart_build.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart_build.php b/smart_build.php index 43734e4f..993d7858 100644 --- a/smart_build.php +++ b/smart_build.php @@ -169,7 +169,7 @@ function die_404() { global $config; else { header("Location: ".$config['page_404']); } - + header("X-Accel-Expires: 120"); die(); } -- cgit v1.3 From 094f60d34dce0d639b04ef28d5719e22551db288 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 6 Apr 2015 18:59:33 +0200 Subject: try_smarter: fix two bugs. 1. uncovered by the second, during a bump only the page the thread was on and first page were rebuild, despite threads rearranging their positions on the remaining pages. happening always. 2. during smart build, the page wasn`t ordered to be rebuilt --- inc/functions.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 676f5b68..a6c85a19 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1104,8 +1104,9 @@ function bumpThread($id) { if (event('bump', $id)) return true; - if ($config['try_smarter']) - $build_pages[] = thread_find_page($id); + if ($config['try_smarter']) { + $build_pages = array_merge(range(1, thread_find_page($id)), $build_pages); + } $query = prepare(sprintf("UPDATE ``posts_%s`` SET `bump` = :time WHERE `id` = :id AND `thread` IS NULL", $board['uri'])); $query->bindValue(':time', time(), PDO::PARAM_INT); @@ -2146,6 +2147,9 @@ function buildThread($id, $return = false, $mod = false) { cache::delete("thread_{$board['uri']}_{$id}"); } + if ($config['try_smarter'] && !$mod) + $build_pages[] = thread_find_page($id); + if (!$config['smart_build'] || $return || $mod) { $query = prepare(sprintf("SELECT * FROM ``posts_%s`` WHERE (`thread` IS NULL AND `id` = :id) OR `thread` = :id ORDER BY `thread`,`id`", $board['uri'])); $query->bindValue(':id', $id, PDO::PARAM_INT); @@ -2180,9 +2184,6 @@ function buildThread($id, $return = false, $mod = false) { 'return' => ($mod ? '?' . $board['url'] . $config['file_index'] : $config['root'] . $board['dir'] . $config['file_index']) )); - if ($config['try_smarter'] && !$mod) - $build_pages[] = thread_find_page($id); - // json api if ($config['api']['enabled']) { $api = new Api(); -- cgit v1.3 From 11dfc8bbdc6c1c3888632c3cd96bcec4a313fc01 Mon Sep 17 00:00:00 2001 From: czaks Date: Mon, 6 Apr 2015 22:51:02 +0200 Subject: fs cache backend: silence the error --- inc/cache.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/cache.php b/inc/cache.php index d6bc9211..852aefa2 100644 --- a/inc/cache.php +++ b/inc/cache.php @@ -132,7 +132,7 @@ class Cache { case 'fs': $key = str_replace('/', '::', $key); $key = str_replace("\0", '', $key); - unlink('tmp/cache/'.$key); + @unlink('tmp/cache/'.$key); break; case 'php': unset(self::$cache[$key]); -- cgit v1.3 From 0658a2b19abbd34f0675f1940aa680eb3dee7139 Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 7 Apr 2015 02:29:38 +0200 Subject: fix banned.php; thanks stigma --- banned.php | 1 + 1 file changed, 1 insertion(+) diff --git a/banned.php b/banned.php index 57e4a9bc..1bee9115 100644 --- a/banned.php +++ b/banned.php @@ -1,5 +1,6 @@ "._("Banned?").""; print "

"._("You are not banned.")."

"; -- cgit v1.3 From 652018f674621b13b8af0c5125cc8cf0de4b1b0f Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 7 Apr 2015 20:54:43 +0200 Subject: own-board.js: initial release --- js/own-board.js | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 js/own-board.js diff --git a/js/own-board.js b/js/own-board.js new file mode 100644 index 00000000..497c568c --- /dev/null +++ b/js/own-board.js @@ -0,0 +1,116 @@ +/***************************************************************** + * ------- WARNING! --------- * + ***************************************************************** + * This script is at the current time undocumented and * + * unsupported. It is still a work in progress and will likely * + * change. You are on your own. * + *****************************************************************/ + ++function() { + +var uniq = function(a) { + var b = {}; + var c = []; + a.forEach(function(i) { + if (!b[i]) { + c.push(i); + b[i] = true; + } + }); + return c; +}; + + +if (active_page == 'thread' || active_page == 'index') { + var board = null; + + $(function() { + board = $('input[name="board"]').first().val(); + }); + + $(document).on('ajax_after_post', function(e, r) { + var threads = JSON.parse(localStorage.obthreads || '[]'); + + var thread = null; + if (active_page == 'index') { + thread = r.id|0; + } + else { + thread = $('[id^="thread_"]').first().attr('id').replace("thread_", "")|0; + } + + threads.push([board, thread]); + threads = uniq(threads); + localStorage.obthreads = JSON.stringify(threads); + }); +} + +var loaded = false; +$(function() { + loaded = true; +}); + +var activate = function() { + if (document.location.hash != '#own') return false; + + if (loaded) late_activate(); + else $(function() { late_activate(); }); + + return true; +}; + +var late_activate = function() { + $('[id^="thread_"]').remove(); + + var threads = JSON.parse(localStorage.obthreads || '[]'); + + threads.forEach(function(v) { + var board = v[0]; + var thread = v[1]; + var url = "/"+board+"/res/"+thread+".html"; + + $.get(url, function(html) { + var s = $(html).find('[id^="thread_"]'); + + s[0].bumptime = (new Date(s.find("time").last().attr("datetime"))).getTime(); + + var added = false; + $('[id^="thread_"]').each(function() { + if (added) return; + if (s[0].bumptime > this.bumptime) { + added = true; + s.insertBefore(this); + } + }); + if (!added) { + s.appendTo('[name="postcontrols"]'); + } + + s.find('.post.reply').addClass('hidden').hide().slice(-3).removeClass('hidden').show(); + + s.find('.post.reply.hidden').next().addClass('hidden').hide(); // Hide
elements + + var posts_omitted = s.find('.post.reply.hidden').length; + var images_omitted = s.find('.post.reply.hidden img').length; + + if (posts_omitted > 0) { + var omitted = $(fmt(''+_('{0} posts and {1} images omitted.')+' '+_('Click reply to view.')+'', + [posts_omitted, images_omitted])); + + omitted.appendTo(s.find('.post.op')); + } + + var reply = $('['+_('Reply')+']').appendTo(s.find('.intro').first()); + + $(document).trigger('new_post', s[0]); + }); + }); +}; + +$(window).on("hashchange", function() { + return !activate(); +}); +activate(); + + +}(); -- cgit v1.3 From f2848f2242a3135277474293347ab47c12782728 Mon Sep 17 00:00:00 2001 From: 8chan Date: Sat, 28 Mar 2015 19:37:57 -0700 Subject: Update GeoIP database --- inc/lib/geoip/GeoIPv6.dat | Bin 1127489 -> 1429913 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/inc/lib/geoip/GeoIPv6.dat b/inc/lib/geoip/GeoIPv6.dat index 1c2658c5..c2f3f11b 100644 Binary files a/inc/lib/geoip/GeoIPv6.dat and b/inc/lib/geoip/GeoIPv6.dat differ -- cgit v1.3 From fae2e33c87d996e206e1d04dd906e667491ee8b0 Mon Sep 17 00:00:00 2001 From: ForklessAnon Date: Sat, 1 Nov 2014 04:00:45 -0500 Subject: Added script for appending thread statistics to the bottom of a thread. --- js/thread-stats.js | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 js/thread-stats.js diff --git a/js/thread-stats.js b/js/thread-stats.js new file mode 100644 index 00000000..e6fb1142 --- /dev/null +++ b/js/thread-stats.js @@ -0,0 +1,115 @@ +/* + * thread-stats.js + * - Adds statistics of the thread below the posts area + * - Shows ID post count beside each postID on hover + * + * Usage: + * $config['additional_javascript'][] = 'js/jquery.min.js'; + * $config['additional_javascript'][] = 'js/thread-stats.js'; + */ +// THREAD STATS +if (active_page == 'thread') { + + var thread_stats_timer = 30, thread_stats_timeout; //it has to be on a timer because there I haven't found a way to hook into when the actual page updates the thread... + //check if page uses unique ID + var IDsupport = ($('.poster_id').length > 0); + var thread_id = (document.location.pathname + document.location.search).split('/'); + thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; + + $('form[name="postcontrols"] > .delete') + .first() + .before('
'); + var el = $('#thread_stats'); + el.prepend('Page ?'); + if (IDsupport){ + el.prepend('0 UIDs | '); + } + el.prepend('0 images | '); + el.prepend('0 replies | '); + delete el; + function update_thread_stats(force){ + var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); + var replies = $('#thread_'+ thread_id +' > div.post.reply:not(.post-hover):not(.inline)'); + // post count + $('#thread_stats_posts').text(replies.length); + // image count + $('#thread_stats_images').text(replies.filter(function(){ + return $(this).find('> .files').text().trim() != false; + }).length); + // unique ID count + if (IDsupport) { + var opID = op.find('> .intro > .poster_id').text(); + var ids = {}; + replies.each(function(){ + var cur = $(this).find('> .intro > .poster_id'); + var curID = cur.text(); + if (ids[curID] === undefined) { + ids[curID] = 0; + } + ids[curID]++; + }); + if (ids[opID] === undefined) { + ids[opID] = 0; + } + ids[opID]++; + replies.each(function(){ + var cur = $(this).find('> .intro > .poster_id'); + cur.find('+ .posts_by_id').remove(); + cur.after(' ('+ ids[cur.text()] +')'); + }); + var size = function(obj) { + var size = 0, key; + for (key in obj) { + if (obj.hasOwnProperty(key)) size++; + } + return size; + }; + $('#thread_stats_uids').text(size(ids)); + } + $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ + var found, page = 'Pruned or Deleted'; + for (var i=0;data[i];i++){ + var threads = data[i].threads; + for (var j=0; threads[j]; j++){ + if (parseInt(threads[j].no) == parseInt(thread_id)) { + page = data[i].page +1; + found = true; + break; + } + } + if (found) break; + } + $('#thread_stats_page').text(page); + if (!found) $('#thread_stats_page').css('color','red'); + }); + } + // load the current page the thread is on. + // uses ajax call so it gets loaded on a delay (depending on network resources available) + var thread_stats_page_timer = setInterval(function(){ + $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ + var found, page = 'Pruned or Deleted'; + for (var i=0;data[i];i++){ + var threads = data[i].threads; + for (var j=0; threads[j]; j++){ + if (parseInt(threads[j].no) == parseInt(thread_id)) { + page = data[i].page +1; + found = true; + break; + } + } + if (found) break; + } + $('#thread_stats_page').text(page); + if (!found) $('#thread_stats_page').css('color','red'); + }); + + },30000); + $(document).ready(function(){ + $('body').append(''); + update_thread_stats(true); + $('#update_thread').click(update_thread_stats); + MutationObserver = window.MutationObserver || window.WebKitMutationObserver; + var observer = new MutationObserver(function(mutations, observer){update_thread_stats();}); + observer.observe($('#thread_' + thread_id)[0], {childList: true}); + }); +} \ No newline at end of file -- cgit v1.3 From 8d451280306c4f05ebb966399420ae4f08831965 Mon Sep 17 00:00:00 2001 From: ForklessAnon Date: Sat, 1 Nov 2014 04:29:21 -0500 Subject: Some code cleanup on thread stats. --- js/thread-stats.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index e6fb1142..59fed912 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -7,10 +7,7 @@ * $config['additional_javascript'][] = 'js/jquery.min.js'; * $config['additional_javascript'][] = 'js/thread-stats.js'; */ -// THREAD STATS if (active_page == 'thread') { - - var thread_stats_timer = 30, thread_stats_timeout; //it has to be on a timer because there I haven't found a way to hook into when the actual page updates the thread... //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); @@ -27,7 +24,7 @@ if (active_page == 'thread') { el.prepend('0 images | '); el.prepend('0 replies | '); delete el; - function update_thread_stats(force){ + function update_thread_stats(){ var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); var replies = $('#thread_'+ thread_id +' > div.post.reply:not(.post-hover):not(.inline)'); // post count @@ -102,14 +99,11 @@ if (active_page == 'thread') { $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); }); - },30000); $(document).ready(function(){ $('body').append(''); - update_thread_stats(true); + update_thread_stats(); $('#update_thread').click(update_thread_stats); - MutationObserver = window.MutationObserver || window.WebKitMutationObserver; - var observer = new MutationObserver(function(mutations, observer){update_thread_stats();}); - observer.observe($('#thread_' + thread_id)[0], {childList: true}); + $(document).on('new_post',update_thread_stats); }); } \ No newline at end of file -- cgit v1.3 From 1aa8f6251d30545242768bf13bbe9ee89c231ca7 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 12 Nov 2014 01:19:02 -0800 Subject: Have to load onready --- js/thread-stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index 59fed912..4050fb67 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -8,8 +8,9 @@ * $config['additional_javascript'][] = 'js/thread-stats.js'; */ if (active_page == 'thread') { +$(document).ready(function(){ //check if page uses unique ID - var IDsupport = ($('.poster_id').length > 0); + var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; @@ -100,10 +101,9 @@ if (active_page == 'thread') { if (!found) $('#thread_stats_page').css('color','red'); }); },30000); - $(document).ready(function(){ $('body').append(''); update_thread_stats(); $('#update_thread').click(update_thread_stats); $(document).on('new_post',update_thread_stats); - }); -} \ No newline at end of file +}); +} -- cgit v1.3 From fdc14c699c25131ffe25536928e0dfac990c4ae3 Mon Sep 17 00:00:00 2001 From: Forkless Date: Mon, 17 Nov 2014 03:06:56 -0600 Subject: Fix color incase page is missed and then found again. --- js/thread-stats.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/thread-stats.js b/js/thread-stats.js index 4050fb67..7c13d66c 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -79,6 +79,7 @@ $(document).ready(function(){ } $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); + else $('#thread_stats_page').css('color',''); }); } // load the current page the thread is on. @@ -99,6 +100,7 @@ $(document).ready(function(){ } $('#thread_stats_page').text(page); if (!found) $('#thread_stats_page').css('color','red'); + else $('#thread_stats_page').css('color',''); }); },30000); $('body').append(''); -- cgit v1.3 From cf91daee7cfbdbede0e0d01b40dd7879cab88186 Mon Sep 17 00:00:00 2001 From: 8chan Date: Fri, 21 Nov 2014 23:33:42 -0800 Subject: No need to display pruned in two places...especially if server times out / errors --- js/thread-stats.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index 7c13d66c..1785b79a 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -65,7 +65,7 @@ $(document).ready(function(){ $('#thread_stats_uids').text(size(ids)); } $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ - var found, page = 'Pruned or Deleted'; + var found, page = '???'; for (var i=0;data[i];i++){ var threads = data[i].threads; for (var j=0; threads[j]; j++){ @@ -86,7 +86,7 @@ $(document).ready(function(){ // uses ajax call so it gets loaded on a delay (depending on network resources available) var thread_stats_page_timer = setInterval(function(){ $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ - var found, page = 'Pruned or Deleted'; + var found, page = '???'; for (var i=0;data[i];i++){ var threads = data[i].threads; for (var j=0; threads[j]; j++){ -- cgit v1.3 From 4b782d6163d061e394e857d6c4f1a94391ddf01b Mon Sep 17 00:00:00 2001 From: Forkless Date: Sat, 22 Nov 2014 19:41:23 -0600 Subject: Fix thread stats so post count hover works on the OP's id. --- js/thread-stats.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index 1785b79a..9b9b3cb3 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -50,9 +50,12 @@ $(document).ready(function(){ ids[opID] = 0; } ids[opID]++; + var cur = op.find('>.intro >.poster_id'); + cur.find('+.posts_by_id').remove(); + cur.after(' ('+ ids[cur.text()] +')'); replies.each(function(){ - var cur = $(this).find('> .intro > .poster_id'); - cur.find('+ .posts_by_id').remove(); + cur = $(this).find('>.intro >.poster_id'); + cur.find('+.posts_by_id').remove(); cur.after(' ('+ ids[cur.text()] +')'); }); var size = function(obj) { -- cgit v1.3 From c4fc8273328a7d4955e472e3242837a4e210adaf Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 11 Mar 2015 18:22:22 -0700 Subject: some style fixes Conflicts: templates/8chan/boards-tags.html --- js/thread-stats.js | 2 +- stylesheets/dark.css | 8 ++++++-- stylesheets/photon.css | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index 9b9b3cb3..fb520c71 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -16,7 +16,7 @@ $(document).ready(function(){ $('form[name="postcontrols"] > .delete') .first() - .before('
'); + .before('
'); var el = $('#thread_stats'); el.prepend('Page ?'); if (IDsupport){ diff --git a/stylesheets/dark.css b/stylesheets/dark.css index 7fc4e199..beb12364 100644 --- a/stylesheets/dark.css +++ b/stylesheets/dark.css @@ -166,13 +166,13 @@ table.modlog tr th { color: #AAAAAA; } -.desktop-style div.boardlist:nth-child(1) { +.desktop-style div.boardlist:not(.bottom) { text-shadow: black 1px 1px 1px, black -1px -1px 1px, black -1px 1px 1px, black 1px -1px 1px; background-color: #666666; } -.desktop-style div.boardlist:nth-child(1):hover, .desktop-style div.boardlist:nth-child(1).cb-menu { +.desktop-style div.boardlist:not(.bottom):hover, .desktop-style div.boardlist:not(.bottom).cb-menu { background-color: rgba(30%, 30%, 30%, 0.65); } @@ -190,3 +190,7 @@ div.report { .options_tab_icon.active { color: #FFFFFF; } + +#quick-reply table { + background: none repeat scroll 0% 0% #333 !important; +} diff --git a/stylesheets/photon.css b/stylesheets/photon.css index db189d77..a487e4dd 100644 --- a/stylesheets/photon.css +++ b/stylesheets/photon.css @@ -326,6 +326,6 @@ form table tr td div { padding: 0px !important; } -.desktop-style div.boardlist:nth-child(1) { +.desktop-style div.boardlist:not(.bottom) { background-color: #DDDDDD; } -- cgit v1.3 From 0d0b2fcd7e807f50b621c17e153194cf99edef5b Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:11:59 +0200 Subject: thread-stats.js: vichan fixes --- js/thread-stats.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index fb520c71..f3b2d375 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,9 +12,9 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split('+')[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split(/+-/)[0].split('.')[0]; - $('form[name="postcontrols"] > .delete') + $('.boardlist.bottom, footer') .first() .before('
'); var el = $('#thread_stats'); @@ -67,6 +67,7 @@ $(document).ready(function(){ }; $('#thread_stats_uids').text(size(ids)); } + var board_name = $('input[name="board"]').val(); $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ var found, page = '???'; for (var i=0;data[i];i++){ @@ -88,6 +89,7 @@ $(document).ready(function(){ // load the current page the thread is on. // uses ajax call so it gets loaded on a delay (depending on network resources available) var thread_stats_page_timer = setInterval(function(){ + var board_name = $('input[name="board"]').val(); $.getJSON('//'+ document.location.host +'/'+ board_name +'/threads.json').success(function(data){ var found, page = '???'; for (var i=0;data[i];i++){ -- cgit v1.3 From c4569b2ea55d162716cda443c7f28ceed672e0eb Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:13:52 +0200 Subject: thread-stats.js: code typo :^) --- js/thread-stats.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index f3b2d375..6035de04 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,7 +12,7 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split(/+-/)[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split(/\+-/)[0].split('.')[0]; $('.boardlist.bottom, footer') .first() -- cgit v1.3 From f86be0f44d126fc11da8644c5999b040a32c69b8 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:17:19 +0200 Subject: thread-stats: best viewed inline --- stylesheets/style.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stylesheets/style.css b/stylesheets/style.css index d2cc0572..64de38bf 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1045,3 +1045,7 @@ span.pln { .dropzone .remove-btn:hover { color: rgba(125, 125, 125, 1); } + +#thread_stats { + display: inline; +} -- cgit v1.3 From 2d68972dd790c96f25b997b2111d0551f1b46029 Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:21:22 +0200 Subject: thread-stats style: add margins --- stylesheets/style.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stylesheets/style.css b/stylesheets/style.css index 64de38bf..80b124f8 100644 --- a/stylesheets/style.css +++ b/stylesheets/style.css @@ -1048,4 +1048,6 @@ span.pln { #thread_stats { display: inline; + margin-left: 10px; + margin-right: 10px; } -- cgit v1.3 From bdda1613a6bc4b88dfe9027dc0f330194654ad9c Mon Sep 17 00:00:00 2001 From: czaks Date: Fri, 10 Apr 2015 23:43:07 +0200 Subject: thread-stats.js: final vichan fix, should work now --- js/thread-stats.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/thread-stats.js b/js/thread-stats.js index 6035de04..8873dbdb 100644 --- a/js/thread-stats.js +++ b/js/thread-stats.js @@ -12,18 +12,18 @@ $(document).ready(function(){ //check if page uses unique ID var IDsupport = ($('.poster_id').length > 0); var thread_id = (document.location.pathname + document.location.search).split('/'); - thread_id = thread_id[thread_id.length -1].split(/\+-/)[0].split('.')[0]; + thread_id = thread_id[thread_id.length -1].split('+')[0].split('-')[0].split('.')[0]; $('.boardlist.bottom, footer') .first() .before('
'); var el = $('#thread_stats'); - el.prepend('Page ?'); + el.prepend(_('Page')+' ?'); if (IDsupport){ el.prepend('0 UIDs | '); } - el.prepend('0 images | '); - el.prepend('0 replies | '); + el.prepend('0 '+_('images')+' | '); + el.prepend('0 '+_('replies')+' | '); delete el; function update_thread_stats(){ var op = $('#thread_'+ thread_id +' > div.post.op:not(.post-hover):not(.inline)').first(); -- cgit v1.3 From 00ad1ecf1560c663e56b53e5686d13d021c195ba Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 11 Apr 2015 21:41:22 +0200 Subject: smart_build: fix one possible performance problem --- smart_build.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smart_build.php b/smart_build.php index 993d7858..31d8110a 100644 --- a/smart_build.php +++ b/smart_build.php @@ -80,7 +80,7 @@ function sb_thread_slugcheck50($b, $thread) { return sb_thread($b, $thread, 50); } -function sb_api($b) { global $config; +function sb_api($b) { global $config, $build_pages; if (!openBoard($b)) return false; $config['try_smarter'] = true; $build_pages = array(-1); -- cgit v1.3 From cb700e6a72602066404a38403c2f559532de26ca Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 11 Apr 2015 23:03:45 +0200 Subject: live index should refresh every 20s --- js/live-index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/live-index.js b/js/live-index.js index 463f7596..017d0c1f 100644 --- a/js/live-index.js +++ b/js/live-index.js @@ -58,7 +58,7 @@ if (active_page == 'index' && (""+document.location).match(/\/(index\.html)?(\?| update_new_threads(new_threads); }); - }, 1000); + }, 20000); }); $(document).on("new_post", function(e, post) { -- cgit v1.3 From 4131a6e5636df3afac7b0894994074cda6fa3b6b Mon Sep 17 00:00:00 2001 From: czaks Date: Sat, 11 Apr 2015 23:12:13 +0200 Subject: watch.js: slow down a little bit, let`s see how it works out --- js/watch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/watch.js b/js/watch.js index 8ac026a7..07c6942a 100644 --- a/js/watch.js +++ b/js/watch.js @@ -248,7 +248,7 @@ $(function(){ var st = storage(); var sched = 0; - var sched_diff = 300; + var sched_diff = 2000; for (var i in st) { if (st[i].watched) { -- cgit v1.3 From 197d5f236f0d35126f90c767c4580a71600298b4 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 12 Apr 2015 00:32:58 +0200 Subject: [code] tag support --- inc/config.php | 11 ++++------- inc/functions.php | 27 ++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/inc/config.php b/inc/config.php index 3a63054c..b7c60125 100644 --- a/inc/config.php +++ b/inc/config.php @@ -624,13 +624,10 @@ $config['markup'][] = array("/\*\*(.+?)\*\*/", "\$1"); $config['markup'][] = array("/^[ |\t]*==(.+?)==[ |\t]*$/m", "\$1"); - // Highlight PHP code wrapped in tags (PHP 5.3+) - // $config['markup'][] = array( - // '/^<code>(.+)<\/code>/ms', - // function($matches) { - // return highlight_string(html_entity_decode($matches[1]), true); - // } - // ); + // Code markup. This should be set to a regular expression, using tags you want to use. Examples: + // "/\[code\](.*?)[\/code]/is" + // "/```([a-z0-9-]{0,20})\n(.*?)\n?```/s" + $config['markup_code'] = false; // Repair markup with HTML Tidy. This may be slower, but it solves nesting mistakes. Tinyboad, at the // time of writing this, can not prevent out-of-order markup tags (eg. "**''test**'') without help from diff --git a/inc/functions.php b/inc/functions.php index a6c85a19..5a52d602 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1857,6 +1857,15 @@ function markup(&$body, $track_cites = false) { if (mysql_version() < 50503) $body = mb_encode_numericentity($body, array(0x010000, 0xffffff, 0, 0xffffff), 'UTF-8'); + if ($config['markup_code']) { + $code_markup = array(); + $body = preg_replace_callback($config['markup_code'], function($matches) use (&$code_markup) { + $d = count($code_markup); + $code_markup[] = $matches; + return ""; + }, $body); + } + foreach ($config['markup'] as $markup) { if (is_string($markup[1])) { $body = preg_replace($markup[0], $markup[1], $body); @@ -2054,7 +2063,19 @@ function markup(&$body, $track_cites = false) { $body = preg_replace('/\s+$/', '', $body); $body = preg_replace("/\n/", '
', $body); - + + // Fix code markup + if ($config['markup_code']) { + foreach ($code_markup as $id => $val) { + $code = isset($val[2]) ? $val[2] : $val[1]; + $code_lang = isset($val[2]) ? $val[1] : ""; + + $code = "
".str_replace(array("\n","\t"), array("
","	"), htmlspecialchars($code))."
"; + + $body = str_replace("", $code, $body); + } + } + if ($config['markup_repair_tidy']) { $tidy = new tidy(); $body = str_replace("\t", ' ', $body); @@ -2072,10 +2093,10 @@ function markup(&$body, $track_cites = false) { ), 'utf8'); $body = str_replace("\n", '', $body); } - + // replace tabs with 8 spaces $body = str_replace("\t", ' ', $body); - + return $tracked_cites; } -- cgit v1.3 From 1b16e97f67853e37641dee3ca1e7d9022a786f2b Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 12 Apr 2015 03:08:40 +0200 Subject: [code] fix regexps --- inc/config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/config.php b/inc/config.php index b7c60125..f11ee5f1 100644 --- a/inc/config.php +++ b/inc/config.php @@ -625,8 +625,8 @@ $config['markup'][] = array("/^[ |\t]*==(.+?)==[ |\t]*$/m", "\$1"); // Code markup. This should be set to a regular expression, using tags you want to use. Examples: - // "/\[code\](.*?)[\/code]/is" - // "/```([a-z0-9-]{0,20})\n(.*?)\n?```/s" + // "/\[code\](.*?)\[\/code\]/is" + // "/```([a-z0-9-]{0,20})\n(.*?)\n?```\n?/s" $config['markup_code'] = false; // Repair markup with HTML Tidy. This may be slower, but it solves nesting mistakes. Tinyboad, at the -- cgit v1.3 From 4060bf10eda3b17513907332890575566cf6e890 Mon Sep 17 00:00:00 2001 From: czaks Date: Sun, 12 Apr 2015 03:17:12 +0200 Subject: update copyright years & vichan website --- README.md | 4 ++-- templates/generic_page.html | 2 +- templates/index.html | 2 +- templates/page.html | 2 +- templates/themes/basic/index.html | 2 +- templates/themes/catalog/catalog.html | 2 +- templates/themes/categories/news.html | 2 +- templates/themes/frameset/news.html | 2 +- templates/themes/recent/recent.html | 2 +- templates/thread.html | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e47dd597..c3383b32 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ vichan is a fork of (now defunc'd) [Tinyboard](http://github.com/savetheinternet a great imageboard package, actively building on it and adding a lot of features and other improvements. -Support and announcements: https://int.vichan.net/devel/ +Support and announcements: https://engine.vichan.net/ Requirements ------------ @@ -90,7 +90,7 @@ links may be helpful for you as well: Donations --------- Do you like our work? You can motivate us financially to do better ;) -* Bitcoin: [![tip for next commit](http://tip4commit.com/projects/708.svg)](http://tip4commit.com/projects/708) +* Bitcoin: 1GjZEdLaTQ8JWVFGZW921Yv4x59f9oiZME You can also ask us to develop some feature specially for you <3. Join our IRC channel and ask for a quote (there are a few of us, who work with the codebase diff --git a/templates/generic_page.html b/templates/generic_page.html index 0fe1f9c5..965cbc2c 100644 --- a/templates/generic_page.html +++ b/templates/generic_page.html @@ -39,7 +39,7 @@

- Tinyboard + vichan {{ config.version }} -
Tinyboard Copyright © 2010-2014 Tinyboard Development Group -
vichan Copyright © 2012-2014 vichan-devel

+
vichan Copyright © 2012-2015 vichan-devel

{% for footer in config.footer %}

{{ footer }}

{% endfor %}