X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=2276a0f42b35d7aec9db2ec014aa7ab8926f6c53;hp=b9decbaac6d40711fb02e40b93b2ed486c0f5837;hb=5071030af40e69ca4284642f44758964e18f5be8;hpb=0437f06b273f885db05736449a952c6eb72086ca;ds=sidebyside diff --git a/inc/functions.php b/inc/functions.php index b9decbaac6..2276a0f42b 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -51,36 +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; - case 'direct': - // If we are switching from render to direct output rendered code - if ((!empty($OUTPUT)) && (constant('_OB_CACHING') != 'on')) { outputRawCode($OUTPUT); $OUTPUT = ''; } + // That's why you don't need any \n at the end of your HTML code... :-) + if ($newLine) $OUTPUT .= "\n"; + } + break; - // The same as above... ^ - outputRawCode($HTML); - if ($newLine) echo "\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 = ''; } - default: - // Huh, something goes wrong or maybe you have edited config.php ??? - app_die(__FUNCTION__, __LINE__, "{--FATAL_ERROR--}: {--LANG_NO_RENDER_DIRECT--}"); - break; + // The same as above... ^ + outputRawCode($HTML); + if ($newLine) echo "\n"; + 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? @@ -233,7 +233,7 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { 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__); + array(getUserId()), __FUNCTION__, __LINE__); // Is content an array? if (is_array($content)) { @@ -300,10 +300,10 @@ function LOAD_TEMPLATE ($template, $return=false, $content=array()) { 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']) + $basePath, + $mode, + $template, + SQL_ESCAPE($GLOBALS['what']) ); // Probe for it... @@ -548,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; } @@ -635,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 @@ -672,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 @@ -709,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; } @@ -730,51 +730,6 @@ function generateCaptchaCode ($code, $type, $DATA, $uid) { return 'Code'; } -// "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; @@ -828,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 @@ -1160,98 +1115,98 @@ function ADD_SELECTION ($type, $default, $prefix = '', $id = '0') { } switch ($type) { - case "day": // Day - for ($idx = 1; $idx < 32; $idx++) { - $OUT .= "\n"; + } + } else { + // Get current year and subtract the configured minimum age + $OUT .= "\n"; + // Calculate earliest year depending on extension version + if (GET_EXT_VERSION('other') >= '0.2.1') { + // Use configured minimum age + $year = date('Y', time()) - getConfig('min_age'); + } else { + // Use fixed 16 years age + $year = date('Y', time()) - 16; + } - // Check if the default value is larger than minimum and bigger than actual year - if (($default > $minYear) && ($default >= $year)) { - for ($idx = $year; $idx < ($year + 11); $idx++) { + // Construct year selection list + for ($idx = $minYear; $idx <= $year; $idx++) { + $OUT .= "\n"; - } - } else { - // Get current year and subtract the configured minimum age - $OUT .= "\n"; - // Calculate earliest year depending on extension version - if (GET_EXT_VERSION('other') >= '0.2.1') { - // Use configured minimum age - $year = date('Y', time()) - getConfig('min_age'); - } else { - // Use fixed 16 years age - $year = date('Y', time()) - 16; - } + break; - // Construct year selection list - for ($idx = $minYear; $idx <= $year; $idx++) { + case "hour": + for ($idx = 0; $idx < 24; $idx++) { + if (strlen($idx) == 1) $idx = '0'.$idx; $OUT .= "