X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ftemplate-functions.php;h=6e2e4730660d0f0e803575ab0fc29e97f4435cb1;hp=7d5e670a2c2eb9b2c4bb0ed47aa5c6da240476c8;hb=ed3a88c0334600c7d7246480008c79716aa3f80b;hpb=f4d7dc336fde4cebc47701026a94d193f77854a1 diff --git a/inc/template-functions.php b/inc/template-functions.php index 7d5e670a2c..6e2e473066 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -218,7 +218,7 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true) $count = 0; // Compile all out - while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 5)) { + while (((strpos($code, '{--') !== false) || (strpos($code, '{DQUOTE}') !== false) || (strpos($code, '{?') !== false) || (strpos($code, '{%') !== false)) && ($count < 7)) { // Init common variables $content = array(); $newContent = ''; @@ -240,10 +240,22 @@ function doFinalCompilation ($code, $insertComments = true, $enableCodes = true) // Use it again $code = $newContent; + // Compile the final code if insertComments is true + if ($insertComments == true) { + // ... because SQL queries shall keep OPEN_CONFIG and such in + $code = compileRawCode($code); + } // END - if + // Count round $count++; } // END - while + // Add debugging data in HTML code, if mode is enabled + if ((isDebugModeEnabled()) && ($insertComments === true)) { + // Add loop count + $code .= ''; + } // END - if + // Return the compiled code return $code; } @@ -262,8 +274,13 @@ function outputRawCode ($htmlCode) { // Load a template file and return it's content (only it's name; do not use ' or ") function loadTemplate ($template, $return = false, $content = array(), $compileCode = true) { - // @TODO Remove this sanity-check if all is fine - if (!is_bool($return)) debug_report_bug(__FUNCTION__, __LINE__, 'return is not bool (' . gettype($return) . ')'); + if (!is_bool($return)) { + // @TODO Remove this sanity-check if all is fine + debug_report_bug(__FUNCTION__, __LINE__, 'return[] is not bool (' . gettype($return) . ')'); + } elseif (!is_string($template)) { + // $template has to be string + debug_report_bug(__FUNCTION__, __LINE__, 'template[] is not string (' . gettype($template) . ')'); + } // Set current template $GLOBALS['current_template'] = $template; @@ -317,10 +334,13 @@ function loadTemplate ($template, $return = false, $content = array(), $compileC // Prepare eval() command, other output doesn't like entities, maybe $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; } - } else { + } elseif (isHtmlOutputMode()) { // Add surrounding HTML comments to help finding bugs faster $ret = '' . $GLOBALS['tpl_content'][$template] . ''; $GLOBALS['template_eval'][$template] = '$ret = "' . getColorSwitchCode($template) . compileRawCode(escapeQuotes($ret), false, true, true, $compileCode) . '";'; + } else { + // JavaScript again + $GLOBALS['template_eval'][$template] = '$ret = decodeEntities("' . compileRawCode(escapeJavaScriptQuotes($GLOBALS['tpl_content'][$template]), false, true, true, $compileCode) . '");'; } // END - if } elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) { // Only admins shall see this warning or when installation mode is active @@ -417,7 +437,8 @@ function detectExtraTemplatePath ($template) { } // Loads an email template and compiles it -function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadUserData = true) { +function loadEmailTemplate ($template, $content = array(), $userid = NULL, $loadUserData = true) { + // @TODO $DATA is deprecated and should be avoided and replaced with $content global $DATA; // Make sure all template names are lowercase! @@ -431,7 +452,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU $content['expiration'] = '{--MAIL_WILL_NEVER_EXPIRE--}'; } elseif (isConfigEntrySet('auto_purge')) { // Create nice date string - $content['expiration'] = '{%pipe,getAutoPurge,createFancyTime%}'; + $content['expiration'] = '{%config,createFancyTime=auto_purge%}'; } else { // Missing entry $content['expiration'] = '{--MAIL_NO_CONFIG_AUTO_PURGE--}'; @@ -439,21 +460,24 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU } // END - if // Load user's data - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "UID={$userid},template={$template},content[]=".gettype($content)); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'UID=' . $userid . ',template=' . $template . ',content[]=' . gettype($content)); if ((isValidUserId($userid)) && (is_array($content))) { // If nickname extension is installed, fetch nickname as well if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NICKNAME!
"); // Load by nickname + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - NICKNAME!'); fetchUserData($userid, 'nickname'); + } elseif (isNicknameUsed($userid)) { + // Non-number characters entered but no ext-nickname found + debug_report_bug(__FUNCTION__, __LINE__, 'userid=' . $userid . ': is no id number and ext-nickname is gone.'); } else { - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NO-NICK!
"); // Load by userid + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ' - USERID!'); fetchUserData($userid); } // Merge data if valid - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - PRE
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content()=' . count($content) . ' - PRE!'); if ((isUserDataValid()) && ($loadUserData === true)) { // It is valid $content = merge_array($content, getUserDataArray()); @@ -462,7 +486,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0', $loadU unset($content['password']); } // END - if - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - AFTER
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'content()=' . count($content) . ' - AFTER!'); } // END - if // Base directory @@ -606,8 +630,8 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $code = str_replace($secChars['to'], $secChars['from'], $code); // Find $content[bla][blub] entries - // @TODO Do only use $content and deprecate $GLOBALS and $DATA in templates - preg_match_all('/\$(content|GLOBALS|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); + // @TODO Do only use $content and deprecate $DATA in templates + preg_match_all('/\$(content|DATA)((\[([a-zA-Z0-9-_]+)\])*)/', $code, $matches); // Are some matches found? if ((count($matches) > 0) && (count($matches[0]) > 0)) { @@ -623,31 +647,36 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $test = substr($found, 0, strlen($match)); // Does this entry exist? - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "found={$found},match={$match},set={$set}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'found=' . $found . ',match=' . $match . ',set=' . $set); if ($test == $match) { // Match found - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "fuzzyFound!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'fuzzyFound!'); $fuzzyFound = true; break; } // END - if } // END - foreach // Skip this entry? - if ($fuzzyFound === true) continue; + if ($fuzzyFound === true) { + continue; + } // END - if // Take all string elements if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key.'_' . $matches[4][$key]]))) { // Replace it in the code - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "key={$key},match={$match}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'key=' . $key . ',match=' . $match); $newMatch = str_replace('[', "['", str_replace(']', "']", $match)); $code = str_replace($match, '".' . $newMatch . '."', $code); $matchesFound[$key . '_' . $matches[4][$key]] = 1; - $matchesFound[$match] = 1; + $matchesFound[$match] = true; } elseif (!isset($matchesFound[$match])) { // Not yet replaced! - //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "match={$match}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match); $code = str_replace($match, '".' . $match . '."', $code); $matchesFound[$match] = 1; + } else { + // Everthing else should be a least logged + logDebugMessage(__FUNCTION__, __LINE__, 'match=' . $match . ',key=' . $key); } } // END - foreach } // END - if @@ -694,7 +723,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 'fo $year = getYear(); // Use configured min age or fixed? - if (isExtensionInstalledAndNewer('order', '0.2.1')) { + if (isExtensionInstalledAndNewer('other', '0.2.1')) { // Configured $startYear = $year - getConfig('min_age'); } else { @@ -721,7 +750,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 'fo // Get current year and subtract the configured minimum age $OUT .= ''; // Calculate earliest year depending on extension version - if (isExtensionInstalledAndNewer('order', '0.2.1')) { + if (isExtensionInstalledAndNewer('other', '0.2.1')) { // Use configured minimum age $year = getYear() - getConfig('min_age'); } else { @@ -1072,6 +1101,12 @@ function generateMemberAdminActionLinks ($userid) { $OUT .= '--}|'; } // END - foreach + // Add special link, in case of the account is unconfirmed + if ($status == 'UNCONFIRMED') { + // Add it + $OUT .= '{--ADMIN_USER_ACTION_LINK_CONFIRM_ACCOUNT--}|'; + } // END - if + // Finish navigation link $OUT = substr($OUT, 0, -1) . ']'; @@ -1096,9 +1131,6 @@ function generateEmailLink ($email, $table = 'admins') { $EMAIL = generateSponsorEmailLink($email); } - // Shall I close the link when there is no admin? - if ((!isAdmin()) && ($EMAIL == $email)) $EMAIL = '#'; // Closed! - // Return email link return $EMAIL; } @@ -1260,7 +1292,7 @@ function generateExtensionOutdatedMessage ($ext_name, $ext_ver) { } // END - if // Default message - $message = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_OUTDATED', $ext_name); + $message = '{%message,EXTENSION_PROBLEM_EXTENSION_OUTDATED=' . $ext_name . '%}'; // Is an admin logged in? if (isAdmin()) { @@ -1281,12 +1313,12 @@ function generateExtensionInactiveMessage ($ext_name) { } // END - if // Default message - $message = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_INACTIVE', $ext_name); + $message = '{%message,EXTENSION_PROBLEM_EXTENSION_INACTIVE=' . $ext_name . '%}'; // Is an admin logged in? if (isAdmin()) { // Then output admin message - $message = getMaskedMessage('ADMIN_EXTENSION_PROBLEM_EXTENSION_INACTIVE', $ext_name); + $message = '{%message,ADMIN_EXTENSION_PROBLEM_EXTENSION_INACTIVE=' . $ext_name . '%}'; } // END - if // Return prepared message @@ -1302,12 +1334,12 @@ function generateExtensionNotInstalledMessage ($ext_name) { } // END - if // Default message - $message = getMaskedMessage('EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', $ext_name); + $message = '{%message,EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED=' . $ext_name . '%}'; // Is an admin logged in? if (isAdmin()) { // Then output admin message - $message = getMaskedMessage('ADMIN_EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED', $ext_name); + $message = '{%message,ADMIN_EXTENSION_PROBLEM_EXTENSION_NOT_INSTALLED=' . $ext_name . '%}'; } // END - if // Return prepared message @@ -1411,7 +1443,10 @@ function determinePageTitle () { $pageTitle = '{--NO_CONFIG_FOUND_TITLE--}'; // Do not add the fatal message in installation mode - if ((!isInstalling()) && (!isConfigurationLoaded())) addFatalMessage(__FUNCTION__, __LINE__, '{--NO_CONFIG_FOUND--}'); + if ((!isInstalling()) && (!isConfigurationLoaded())) { + // Please report this + debug_report_bug(__FUNCTION__, __LINE__, 'No configuration data found!'); + } // END - if } // Return title @@ -1580,9 +1615,9 @@ function sendModeMails ($mod, $modes) { } // Send email to user if required - if ((!empty($sub_mem)) && (!empty($message)) && (!empty($content['email']))) { + if ((!empty($sub_mem)) && (!empty($message)) && (!empty($content['userid']))) { // Send member mail - sendEmail($content['email'], $sub_mem, $message); + sendEmail($content['userid'], $sub_mem, $message); } // END - if // Send only if no other error has occured @@ -1602,7 +1637,7 @@ function sendModeMails ($mod, $modes) { } // Generates a 'selection box' from given array -function generateSelectionBoxFromArray (array $options, $name, $optionValue, $optionContent = '', $extraName = '') { +function generateSelectionBoxFromArray ($options, $name, $optionValue, $optionContent = '', $extraName = '') { // Start the output $OUT = '