X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=71538ea79815e23daf5961754171266df50ce86d;hp=64e185bdec56a990499f7ae4018c482ea523da91;hb=1355d2c0b29510dbd407f9cde9f41a5ac02d01fa;hpb=116f17077ae6fa32c7373ccd6aaf94044bb6c276
diff --git a/inc/functions.php b/inc/functions.php
index 64e185bdec..71538ea798 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -51,37 +51,36 @@ function OUTPUT_HTML ($HTML, $newLine = true) {
// Yes, so we handle it as you have configured
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') {
- // Output into PHP's internal buffer
- outputRawCode($HTML);
-
+ case 'render':
// That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) echo "\n";
- } else {
- // Render mode for old or lame servers...
- $OUTPUT .= $HTML;
+ if (constant('_OB_CACHING') == 'on') {
+ // Output into PHP's internal buffer
+ outputRawCode($HTML);
- // That's why you don't need any \n at the end of your HTML code... :-)
- if ($newLine) $OUTPUT .= "\n";
- }
- break;
+ // That's why you don't need any \n at the end of your HTML code... :-)
+ if ($newLine) echo "\n";
+ } else {
+ // Render mode for old or lame servers...
+ $OUTPUT .= $HTML;
+
+ // That's why you don't need any \n at the end of your HTML code... :-)
+ if ($newLine) $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 = ''; }
+ case 'direct':
+ // If we are switching from render to direct output rendered code
+ if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; }
- // The same as above... ^
- outputRawCode($HTML);
- if ($newLine) echo "\n";
- break;
+ // The same as above... ^
+ outputRawCode($HTML);
+ if ($newLine) echo "\n";
+ break;
- default:
- // Huh, something goes wrong or maybe you have edited config.php ???
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", getConfig('OUTPUT_MODE')));
- app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
- break;
+ default:
+ // Huh, something goes wrong or maybe you have edited config.php ???
+ app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}");
+ break;
}
} elseif ((constant('_OB_CACHING') == 'on') && (isset($GLOBALS['footer_sent'])) && ($GLOBALS['footer_sent'] == 1)) {
// Headers already sent?
@@ -231,7 +230,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
// @DEPRECATED Try to rewrite the if() condition
- if ($template == "member_support_form") {
+ 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__);
@@ -266,27 +265,27 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
$mode = '';
// Check for admin/guest/member templates
- if (strpos($template, "admin_") > -1) {
+ if (strpos($template, 'admin_') > -1) {
// Admin template found
- $mode = "admin/";
- } elseif (strpos($template, "guest_") > -1) {
+ $mode = 'admin/';
+ } elseif (strpos($template, 'guest_') > -1) {
// Guest template found
- $mode = "guest/";
- } elseif (strpos($template, "member_") > -1) {
+ $mode = 'guest/';
+ } elseif (strpos($template, 'member_') > -1) {
// Member template found
- $mode = "member/";
- } elseif (strpos($template, "install_") > -1) {
+ $mode = 'member/';
+ } elseif (strpos($template, 'install_') > -1) {
// Installation template found
- $mode = "install/";
- } elseif (strpos($template, "ext_") > -1) {
+ $mode = 'install/';
+ } elseif (strpos($template, 'ext_') > -1) {
// Extension template found
- $mode = "ext/";
- } elseif (strpos($template, "la_") > -1) {
- // "Logical-area" template found
- $mode = "la/";
+ $mode = 'ext/';
+ } elseif (strpos($template, 'la_') > -1) {
+ // 'Logical-area' template found
+ $mode = 'la/';
} else {
// Test for extension
- $test = substr($template, 0, strpos($template, "_"));
+ $test = substr($template, 0, strpos($template, '_'));
if (EXT_IS_ACTIVE($test)) {
// Set extra path to extension's name
$mode = $test.'/';
@@ -296,9 +295,9 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
////////////////////////
// Generate file name //
////////////////////////
- $FQFN = $basePath.$mode.$template.".tpl";
+ $FQFN = $basePath . $mode . $template . '.tpl';
- if ((!empty($GLOBALS['what'])) && ((strpos($template, "_header") > 0) || (strpos($template, "_footer") > 0)) && (($mode == "guest/") || ($mode == "member/") || ($mode == "admin/"))) {
+ 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,
@@ -312,12 +311,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
// 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?
@@ -340,7 +339,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
}
// Add surrounding HTML comments to help finding bugs faster
- $ret = "\n".$ret."\n";
+ $ret = "\n" . $ret . "\n";
} elseif ((IS_ADMIN()) || ((isInstalling()) && (!isInstalled()))) {
// Only admins shall see this warning or when installation mode is active
$ret = "
{--TEMPLATE_404--}
@@ -369,12 +368,12 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) {
}
} elseif (isDebugModeEnabled()) {
// Warning, empty output!
- return "E:".$template."
\n";
+ return "E:" . $template."
\n";
}
}
// Send mail out to an email address
-function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
+function sendEmail ($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '') {
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
\n";
// Compile subject line (for POINTS constant etc.)
@@ -404,7 +403,7 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
// Free result
SQL_FREERESULT($result_email);
}
- } elseif ("$toEmail" == '0') {
+ } elseif ($toEmail == '0') {
// Is the webmaster!
$toEmail = constant('WEBMASTER');
}
@@ -415,18 +414,18 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
// Not in PHPMailer-Mode
if (empty($mailHeader)) {
// Load email header template
- $mailHeader = LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader = LOAD_EMAIL_TEMPLATE('header');
} else {
// Append header
- $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
}
} elseif (isDebugModeEnabled()) {
if (empty($mailHeader)) {
// Load email header template
- $mailHeader = LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader = LOAD_EMAIL_TEMPLATE('header');
} else {
// Append header
- $mailHeader .= LOAD_EMAIL_TEMPLATE("header");
+ $mailHeader .= LOAD_EMAIL_TEMPLATE('header');
}
}
@@ -442,11 +441,11 @@ function sendEmail($toEmail, $subject, $message, $HTML = 'N', $mailHeader = '')
if (empty($HTML)) $HTML = 'N';
if (isDebugModeEnabled()) {
// In debug mode we want to display the mail instead of sending it away so we can debug this part
- print("
+ OUTPUT_HTML("
".htmlentities(trim($mailHeader))."
-To : ".$toEmail."
-Subject : ".$subject."
-Message : ".$message."
+To : " . $toEmail."
+Subject : " . $subject."
+Message : " . $message."
\n");
} elseif (($HTML == 'Y') && (EXT_IS_ACTIVE('html_mail'))) {
// Send mail as HTML away
@@ -468,7 +467,7 @@ function checkPhpMailerUsage() {
}
// Send out a raw email with PHPMailer class or legacy mail() command
-function sendRawEmail ($toEmail, $subject, $msg, $from) {
+function sendRawEmail ($toEmail, $subject, $message, $from) {
// Shall we use PHPMailer class or legacy mode?
if (checkPhpMailerUsage()) {
// Use PHPMailer class with SMTP enabled
@@ -492,13 +491,13 @@ function sendRawEmail ($toEmail, $subject, $msg, $from) {
}
$mail->FromName = constant('MAIN_TITLE');
$mail->Subject = $subject;
- if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($msg) != $msg)) {
- $mail->Body = $msg;
+ if ((EXT_IS_ACTIVE('html_mail')) && (strip_tags($message) != $message)) {
+ $mail->Body = $message;
$mail->AltBody = 'Your mail program required HTML support to read this mail!';
$mail->WordWrap = 70;
$mail->IsHTML(true);
} else {
- $mail->Body = decodeEntities($msg);
+ $mail->Body = decodeEntities($message);
}
$mail->AddAddress($toEmail, '');
$mail->AddReplyTo(constant('WEBMASTER'), constant('MAIN_TITLE'));
@@ -507,7 +506,7 @@ function sendRawEmail ($toEmail, $subject, $msg, $from) {
$mail->Send();
} else {
// Use legacy mail() command
- @mail($toEmail, $subject, decodeEntities($msg), $from);
+ mail($toEmail, $subject, decodeEntities($message), $from);
}
}
@@ -549,28 +548,28 @@ function generateDateTime ($time, $mode = '0') {
switch (getLanguage())
{
- case 'de': // German date / time format
- switch ($mode) {
- case '0': $ret = date("d.m.Y \u\m H:i \U\h\\r", $time); break;
- case '1': $ret = strtolower(date("d.m.Y - H:i", $time)); break;
- case '2': $ret = date("d.m.Y|H:i", $time); break;
- case '3': $ret = date("d.m.Y", $time); break;
- default:
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
- break;
- }
- break;
-
- default: // Default is the US date / time format!
- switch ($mode) {
- case '0': $ret = date("r", $time); break;
- case '1': $ret = date("Y-m-d - g:i A", $time); break;
- case '2': $ret = date("y-m-d|H:i", $time); break;
- case '3': $ret = date("y-m-d", $time); break;
- default:
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
- break;
- }
+ case 'de': // German date / time format
+ switch ($mode) {
+ case '0': $ret = date("d.m.Y \u\m H:i \U\h\\r", $time); break;
+ case '1': $ret = strtolower(date("d.m.Y - H:i", $time)); break;
+ case '2': $ret = date("d.m.Y|H:i", $time); break;
+ case '3': $ret = date("d.m.Y", $time); break;
+ default:
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+ break;
+ }
+ break;
+
+ default: // Default is the US date / time format!
+ switch ($mode) {
+ case '0': $ret = date("r", $time); break;
+ case '1': $ret = date("Y-m-d - g:i A", $time); break;
+ case '2': $ret = date("y-m-d|H:i", $time); break;
+ case '3': $ret = date("y-m-d", $time); break;
+ default:
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
+ break;
+ }
}
return $ret;
}
@@ -578,7 +577,7 @@ function generateDateTime ($time, $mode = '0') {
// Translates Y/N to yes/no
function translateYesNo ($yn) {
// Default
- $translated = "??? (".$yn.')';
+ $translated = "??? (" . $yn.')';
switch ($yn) {
case 'Y': $translated = getMessage('YES'); break;
case 'N': $translated = getMessage('NO'); break;
@@ -636,13 +635,13 @@ function translateComma ($dotted, $cut = true, $max = 0) {
// Translate it now
switch (getLanguage()) {
- case 'de':
- $dotted = number_format($dotted, $maxComma, ',', '.');
- break;
+ case 'de':
+ $dotted = number_format($dotted, $maxComma, ',', '.');
+ break;
- default:
- $dotted = number_format($dotted, $maxComma, '.', ',');
- break;
+ default:
+ $dotted = number_format($dotted, $maxComma, '.', ',');
+ break;
}
// Return translated value
@@ -673,21 +672,21 @@ function translateGender ($gender) {
function translateUserStatus ($status) {
switch ($status)
{
- case 'UNCONFIRMED':
- case 'CONFIRMED':
- case 'LOCKED':
- $ret = getMessage(sprintf("ACCOUNT_%s", $status));
- break;
-
- case '':
- case null:
- $ret = getMessage('ACCOUNT_DELETED');
- break;
-
- default:
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
- $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
- break;
+ case 'UNCONFIRMED':
+ case 'CONFIRMED':
+ case 'LOCKED':
+ $ret = getMessage(sprintf("ACCOUNT_%s", $status));
+ break;
+
+ case '':
+ case null:
+ $ret = getMessage('ACCOUNT_DELETED');
+ break;
+
+ default:
+ DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
+ $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
+ break;
}
// Return it
@@ -710,7 +709,7 @@ function DEREFERER ($URL) {
function FRAMETESTER ($URL) {
// Prepare frametester URL
$frametesterUrl = sprintf("{!URL!}/modules.php?module=frametester&url=%s",
- encodeString(compileUriCode($URL))
+ encodeString(compileUriCode($URL))
);
return $frametesterUrl;
}
@@ -731,51 +730,6 @@ function generateCaptchaCode ($code, $type, $DATA, $uid) {
return '';
}
-// "Getter" for language
-function getLanguage () {
- // Set default return value to default language from config
- $ret = getConfig('DEFAULT_LANG');
-
- // Init variable
- $lang = '';
-
- // Is the variable set
- if (REQUEST_ISSET_GET('mx_lang')) {
- // Accept only first 2 chars
- $lang = substr(REQUEST_GET('mx_lang'), 0, 2);
- } elseif (isset($GLOBALS['cache_array']['language'])) {
- // Use cached
- $ret = $GLOBALS['cache_array']['language'];
- } elseif (!empty($lang)) {
- // Check if main language file does exist
- if (isFileReadable(constant('PATH') . 'inc/language/'.$lang.'.php')) {
- // Okay found, so let's update cookies
- setLanguage($lang);
- } // END - if
- } elseif (isSessionVariableSet('mx_lang')) {
- // Return stored value from cookie
- $ret = getSession('mx_lang');
-
- // Fixes a warning before the session has the mx_lang constant
- if (empty($ret)) $ret = getConfig('DEFAULT_LANG');
- }
-
- // Cache entry
- $GLOBALS['cache_array']['language'] = $ret;
-
- // Return value
- return $ret;
-}
-
-// "Setter" for language
-function setLanguage ($lang) {
- // Accept only first 2 chars!
- $lang = substr(SQL_ESCAPE(strip_tags($lang)), 0, 2);
-
- // Set cookie
- setSession('mx_lang', $lang);
-}
-
// Loads an email template and compiles it
function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
global $DATA, $_CONFIG;
@@ -829,12 +783,12 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):NICKNAME!
\n";
// 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__);
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
} else {
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):NO-NICK!
\n";
/// 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__);
+ array(bigintval($UID)), __FUNCTION__, __LINE__);
}
// Fetch and merge data
@@ -861,29 +815,29 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
// Check for admin/guest/member templates
if (strpos($template, 'admin_') > -1) {
// Admin template found
- $FQFN = $basePath.'admin/'.$template.'.tpl';
+ $FQFN = $basePath.'admin/' . $template.'.tpl';
} elseif (strpos($template, 'guest_') > -1) {
// Guest template found
- $FQFN = $basePath.'guest/'.$template.'.tpl';
+ $FQFN = $basePath.'guest/' . $template.'.tpl';
} elseif (strpos($template, 'member_') > -1) {
// Member template found
- $FQFN = $basePath.'member/'.$template.'.tpl';
+ $FQFN = $basePath.'member/' . $template.'.tpl';
} else {
// Test for extension
$test = substr($template, 0, strpos($template, '_'));
if (EXT_IS_ACTIVE($test)) {
// Set extra path to extension's name
- $FQFN = $basePath.$test.'/'.$template.'.tpl';
+ $FQFN = $basePath . $test.'/' . $template.'.tpl';
} else {
// No special filename
- $FQFN = $basePath.$template.'.tpl';
+ $FQFN = $basePath . $template.'.tpl';
}
}
// 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?
@@ -898,7 +852,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
eval($tmpl_file);
} elseif (!empty($template)) {
// Template file not found!
- $newContent = "{--TEMPLATE_404--}: ".$template."
+ $newContent = "{--TEMPLATE_404--}: " . $template."
{--TEMPLATE_CONTENT--}
".print_r($content, true)."
{--TEMPLATE_DATA--}
@@ -915,7 +869,7 @@ function LOAD_EMAIL_TEMPLATE ($template, $content = array(), $UID = '0') {
// Is there some content?
if (empty($newContent)) {
// Compiling failed
- $newContent = "Compiler error for template {$template}!\nUncompiled content:\n".$tmpl_file;
+ $newContent = "Compiler error for template {$template}!\nUncompiled content:\n" . $tmpl_file;
// 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
@@ -951,7 +905,7 @@ function redirectToUrl ($URL) {
} // END - if
// Three different debug ways...
- /* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
+ //* DEBUG: */ debug_report_bug(sprintf("%s[%s:] URL=%s", __FUNCTION__, __LINE__, $URL));
//* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, $URL);
//* DEBUG: */ die($URL);
@@ -1073,17 +1027,17 @@ function COMPILE_CODE ($code, $simple = false, $constants = true, $full = true)
if ($fuzzyFound) 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: */ print __FUNCTION__."(".__LINE__."):key={$key},match={$match}
\n";
- $newMatch = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $match);
- $code = str_replace($match, "\".".$newMatch.".\"", $code);
- $matchesFound[$key."_".$matches[4][$key]] = 1;
+ $newMatch = str_replace("[" . $matches[4][$key]."]", "['" . $matches[4][$key]."']", $match);
+ $code = str_replace($match, "\"." . $newMatch.".\"", $code);
+ $matchesFound[$key."_" . $matches[4][$key]] = 1;
$matchesFound[$match] = 1;
} elseif (!isset($matchesFound[$match])) {
// Not yet replaced!
//* DEBUG: */ print __FUNCTION__."(".__LINE__."):match={$match}
\n";
- $code = str_replace($match, "\".".$match.".\"", $code);
+ $code = str_replace($match, "\"." . $match.".\"", $code);
$matchesFound[$match] = 1;
}
} // END - foreach
@@ -1150,109 +1104,109 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') {
if ($type == 'yn') {
// This is a yes/no selection only!
- if ($id > 0) $prefix .= "[".$id."]";
- $OUT .= "