X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=8d4cc44e906a65030c6543570847e47885006dbe;hb=9f6c30cc0e06098171d773d671292081ecee3d29;hp=5a3d2155ca18b4e7c9392c2a0e53a8ce4a1e2c5d;hpb=4939d0ea8f0846283675f45c1d47f15b587789aa;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index 5a3d2155ca..8d4cc44e90 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -246,34 +246,6 @@ function loadTemplate ($template, $return=false, $content=array()) {
// Is content an array
if (is_array($content)) $content['date_time'] = $date_time;
- // @DEPRECATED Try to rewrite the if() condition
- if ($template == 'member_support_form') {
- // Support request of a member
- $result = SQL_QUERY_ESC("SELECT `userid`, `gender`, `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
- array(getUserId()), __FUNCTION__, __LINE__);
-
- // Is content an array?
- if (is_array($content)) {
- // Merge data
- $content = merge_array($content, SQL_FETCHARRAY($result));
-
- // Translate gender
- $content['gender'] = translateGender($content['gender']);
- } else {
- // @DEPRECATED
- // @TODO Find all templates which are using these direct variables and rewrite them.
- // @TODO After this step is done, this else-block is history
- list($gender, $surname, $family, $email) = SQL_FETCHROW($result);
-
- // Translate gender
- $gender = translateGender($gender);
- logDebugMessage(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array [%s], template=%s.", gettype($content), $template));
- }
-
- // Free result
- SQL_FREERESULT($result);
- } // END - if
-
// Base directory
$basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
$mode = '';
@@ -353,7 +325,7 @@ function loadTemplate ($template, $return=false, $content=array()) {
$ret = '';
if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (strpos($GLOBALS['tpl_content'], '{--') !== false) || (strpos($GLOBALS['tpl_content'], '{!') !== false) || (strpos($GLOBALS['tpl_content'], '{?') !== false)) {
// Normal HTML output?
- if ($GLOBALS['output_mode'] == 0) {
+ if (getOutputMode() == 0) {
// Add surrounding HTML comments to help finding bugs faster
$ret = "\n" . $GLOBALS['tpl_content'] . "\n";
@@ -458,28 +430,25 @@ function loadEmailTemplate ($template, $content = array(), $UID = 0) {
} // END - if
// Load user's data
- //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content)."
");
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):UID={$UID},template={$template},content[]=".gettype($content).'
');
if (($UID > 0) && (is_array($content))) {
// If nickname extension is installed, fetch nickname as well
- if (isExtensionActive('nickname')) {
+ if (isNicknameUsed($UID)) {
//* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NICKNAME!
");
- // Load nickname
- $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email`, `nickname` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ // Load by nickname
+ fetchUserData($UID, 'nickname');
} else {
//* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NO-NICK!
");
- /// Load normal data
- $result = SQL_QUERY_ESC("SELECT `surname`, `family`, `gender`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
- array(bigintval($UID)), __FUNCTION__, __LINE__);
+ /// Load by userid
+ fetchUserData($UID);
}
- // Fetch and merge data
+ // Merge data if valid
//* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
");
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ if (isUserDataValid()) {
+ $content = merge_array($content, getUserDataArray());
+ } // END - if
//* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
");
-
- // Free result
- SQL_FREERESULT($result);
} // END - if
// Translate M to male or F to female if present
@@ -529,7 +498,7 @@ function loadEmailTemplate ($template, $content = array(), $UID = 0) {
$GLOBALS['tpl_content'] = readFromFile($FQFN);
// Run code
- $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileCode($GLOBALS['tpl_content'])."\");";
+ $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileCode(smartAddSlashes($GLOBALS['tpl_content']))."\");";
eval($GLOBALS['tpl_content']);
} elseif (!empty($template)) {
// Template file not found!
@@ -582,22 +551,14 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $isHtml);
return;
} else {
- // Load email address
- $result_email = SQL_QUERY_ESC("SELECT `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
- array(bigintval($toEmail)), __FUNCTION__, __LINE__);
- //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)."
");
-
// Does the user exist?
- if (SQL_NUMROWS($result_email)) {
- // Load email address
- list($toEmail) = SQL_FETCHROW($result_email);
+ if (fetchUserData($toEmail)) {
+ // Get the email
+ $toEmail = getUserData('email');
} else {
// Set webmaster
$toEmail = getConfig('WEBMASTER');
}
-
- // Free result
- SQL_FREERESULT($result_email);
}
} elseif ($toEmail == '0') {
// Is the webmaster!
@@ -670,6 +631,11 @@ function sendRawEmail ($toEmail, $subject, $message, $from) {
// get new instance
$mail = new PHPMailer();
+
+ // Set charset to UTF-8
+ $mail->CharSet('UTF-8');
+
+ // Path for PHPMailer
$mail->PluginDir = sprintf("%sinc/phpmailer/", getConfig('PATH'));
$mail->IsSMTP();
@@ -957,8 +923,8 @@ function makeTime ($hours, $minutes, $seconds, $stamp) {
// Redirects to an URL and if neccessarry extends it with own base URL
function redirectToUrl ($URL) {
- // Compile out URI codes
- $URL = compileUriCode($URL);
+ // Compile out codes
+ eval('$URL = "' . compileCode($URL) . '";');
// Check if http(s):// is there
if ((substr($URL, 0, 7) != 'http://') && (substr($URL, 0, 8) != 'https://')) {
@@ -968,7 +934,7 @@ function redirectToUrl ($URL) {
// Three different debug ways...
//* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
- //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, $URL);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'URL=' . $URL);
//* DEBUG: */ die($URL);
// Default 'rel' value is external, nofollow is evil from Google and hurts the Internet
@@ -1307,7 +1273,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') {
// Calculate number for generating the code
$a = $code + getConfig('_ADD') - 1;
- if (isConfigEntrySet('master_hash')) {
+ if (isConfigEntrySet('master_salt')) {
// Generate hash with master salt from modula of number with the prime number and other data
$saltedHash = generateHash(($a % getConfig('_PRIME')) . getConfig('ENCRYPT_SEPERATOR') . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a, getConfig('master_salt'));
@@ -1315,7 +1281,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') {
$rcode = hexdec(substr($saltedHash, strlen(getConfig('master_salt')), 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi();
} else {
// Generate hash with "hash of site key" from modula of number with the prime number and other data
- $saltedHash = generateHash(($a % getConfig('_PRIME')) . getConfig('ENCRYPT_SEPERATOR') . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a, substr(sha1(getConfig('SITE_KEY')), 0, 8));
+ $saltedHash = generateHash(($a % getConfig('_PRIME')) . getConfig('ENCRYPT_SEPERATOR') . $server . getConfig('ENCRYPT_SEPERATOR') . $keys . getConfig('ENCRYPT_SEPERATOR') . $data . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY') . getConfig('ENCRYPT_SEPERATOR') . $a, substr(sha1(getConfig('SITE_KEY')), 0, getConfig('salt_length')));
// Create number from hash
$rcode = hexdec(substr($saltedHash, 8, 9)) / abs(getConfig('rand_no') - $a + sqrt(getConfig('_ADD'))) / pi();
@@ -1724,7 +1690,7 @@ function extractHostnameFromUrl (&$script) {
if (ereg('/', $host)) $host = substr($host, 0, strpos($host, '/'));
// Generate relative URL
- //* DEBUG: */ print("SCRIPT=" . $script."
");
+ //* DEBUG: */ print("SCRIPT=" . $script.'
');
if (substr(strtolower($script), 0, 7) == 'http://') {
// But only if http:// is in front!
$script = substr($script, (strlen($url) + 7));
@@ -1733,7 +1699,7 @@ function extractHostnameFromUrl (&$script) {
$script = substr($script, (strlen($url) + 8));
}
- //* DEBUG: */ print("SCRIPT=" . $script."
");
+ //* DEBUG: */ print("SCRIPT=" . $script.'
');
if (substr($script, 0, 1) == '/') $script = substr($script, 1);
// Return host name
@@ -1834,7 +1800,7 @@ function sendRawRequest ($host, $request) {
} // END - if
// Open connection
- //* DEBUG: */ die("SCRIPT=" . $script."
");
+ //* DEBUG: */ die("SCRIPT=" . $script.'
');
if ($useProxy === true) {
// Connect to host through proxy connection
$fp = @fsockopen(compileCode(getConfig('proxy_host')), bigintval(getConfig('proxy_port')), $errno, $errdesc, 30);
@@ -1952,11 +1918,11 @@ function isEmailValid ($email) {
function isUrlValid ($URL, $compile=true) {
// Trim URL a little
$URL = trim(urldecode($URL));
- //* DEBUG: */ outputHtml($URL."
");
+ //* DEBUG: */ outputHtml($URL.'
');
// Compile some chars out...
if ($compile === true) $URL = compileUriCode($URL, false, false, false);
- //* DEBUG: */ outputHtml($URL."
");
+ //* DEBUG: */ outputHtml($URL.'
');
// Check for the extension filter
if (isExtensionActive('filter')) {
@@ -2073,8 +2039,15 @@ function generateHash ($plainText, $salt = '') {
//* DEBUG: */ outputHtml($salt." (".strlen($salt).")
");
} else {
// Use given salt
+ //* DEBUG: */ print 'salt=' . $salt . '
';
$salt = substr($salt, 0, getConfig('salt_length'));
- //* DEBUG: */ outputHtml("GIVEN={$salt}
");
+ //* DEBUG: */ print 'salt=' . $salt . '(' . strlen($salt) . '/' . getConfig('salt_length') . ')
';
+
+ // Sanity check on salt
+ if (strlen($salt) != getConfig('salt_length')) {
+ // Not the same!
+ debug_report_bug(__FUNCTION__.': salt length mismatch! ('.strlen($salt).'/'.getConfig('salt_length').')');
+ } // END - if
}
// Return hash
@@ -2167,7 +2140,7 @@ function generatePassString ($passHash) {
$ret = $passHash;
// Is a secret key and master salt already initialized?
- if ((isExtensionInstalled('sql_patches')) && (isConfigEntrySet('_PRIME')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) {
+ if ((isExtensionInstalled('sql_patches')) && (isExtensionInstalledAndNewer('other', '0.2.5')) && (isConfigEntrySet('_PRIME')) && (isConfigEntrySet('secret_key')) && (isConfigEntrySet('master_salt'))) {
// Only calculate when the secret key is generated
$newHash = ''; $start = 9;
for ($idx = 0; $idx < 10; $idx++) {
@@ -2179,16 +2152,17 @@ function generatePassString ($passHash) {
} elseif ($part2 > $part1) {
$mod = dechex(sqrt(($part2 - $part1) * getConfig('_PRIME') / pi()));
}
- $mod = substr(round($mod), 0, 4);
- $mod = str_repeat(0, 4-strlen($mod)) . $mod;
- //* DEBUG: */ outputHtml("*" . $start.'=' . $mod."*
");
+ $mod = substr($mod, 0, 4);
+ //* DEBUG: */ outputHtml('part1='.$part1.'/part2='.$part2.'/mod=' . $mod . '('.strlen($mod).')
');
+ $mod = str_repeat(0, (4 - strlen($mod))) . $mod;
+ //* DEBUG: */ outputHtml('*' . $start . '=' . $mod . '*
');
$start += 4;
$newHash .= $mod;
} // END - for
- //* DEBUG: */ print($passHash."
" . $newHash." (".strlen($newHash).')');
+ //* DEBUG: */ print($passHash.'
' . $newHash." (".strlen($newHash).')
');
$ret = generateHash($newHash, getConfig('master_salt'));
- //* DEBUG: */ print($ret."
");
+ //* DEBUG: */ print('ret='.$ret.'
');
} else {
// Hash it simple
//* DEBUG: */ outputHtml("--" . $passHash."--
");
@@ -2392,11 +2366,11 @@ function getThemeId ($name) {
}
// Generates an error code from given account status
-function generateErrorCodeFromUserStatus ($status) {
- // @TODO The status should never be empty
- if (empty($status)) {
- // Something really bad happend here
- debug_report_bug(__FUNCTION__ . ': status is empty.');
+function generateErrorCodeFromUserStatus ($status='') {
+ // If no status is provided, use the default, cached
+ if ((empty($status)) && (isMember())) {
+ // Get user status
+ $status = getUserData('status');
} // END - if
// Default error code if unknown account status
@@ -2421,12 +2395,12 @@ function generateErrorCodeFromUserStatus ($status) {
// Function to search for the last modifified file
function searchDirsRecursive ($dir, &$last_changed) {
// Get dir as array
- //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):dir=" . $dir."
");
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):dir=" . $dir.'
');
// Does it match what we are looking for? (We skip a lot files already!)
// RegexPattern to exclude ., .., .revision, .svn, debug.log or .cache in the filenames
$excludePattern = '@(\.revision|debug\.log|\.cache|config\.php)$@';
$ds = getArrayFromDirectory($dir, '', true, false, array(), '.php', $excludePattern);
- //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):ds[]=".count($ds)."
");
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):ds[]=".count($ds).'
');
// Walk through all entries
foreach ($ds as $d) {
@@ -2439,7 +2413,7 @@ function searchDirsRecursive ($dir, &$last_changed) {
// $FQFN is a directory so also crawl into this directory
$newDir = $d;
if (!empty($dir)) $newDir = $dir . '/'. $d;
- //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):DESCENT: " . $newDir."
");
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):DESCENT: " . $newDir.'
');
searchDirsRecursive($newDir, $last_changed);
} elseif (isFileReadable($FQFN)) {
// $FQFN is a filename and no directory
@@ -2854,7 +2828,7 @@ function isUrlValidSimple ($url) {
// @TODO Are these convertions still required?
$pat = str_replace('.', "\.", $pat);
$pat = str_replace('@', "\@", $pat);
- //* DEBUG: */ outputHtml($key."= " . $pat . "
");
+ //* DEBUG: */ outputHtml($key."= " . $pat . '
');
} // END - if
// Check if expression matches
@@ -2964,7 +2938,7 @@ function logDebugMessage ($funcFile, $line, $message, $force=true) {
// Log this message away, we better don't call app_die() here to prevent an endless loop
$fp = fopen(getConfig('CACHE_PATH') . 'debug.log', 'a') or die(__FUNCTION__.'['.__LINE__.']: Cannot write logfile debug.log!');
- fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule() . '|' . basename($funcFile) . '|' . $line . '|' . $message . "\n");
+ fwrite($fp, date('d.m.Y|H:i:s', time()) . '|' . getModule(false) . '|' . basename($funcFile) . '|' . $line . '|' . $message . "\n");
fclose($fp);
} // END - if
}
@@ -3005,6 +2979,7 @@ function handleExtraValues ($filterFunction, $value, $extraValue) {
// Converts timestamp selections into a timestamp
function convertSelectionsToTimestamp (&$postData, &$DATA, &$id, &$skip) {
// Init test variable
+ $skip = false;
$test2 = '';
// Get last three chars
@@ -3017,21 +2992,20 @@ function convertSelectionsToTimestamp (&$postData, &$DATA, &$id, &$skip) {
if ((isset($postData[$test.'_ye'])) && (isset($postData[$test.'_mo'])) && (isset($postData[$test.'_we'])) && (isset($postData[$test.'_da'])) && (isset($postData[$test.'_ho'])) && (isset($postData[$test.'_mi'])) && (isset($postData[$test.'_se'])) && ($test != $test2)) {
// Generate timestamp
$postData[$test] = createTimestampFromSelections($test, $postData);
- $DATA[] = sprintf("%s='%s'", $test, $postData[$test]);
+ $DATA[] = sprintf("`%s`='%s'", $test, $postData[$test]);
+ $GLOBALS['skip_config'][$test] = true;
// Remove data from array
foreach (array('ye', 'mo', 'we', 'da', 'ho', 'mi', 'se') as $rem) {
- unset($postData[$test.'_' . $rem]);
+ unset($postData[$test . '_' . $rem]);
} // END - foreach
// Skip adding
- unset($id); $skip = true; $test2 = $test;
+ unset($id);
+ $skip = true;
+ $test2 = $test;
} // END - if
- } else {
- // Process this entry
- $skip = false;
- $test2 = '';
- }
+ } // END - if
}
// Reverts the german decimal comma into Computer decimal dot
@@ -3180,8 +3154,8 @@ function addNewBonusMail ($data, $mode = '', $output=true) {
// Determines referal id and sets it
function determineReferalId () {
- // Skip this in non-html-mode
- if (getOutputMode() != 0) return false;
+ // Skip this in non-html-mode and outside ref.php
+ if ((getOutputMode() != 0) && (basename($_SERVER['PHP_SELF']) != 'ref.php')) return false;
// Check if refid is set
if ((isset($GLOBALS['refid'])) && ($GLOBALS['refid'] > 0)) {
@@ -3208,12 +3182,30 @@ function determineReferalId () {
// Set default refid as refid in URL
$GLOBALS['refid'] = getConfig('def_refid');
} else {
- // No default ID when sql_patches is not installed or none set
+ // No default id when sql_patches is not installed or none set
$GLOBALS['refid'] = 0;
}
// Set cookie when default refid > 0
if (!isSessionVariableSet('refid') || (!empty($GLOBALS['refid'])) || ((getSession('refid') == 0) && (isConfigEntrySet('def_refid')) && (getConfig('def_refid') > 0))) {
+ // Default is not found
+ $found = false;
+
+ // Do we have nickname or userid set?
+ if (isNicknameUsed($GLOBALS['refid'])) {
+ // Nickname in URL, so load the id
+ $found = fetchUserData($GLOBALS['refid'], 'nickname');
+ } elseif ($GLOBALS['refid'] > 0) {
+ // Direct userid entered
+ $found = fetchUserData($GLOBALS['refid']);
+ }
+
+ // Is the record valid?
+ if (($found === false) || (!isUserDataValid())) {
+ // No, then reset referal id
+ $GLOBALS['refid'] = getConfig('def_refid');
+ } // END - if
+
// Set cookie
setSession('refid', $GLOBALS['refid']);
} // END - if
@@ -3250,6 +3242,10 @@ function shutdown () {
// Setter for userid
function setUserId ($userid) {
+ // We should not set userid to zero
+ if ($userid == 0) debug_report_bug('Userid should not be set zero.');
+
+ // Set it secured
$GLOBALS['userid'] = bigintval($userid);
}
@@ -3402,7 +3398,7 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
// Exclude '.', '..' and entries in $excludeArray automatically
if (in_array($baseFile, $excludeArray, true)) {
// Exclude them
- //* DEBUG: */ outputHtml('excluded=' . $baseFile . "
");
+ //* DEBUG: */ outputHtml('excluded=' . $baseFile . '
');
continue;
} // END - if
@@ -3416,9 +3412,9 @@ function getArrayFromDirectory ($baseDir, $prefix, $fileIncludeDirs = false, $ad
// Check if the base filename matches an exclusion pattern and if the pattern is not empty
if ((!empty($excludePattern)) && (preg_match($excludePattern, $baseFile, $match))) {
// These Lines are only for debugging!!
- //* DEBUG: */ outputHtml('baseDir:' . $baseDir . "
");
- //* DEBUG: */ outputHtml('baseFile:' . $baseFile . "
");
- //* DEBUG: */ outputHtml('FQFN:' . $FQFN . "
");
+ //* DEBUG: */ outputHtml('baseDir:' . $baseDir . '
');
+ //* DEBUG: */ outputHtml('baseFile:' . $baseFile . '
');
+ //* DEBUG: */ outputHtml('FQFN:' . $FQFN . '
');
// Exclude this one
continue;
@@ -3590,6 +3586,62 @@ function convertReceivers ($old) {
return str_replace(';', ', ', $old);
}
+// Determines the right page title
+function determinePageTitle () {
+ // Config and database connection valid?
+ if ((isConfigLocalLoaded()) && (isConfigurationLoaded()) && (SQL_IS_LINK_UP()) && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) {
+ // Init title
+ $TITLE = '';
+
+ // Title decoration enabled?
+ if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_left') != '')) $TITLE .= trim(getConfig('title_left'))." ";
+
+ // Do we have some extra title?
+ if (isExtraTitleSet()) {
+ // Then prepent it
+ $TITLE .= getExtraTitle() . ' by ';
+ } // END - if
+
+ // Add main title
+ $TITLE .= getConfig('MAIN_TITLE');
+
+ // Add title of module? (middle decoration will also be added!)
+ if ((getConfig('enable_mod_title') == 'Y') || ((!isWhatSet()) && (!isActionSet())) || (getModule() == 'admin')) {
+ $TITLE .= ' ' . trim(getConfig('title_middle')) . ' ' . getModuleTitle(getModule());
+ } // END - if
+
+ // Add title from what file
+ $mode = '';
+ if (getModule() == 'login') $mode = 'member';
+ elseif (getModule() == 'index') $mode = 'guest';
+ if ((!empty($mode)) && (getConfig('enable_what_title') == 'Y')) $TITLE .= " ".trim(getConfig('title_middle'))." ".getModuleDescription($mode, getWhat());
+
+ // Add title decorations? (right)
+ if ((getConfig('enable_title_deco') == 'Y') && (getConfig('title_right') != '')) $TITLE .= " ".trim(getConfig('title_right'));
+
+ // Remember title in constant for the template
+ $pageTitle = $TITLE;
+ } elseif ((isInstalled()) && (isAdminRegistered())) {
+ // Installed, admin registered but no ext-sql_patches
+ $pageTitle = '[-- ' . getConfig('MAIN_TITLE').' - '.getModuleTitle(getModule()) . ' --]';
+ } elseif ((isInstalled()) && (!isAdminRegistered())) {
+ // Installed but no admin registered
+ $pageTitle = sprintf(getMessage('SETUP_OF_MXCHANGE'), getConfig('MAIN_TITLE'));
+ } elseif ((!isInstalled()) || (!isAdminRegistered())) {
+ // Installation mode
+ $pageTitle = getMessage('INSTALLATION_OF_MXCHANGE');
+ } else {
+ // Configuration not found!
+ $pageTitle = getMessage('NO_CONFIG_FOUND_TITLE');
+
+ // Do not add the fatal message in installation mode
+ if ((!isInstalling()) && (!isConfigurationLoaded())) addFatalMessage(__FILE__, __LINE__, getMessage('NO_CONFIG_FOUND'));
+ }
+
+ // Return title
+ return $pageTitle;
+}
+
//////////////////////////////////////////////////
// AUTOMATICALLY RE-GENERATED MISSING FUNCTIONS //
//////////////////////////////////////////////////