From 0eba6fa4c33d16012c7061c3256c4dfa217bef7c Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 22 Oct 2014 19:16:13 -0700 Subject: [PATCH 01/12] This was crashing rebuild.php for some reason... --- inc/api.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/api.php b/inc/api.php index c9608f06..db723962 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'] = @substr($file->name, 0, strrpos($file->name, '.')); $dotPos = strrpos($file->file, '.'); $apiPost['ext'] = substr($file->file, $dotPos); $apiPost['tim'] = substr($file->file, 0, $dotPos); From 840c42adc4974dec3d42ee2ee8f5cfaae3a3fe80 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 22 Oct 2014 19:16:45 -0700 Subject: [PATCH 02/12] array_unique to prevent JS Errors --- inc/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/functions.php b/inc/functions.php index b2d945d2..1e5fa833 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1541,7 +1541,7 @@ function buildJavascript() { } if ($config['additional_javascript_compile']) { - foreach ($config['additional_javascript'] as $file) { + foreach (array_unique($config['additional_javascript']) as $file) { $script .= file_get_contents($file); } } From a8effc870dae6b32cfbc20fa0be3345bc6d6ed5f Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 22 Oct 2014 19:17:18 -0700 Subject: [PATCH 03/12] Fix bans page on Firefox --- inc/mod/pages.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 3cdf1374..f8a29c7d 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -1032,7 +1032,7 @@ function mod_bans_json() { error($config['error']['noaccess']); // Compress the json for faster loads - if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); + if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); Bans::stream_json(false, !hasPermission($config['mod']['show_ip']), !hasPermission($config['mod']['view_banstaff']), $mod['boards']); } From ab3fd973ad67a2680ba84c6f503a52a3e55b1ae9 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 22 Oct 2014 19:17:32 -0700 Subject: [PATCH 04/12] Fix index page for new update_boards.js --- templates/8chan/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/8chan/index.html b/templates/8chan/index.html index 2bad668d..a5a3c8a5 100644 --- a/templates/8chan/index.html +++ b/templates/8chan/index.html @@ -237,7 +237,7 @@ {% trans %}Welcome to ∞chan, the infinitely expanding imageboard.{% endtrans %}
{% trans %}Featured boards:{% endtrans %} - +
{% trans %}Boards of the week:{% endtrans %} [  From ff225064a1f9d0a356c69a06638dcc3cead4dd35 Mon Sep 17 00:00:00 2001 From: 8chan Date: Wed, 22 Oct 2014 19:18:23 -0700 Subject: [PATCH 05/12] Add ?/flags [NOT DONE] and $config[allow_delete] to ?/settings --- inc/instance-config.php | 82 ++++++++++++++++++++++++++++++++++--- templates/mod/settings.html | 1 + 2 files changed, 77 insertions(+), 6 deletions(-) diff --git a/inc/instance-config.php b/inc/instance-config.php index c2df3b5b..f2edfad7 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -86,6 +86,9 @@ $config['mod']['debug_antispam'] = ADMIN; $config['mod']['modlog'] = SUPERMOD; $config['mod']['editpost'] = MOD; + $config['mod']['edit_banners'] = MOD; + $config['mod']['edit_flags'] = MOD; + $config['mod']['edit_settings'] = MOD; $config['mod']['recent_reports'] = 65535; $config['mod']['ip_less_recentposts'] = 75; $config['ban_show_post'] = true; @@ -93,10 +96,14 @@ // Board shit $config['max_links'] = 40; $config['poster_id_length'] = 6; - $config['ayah_enabled'] = true; + $config['ayah_enabled'] = false; + $config['cbRecaptcha'] = true; $config['url_banner'] = '/banners.php'; + $config['additional_javascript_compile'] = true; //$config['default_stylesheet'] = array('Notsuba', 'notsuba.css'); $config['additional_javascript'][] = 'js/jquery.min.js'; + $config['additional_javascript'][] = 'js/jquery.mixitup.min.js'; + $config['additional_javascript'][] = 'js/catalog.js'; $config['additional_javascript'][] = 'js/jquery.tablesorter.min.js'; $config['additional_javascript'][] = 'js/options.js'; $config['additional_javascript'][] = 'js/style-select.js'; @@ -136,6 +143,8 @@ $config['additional_javascript'][] = 'js/infinite-scroll.js'; $config['additional_javascript'][] = 'js/download-original.js'; $config['additional_javascript'][] = 'js/thread-watcher.js'; + $config['additional_javascript'][] = 'js/ajax.js'; + $config['additional_javascript'][] = 'js/show-own-posts.js'; //$config['font_awesome_css'] = '/netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css'; @@ -176,11 +185,72 @@ } } + $config['mod']['custom_pages']['/flags/(\%b)'] = function($b) { + global $config, $mod, $board; + require_once 'inc/image.php'; + + if (!hasPermission($config['mod']['edit_flags'], $b)) + error($config['mod']['noaccess']); + + if (!openBoard($b)) + error("Could not open board!"); + + $dir = 'static/custom-flags/'.$b; + + if (!is_dir($dir)){ + mkdir($dir, 0777, true); + } + + if (isset($_FILES['file'])){ + $upload = $_FILES['file']['tmp_name']; + $banners = array_diff(scandir($dir), array('..', '.')); + + if (!is_readable($upload)) + error($config['error']['nomove']); + + $id = time() . substr(microtime(), 2, 3); + $extension = strtolower(mb_substr($_FILES['file']['name'], mb_strrpos($_FILES['file']['name'], '.') + 1)); + + if ($extension != 'png') { + error(_('Flags must be in PNG format.')); + } + + if (filesize($upload) > 48000){ + error(_('File too large!')); + } + + if (!$size = @getimagesize($upload)) { + error($config['error']['invalidimg']); + } + + if ($size[0] != 16 or $size[1] != 11){ + error(_('Image wrong size!')); + } + if (sizeof($banners) >= 100) { + error(_('Too many flags.')); + } + + copy($upload, "$dir/$id.$extension"); + } + + if (isset($_POST['delete'])){ + foreach ($_POST['delete'] as $i => $d){ + if (!preg_match('/[0-9+]\.(png|jpeg|jpg|gif)/', $d)){ + error('Nice try.'); + } + unlink("$dir/$d"); + } + } + + $banners = array_diff(scandir($dir), array('..', '.')); + mod_page(_('Edit banners'), 'mod/banners.html', array('board'=>$board,'banners'=>$banners,'token'=>make_secure_link_token('banners/'.$board['uri']))); + }; + $config['mod']['custom_pages']['/banners/(\%b)'] = function($b) { global $config, $mod, $board; require_once 'inc/image.php'; - if (!in_array($b, $mod['boards']) and $mod['boards'][0] != '*') + if (!hasPermission($config['mod']['edit_banners'], $b)) error($config['error']['noaccess']); if (!openBoard($b)) @@ -263,12 +333,12 @@ $auto_unicode = isset($_POST['auto_unicode']) ? 'true' : 'false'; $allow_roll = isset($_POST['allow_roll']) ? 'true' : 'false'; $image_reject_repost = isset($_POST['image_reject_repost']) ? 'true' : 'false'; + $allow_delete = isset($_POST['allow_delete']) ? 'true' : 'false'; $allow_flash = isset($_POST['allow_flash']) ? '$config[\'allowed_ext_files\'][] = \'swf\';' : ''; $code_tags = isset($_POST['code_tags']) ? '$config[\'additional_javascript\'][] = \'js/code_tags/run_prettify.js\';$config[\'markup\'][] = array("/\[code\](.+?)\[\/code\]/ms", "
\$1
");' : ''; $katex = isset($_POST['katex']) ? '$config[\'katex\'] = true;$config[\'additional_javascript\'][] = \'js/katex/katex.min.js\'; $config[\'markup\'][] = array("/\[tex\](.+?)\[\/tex\]/ms", "\$1"); $config[\'additional_javascript\'][] = \'js/katex-enable.js\';' : ''; $oekaki_js = <<{% trans %}Allow SWF uploading{% endtrans %} {% trans %}Enable dice rolling{% endtrans %} {% trans %}Don't allow users to repost images{% endtrans %} + {% trans %}Allow a poster to delete his own posts{% endtrans %} {% trans %}Language{% endtrans %}
{% trans %}To contribute translations, register at Transifex{% endtrans %}