From f09804171313b05c6a06482d75a6f296bafb8f9e Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 12 Nov 2023 01:05:14 +0700 Subject: [PATCH] =?UTF-8?q?Simplified=20jumpbox=20=F0=9F=93=9C=20(#815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Simplified jumpbox 📜 * Updated * Update README.md * Updated * Update page_header.tpl * Update functions.php --- .gitignore | 1 - README.md | 1 - internal_data/ajax_html/.keep | 0 library/defines.php | 1 - .../includes/datastore/build_cat_forums.php | 15 +++++++-------- library/includes/functions.php | 10 +++++++--- library/includes/page_header.php | 5 +++-- styles/templates/default/page_header.tpl | 19 ++++++++++--------- 8 files changed, 27 insertions(+), 25 deletions(-) delete mode 100644 internal_data/ajax_html/.keep diff --git a/.gitignore b/.gitignore index 7cafde02f..b3f6e9a7a 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ composer.phar configs/local.php data/avatars data/torrent_files -internal_data/ajax_html internal_data/atom internal_data/cache internal_data/log diff --git a/README.md b/README.md index 6721c4603..7c0fbcde1 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,6 @@ You must provide write permissions to the specified folders: * `data/avatars` * `data/torrent_files` * `data/torrent_files/thumbs` -* `internal_data/ajax_html` * `internal_data/atom` * `internal_data/cache` * `internal_data/log` diff --git a/internal_data/ajax_html/.keep b/internal_data/ajax_html/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/library/defines.php b/library/defines.php index 7ebb95591..4646deb2e 100644 --- a/library/defines.php +++ b/library/defines.php @@ -36,7 +36,6 @@ define('CHECK_REQIREMENTS', [ define('ADMIN_DIR', BB_PATH . '/admin'); define('DATA_DIR', BB_PATH . '/data'); define('INT_DATA_DIR', BB_PATH . '/internal_data'); -define('AJAX_HTML_DIR', BB_PATH . '/internal_data/ajax_html'); define('CACHE_DIR', BB_PATH . '/internal_data/cache'); define('LOG_DIR', BB_PATH . '/internal_data/log'); define('TRIGGERS_DIR', BB_PATH . '/internal_data/triggers'); diff --git a/library/includes/datastore/build_cat_forums.php b/library/includes/datastore/build_cat_forums.php index 8523bc5e5..d6360f281 100644 --- a/library/includes/datastore/build_cat_forums.php +++ b/library/includes/datastore/build_cat_forums.php @@ -106,15 +106,14 @@ $this->store('cat_forums', $data); // // jumpbox // -$data = [ - 'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), - 'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), -]; +if ($bb_cfg['show_jumpbox']) { + $data = [ + 'guest' => get_forum_select('guest', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), + 'user' => get_forum_select('user', 'f', null, null, null, 'id="jumpbox" onchange="window.location.href=\'' . FORUM_URL . '\'+this.value;"'), + ]; -$this->store('jumpbox', $data); - -file_write($data['guest'], AJAX_HTML_DIR . '/jumpbox_guest.html', false, true, true); -file_write($data['user'], AJAX_HTML_DIR . '/jumpbox_user.html', false, true, true); + $this->store('jumpbox', $data); +} // // viewtopic_forum_select diff --git a/library/includes/functions.php b/library/includes/functions.php index 3486bdd27..3bd242db5 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -1012,16 +1012,20 @@ function get_userdata($u, bool $is_name = false, bool $allow_guest = false) return $u_data; } -function make_jumpbox($selected = 0) +function make_jumpbox() { - global $datastore, $template; + global $datastore, $template, $bb_cfg; + + if (!$bb_cfg['show_jumpbox']) { + return; + } if (!$jumpbox = $datastore->get('jumpbox')) { $datastore->update('jumpbox'); $jumpbox = $datastore->get('jumpbox'); } - $template->assign_vars(['JUMPBOX' => (IS_GUEST) ? $jumpbox['guest'] : $jumpbox['user']]); + $template->assign_vars(['JUMPBOX' => (IS_GUEST) ? DB()->escape($jumpbox['guest']) : DB()->escape($jumpbox['user'])]); } // $mode: array(not_auth_forum1,not_auth_forum2,..) or (string) 'mode' diff --git a/library/includes/page_header.php b/library/includes/page_header.php index 9b8b408e5..4afbc1270 100644 --- a/library/includes/page_header.php +++ b/library/includes/page_header.php @@ -56,6 +56,9 @@ if (defined('SHOW_ONLINE') && SHOW_ONLINE) { ]); } +// Make jumpbox +make_jumpbox(); + // Info about new private messages $icon_pm = $images['pm_no_new_msg']; $pm_info = $lang['NO_NEW_PM']; @@ -192,8 +195,6 @@ $template->assign_vars([ 'BONUS_URL' => BB_ROOT . BONUS_URL, 'TOPIC_URL' => BB_ROOT . TOPIC_URL, - 'AJAX_HTML_DIR' => AJAX_HTML_DIR, - // Misc 'BOT_UID' => BOT_UID, 'SID' => $userdata['session_id'], diff --git a/styles/templates/default/page_header.tpl b/styles/templates/default/page_header.tpl index 52edacc73..be487c50b 100644 --- a/styles/templates/default/page_header.tpl +++ b/styles/templates/default/page_header.tpl @@ -68,9 +68,9 @@ var user = { } }; - -$(document).ready(function(){ - $("div.jumpbox").html('\ + +$(document).ready(function () { + $("div.jumpbox").html('\ \ \ '); - $('#jumpbox-container').one('click', function(){ - $('#jumpbox-title').html('   {L_LOADING} ...  '); - var jumpbox_src = '/internal_data/ajax_html' + ({LOGGED_IN} ? '/jumpbox_user.html' : '/jumpbox_guest.html'); - $(this).load(jumpbox_src); - $('#jumpbox-submit').click(function(){ window.location.href='{FORUM_URL}'+$('#jumpbox').val(); }); - }); + $('#jumpbox-container').one('click', function () { + $('#jumpbox-title').html('   {L_LOADING} ...  '); + $(this).html('{JUMPBOX}'); + $('#jumpbox-submit').click(function () { + window.location.href = '{FORUM_URL}' + $('#jumpbox').val(); + }); + }); });