X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=c1293681cef302da6f78545014bd5c7152985f6e;hp=95d143c2a33e1dcde41e965dd93ac032694a99c5;hb=9b8d0c1de007c1149af813c07773c3536c71ddd5;hpb=9c233ac3be8ef85040fc580689bf2436c81522ec diff --git a/inc/functions.php b/inc/functions.php index 95d143c2a3..c1293681ce 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -18,6 +18,7 @@ * svn:keywords Date Revision" (autoprobset!) at least!!!!!! * * -------------------------------------------------------------------- * * Copyright (c) 2003 - 2009 by Roland Haeder * + * Copyright (c) 2009, 2010 by Mailer Developer Team * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -150,6 +151,9 @@ function compileFinalOutput () { // Init counter $cnt = '0'; + // Add page header and footer + addPageHeaderFooter(); + // Compile all out while (((strpos($GLOBALS['output'], '{--') > 0) || (strpos($GLOBALS['output'], '{!') > 0) || (strpos($GLOBALS['output'], '{?') > 0)) && ($cnt < 3)) { // Init common variables @@ -229,7 +233,6 @@ function addFatalMessage ($F, $L, $message, $extra = '') { $GLOBALS['fatal_messages'][] = $message; // Log fatal messages away - debug_report_bug($message); logDebugMessage($F, $L, 'Fatal error message: ' . $message); } @@ -296,7 +299,7 @@ function loadTemplate ($template, $return = false, $content = array()) { // 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)) { + if ((strpos($GLOBALS['tpl_content'], '$') !== false) || (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 @@ -427,35 +430,38 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') { // Is content an array? if (is_array($content)) { // Add expiration to array - if (getConfig('auto_purge') == '0') { + if ((isConfigEntrySet('auto_purge')) && (getConfig('auto_purge') == '0')) { // Will never expire! $content['expiration'] = getMessage('MAIL_WILL_NEVER_EXPIRE'); - } else { + } elseif (isConfigEntrySet('auto_purge')) { // Create nice date string $content['expiration'] = createFancyTime(getConfig('auto_purge')); + } else { + // Missing entry + $content['expiration'] = getMessage('MAIL_NO_CONFIG_AUTO_PURGE'); } } // END - if // Load user's data - //* DEBUG: */ outputHtml(__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))) { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NICKNAME!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NICKNAME!
"); // Load by nickname fetchUserData($userid, 'nickname'); } else { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):NO-NICK!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "NO-NICK!
"); /// Load by userid fetchUserData($userid); } // Merge data if valid - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - PRE
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - PRE
"); if (isUserDataValid()) { $content = merge_array($content, getUserDataArray()); } // END - if - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):content()=".count($content)." - AFTER
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "content()=".count($content)." - AFTER
"); } // END - if // Translate M to male or F to female if present @@ -464,7 +470,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') { // Overwrite email from data if present if (isset($content['email'])) $email = $content['email']; - // Store email for some functions in global data array + // Store email for some functions in global $DATA array // @TODO Do only use $content, not $DATA or raw variables $DATA['email'] = $email; @@ -527,7 +533,7 @@ function loadEmailTemplate ($template, $content = array(), $userid = '0') { // Send mail out to an email address function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = '') { - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail},SUBJECT={$subject}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail},SUBJECT={$subject}
"); // Compile subject line (for POINTS constant etc.) eval("\$subject = decodeEntities(\"".compileRawCode(escapeQuotes($subject))."\");"); @@ -553,7 +559,7 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' // Is the webmaster! $toEmail = getConfig('WEBMASTER'); } - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):TO={$toEmail}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "TO={$toEmail}
"); // Check for PHPMailer or debug-mode if (!checkPhpMailerUsage()) { @@ -586,10 +592,10 @@ function sendEmail ($toEmail, $subject, $message, $isHtml = 'N', $mailHeader = ' if (isDebugModeEnabled()) { // In debug mode we want to display the mail instead of sending it away so we can debug this part outputHtml('
-Headers : ' . str_replace('<', '<', str_replace('>', '>', secureString(trim($mailHeader)))) . '
-To      : ' . $toEmail . '
-Subject : ' . $subject . '
-Message : ' . $message . '
+Headers : ' . htmlentities(utf8_decode(trim($mailHeader))) . '
+To      : ' . htmlentities(utf8_decode($toEmail)) . '
+Subject : ' . htmlentities(utf8_decode($subject)) . '
+Message : ' . htmlentities(utf8_decode($message)) . '
 
