diff --git a/SSI.php b/SSI.php index 064140af..14af4d4b 100644 --- a/SSI.php +++ b/SSI.php @@ -14,10 +14,9 @@ define('WEDGE', 'SSI'); -// We're going to want a few globals... these are all set later. -global $settings, $context, $sc, $topic, $board, $txt; -global $time_start, $maintenance, $msubject, $mmessage, $mbname; -global $boardurl, $webmaster_email, $cookiename; +// For reference, mainly. +global $settings, $context, $sc, $topic, $board, $txt, $time_start; +global $maintenance, $msubject, $mmessage, $mbname, $webmaster_email, $cookiename; global $db_server, $db_connection, $db_name, $db_user, $db_prefix, $db_persist; global $db_error_send, $db_last_error, $ssi_db_user, $ssi_db_passwd, $db_passwd; @@ -1023,7 +1022,7 @@ function ssi_topPoll($output_method = 'echo') // Show the most recently posted poll. function ssi_recentPoll($topPollInstead = false, $output_method = 'echo') { - global $txt, $boardurl, $context, $settings; + global $txt, $context, $settings; $boardsAllowed = array_intersect(boardsAllowedTo('poll_view'), boardsAllowedTo('poll_vote')); @@ -1133,7 +1132,7 @@ function ssi_recentPoll($topPollInstead = false, $output_method = 'echo') if ($allow_view_results) { echo ' -
+ ', $return['question'], '
', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '
' : ''; @@ -1153,7 +1152,7 @@ function ssi_recentPoll($topPollInstead = false, $output_method = 'echo') function ssi_showPoll($id_topic = null, $output_method = 'echo') { - global $txt, $boardurl, $context; + global $txt, $context; $boardsAllowed = boardsAllowedTo('poll_view'); @@ -1283,7 +1282,7 @@ function ssi_showPoll($id_topic = null, $output_method = 'echo') if ($return['allow_vote']) { echo ' - + ', $return['question'], '
', !empty($return['allowed_warning']) ? $return['allowed_warning'] . '
' : ''; diff --git a/core/app/Class-System.php b/core/app/Class-System.php index db21c8e5..73788772 100644 --- a/core/app/Class-System.php +++ b/core/app/Class-System.php @@ -56,7 +56,7 @@ public static function &getInstance($load_user = true) */ protected static function init_user() { - global $context, $settings, $user_settings, $cookiename, $boardurl; + global $context, $settings, $user_settings, $cookiename; $id_member = 0; @@ -435,7 +435,7 @@ protected static function init_user() // Fill in the server URL for the current user. This is user-specific, as they may be using a different URL than the script's default URL (Pretty URL, secure access...) // Note that HTTP_X_FORWARDED_SERVER is mostly used by proxy servers. If the client doesn't provide anything, it's probably a bot. - $user['host'] = empty($_SERVER['REAL_HTTP_HOST']) ? (empty($_SERVER['HTTP_HOST']) ? (empty($_SERVER['HTTP_X_FORWARDED_SERVER']) ? substr(strrchr($boardurl, ':'), 3) : $_SERVER['HTTP_X_FORWARDED_SERVER']) : $_SERVER['HTTP_HOST']) : $_SERVER['REAL_HTTP_HOST']; + $user['host'] = empty($_SERVER['REAL_HTTP_HOST']) ? (empty($_SERVER['HTTP_HOST']) ? (empty($_SERVER['HTTP_X_FORWARDED_SERVER']) ? substr(strrchr(ROOT, ':'), 3) : $_SERVER['HTTP_X_FORWARDED_SERVER']) : $_SERVER['HTTP_HOST']) : $_SERVER['REAL_HTTP_HOST']; $user['server'] = $context['protocol'] . $user['host']; // The URL in your address bar. Also contains the query string. diff --git a/core/app/Load.php b/core/app/Load.php index 56f441b0..c8b04268 100644 --- a/core/app/Load.php +++ b/core/app/Load.php @@ -2145,7 +2145,7 @@ function getLanguages($use_cache = true) */ function loadSession() { - global $settings, $boardurl, $sc; + global $settings, $sc; // Attempt to change a few PHP settings. ini_set('session.use_cookies', true); @@ -2156,7 +2156,7 @@ function loadSession() if (!empty($settings['globalCookies'])) { - $parsed_url = parse_url($boardurl); + $parsed_url = parse_url(ROOT); if (!preg_match('~^\d{1,3}(\.\d{1,3}){3}$~', $parsed_url['host']) && preg_match('~(?:[^.]+\.)?([^.]{2,}\..+)\z~i', $parsed_url['host'], $parts)) ini_set('session.cookie_domain', '.' . $parts[1]); diff --git a/core/app/ManageNews.php b/core/app/ManageNews.php index 17c35524..014d6f17 100644 --- a/core/app/ManageNews.php +++ b/core/app/ManageNews.php @@ -473,7 +473,7 @@ function ComposeMailing() // Send out the mailing! function SendMailing($clean_only = false) { - global $txt, $context, $boardurl, $settings; + global $txt, $context, $settings; // How many to send at once? Quantity depends on whether we are queueing or not. $num_at_once = empty($settings['mail_queue']) ? 60 : 1000; @@ -602,7 +602,7 @@ function SendMailing($clean_only = false) // Replace in all the standard things. $_POST['message'] = str_replace($variables, array( - !empty($_POST['send_html']) ? '' . $boardurl . '' : $boardurl, + !empty($_POST['send_html']) ? '' . ROOT . '' : ROOT, timeformat(forum_time(), false), !empty($_POST['send_html']) ? '' . $cleanLatestMember . '' : ($context['send_pm'] ? '[url=' . SCRIPT . '?action=profile;u=' . $settings['latestMember'] . ']' . $cleanLatestMember . '[/url]' : $cleanLatestMember), $settings['latestMember'], @@ -610,7 +610,7 @@ function SendMailing($clean_only = false) ), $_POST['message']); $_POST['subject'] = str_replace($variables, array( - $boardurl, + ROOT, timeformat(forum_time(), false), $settings['latestRealName'], $settings['latestMember'], diff --git a/core/app/ManagePaid.php b/core/app/ManagePaid.php index 1f8572c5..724af28d 100644 --- a/core/app/ManagePaid.php +++ b/core/app/ManagePaid.php @@ -111,7 +111,7 @@ function ManagePaidSubscriptions() // Modify which payment methods are to be used. function ModifySubscriptionSettings($return_config = false) { - global $context, $txt, $settings, $boardurl; + global $context, $txt, $settings; // If the currency is set to something different then we need to set it to other for this to work and set it back shortly. $settings['paid_currency'] = !empty($settings['paid_currency_code']) ? $settings['paid_currency_code'] : ''; @@ -159,7 +159,7 @@ function ModifySubscriptionSettings($return_config = false) // Some important context stuff $context['page_title'] = $txt['settings']; wetem::load('show_settings'); - $context['settings_message'] = str_replace('{board_url}', $boardurl, $txt['paid_note']); + $context['settings_message'] = str_replace('{board_url}', ROOT, $txt['paid_note']); $context[$context['admin_menu_name']]['current_subsection'] = 'settings'; // Get the final touches in place. diff --git a/core/app/ManageSettings.php b/core/app/ManageSettings.php index c49b61b8..24617ee2 100644 --- a/core/app/ManageSettings.php +++ b/core/app/ManageSettings.php @@ -488,8 +488,8 @@ function ModifyPmSettings($return_config = false) // !!! To-do: // - Specifically allow for subdomains -// - Disable the area and subdomain feature, and explain why, if $boardurl has a subfolder name in it! -// i.e. if (preg_match('~://[^/]+/[^/]+~', $boardurl)) +// - Disable the area and subdomain feature, and explain why, if ROOT has a subfolder name in it! +// i.e. if (preg_match('~://[^/]+/[^/]+~', ROOT)) // Shell for all the Pretty URL interfaces function ModifyPrettyURLs($return_config = false) diff --git a/core/app/PrettyUrls-Filters.php b/core/app/PrettyUrls-Filters.php index 2be58dec..82833b9e 100644 --- a/core/app/PrettyUrls-Filters.php +++ b/core/app/PrettyUrls-Filters.php @@ -93,7 +93,7 @@ function pretty_synchronize_topic_urls() */ function pretty_filter_actions(&$urls) { - global $boardurl, $settings; + global $settings; $action_pattern = '~(?<=[?;&])action=([^;]+)~'; $action_replacement = isset($settings['pretty_prefix_action']) ? $settings['pretty_prefix_action'] : 'do/'; @@ -101,7 +101,7 @@ function pretty_filter_actions(&$urls) foreach ($urls as &$url) { if (!isset($url['replacement'])) - $url['replacement'] = $boardurl . '/' . $url['url']; + $url['replacement'] = ROOT . '/' . $url['url']; if (strpos($url['replacement'], 'action=') !== false && preg_match($action_pattern, $url['replacement'], $action)) $url['replacement'] = str_replace($action[0], '', substr_replace($url['replacement'], $action_replacement . $action[1] . '/', strpos($url['replacement'], '?'), 0)); } @@ -112,7 +112,7 @@ function pretty_filter_actions(&$urls) */ function pretty_filter_topics(&$urls) { - global $boardurl, $settings, $context; + global $settings, $context; $pattern = '~(?<=[?;&])topic=(\d+)(?:\.([a-zA-Z0-9$%]+))?~'; $query_data = array(); @@ -148,7 +148,7 @@ function pretty_filter_topics(&$urls) { if (isset($row['pretty_url'])) $topicData[$row['id_topic']] = array( - 'pretty_board' => !empty($row['url']) ? $context['protocol'] . $row['url'] : $boardurl, + 'pretty_board' => !empty($row['url']) ? $context['protocol'] . $row['url'] : ROOT, 'pretty_url' => $row['pretty_url'], ); else @@ -240,7 +240,7 @@ function pretty_filter_topics(&$urls) */ function pretty_filter_boards(&$urls) { - global $boardurl, $context; + global $context; $pattern = '~(.*[?;&])\bboard=([.0-9$%d]+)(?:;(cat|tag)=([^;&]+))?(?:;month=(\d{6,8}))?(.*)~S'; $bo_list = array(); @@ -287,11 +287,11 @@ function pretty_filter_boards(&$urls) foreach ($urls as &$url) if (!isset($url['replacement']) && isset($url['board_id'])) - $url['replacement'] = (!empty($url_list[$url['board_id']]) ? $context['protocol'] . $url_list[$url['board_id']] : $boardurl) . '/' . $url['cattag'] . $url['epoch'] . $url['start'] . $url['match1'] . $url['match6']; + $url['replacement'] = (!empty($url_list[$url['board_id']]) ? $context['protocol'] . $url_list[$url['board_id']] : ROOT) . '/' . $url['cattag'] . $url['epoch'] . $url['start'] . $url['match1'] . $url['match6']; } $cat_pattern = '~(.*)\bcategory=([^;]+)~S'; - $cat_replacement = $boardurl . '/category/$2/$1'; + $cat_replacement = ROOT . '/category/$2/$1'; foreach ($urls as &$url) if (!isset($url['replacement']) && strpos($url['url'], 'category=') !== false && preg_match($cat_pattern, $url['url'])) @@ -303,7 +303,7 @@ function pretty_filter_boards(&$urls) */ function pretty_filter_profiles(&$urls) { - global $boardurl, $settings; + global $settings; $pattern = '~(.*)\baction=profile(;u=([0-9]+))?(.*)~S'; $query_data = array(); @@ -321,7 +321,7 @@ function pretty_filter_profiles(&$urls) if ($url['profile_id'] > 0) $query_data[$url['profile_id']] = true; else - $url['replacement'] = $boardurl . $prefix . ($url['this_is_me'] ? $me_postfix : 'guest/') . $url['match1'] . $url['match3']; + $url['replacement'] = ROOT . $prefix . ($url['this_is_me'] ? $me_postfix : 'guest/') . $url['match1'] . $url['match3']; } } @@ -346,6 +346,6 @@ function pretty_filter_profiles(&$urls) // Build the replacement URLs foreach ($urls as &$url) if (isset($url['profile_id'])) - $url['replacement'] = $boardurl . $prefix . (!empty($memberNames[$url['profile_id']]) ? $memberNames[$url['profile_id']] . '/' : ($url['this_is_me'] ? $me_postfix : 'guest/')) . $url['match1'] . $url['match3']; + $url['replacement'] = ROOT . $prefix . (!empty($memberNames[$url['profile_id']]) ? $memberNames[$url['profile_id']] . '/' : ($url['this_is_me'] ? $me_postfix : 'guest/')) . $url['match1'] . $url['match3']; } } diff --git a/core/app/Security.php b/core/app/Security.php index 29c5276b..4567c76b 100644 --- a/core/app/Security.php +++ b/core/app/Security.php @@ -795,7 +795,7 @@ function query_for_bans($type) // Make sure the user's correct session was passed, and they came from here. (type can be post, get, or request.) function checkSession($type = 'post', $from_action = '', $is_fatal = true) { - global $sc, $settings, $boardurl; + global $sc, $settings; // Is it in as $_POST? if ($type == 'post') @@ -842,7 +842,7 @@ function checkSession($type = 'post', $from_action = '', $is_fatal = true) else $real_host = $_SERVER['HTTP_HOST']; - $parsed_url = parse_url($boardurl); + $parsed_url = parse_url(ROOT); // Are global cookies on? If so, let's check them ;) if (!empty($settings['globalCookies'])) diff --git a/core/app/Subs-Auth.php b/core/app/Subs-Auth.php index cae2e6eb..b9212267 100644 --- a/core/app/Subs-Auth.php +++ b/core/app/Subs-Auth.php @@ -124,7 +124,7 @@ function setLoginCookie($cookie_length, $id, $password = '') foreach ($aliases as $alias) { - // Fake the $boardurl so we can set a different cookie. + // Fake the ROOT so we can set a different cookie. $alias = strtr(trim($alias), array('http://' => '', 'https://' => '')); $cookie_url = url_parts(!empty($settings['localCookies']), !empty($settings['globalCookies']), 'http://' . $alias); @@ -157,10 +157,8 @@ function setLoginCookie($cookie_length, $id, $password = '') // Get the domain and path for the cookie... function url_parts($local, $global, $force_url = '') { - global $boardurl; - // Parse the URL with PHP to make life easier. - $parsed_url = parse_url(empty($url) ? $boardurl : $force_url); + $parsed_url = parse_url(empty($url) ? ROOT : $force_url); // Is local cookies off? if (empty($parsed_url['path']) || !$local) diff --git a/core/app/Subs-Cache.php b/core/app/Subs-Cache.php index 1e20bb4e..453a439a 100644 --- a/core/app/Subs-Cache.php +++ b/core/app/Subs-Cache.php @@ -1927,7 +1927,7 @@ function cache_get_data($orig_key, $ttl = 120, $put_callback = null) function cache_prepare_key($key, $val = '', $type = 'get') { - global $boardurl, $settings, $cache_hits, $cache_count, $db_show_debug; + global $settings, $cache_hits, $cache_count, $db_show_debug; $cache_count = isset($cache_count) ? $cache_count + 1 : 1; if (!empty($db_show_debug)) @@ -1937,7 +1937,7 @@ function cache_prepare_key($key, $val = '', $type = 'get') { if (!file_exists(CACHE_DIR . '/cache.lock')) @fclose(@fopen(CACHE_DIR . '/cache.lock', 'w')); - $settings['cache_hash'] = md5($boardurl . filemtime(CACHE_DIR . '/cache.lock')); + $settings['cache_hash'] = md5(ROOT_DIR . filemtime(CACHE_DIR . '/cache.lock')); } return $settings['cache_hash'] . '-' . bin2hex($key); diff --git a/core/app/Subs-PrettyUrls.php b/core/app/Subs-PrettyUrls.php index fa91d852..256b25b1 100644 --- a/core/app/Subs-PrettyUrls.php +++ b/core/app/Subs-PrettyUrls.php @@ -88,10 +88,10 @@ function pretty_generate_url($text, $is_board = false, $slash = false) // Check a new pretty URL against the list of existing boards to ensure there won't be a conflict. function is_already_taken($url, $id, $id_owner) { - global $context, $action_list, $boardurl; + global $context, $action_list; // Is the board name in the action list? - $board_name = substr($url, strlen($boardurl) + 1); + $board_name = substr($url, strlen(ROOT) + 1); $forbidden = array_merge($action_list, array('do' => true)); foreach (explode('/', $board_name) as $name) diff --git a/core/app/Subscriptions-PayPal.php b/core/app/Subscriptions-PayPal.php index a5283333..b66679bd 100644 --- a/core/app/Subscriptions-PayPal.php +++ b/core/app/Subscriptions-PayPal.php @@ -40,7 +40,7 @@ public function gatewayEnabled() // What do we want? public function fetchGatewayFields($unique_id, $sub_data, $value, $period, $return_url) { - global $settings, $txt, $boardurl; + global $settings, $txt; $return_data = array( 'form' => 'https://www.' . (!empty($settings['paidsubs_test']) ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr', @@ -63,7 +63,7 @@ public function fetchGatewayFields($unique_id, $sub_data, $value, $period, $retu $return_data['hidden']['cmd'] = !$sub_data['repeatable'] ? '_xclick' : '_xclick-subscriptions'; $return_data['hidden']['return'] = $return_url; $return_data['hidden']['src'] = 1; - $return_data['hidden']['notify_url'] = $boardurl . '/subscriptions.php'; + $return_data['hidden']['notify_url'] = ROOT . '/subscriptions.php'; // Now then, what language should we use? A language pack should indicate the language PayPal should use. $return_data['hidden']['lc'] = isset($txt['lang_paypal']) ? $txt['lang_paypal'] : 'US'; diff --git a/core/app/Upgrade.php b/core/app/Upgrade.php index 80d6b7d6..ff2ce023 100644 --- a/core/app/Upgrade.php +++ b/core/app/Upgrade.php @@ -32,6 +32,7 @@ function upgrade_db() } // We might want to add some message here... + // Note: ROOT isn't defined at this point, so stick to $boardurl! redirectexit($boardurl . '/index.php?' . ($v < WEDGE ? 'upgrading-step-' . $v : 'upgraded')); } diff --git a/core/app/media/Aeva-Embed.php b/core/app/media/Aeva-Embed.php index 993b56a6..b01cddcf 100644 --- a/core/app/media/Aeva-Embed.php +++ b/core/app/media/Aeva-Embed.php @@ -1098,7 +1098,7 @@ function aeva_embed_video($message, $id_media = 0, $id_preview = 0) function aeva_check_embed_link($link) { - global $sites, $boardurl, $settings; + global $sites, $settings; if (empty($settings['embed_enabled'])) return false; @@ -1109,7 +1109,7 @@ function aeva_check_embed_link($link) return $link2; // Parse the boardurl to grab the domain we're on. - $x = @parse_url($boardurl); + $x = @parse_url(ROOT); $x['scheme'] = !empty($x['scheme']) ? $x['scheme'] : 'http'; $x['host'] = !empty($x['host']) ? $x['host'] : null; diff --git a/core/html/Admin.template.php b/core/html/Admin.template.php index 56f802e4..a5912a0e 100644 --- a/core/html/Admin.template.php +++ b/core/html/Admin.template.php @@ -1669,7 +1669,7 @@ function doAutoSubmit() // Pretty URLs function template_pretty_urls() { - global $context, $txt, $settings, $boardurl; + global $context, $txt, $settings; if (!empty($context['pretty']['chrome']['menu'])) { @@ -1721,8 +1721,8 @@ function template_pretty_urls() $prefix = empty($settings['pretty_prefix_action']) ? '' : $settings['pretty_prefix_action']; echo ' '; } @@ -1731,8 +1731,8 @@ function template_pretty_urls() $prefix = empty($settings['pretty_prefix_profile']) ? '' : $settings['pretty_prefix_profile']; echo ' '; } diff --git a/core/html/Media.template.php b/core/html/Media.template.php index e2b3989f..7541ae3a 100644 --- a/core/html/Media.template.php +++ b/core/html/Media.template.php @@ -360,7 +360,7 @@ function template_aeva_item_main_after() function template_aeva_item_details() { - global $galurl, $context, $amSettings, $txt, $boardurl; + global $galurl, $context, $amSettings, $txt; $item =& $context['item_data']; $in_sidebar = wetem::parent('aeva_item_details') == 'sidebar'; @@ -451,14 +451,14 @@ function template_aeva_item_details()
', $txt['media_embed_html'], '
') : + westr::htmlspecialchars('') : westr::htmlspecialchars(trim(preg_replace('/[\t\r\n]+/', ' ', $item['embed_object']))), '" onclick="this.focus(); this.select();" readonly>
'; if ($item['type'] != 'embed') echo '
', $txt['media_direct_link'], '
- +
'; } } @@ -1686,7 +1686,7 @@ function template_aeva_multiUpload_xml() function template_aeva_multiUpload() { - global $context, $txt, $boardurl; + global $context, $txt; echo '
@@ -1709,7 +1709,7 @@ function template_aeva_multiUpload()
- + 1. ', $txt['media_sort_order'], ' –