diff --git a/SSI.php b/SSI.php
index 14af4d4b..58eed2e2 100644
--- a/SSI.php
+++ b/SSI.php
@@ -32,7 +32,7 @@
define('ROOT_DIR', str_replace('\\', '/', dirname(__FILE__)));
define('APP_DIR', ROOT_DIR . '/core/app');
-// Get the forum's settings for database and file paths.
+// Get the forum's settings and loadSource() definition.
require_once(dirname(__FILE__) . '/Settings.php');
require_once(dirname(__FILE__) . '/index.php');
@@ -61,6 +61,7 @@
));
// Initiate the database connection and load $settings data.
+loadConstants();
loadDatabase();
loadSettings();
diff --git a/core/app/Class-System.php b/core/app/Class-System.php
index 73788772..f3ecbdc2 100644
--- a/core/app/Class-System.php
+++ b/core/app/Class-System.php
@@ -436,7 +436,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(ROOT, ':'), 3) : $_SERVER['HTTP_X_FORWARDED_SERVER']) : $_SERVER['HTTP_HOST']) : $_SERVER['REAL_HTTP_HOST'];
- $user['server'] = $context['protocol'] . $user['host'];
+ $user['server'] = PROTOCOL . $user['host'];
// The URL in your address bar. Also contains the query string.
// Do not print this without sanitizing first!
diff --git a/core/app/Credits.php b/core/app/Credits.php
index 5a248bcd..48496307 100644
--- a/core/app/Credits.php
+++ b/core/app/Credits.php
@@ -55,7 +55,7 @@ function Credits()
array(
'title' => $txt['credits_groups_dev'],
'members' => array(
- '
René-Gilles Deberdt
(Nao 尚)
',
+ '
René-Gilles Deberdt
(Nao 尚)
',
),
),
array(
diff --git a/core/app/Load.php b/core/app/Load.php
index c8b04268..289396a2 100644
--- a/core/app/Load.php
+++ b/core/app/Load.php
@@ -35,11 +35,6 @@ function loadSettings()
'app_error_count' => 0,
);
- // Is this a page requested through jQuery? If yes, set the AJAX constant so we can choose to show only the template's default block.
- $ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
- define('INFINITE', $ajax && !empty($_POST['infinite']));
- define('AJAX', $ajax && !INFINITE);
-
// Try to load settings from the cache first; they'll never get cached if the setting is off.
if (($settings = cache_get_data('settings', 'forever')) === null)
{
@@ -162,9 +157,6 @@ function loadSettings()
// If an action should not influence the who's online list, please add it to the $action_no_log global from your own action.
$action_no_log = array('ajax', 'dlattach', 'feed', 'like', 'notification', 'verification', 'viewquery', 'viewremote');
- // Set up path constants.
- loadPaths();
-
// Deal with loading plugins.
$context['enabled_plugins'] = array();
if (!empty($settings['enabled_plugins']))
diff --git a/core/app/ManageServer.php b/core/app/ManageServer.php
index 2c871b0f..0c992a28 100644
--- a/core/app/ManageServer.php
+++ b/core/app/ManageServer.php
@@ -331,7 +331,7 @@ function ModifyCookieSettings($return_config = false)
array('int', 'cookieTime'),
array('check', 'localCookies', 'subtext' => $txt['localCookies_subtext']),
array('check', 'globalCookies', 'subtext' => $txt['globalCookies_subtext']),
- array('check', 'secureCookies', 'disabled' => $context['protocol'] != 'https://', 'subtext' => $txt['secureCookies_subtext']),
+ array('check', 'secureCookies', 'disabled' => PROTOCOL != 'https://', 'subtext' => $txt['secureCookies_subtext']),
'',
// Sessions
array('check', 'databaseSession_enable'),
diff --git a/core/app/ManageSettings.php b/core/app/ManageSettings.php
index 24617ee2..c07b35c3 100644
--- a/core/app/ManageSettings.php
+++ b/core/app/ManageSettings.php
@@ -494,7 +494,7 @@ function ModifyPmSettings($return_config = false)
// Shell for all the Pretty URL interfaces
function ModifyPrettyURLs($return_config = false)
{
- global $context, $settings, $txt;
+ global $context, $settings, $txt, $remove_index;
// For the administrative search function not to get upset.
if ($return_config)
@@ -542,12 +542,12 @@ function ModifyPrettyURLs($return_config = false)
array(
'pretty_enable_filters' => $is_enabled,
'pretty_enable_cache' => isset($_POST['pretty_cache']) ? ($_POST['pretty_cache'] == 'on' ? 'on' : '') : '',
- 'pretty_remove_index' => isset($_POST['pretty_remove_index']) ? ($_POST['pretty_remove_index'] == 'on' ? 'on' : '') : '',
'pretty_filters' => serialize($settings['pretty_filters']),
'pretty_prefix_action' => $action,
'pretty_prefix_profile' => $profile,
)
);
+ updateSettingsFile(array('remove_index' => isset($_POST['pretty_remove_index']) ? ($_POST['pretty_remove_index'] == 'on' ? 1 : 0) : 1));
$settings['pretty_filters'] = unserialize($settings['pretty_filters']);
if (isset($_REQUEST['pretty_cache']))
@@ -565,7 +565,7 @@ function ModifyPrettyURLs($return_config = false)
$context['pretty']['settings'] = array(
'cache' => !empty($settings['pretty_enable_cache']) ? $settings['pretty_enable_cache'] : 0,
- 'index' => !empty($settings['pretty_remove_index']) ? $settings['pretty_remove_index'] : 0,
+ 'index' => !empty($remove_index) ? $remove_index : 0,
);
}
diff --git a/core/app/OriginalFiles.php b/core/app/OriginalFiles.php
index 677ff90b..9170f495 100644
--- a/core/app/OriginalFiles.php
+++ b/core/app/OriginalFiles.php
@@ -36,6 +36,7 @@ function create_settings_file()
$webmaster_email = \'noreply@myserver.com\';
$cookiename = \'WedgeCookie01\';
$cache_type = \'file\';
+$remove_index = 0;
$we_shot = ' . WEDGE . ';
# MySQL server
diff --git a/core/app/PrettyUrls-Filters.php b/core/app/PrettyUrls-Filters.php
index 82833b9e..9a3efe7b 100644
--- a/core/app/PrettyUrls-Filters.php
+++ b/core/app/PrettyUrls-Filters.php
@@ -112,7 +112,7 @@ function pretty_filter_actions(&$urls)
*/
function pretty_filter_topics(&$urls)
{
- global $settings, $context;
+ global $settings;
$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'] : ROOT,
+ 'pretty_board' => !empty($row['url']) ? PROTOCOL . $row['url'] : ROOT,
'pretty_url' => $row['pretty_url'],
);
else
@@ -210,7 +210,7 @@ function pretty_filter_topics(&$urls)
$add_new[] = array($row['id_topic'], $pretty_text);
// Add to the original array of topic URLs
$topicData[$row['id_topic']] = array(
- 'pretty_board' => $context['protocol'] . (!empty($row['board_url']) ? $row['board_url'] : $row['id_board']),
+ 'pretty_board' => PROTOCOL . (!empty($row['board_url']) ? $row['board_url'] : $row['id_board']),
'pretty_url' => $pretty_text,
);
}
@@ -240,8 +240,6 @@ function pretty_filter_topics(&$urls)
*/
function pretty_filter_boards(&$urls)
{
- global $context;
-
$pattern = '~(.*[?;&])\bboard=([.0-9$%d]+)(?:;(cat|tag)=([^;&]+))?(?:;month=(\d{6,8}))?(.*)~S';
$bo_list = array();
foreach ($urls as &$url)
@@ -287,7 +285,7 @@ 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']] : ROOT) . '/' . $url['cattag'] . $url['epoch'] . $url['start'] . $url['match1'] . $url['match6'];
+ $url['replacement'] = (!empty($url_list[$url['board_id']]) ? PROTOCOL . $url_list[$url['board_id']] : ROOT) . '/' . $url['cattag'] . $url['epoch'] . $url['start'] . $url['match1'] . $url['match6'];
}
$cat_pattern = '~(.*)\bcategory=([^;]+)~S';
diff --git a/core/app/QueryString.php b/core/app/QueryString.php
index 86f7f849..67e38d5b 100644
--- a/core/app/QueryString.php
+++ b/core/app/QueryString.php
@@ -12,23 +12,28 @@
die('Hacking attempt...');
/**
- * Initializes all of the path constants.
+ * Initializes all of the constants, especially all paths.
*/
-function loadPaths()
+function loadConstants()
{
- global $boardurl, $settings, $context;
+ global $boardurl, $remove_index, $aliases;
+
+ // Is this a page requested through jQuery? If yes, set the AJAX constant so we can choose to show only the template's default block.
+ $ajax = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
+ define('INFINITE', $ajax && !empty($_POST['infinite']));
+ define('AJAX', $ajax && !INFINITE);
// $scripturl is your board URL if you asked to remove index.php or the user visits for the first time
// (in which case they'll get the annoying PHPSESSID stuff in their URL and we need index.php in them.)
- $scripturl = $boardurl . (!empty($settings['pretty_remove_index']) && isset($_COOKIE[session_name()]) ? '/' : '/index.php');
+ $scripturl = $boardurl . (!empty($remove_index) && isset($_COOKIE[session_name()]) ? '/' : '/index.php');
$is_secure = (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)) || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https');
- $context['protocol'] = $is_secure ? 'https://' : 'http://';
+ define('PROTOCOL', $is_secure ? 'https://' : 'http://');
// Check to see if they're accessing it from the wrong place.
if (isset($_SERVER['HTTP_HOST']) || isset($_SERVER['SERVER_NAME']))
{
- $detected_url = $context['protocol'];
+ $detected_url = PROTOCOL;
$detected_url .= empty($_SERVER['HTTP_HOST']) ? $_SERVER['SERVER_NAME'] . (empty($_SERVER['SERVER_PORT']) || $_SERVER['SERVER_PORT'] == '80' ? '' : ':' . $_SERVER['SERVER_PORT']) : $_SERVER['HTTP_HOST'];
$temp = preg_replace('~/' . basename($scripturl) . '(/.+)?$~', '', strtr(dirname($_SERVER['PHP_SELF']), '\\', '/'));
if ($temp != '/')
@@ -38,16 +43,12 @@ function loadPaths()
// Is everything all right, URL-wise..? Then waste no more.
if (isset($detected_url) && $detected_url != $boardurl)
{
- // Try #1 - check if it's in a list of alias addresses
- if (!empty($settings['forum_alias_urls']))
- {
- $aliases = explode(',', $settings['forum_alias_urls']);
-
- // Rip off all the boring parts, spaces, etc.
- foreach ($aliases as $alias)
+ // Try #1 - check if it's in a list of alias addresses.
+ // Define these in Settings.php! e.g. $aliases = 'mainsite.com,altsite.org,anothersite.net'.
+ if (!empty($aliases))
+ foreach (explode(',', $aliases) as $alias)
if ($detected_url == trim($alias) || strtr($detected_url, array('http://' => '', 'https://' => '')) == trim($alias))
$do_fix = true;
- }
// Hmm... check #2 - is it just different by a www? Send them to the correct place!!
if (empty($do_fix) && strtr($detected_url, array('://' => '://www.')) == $boardurl && (empty($_GET) || count($_GET) == 1) && WEDGE != 'SSI')
@@ -63,7 +64,7 @@ function loadPaths()
if (strtr($detected_url, array('https://' => 'http://')) == $boardurl)
$do_fix = true;
- // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (assuming it's the IP or something...)
+ // Okay, #4 - perhaps it's an IP address? We're gonna want to use that one, then. (Assuming it's the IP or something...)
if (!empty($do_fix) || preg_match('~^http[s]?://(?:[\d.:]+|\[[\d:]+\](?::\d+)?)(?:$|/)~', $detected_url) == 1)
{
// Fix $boardurl and $scripturl
@@ -571,7 +572,7 @@ function cleanRequest()
if (empty($_SERVER['REQUEST_URI']))
$_SERVER['REQUEST_URL'] = SCRIPT . (!empty($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '');
else
- $_SERVER['REQUEST_URL'] = $context['protocol'] . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
+ $_SERVER['REQUEST_URL'] = PROTOCOL . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
// And make sure HTTP_USER_AGENT is set.
$_SERVER['HTTP_USER_AGENT'] = isset($_SERVER['HTTP_USER_AGENT']) ? htmlspecialchars(wesql::unescape_string($_SERVER['HTTP_USER_AGENT']), ENT_QUOTES) : '';
diff --git a/core/app/Subs-Auth.php b/core/app/Subs-Auth.php
index b9212267..64685144 100644
--- a/core/app/Subs-Auth.php
+++ b/core/app/Subs-Auth.php
@@ -87,7 +87,7 @@
// Actually set the login cookie...
function setLoginCookie($cookie_length, $id, $password = '')
{
- global $cookiename, $settings;
+ global $cookiename, $settings, $aliases;
// If changing state force them to re-address some permission caching.
$_SESSION['mc']['time'] = 0;
@@ -118,11 +118,9 @@ function setLoginCookie($cookie_length, $id, $password = '')
setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], '', !empty($settings['secureCookies']), true);
// Any alias URLs? This is mainly for use with frames, etc.
- if (!empty($settings['forum_alias_urls']))
+ if (!empty($aliases))
{
- $aliases = explode(',', $settings['forum_alias_urls']);
-
- foreach ($aliases as $alias)
+ foreach (explode(',', $aliases) as $alias)
{
// Fake the ROOT so we can set a different cookie.
$alias = strtr(trim($alias), array('http://' => '', 'https://' => ''));
diff --git a/index.php b/index.php
index 9a8e8885..391a16b1 100644
--- a/index.php
+++ b/index.php
@@ -49,6 +49,9 @@
'Security',
));
+// Load paths.
+loadConstants();
+
// Are we installing, or doing something that needs the forum to be down?
if (!empty($maintenance) && $maintenance > 1)
{
diff --git a/install/install.php b/install/install.php
index 7fc71452..7a7100de 100644
--- a/install/install.php
+++ b/install/install.php
@@ -24,16 +24,9 @@
$boardurl = 'http' . (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off' ? 's' : '') . '://' . $host;
$boardurl .= substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/'));
-// Define our constants. (cf. QueryString.php)
-define('ROOT', $boardurl);
-define('SCRIPT', ROOT_DIR . '/index.php');
-define('TEMPLATES', ROOT . '/core/html'); define('TEMPLATES_DIR', ROOT_DIR . '/core/html');
-define('SKINS', ROOT . '/core/skins'); define('SKINS_DIR', ROOT_DIR . '/core/skins');
-define('LANGUAGES', ROOT . '/core/languages'); define('LANGUAGES_DIR', ROOT_DIR . '/core/languages');
-define('ASSETS', ROOT . '/assets'); define('ASSETS_DIR', ROOT_DIR . '/assets');
-define('CACHE', ROOT . '/gz'); define('CACHE_DIR', ROOT_DIR . '/gz');
-define('SMILEYS', ROOT . '/assets/smileys');
-define('AVATARS', ROOT . '/assets/avatars');
+// Define our paths and constants.
+require_once(ROOT_DIR . '/core/QueryString.php');
+loadConstants();
define('INVALID_IP', '00000000000000000000000000000000');
define('IS_WINDOWS', strpos(__FILE__, ':\\') !== false);
@@ -282,11 +275,12 @@ function load_lang_file()
arsort($preferred, SORT_NUMERIC);
}
- // This is the list of known Wedge language packs/mappings as of March 2013.
+ // This is the list of known Wedge language packs/mappings as of March 2014.
$langs = array(
'en' => 'Install.english.php',
'en-gb' => 'Install.english-uk.php',
'fr' => 'Install.french.php',
+ 'de' => 'Install.german.php',
);
foreach ($preferred as $key => $value)