From f9257b8a23f4acf6d7d80494ade667a8d068454d Mon Sep 17 00:00:00 2001 From: 8chan Admin Date: Thu, 31 Oct 2013 22:14:19 +0000 Subject: [PATCH] Fixed ?/debug/* --- inc/config.php | 4 + inc/instance-config.php | 183 +++++++++++++++++++++++++++++++++++----- inc/mod/pages.php | 6 ++ 3 files changed, 170 insertions(+), 23 deletions(-) diff --git a/inc/config.php b/inc/config.php index a9ed2069..6eebf36d 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1341,6 +1341,10 @@ $config['mod']['debug_sql'] = DISABLED; // Look through all cache values for debugging when APC is enabled (?/debug/apc) $config['mod']['debug_apc'] = ADMIN; + // Look through debug information for recent posts (?/debug/recent) + $config['mod']['debug_recent'] = ADMIN; + // Look through debug information for the antispam system (?/debug/antispam) + $config['mod']['debug_antispam'] = ADMIN; // Edit the current configuration (via web interface) $config['mod']['edit_config'] = ADMIN; // View ban appeals diff --git a/inc/instance-config.php b/inc/instance-config.php index f2dafe6f..b788e4ff 100644 --- a/inc/instance-config.php +++ b/inc/instance-config.php @@ -1,23 +1,160 @@ - \ No newline at end of file +\$1"); + $config['markup'][] = array("/\[spoiler\](.+?)\[\/spoiler\]/", "\$1"); + + $config['boards'] = array(array('' => '/', '' => '/boards.php', '' => '/faq.html', '' => '/random.php', '' => '/mod.php', '' => 'https://qchat.rizon.net/?channels=#8chan'), array('b' => '/b', 'meta' => '/meta')); + + //$config['debug'] = true; + + if (!function_exists('prettify_textarea')){ + function prettify_textarea($s){ + return str_replace("\t", ' ', str_replace("\n", ' ', $s)); + } + } + + if (!function_exists('purify')){ + function purify($s){ + $config = HTMLPurifier_Config::createDefault(); + $purifier = new HTMLPurifier($config); + $clean_html = $purifier->purify($s); + return $clean_html; + } + } + + $config['mod']['custom_pages']['/settings/(\%b)'] = function($b) { + global $config, $mod; + + if (!in_array($b, $mod['boards']) and $mod['boards'][0] != '*') + error($config['error']['noaccess']); + + if (!openBoard($b)) + error("Could not open board!"); + + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + $title = $_POST['title']; + $subtitle = $_POST['subtitle']; + $country_flags = isset($_POST['country_flags']) ? 'true' : 'false'; + $field_disable_name = isset($_POST['field_disable_name']) ? 'true' : 'false'; + $enable_embedding = isset($_POST['enable_embedding']) ? 'true' : 'false'; + $force_image_op = isset($_POST['force_image_op']) ? 'true' : 'false'; + $disable_images = isset($_POST['disable_images']) ? 'true' : 'false'; + $poster_ids = isset($_POST['poster_ids']) ? 'true' : 'false'; + $code_tags = isset($_POST['code_tags']) ? '$config[\'additional_javascript\'][] = \'js/code_tags/run_prettify.js\';$config[\'markup\'][] = array("/\[code\](.+?)\[\/code\]/ms", "
\$1
");' : ''; + $mathjax = isset($_POST['mathjax']) ? '$config[\'mathjax\'] = true;$config[\'additional_javascript\'][] = \'js/mathjax-MathJax-727332c/MathJax.js?config=TeX-AMS_HTML-full\';' : ''; + $anonymous = base64_encode($_POST['anonymous']); + $blotter = base64_encode(purify(html_entity_decode($_POST['blotter']))); + + if (!(strlen($title) < 40)) + error('Invalid title'); + if (!(strlen($subtitle) < 200)) + error('Invalid subtitle'); + + $query = prepare('UPDATE ``boards`` SET `title` = :title, `subtitle` = :subtitle WHERE `uri` = :uri'); + $query->bindValue(':title', $title); + $query->bindValue(':subtitle', $subtitle); + $query->bindValue(':uri', $b); + $query->execute() or error(db_error($query)); + + $config_file = <<'Rules', 'subtitle'=>'', 'config'=>$config, 'body'=>'
'.purify($_POST['rules']).'
'))); + file_write($b.'/rules.txt', $_POST['rules']); + } + + $query = prepare('SELECT * FROM boards WHERE uri = :board'); + $query->bindValue(':board', $b); + $query->execute() or error(db_error($query)); + $board = $query->fetchAll()[0]; + + $rules = @file_get_contents($board['uri'] . '/rules.txt'); + $css = @file_get_contents('stylesheets/board/' . $board['uri'] . '.css'); + + openBoard($b); + + buildIndex(); + + mod_page(_('Board configuration'), 'mod/settings.html', array('board'=>$board, 'rules'=>prettify_textarea($rules), 'css'=>prettify_textarea($css), 'token'=>make_secure_link_token('settings/'.$board['uri']))); + }; diff --git a/inc/mod/pages.php b/inc/mod/pages.php index aebaeadf..f2426278 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -2390,6 +2390,9 @@ function mod_theme_rebuild($theme_name) { function mod_debug_antispam() { global $pdo, $config; + + if (!hasPermission($config['mod']['debug_antispam'])) + error($config['error']['noaccess']); $args = array(); @@ -2427,6 +2430,9 @@ function mod_debug_antispam() { function mod_debug_recent_posts() { global $pdo, $config; + + if (!hasPermission($config['mod']['debug_recent'])) + error($config['error']['noaccess']); $limit = 500;