'); } elseif (($isHtml == 'Y') && (isExtensionActive('html_mail'))) { // Send mail as HTML away @@ -750,7 +756,7 @@ function translateYesNo ($yn) { // Translates the "pool type" into human-readable function translatePoolType ($type) { // Default?type is unknown - $translated = sprintf(getMessage('POOL_TYPE_UNKNOWN'), $type); + $translated = getMaskedMessage('POOL_TYPE_UNKNOWN', $type); // Generate constant $constName = sprintf("POOL_TYPE_%s", $type); @@ -815,10 +821,10 @@ function translateGender ($gender) { case 'F': $ret = getMessage('GENDER_F'); break; case 'C': $ret = getMessage('GENDER_C'); break; default: - // Log unknown gender - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender)); + // Please report bugs on unknown genders + debug_report_bug(sprintf("Unknown gender %s detected.", $gender)); break; - } + } // END - switch // Return translated gender return $ret; @@ -840,8 +846,8 @@ function translateUserStatus ($status) { break; default: - logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); - $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status); + // Please report all unknown status + debug_report_bug(sprintf("Unknown status %s detected.", $status)); break; } // END - switch @@ -917,7 +923,7 @@ function makeTime ($hours, $minutes, $seconds, $stamp) { } // Redirects to an URL and if neccessarry extends it with own base URL -function redirectToUrl ($URL) { +function redirectToUrl ($URL, $allowSpider = true) { // Compile out codes eval('$URL = "' . compileRawCode(encodeUrl($URL)) . '";'); @@ -936,10 +942,13 @@ function redirectToUrl ($URL) { //* DEBUG: */ die($URL); // Simple probe for bots/spiders from search engines - if (isSpider()) { + if ((isSpider()) && ($allowSpider === true)) { // Secure the URL against bad things such als HTML insertions and so on... $URL = secureString($URL); + // Set content-type here to fix a missing array element + setContentType('text/html'); + // Output new location link as anchor outputHtml('' . $URL . ''); } elseif (!headers_sent()) { @@ -1051,10 +1060,10 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true $test = substr($found, 0, strlen($match)); // Does this entry exist? - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):found={$found},match={$match},set={$set}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "found={$found},match={$match},set={$set}
"); if ($test == $match) { // Match found! - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):fuzzyFound!
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "fuzzyFound!
"); $fuzzyFound = true; break; } // END - if @@ -1066,14 +1075,14 @@ function compileRawCode ($code, $simple = false, $constants = true, $full = true // 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: */ outputHtml(__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; } elseif (!isset($matchesFound[$match])) { // Not yet replaced! - //* DEBUG: */ outputHtml(__FUNCTION__."(".__LINE__."):match={$match}
"); + //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, "match={$match}
"); $code = str_replace($match, '".' . $match . '."', $code); $matchesFound[$match] = 1; } @@ -1255,7 +1264,7 @@ function addSelectionBox ($type, $default, $prefix = '', $id = '0', $class = 're // function generateRandomCode ($length, $code, $userid, $DATA = '') { // Build server string - $server = $_SERVER['PHP_SELF'] . getConfig('ENCRYPT_SEPERATOR') . detectUserAgent() . getConfig('ENCRYPT_SEPERATOR') . getenv('SERVER_SOFTWARE') . getConfig('ENCRYPT_SEPERATOR') . detectRemoteAddr().":'.':".filemtime(getConfig('PATH').'inc/databases.php'); + $server = $_SERVER['PHP_SELF'] . getConfig('ENCRYPT_SEPERATOR') . detectUserAgent() . getConfig('ENCRYPT_SEPERATOR') . getenv('SERVER_SOFTWARE') . getConfig('ENCRYPT_SEPERATOR') . detectRemoteAddr(); // Build key string $keys = getConfig('SITE_KEY') . getConfig('ENCRYPT_SEPERATOR') . getConfig('DATE_KEY'); @@ -1306,7 +1315,7 @@ function generateRandomCode ($length, $code, $userid, $DATA = '') { } // Does only allow numbers -function bigintval ($num, $castValue = true) { +function bigintval ($num, $castValue = true, $abortOnMismatch = true) { // Filter all numbers out $ret = preg_replace('/[^0123456789]/', '', $num); @@ -1314,7 +1323,7 @@ function bigintval ($num, $castValue = true) { if ($castValue === true) $ret = (double)$ret; // Has the whole value changed? - if ('' . $ret . '' != '' . $num . '') { + if (('' . $ret . '' != '' . $num . '') && ($abortOnMismatch === true)) { // Log the values debug_report_bug('Problem with number found. ret=' . $ret . ', num='. $num); } // END - if @@ -1382,6 +1391,16 @@ function generateImageOrCode ($img_code, $headerSent = true) { } // Create selection box or array of splitted timestamp function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = 'center', $return_array=false) { + // Do not continue if ONE_DAY is absend + if (!isConfigEntrySet('ONE_DAY')) { + // And return the timestamp itself or empty array + if ($return_array === true) { + return array(); + } else { + return $timestamp; + } + } // END - if + // Calculate 2-seconds timestamp $stamp = round($timestamp); //* DEBUG: */ print("*" . $stamp.'/' . $timestamp."*
"); @@ -1476,7 +1495,7 @@ function createTimeSelections ($timestamp, $prefix = '', $display = '', $align = if (ereg('Y', $display) || (empty($display))) { // Generate year selection - $OUT .= " \n"; for ($idx = '0'; $idx <= 10; $idx++) { $OUT .= "