X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=inc%2Ffunctions.php;h=a0418238dc546b7b2d410dd742b780fa0d8a3d75;hb=2a4cfc2b30c28bd1648717d86cd2c1353d7a2565;hp=fd2eab7f3dd216f1fccbe8b94ec91c072ea06f23;hpb=5b748baafe92fe299b194a1217ab69536f3a24ff;p=mailer.git
diff --git a/inc/functions.php b/inc/functions.php
index fd2eab7f3d..a0418238dc 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -44,7 +44,8 @@ if (!defined('__SECURITY')) {
// Output HTML code directly or 'render' it. You addionally switch the new-line character off
function outputHtml ($htmlCode, $newLine = true) {
// Transfer username
- $username = getUsername();
+ $username = getMessage('USERNAME_UNKNOWN');
+ if (isset($GLOBALS['username'])) $username = getUsername();
// Do we have HTML-Code here?
if (!empty($htmlCode)) {
@@ -115,12 +116,15 @@ function outputHtml ($htmlCode, $newLine = true) {
sendHeader('Content-language: ' . getLanguage());
// Extension 'rewrite' installed?
- if ((isExtensionActive('rewrite')) && (getOutputMode() != '1')) {
+ 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($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['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 = '';
@@ -132,16 +136,19 @@ function outputHtml ($htmlCode, $newLine = true) {
// Was that eval okay?
if (empty($newContent)) {
// Something went wrong!
- debug_report_bug('Evaluation error:
' . htmlentities($eval) . '
');
+ debug_report_bug('Evaluation error:' . linenumberCode($eval) . '
');
} // END - if
$GLOBALS['output'] = $newContent;
+
+ // Count round
+ $cnt++;
} // END - while
// Output code here, DO NOT REMOVE! ;-)
outputRawCode($GLOBALS['output']);
} elseif ((getConfig('OUTPUT_MODE') == 'render') && (!empty($GLOBALS['output']))) {
// Rewrite links when rewrite extension is active
- if ((isExtensionActive('rewrite')) && (getOutputMode() != '1')) {
+ if ((isExtensionActive('rewrite')) && (getOutputMode() != 1)) {
$GLOBALS['output'] = rewriteLinksInCode($GLOBALS['output']);
} // END - if
@@ -191,6 +198,7 @@ function addFatalMessage ($F, $L, $message, $extra='') {
$GLOBALS['fatal_messages'][] = $message;
// Log fatal messages away
+ debug_report_bug($message);
logDebugMessage($F, $L, " message={$message}");
}
@@ -233,7 +241,7 @@ function loadTemplate ($template, $return=false, $content=array()) {
if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0;
// Generate date/time string
- $date_time = generateDateTime(time(), '1');
+ $date_time = generateDateTime(time(), 1);
// Is content an array
if (is_array($content)) $content['date_time'] = $date_time;
@@ -345,7 +353,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";
@@ -356,8 +364,9 @@ function loadTemplate ($template, $return=false, $content=array()) {
$eval = '$ret = "' . compileCode(smartAddSlashes($GLOBALS['tpl_content'])) . '";';
}
} else {
- // Simply return loaded code
- $eval = '$ret = $GLOBALS[\'tpl_content\'];';
+ // 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
@@ -401,7 +410,7 @@ function loadTemplate ($template, $return=false, $content=array()) {
}
// Loads an email template and compiles it
-function loadEmailTemplate ($template, $content = array(), $UID = '0') {
+function loadEmailTemplate ($template, $content = array(), $UID = 0) {
global $DATA;
// Our configuration is kept non-global here
@@ -449,7 +458,7 @@ 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')) {
@@ -518,10 +527,9 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
if (isFileReadable($FQFN)) {
// The local file does exists so we load it. :)
$GLOBALS['tpl_content'] = readFromFile($FQFN);
- $GLOBALS['tpl_content'] = SQL_ESCAPE($GLOBALS['tpl_content']);
// 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!
@@ -551,8 +559,12 @@ function loadEmailTemplate ($template, $content = array(), $UID = '0') {
unset($content);
unset($DATA);
- // Return compiled content
- return compileCode($newContent);
+ // Compile the code and eval it
+ $eval = '$newContent = "' . compileCode(smartAddSlashes($newContent)) . '";';
+ eval($eval);
+
+ // Return content
+ return $newContent;
}
// Send mail out to an email address
@@ -573,7 +585,7 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
// 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)."
");
+ //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):numRows=".SQL_NUMROWS($result_email).'
');
// Does the user exist?
if (SQL_NUMROWS($result_email)) {
@@ -623,12 +635,12 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '
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
- outputHtml("
-".htmlentities(trim($mailHeader))."
-To : " . $toEmail."
-Subject : " . $subject."
-Message : " . $message."
-
\n");
+ outputHtml('
+Headers : ' . str_replace('<', '<', str_replace('>', '>', htmlentities(trim($mailHeader)))) . '
+To : ' . $toEmail . '
+Subject : ' . $subject . '
+Message : ' . $message . '
+
');
} elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) {
// Send mail as HTML away
sendHtmlEmail($toEmail, $subject, $message, $mailHeader);
@@ -658,6 +670,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();
@@ -718,7 +735,7 @@ function generatePassword ($length = 0) {
}
// Generates a human-readable timestamp from the Uni* stamp
-function generateDateTime ($time, $mode = '0') {
+function generateDateTime ($time, $mode = 0) {
// Filter out numbers
$time = bigintval($time);
@@ -731,10 +748,10 @@ 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;
+ 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:
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
break;
@@ -743,10 +760,10 @@ function generateDateTime ($time, $mode = '0') {
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;
+ 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:
logDebugMessage(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode));
break;
@@ -760,7 +777,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;
@@ -795,7 +812,7 @@ function translatePoolType ($type) {
// Translates the american decimal dot into a german comma
function translateComma ($dotted, $cut = true, $max = 0) {
// Default is 3 you can change this in admin area "Misc -> Misc Options"
- if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', '3');
+ if (!isConfigEntrySet('max_comma')) setConfigEntry('max_comma', 3);
// Use from config is default
$maxComma = getConfig('max_comma');
@@ -881,7 +898,7 @@ function generateDerefererUrl ($URL) {
// Don't de-refer our own links!
if (substr($URL, 0, strlen(getConfig('URL'))) != getConfig('URL')) {
// De-refer this link
- $URL = 'modules.php?module=loader&url=' . encodeString(compileUriCode($URL));
+ $URL = '{?URL?}/modules.php?module=loader&url=' . encodeString(compileUriCode($URL));
} // END - if
// Return link
@@ -922,24 +939,31 @@ function countSelection ($array) {
// Generate XHTML code for the CAPTCHA
function generateCaptchaCode ($code, $type, $DATA, $userid) {
- return '';
+ return '';
}
// Generates a timestamp (some wrapper for mktime())
-function makeTime ($H, $M, $S, $stamp) {
+function makeTime ($hours, $minutes, $seconds, $stamp) {
// Extract day, month and year from given timestamp
- $day = date('d', $stamp);
- $month = date('m', $stamp);
- $year = date('Y', $stamp);
+ $days = date('d', $stamp);
+ $months = date('m', $stamp);
+ $years = date('Y', $stamp);
// Create timestamp for wished time which depends on extracted date
- return mktime($H, $M, $S, $month, $day, $year);
+ return mktime(
+ $hours,
+ $minutes,
+ $seconds,
+ $months,
+ $days,
+ $years
+ );
}
// 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://')) {
@@ -1145,7 +1169,7 @@ function array_pk_sort (&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
}
//
-function addSelectionBox ($type, $default, $prefix = '', $id = '0') {
+function addSelectionBox ($type, $default, $prefix = '', $id = 0) {
$OUT = '';
if ($type == 'yn') {
@@ -1230,7 +1254,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0') {
case 'sec':
case 'min':
for ($idx = 0; $idx < 60; $idx+=5) {
- if (strlen($idx) == 1) $idx = '0' . $idx;
+ if (strlen($idx) == 1) $idx = 0 . $idx;
$OUT .= "