X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=8d4cc44e906a65030c6543570847e47885006dbe;hb=9f6c30cc0e06098171d773d671292081ecee3d29;hp=ab9fec7b50fa976d8310be6febcdc5958661ef98;hpb=a6471bb025f8149ec310a1eb6371cdc7d0011b49;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index ab9fec7b50..8d4cc44e90 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -17,7 +17,7 @@
* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -35,68 +35,68 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301 USA *
************************************************************************/
+
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
- require($INC);
-}
+ die();
+} // END - if
// Output HTML code directly or 'render' it. You addionally switch the new-line character off
-function OUTPUT_HTML ($HTML, $newLine = true) {
- // Some global variables
- global $OUTPUT;
+function outputHtml ($htmlCode, $newLine = true) {
+ // Transfer username
+ $username = getMessage('USERNAME_UNKNOWN');
+ if (isset($GLOBALS['username'])) $username = getUsername();
// Do we have HTML-Code here?
- if (!empty($HTML)) {
+ if (!empty($htmlCode)) {
// Yes, so we handle it as you have configured
- switch (getConfig('OUTPUT_MODE'))
- {
+ switch (getConfig('OUTPUT_MODE')) {
case 'render':
// That's why you don't need any \n at the end of your HTML code... :-)
- if (constant('_OB_CACHING') == 'on') {
+ if (getPhpCaching() == 'on') {
// Output into PHP's internal buffer
- outputRawCode($HTML);
+ outputRawCode($htmlCode);
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) echo "\n";
+ if ($newLine === true) print("\n");
} else {
// Render mode for old or lame servers...
- $OUTPUT .= $HTML;
+ $GLOBALS['output'] .= $htmlCode;
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) $OUTPUT .= "\n";
+ if ($newLine === true) $GLOBALS['output'] .= "\n";
}
break;
case 'direct':
// If we are switching from render to direct output rendered code
- if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; }
+ if ((!empty($GLOBALS['output'])) && (getPhpCaching() != 'on')) { outputRawCode($GLOBALS['output']); $GLOBALS['output'] = ''; }
// The same as above... ^
- outputRawCode($HTML);
- if ($newLine) echo "\n";
+ outputRawCode($htmlCode);
+ if ($newLine) print("\n");
break;
default:
// Huh, something goes wrong or maybe you have edited config.php ???
- app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
+ app_die(__FUNCTION__, __LINE__, '{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}');
break;
- }
- } elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
+ } // END - switch
+ } elseif ((getPhpCaching() == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
// Headers already sent?
if (headers_sent()) {
// Log this error
- DEBUG_LOG(__FUNCTION__, __LINE__, "Headers already sent! We need debug backtrace here.");
+ logDebugMessage(__FUNCTION__, __LINE__, 'Headers already sent! We need debug backtrace here.');
// Trigger an user error
- debug_report_bug("Headers are already sent!");
+ debug_report_bug('Headers are already sent!');
} // END - if
// Output cached HTML code
- $OUTPUT = ob_get_contents();
+ $GLOBALS['output'] = ob_get_contents();
// Clear output buffer for later output if output is found
- if (!empty($OUTPUT)) {
+ if (!empty($GLOBALS['output'])) {
clearOutputBuffer();
} // END - if
@@ -112,53 +112,63 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
sendHeader('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
sendHeader('Pragma: no-cache'); // HTTP/1.0
sendHeader('Connection: Close');
+ sendHeader('Content-Type: ' . getContentType() . '; charset=UTF-8');
+ sendHeader('Content-language: ' . getLanguage());
// Extension 'rewrite' installed?
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
- $OUTPUT = rewriteLinksInCode($OUTPUT);
+ if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) {
+ $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
} // END - if
+ // Init counter
+ $cnt = 0;
+
// Compile and run finished rendered HTML code
- while (strpos($OUTPUT, '{!') > 0) {
+ while (((strpos($GLOBALS['output'], '{--') > 0) || (strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) {
// Prepare the content and eval() it...
+ $content = array();
$newContent = '';
- $eval = "\$newContent = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";";
+
+ // Compile it
+ $eval = "\$newContent = \"".compileCode(smartAddSlashes($GLOBALS['output']))."\";";
eval($eval);
// Was that eval okay?
if (empty($newContent)) {
// Something went wrong!
- app_die(__FUNCTION__, __LINE__, "Evaluation error:
".htmlentities($eval)."
");
+ debug_report_bug('Evaluation error:
' . linenumberCode($eval) . '
');
} // END - if
- $OUTPUT = $newContent;
+ $GLOBALS['output'] = $newContent;
+
+ // Count round
+ $cnt++;
} // END - while
// Output code here, DO NOT REMOVE! ;-)
- outputRawCode($OUTPUT);
- } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($OUTPUT))) {
+ outputRawCode($GLOBALS['output']);
+ } elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) {
// Rewrite links when rewrite extension is active
- if ((EXT_IS_ACTIVE('rewrite')) && ($GLOBALS['output_mode'] != '1') && ($GLOBALS['output_mode'] != '-1')) {
- $OUTPUT = rewriteLinksInCode($OUTPUT);
+ if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) {
+ $GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
} // END - if
// Compile and run finished rendered HTML code
- while (strpos($OUTPUT, '{!') > 0) {
- $eval = "\$OUTPUT = \"".COMPILE_CODE(smartAddSlashes($OUTPUT))."\";";
- eval($eval);
+ while (strpos($GLOBALS['output'], '{!') > 0) {
+ eval("\$GLOBALS['output'] = \"".compileCode(smartAddSlashes($GLOBALS['output']))."\";");
} // END - while
// Output code here, DO NOT REMOVE! ;-)
- outputRawCode($OUTPUT);
+ outputRawCode($GLOBALS['output']);
}
}
// Output the raw HTML code
-function outputRawCode ($HTML) {
+function outputRawCode ($htmlCode) {
// Output stripped HTML code to avoid broken JavaScript code, etc.
- echo stripslashes(stripslashes($HTML));
+ print(stripslashes(stripslashes($htmlCode)));
- // Flush the output if only constant('_OB_CACHING') is not 'on'
- if (constant('_OB_CACHING') != 'on') {
+ // Flush the output if only getPhpCaching() is not 'on'
+ if (getPhpCaching() != 'on') {
// Flush it
flush();
} // END - if
@@ -188,7 +198,8 @@ function addFatalMessage ($F, $L, $message, $extra='') {
$GLOBALS['fatal_messages'][] = $message;
// Log fatal messages away
- DEBUG_LOG($F, $L, " message={$message}");
+ debug_report_bug($message);
+ logDebugMessage($F, $L, " message={$message}");
}
// Getter for total fatal message count
@@ -207,258 +218,399 @@ function getTotalFatalErrors () {
}
// Load a template file and return it's content (only it's name; do not use ' or ")
-function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
+function loadTemplate ($template, $return=false, $content=array()) {
// @TODO Remove this sanity-check if all is fine
if (!is_bool($return)) debug_report_bug('return is not bool (' . gettype($return) . ')');
- // Add more variables which you want to use in your template files
- global $DATA, $username;
+ // @TODO Try to rewrite all $DATA to $content
+ global $DATA;
+
+ // Do we have cache?
+ if (!isset($GLOBALS['template_eval'][$template])) {
+ // Add more variables which you want to use in your template files
+ $username = getUsername();
+
+ // Make all template names lowercase
+ $template = strtolower($template);
+
+ // Count the template load
+ incrementConfigEntry('num_templates');
+
+ // Init some data
+ $ret = '';
+ if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
+
+ // Generate date/time string
+ $date_time = generateDateTime(time(), 1);
+
+ // Is content an array
+ if (is_array($content)) $content['date_time'] = $date_time;
+
+ // Base directory
+ $basePath = sprintf("%stemplates/%s/html/", getConfig('PATH'), getLanguage());
+ $mode = '';
+
+ // Check for admin/guest/member templates
+ if (substr($template, 0, 6) == 'admin_') {
+ // Admin template found
+ $mode = 'admin/';
+ } elseif (substr($template, 0, 6) == 'guest_') {
+ // Guest template found
+ $mode = 'guest/';
+ } elseif (substr($template, 0, 7) == 'member_') {
+ // Member template found
+ $mode = 'member/';
+ } elseif (substr($template, 0, 8) == 'install_') {
+ // Installation template found
+ $mode = 'install/';
+ } elseif (substr($template, 0, 4) == 'ext_') {
+ // Extension template found
+ $mode = 'ext/';
+ } elseif (substr($template, 0, 3) == 'la_') {
+ // 'Logical-area' template found
+ $mode = 'la/';
+ } elseif (substr($template, 0, 3) == 'js_') {
+ // JavaScript template found
+ $mode = 'js/';
+ } elseif (substr($template, 0, 5) == 'menu_') {
+ // Menu template found
+ $mode = 'menu/';
+ } else {
+ // Test for extension
+ $test = substr($template, 0, strpos($template, '_'));
+
+ // Probe for valid extension name
+ if (isExtensionNameValid($test)) {
+ // Set extra path to extension's name
+ $mode = $test . '/';
+ } // END - if
+ }
+
+ ////////////////////////
+ // Generate file name //
+ ////////////////////////
+ $FQFN = $basePath . $mode . $template . '.tpl';
+
+ if ((isWhatSet()) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
+ // Select what depended header/footer template file for admin/guest/member area
+ $file2 = sprintf("%s%s%s_%s.tpl",
+ $basePath,
+ $mode,
+ $template,
+ getWhat()
+ );
+
+ // Probe for it...
+ if (isFileReadable($file2)) $FQFN = $file2;
+
+ // Remove variable from memory
+ unset($file2);
+ } // END - if
+
+ // Does the special template exists?
+ if (!isFileReadable($FQFN)) {
+ // Reset to default template
+ $FQFN = $basePath . $template . '.tpl';
+ } // END - if
+
+ // Now does the final template exists?
+ if (isFileReadable($FQFN)) {
+ // The local file does exists so we load it. :)
+ $GLOBALS['tpl_content'] = readFromFile($FQFN);
+
+ // Replace ' to our own chars to preventing them being quoted
+ while (strpos($GLOBALS['tpl_content'], "'") !== false) { $GLOBALS['tpl_content'] = str_replace("'", '{QUOT}', $GLOBALS['tpl_content']); }
+
+ // Do we have to compile the code?
+ $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 (getOutputMode() == 0) {
+ // Add surrounding HTML comments to help finding bugs faster
+ $ret = "\n" . $GLOBALS['tpl_content'] . "\n";
+
+ // Prepare eval() command
+ $eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
+ } else {
+ // Prepare eval() command
+ $eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
+ }
+ } else {
+ // Add surrounding HTML comments to help finding bugs faster
+ $ret = "\n" . $GLOBALS['tpl_content'] . "\n";
+ $eval = '$ret = "' . smartAddSlashes($ret) . '";';
+ } // END - if
+
+ // Cache the eval() command here
+ $GLOBALS['template_eval'][$template] = $eval;
+
+ // Eval the code
+ eval($GLOBALS['template_eval'][$template]);
+ } else {
+ // No file!
+ $GLOBALS['template_eval'][$template] = '404';
+ }
+ } elseif (((isAdmin()) || ((isInstalling()) && (!isInstalled()))) && ($GLOBALS['template_eval'][$template] == '404')) {
+ // 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) . '
+
\";';
+ } else {
+ // Eval the code
+ eval($GLOBALS['template_eval'][$template]);
+ }
- // Get whole config array
+ // Do we have some content to output or return?
+ if (!empty($ret)) {
+ // Not empty so let's put it out! ;)
+ if ($return === true) {
+ // Return the HTML code
+ return $ret;
+ } else {
+ // Output direct
+ outputHtml($ret);
+ }
+ } elseif (isDebugModeEnabled()) {
+ // Warning, empty output!
+ return 'E:' . $template . ',content=
' . print_r($content, true) . '
';
+ }
+}
+
+// Loads an email template and compiles it
+function loadEmailTemplate ($template, $content = array(), $UID = 0) {
+ global $DATA;
+
+ // Our configuration is kept non-global here
$_CONFIG = getConfigArray();
- // Make all template names lowercase
+ // Make sure all template names are lowercase!
$template = strtolower($template);
- // Count the template load
- incrementConfigEntry('num_templates');
+ // Default 'nickname' if extension is not installed
+ $nick = '---';
// Prepare IP number and User Agent
$REMOTE_ADDR = detectRemoteAddr();
- if (!defined('REMOTE_ADDR')) define('REMOTE_ADDR', $REMOTE_ADDR);
$HTTP_USER_AGENT = detectUserAgent();
- // Init some data
- $ret = '';
- if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
+ // Default admin
+ $ADMIN = getConfig('MAIN_TITLE');
- // @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 the admin logged in?
+ if (isAdmin()) {
+ // Get admin id
+ $adminId = getCurrentAdminId();
+
+ // Load Admin data
+ $ADMIN = getAdminEmail($adminId);
+ } // END - if
- // Is content an array?
- if (is_array($content)) {
- // Merge data
- $content = merge_array($content, SQL_FETCHARRAY($result));
+ // Neutral email address is default
+ $email = getConfig('WEBMASTER');
- // Translate gender
- $content['gender'] = translateGender($content['gender']);
+ // Expiration in a nice output format
+ // NOTE: Use $content[expiration] in your templates instead of $EXPIRATION
+ if (getConfig('auto_purge') == 0) {
+ // Will never expire!
+ $EXPIRATION = getMessage('MAIL_WILL_NEVER_EXPIRE');
+ } else {
+ // Create nice date string
+ $EXPIRATION = createFancyTime(getConfig('auto_purge'));
+ }
+
+ // Is content an array?
+ if (is_array($content)) {
+ // Add expiration to array, $EXPIRATION is now deprecated!
+ $content['expiration'] = $EXPIRATION;
+ } // END - if
+
+ // Load user's data
+ //* 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 (isNicknameUsed($UID)) {
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NICKNAME! ");
+ // Load by nickname
+ fetchUserData($UID, 'nickname');
} else {
- // @DEPRECATED
- // @TODO Fine 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);
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content)));
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NO-NICK! ");
+ /// Load by userid
+ fetchUserData($UID);
}
- // Free result
- SQL_FREERESULT($result);
+ // Merge data if valid
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE ");
+ if (isUserDataValid()) {
+ $content = merge_array($content, getUserDataArray());
+ } // END - if
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER ");
} // END - if
- // Generate date/time string
- $date_time = generateDateTime(time(), '1');
+ // 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'];
+
+ // Store email for some functions in global data array
+ $DATA['email'] = $email;
// Base directory
- $basePath = sprintf("%stemplates/%s/html/", constant('PATH'), getLanguage());
- $mode = '';
+ $basePath = sprintf("%stemplates/%s/emails/", getConfig('PATH'), getLanguage());
// Check for admin/guest/member templates
- if (strpos($template, 'admin_') > -1) {
+ if (substr($template, 0, 6) == 'admin_') {
// Admin template found
- $mode = 'admin/';
- } elseif (strpos($template, 'guest_') > -1) {
+ $FQFN = $basePath.'admin/' . $template.'.tpl';
+ } elseif (substr($template, 0, 6) == 'guest_') {
// Guest template found
- $mode = 'guest/';
- } elseif (strpos($template, 'member_') > -1) {
+ $FQFN = $basePath.'guest/' . $template.'.tpl';
+ } elseif (substr($template, 0, 7) == 'member_') {
// Member template found
- $mode = 'member/';
- } elseif (strpos($template, 'install_') > -1) {
- // Installation template found
- $mode = 'install/';
- } elseif (strpos($template, 'ext_') > -1) {
- // Extension template found
- $mode = 'ext/';
- } elseif (strpos($template, 'la_') > -1) {
- // 'Logical-area' template found
- $mode = 'la/';
+ $FQFN = $basePath.'member/' . $template.'.tpl';
} else {
// Test for extension
$test = substr($template, 0, strpos($template, '_'));
- if (EXT_IS_ACTIVE($test)) {
+ if (isExtensionNameValid($test)) {
// Set extra path to extension's name
- $mode = $test.'/';
+ $FQFN = $basePath . $test.'/' . $template.'.tpl';
+ } else {
+ // No special filename
+ $FQFN = $basePath . $template.'.tpl';
}
}
- ////////////////////////
- // Generate file name //
- ////////////////////////
- $FQFN = $basePath . $mode . $template . '.tpl';
-
- if ((!empty($GLOBALS['what'])) && ((strpos($template, '_header') > 0) || (strpos($template, '_footer') > 0)) && (($mode == 'guest/') || ($mode == 'member/') || ($mode == 'admin/'))) {
- // Select what depended header/footer template file for admin/guest/member area
- $file2 = sprintf("%s%s%s_%s.tpl",
- $basePath,
- $mode,
- $template,
- SQL_ESCAPE($GLOBALS['what'])
- );
-
- // Probe for it...
- if (isFileReadable($file2)) $FQFN = $file2;
-
- // Remove variable from memory
- unset($file2);
- } // END - if
-
// Does the special template exists?
if (!isFileReadable($FQFN)) {
// Reset to default template
- $FQFN = $basePath . $template . '.tpl';
+ $FQFN = $basePath . $template.'.tpl';
} // END - if
// Now does the final template exists?
+ $newContent = '';
if (isFileReadable($FQFN)) {
// The local file does exists so we load it. :)
- $tmpl_file = readFromFile($FQFN);
+ $GLOBALS['tpl_content'] = readFromFile($FQFN);
- // Replace ' to our own chars to preventing them being quoted
- while (strpos($tmpl_file, "'") !== false) { $tmpl_file = str_replace("'", '{QUOT}', $tmpl_file); }
-
- // Do we have to compile the code?
- $ret = '';
- if ((strpos($tmpl_file, "\$") !== false) || (strpos($tmpl_file, '{--') !== false) || (strpos($tmpl_file, '--}') > 0)) {
- // Okay, compile it!
- $tmpl_file = "\$ret=\"".COMPILE_CODE(smartAddSlashes($tmpl_file))."\";";
- eval($tmpl_file);
- } else {
- // Simply return loaded code
- $ret = $tmpl_file;
- }
-
- // Add surrounding HTML comments to help finding bugs faster
- $ret = "\n" . $ret . "\n";
- } elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
- // Only admins shall see this warning or when installation mode is active
- $ret = " {--TEMPLATE_404--}
-(".basename($FQFN).")
-
+ // Run code
+ $GLOBALS['tpl_content'] = "\$newContent = decodeEntities(\"".compileCode(smartAddSlashes($GLOBALS['tpl_content']))."\");";
+ 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)."
";
+
+ // Debug mode not active? Then remove the HTML tags
+ if (!isDebugModeEnabled()) $newContent = secureString($newContent);
+ } else {
+ // No template name supplied!
+ $newContent = getMessage('NO_TEMPLATE_SUPPLIED');
}
+ // Is there some content?
+ if (empty($newContent)) {
+ // Compiling failed
+ $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $GLOBALS['tpl_content'];
+ // Add last error if the required function exists
+ if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx.";
+ } // END - if
+
// Remove content and data
unset($content);
unset($DATA);
- // Do we have some content to output or return?
- if (!empty($ret)) {
- // Not empty so let's put it out! ;)
- if ($return === true) {
- // Return the HTML code
- return $ret;
- } else {
- // Output direct
- OUTPUT_HTML($ret);
- }
- } elseif (isDebugModeEnabled()) {
- // Warning, empty output!
- return "E:" . $template." \n";
- }
+ // Compile the code and eval it
+ $eval = '$newContent = "' . compileCode(smartAddSlashes($newContent)) . '";';
+ eval($eval);
+
+ // Return content
+ return $newContent;
}
// Send mail out to an email address
-function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject} \n";
+function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '') {
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject} ");
// Compile subject line (for POINTS constant etc.)
- $eval = "\$subject = decodeEntities(\"".COMPILE_CODE(smartAddSlashes($subject))."\");";
- eval($eval);
+ eval("\$subject = decodeEntities(\"".compileCode(smartAddSlashes($subject))."\");");
// Set from header
- if ((!eregi("@", $toEmail)) && ($toEmail > 0)) {
+ if ((!eregi('@', $toEmail)) && ($toEmail > 0)) {
// Value detected, is the message extension installed?
- if (EXT_IS_ACTIVE("msg")) {
- ADD_MESSAGE_TO_BOX($toEmail, $subject, $message, $HTML);
+ // @TODO Extension 'msg' does not exist
+ if (isExtensionActive('msg')) {
+ 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: */ print __FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email)." \n";
-
// 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 = constant('WEBMASTER');
+ $toEmail = getConfig('WEBMASTER');
}
-
- // Free result
- SQL_FREERESULT($result_email);
}
} elseif ($toEmail == '0') {
// Is the webmaster!
- $toEmail = constant('WEBMASTER');
+ $toEmail = getConfig('WEBMASTER');
}
- //* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail} \n";
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail} ");
// Check for PHPMailer or debug-mode
if (!checkPhpMailerUsage()) {
// Not in PHPMailer-Mode
if (empty($mailHeader)) {
// Load email header template
- $mailHeader = LOAD_EMAIL_TEMPLATE('header');
+ $mailHeader = loadEmailTemplate('header');
} else {
// Append header
- $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
+ $mailHeader .= loadEmailTemplate('header');
}
} elseif (isDebugModeEnabled()) {
if (empty($mailHeader)) {
// Load email header template
- $mailHeader = LOAD_EMAIL_TEMPLATE('header');
+ $mailHeader = loadEmailTemplate('header');
} else {
// Append header
- $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
+ $mailHeader .= loadEmailTemplate('header');
}
}
// Compile "TO"
- $eval = "\$toEmail = \"".COMPILE_CODE(smartAddSlashes($toEmail))."\";";
- eval($eval);
+ eval("\$toEmail = \"".compileCode(smartAddSlashes($toEmail))."\";");
// Compile "MSG"
- $eval = "\$message = \"".COMPILE_CODE(smartAddSlashes($message))."\";";
- eval($eval);
+ eval("\$message = \"".compileCode(smartAddSlashes($message))."\";");
// Fix HTML parameter (default is no!)
- if (empty($HTML)) $HTML = 'N';
+ if (empty($isHtml)) $isHtml = 'N';
if (isDebugModeEnabled()) {
// In debug mode we want to display the mail instead of sending it away so we can debug this part
- OUTPUT_HTML("