X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=7838ec88620947b87d2cc7c6bb17e64386358bf7;hp=a1577f58a7e5b6caedd1817a0c10ae43e4f6cf49;hb=f57261751b221bd64a7dfe96d7a90404e6974d23;hpb=4707e8e1d5511597b3d425bca0fd5addbb6fe2a8
diff --git a/inc/functions.php b/inc/functions.php
index a1577f58a7..7838ec8862 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -171,7 +171,7 @@ function compileFinalOutput () {
// Main compilation loop
function doFinalCompilation ($code, $insertComments = true) {
- // Insert comments?
+ // Insert comments? (Only valid with HTML templates, of course)
enableTemplateHtml($insertComments);
// Init counter
@@ -184,9 +184,9 @@ function doFinalCompilation ($code, $insertComments = true) {
$newContent = '';
// Compile it
- //* DEBUG: */ print '
'.htmlentities($code).'
';
+ //* DEBUG: */ debugOutput(''.htmlentities($code).'
');
$eval = '$newContent = "' . str_replace('{DQUOTE}', '"', compileCode(escapeQuotes($code))) . '";';
- //* DEBUG: */ die(''.htmlentities($eval).'
');
+ //* DEBUG: */ if ($insertComments) die(''.linenumberCode($eval).'
');
eval($eval);
//* DEBUG: */ die(''.htmlentities($newContent).'
');
@@ -331,14 +331,18 @@ function loadTemplate ($template, $return = false, $content = array()) {
$GLOBALS['template_eval'][$template] = $eval;
} elseif ((isAdmin()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
- $ret = '
{--TEMPLATE_404--}
-(' . $template . ')
-
-{--TEMPLATE_CONTENT--}
-' . print_r($content, true) . '
-{--TEMPLATE_DATA--}
-' . print_r($DATA, true) . '
-
';
+ $ret = '
+ {--TEMPLATE_404--}
+
+
+ (' . $template . ')
+
+
+ {--TEMPLATE_CONTENT--}
+
' . print_r($content, true) . '
+ {--TEMPLATE_DATA--}
+
' . print_r($DATA, true) . '
+
';
} else {
// No file!
$GLOBALS['template_eval'][$template] = '404';
@@ -450,7 +454,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') {
} // 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 (($userid > 0) && (is_array($content))) {
// If nickname extension is installed, fetch nickname as well
if ((isExtensionActive('nickname')) && (isNicknameUsed($userid))) {
@@ -471,9 +475,6 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') {
//* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - AFTER
");
} // END - if
- // Translate M to male or F to female if present
- if (isset($content['gender'])) $content['gender'] = translateGender($content['gender']);
-
// Overwrite email from data if present
if (isset($content['email'])) $email = $content['email'];
@@ -507,12 +508,15 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') {
eval($GLOBALS['tpl_content']);
} elseif (!empty($template)) {
// Template file not found!
- $newContent = '{--TEMPLATE_404--}: ' . $template . '
-{--TEMPLATE_CONTENT--}
-' . print_r($content, true) . '
-{--TEMPLATE_DATA--}
-' . print_r($DATA, true) . '
-
';
+ $newContent = '
+ {--TEMPLATE_404--}: ' . $template . '
+
+
+ {--TEMPLATE_CONTENT--}
+
' . print_r($content, true) . '
+ {--TEMPLATE_DATA--}
+
' . print_r($DATA, true) . '
+
';
// Debug mode not active? Then remove the HTML tags
if (!isDebugModeEnabled()) $newContent = secureString($newContent);
@@ -874,24 +878,24 @@ function translateUserStatus ($status) {
// "Translates" 'visible' and 'locked' to a CSS class
function translateMenuVisibleLocked ($content, $prefix = '') {
// Translate 'visible' and keep an eye on the prefix
- switch ($content[$prefix . 'visible']) {
+ switch ($content['visible']) {
// Should be visible
- case 'Y': $content[$prefix . 'visible_css'] = $prefix . 'menu_visible' ; break;
- case 'N': $content[$prefix . 'visible_css'] = $prefix . 'menu_invisible'; break;
+ case 'Y': $content['visible_css'] = $prefix . 'menu_visible' ; break;
+ case 'N': $content['visible_css'] = $prefix . 'menu_invisible'; break;
default:
// Please report this
- debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported visible value detected. content='.print_r($content, true).'
');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported visible value detected. content=' . print_r($content, true) . '
');
break;
} // END - switch
// Translate 'locked' and keep an eye on the prefix
- switch ($content[$prefix . 'locked']) {
+ switch ($content['locked']) {
// Should be locked
- case 'Y': $content[$prefix . 'locked_css'] = $prefix . 'menu_locked' ; break;
- case 'N': $content[$prefix . 'locked_css'] = $prefix . 'menu_unlocked'; break;
+ case 'Y': $content['locked_css'] = $prefix . 'menu_locked' ; break;
+ case 'N': $content['locked_css'] = $prefix . 'menu_unlocked'; break;
default:
// Please report this
- debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported locked value detected. content='.print_r($content, true).'
');
+ debug_report_bug(__FUNCTION__, __LINE__, 'Unsupported locked value detected. content=' . print_r($content, true) . '
');
break;
} // END - switch
@@ -899,6 +903,25 @@ function translateMenuVisibleLocked ($content, $prefix = '') {
return $content;
}
+// "Getter" for menu CSS classes, mainly used in templates
+function getMenuCssClasses ($data) {
+ // $data needs to be converted into an array
+ $content = explode('|', $data);
+
+ // Non-existent index 2 will happen in menu blocks
+ if (!isset($content[2])) $content[2] = '';
+
+ // Re-construct the array: 0=visible,1=locked,2=prefix
+ $content['visible'] = $content[0];
+ $content['locked'] = $content[1];
+
+ // Call our "translator" function
+ $content = translateMenuVisibleLocked($content, $content[2]);
+
+ // Return CSS classes
+ return ($content['visible_css'] . ' ' . $content['locked_css']);
+}
+
// Generates an URL for the dereferer
function generateDerefererUrl ($URL) {
// Don't de-refer our own links!
@@ -987,6 +1010,9 @@ function redirectToUrl ($URL, $allowSpider = true) {
// Simple probe for bots/spiders from search engines
if ((isSpider()) && ($allowSpider === true)) {
+ // Set HTTP-Status
+ setHttpStatus('200 OK');
+
// Set content-type here to fix a missing array element
setContentType('text/html');
@@ -1106,7 +1132,7 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true
if ($fuzzyFound === true) continue;
// Take all string elements
- if ((is_string($matches[4][$key])) && (!isset($matchesFound[$match])) && (!isset($matchesFound[$key."_" . $matches[4][$key]]))) {
+ 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}
");
$newMatch = str_replace('[', "['", str_replace(']', "']", $match));
@@ -1187,7 +1213,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're
$OUT .= '