X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Ffunctions.php;h=d5a4f20347509cd0f2b2833ad90ad51290228827;hp=cfbd66538429ce16230912500ad6b680bf9f6607;hb=6586600d8020147192e5f28ca2a3a0153f774d3c;hpb=37b921016ad1685c0938cff9d7069fb8e8b3f0cf diff --git a/inc/functions.php b/inc/functions.php index cfbd665384..d5a4f20347 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -132,7 +132,7 @@ function OUTPUT_HTML($HTML, $NEW_LINE = true) { default: // Huh, something goes wrong or maybe you have edited config.php ??? - DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid renderer %s detected.", OUTPUT_MODE)); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid renderer %s detected.", OUTPUT_MODE)); MXCHANGE_DIE("".FATAL_ERROR.": ".LANG_NO_RENDER_DIRECT); break; } @@ -240,11 +240,11 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) { $ret = ""; if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0; - // @DEPRECATED Try to remove this if() block + // @DEPRECATED Try to rewrite the if() condition if ($template == "member_support_form") { // Support request of a member - $result = SQL_QUERY_ESC("SELECT gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", - array($GLOBALS['userid']), __FILE__, __LINE__); + $result = SQL_QUERY_ESC("SELECT userid, gender, surname, family, email FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", + array($GLOBALS['userid']), __FILE__, __LINE__); // Is content an array? if (is_array($content)) { @@ -259,6 +259,7 @@ function LOAD_TEMPLATE($template, $return=false, $content=array()) { // Translate gender $gender = TRANSLATE_GENDER($gender); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("DEPRECATION-WARNING: content is not array (%s).", gettype($content))); } // Free result @@ -569,7 +570,7 @@ function MAKE_DATETIME ($time, $mode="0") case "2": $ret = date("d.m.Y|H:i", $time); break; case "3": $ret = date("d.m.Y", $time); break; default: - DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); break; } break; @@ -581,7 +582,7 @@ function MAKE_DATETIME ($time, $mode="0") case "2": $ret = date("y-m-d|H:i", $time); break; case "3": $ret = date("y-m-d", $time); break; default: - DEBUG_LOG(__FILE__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Invalid date mode %s detected.", $mode)); break; } } @@ -602,23 +603,17 @@ function TRANSLATE_COMMA ($dotted, $cut=true, $max=0) { if ($max > 0) $maxComma = $max; // Cut zeros off? - if ($cut) { + if (($cut) && ($max == 0)) { // Test for commata if in cut-mode $com = explode(".", $dotted); - if (count($com) > 1) { - // Commata found, so only zeros? - if ($com[1] == str_repeat("0", strlen($com[1]))) { - // Only zeros, so display only one - $maxComma = 1; - } // END - if - } else { + if (count($com) < 2) { // Don't display commatas even if there are none... ;-) $maxComma = 0; } } // END - if // Debug log - //DEBUG_LOG(__FUNCTION__, __LINE__, "dotted={$dotted},maxComma={$maxComma}"); + //* DEBUG: */ DEBUG_LOG(__FUNCTION__, __LINE__, "dotted={$dotted},maxComma={$maxComma}"); // Translate it now switch (GET_LANGUAGE()) { @@ -703,7 +698,7 @@ function TRANSLATE_STATUS($status) { break; default: - DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown status %s detected.", $status)); + DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status)); $ret = UNKNOWN_STATUS_1.$status.UNKNOWN_STATUS_2; break; } @@ -711,19 +706,22 @@ function TRANSLATE_STATUS($status) { } // function GET_LANGUAGE() { - if (!empty($_GET['mx_lang'])) { - // Accept only first 2 chars - $lang = substr($_GET['mx_lang'], 0, 2); - } else { - // Do nothing - $lang = ""; - } + global $cacheArray; // Set default return value to default language from config $ret = DEFAULT_LANG; - // Check GET variable and cookie - if (!empty($lang)) { + // Init variable + $lang = ""; + + // Is the variable set + if (!empty($_GET['mx_lang'])) { + // Accept only first 2 chars + $lang = substr($_GET['mx_lang'], 0, 2); + } elseif (isset($cacheArray['language'])) { + // Use cached + $ret = $cacheArray['language']; + } elseif (!empty($lang)) { // Check if main language file does exist if (FILE_READABLE(PATH."inc/language/".$lang.".php")) { // Okay found, so let's update cookies @@ -736,6 +734,11 @@ function GET_LANGUAGE() { // Fixes a warning before the session has the mx_lang constant if (empty($ret)) $ret = DEFAULT_LANG; } + + // Cache entry + $cacheArray['language'] = $ret; + + // Return value return $ret; } // @@ -920,15 +923,15 @@ function MAKE_TIME($H, $M, $S, $stamp) { function LOAD_URL($URL, $addUrlData=true) { global $CSS, $_CONFIG, $footer; + // Compile out URI codes + $URL = COMPILE_CODE($URL); + // Check if http(s):// is there if ((substr($URL, 0, 7) != "http://") && (substr($URL, 0, 8) != "https://")) { // Make all URLs full-qualified $URL = URL."/".$URL; } - // Compile out URI codes - $URL = COMPILE_CODE($URL); - // Get output buffer $OUTPUT = ob_get_contents(); @@ -1099,76 +1102,86 @@ function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums = $array = $dummy; } // -function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") -{ - global $MONTH_DESCR; $OUT = ""; - if ($type == "yn") - { +function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0") { + global $MONTH_DESCR, $_CONFIG; + $OUT = ""; + + if ($type == "yn") { // This is a yes/no selection only! if ($id > 0) $prefix .= "[".$id."]"; $OUT .= " \n"; } - switch ($type) - { + + switch ($type) { case "day": // Day - for ($idx = 1; $idx < 32; $idx++) - { + for ($idx = 1; $idx < 32; $idx++) { $OUT .= "\n"; } - } - else - { - // Get current year and subtract 16 (for erotic content) - $OUT .= "\n"; - $YEAR = date('Y', time()) - 16; - for ($idx = 1930; $idx <= $YEAR; $idx++) - { + } 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()) - $_CONFIG['min_age']; + } else { + // Use fixed 16 years age + $YEAR = date('Y', time()) - 16; + } + + // Construct year selection list + for ($idx = $minYear; $idx <= $YEAR; $idx++) { $OUT .= "