X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Ffunctions.php;h=be503dcc6c07c68da41bb4350e490d889ec366d5;hb=7fbaac24c4f4f701c2f0e75fab418a6e2894a3a9;hp=44fdf95282a4dbaeeb6d67974b1420ba5e968137;hpb=963e55ca1ea79e255f235e359cde9f7862191dc5;p=mailer.git diff --git a/inc/functions.php b/inc/functions.php index 44fdf95282..be503dcc6c 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -207,11 +207,8 @@ function LOAD_TEMPLATE($template, $return=false, $content="") { $_CONFIG['num_templates']++; // Init some data - $ACTION = SQL_ESCAPE($GLOBALS['action']); - $WHAT = SQL_ESCAPE($GLOBALS['what']); $ret = ""; if (empty($GLOBALS['refid'])) $GLOBALS['refid'] = 0; - $REFID = $GLOBALS['refid']; // @DEPRECATED Try to remove this if() block if ($template == "member_support_form") { @@ -1263,8 +1260,8 @@ function GENERATE_IMAGE($img_code, $header=true) { } // Create selection box or array of splitted timestamp function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="center", $return_array=false) { - // Calculate 15-seconds timestamp (15-seconds-steps shall be fine ;) ) - $stamp = round($timestamp / 15) * 15; + // Calculate 2-seconds timestamp + $stamp = round($timestamp / 2) * 2; // Do we have a leap year? $SWITCH = 0; @@ -1293,7 +1290,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen // Is seconds zero and time is < 60 seconds? if (($s == 0) && ($stamp < 60)) { // Fix seconds - $s = $timestamp; + $s = round($timestamp); } // END - if // @@ -1481,10 +1478,10 @@ function SEND_ADMIN_EMAILS_PRO($subj, $template, $content, $UID) { // Load email template $msg = LOAD_EMAIL_TEMPLATE($template, $content, $UID); - if (GET_EXT_VERSION("admins") < "0.4.0") { + if (EXT_VERSION_IS_OLDER("admins", "0.4.0")) { // Older version detected! return SEND_ADMIN_EMAILS($subj, $msg); - } + } // END - if // Check which admin shall receive this mail $result = SQL_QUERY_ESC("SELECT DISTINCT admin_id FROM "._MYSQL_PREFIX."_admins_mails WHERE mail_template='%s' ORDER BY admin_id", @@ -1540,8 +1537,14 @@ function CREATE_FANCY_TIME($stamp) { } // END - if } // END - foreach - // Remove leading commata and space - $ret = substr($ret, 2); + // Do we have something there? + if (strlen($ret) > 0) { + // Remove leading commata and space + $ret = substr($ret, 2); + } else { + // Zero seconds + $ret = "0 "._SECONDS; + } // Return fancy time string return $ret; @@ -1913,7 +1916,7 @@ function generateHash ($plainText, $salt = "") { global $_CONFIG, $_SERVER; // Is the required extension "sql_patches" there and a salt is not given? - if (((GET_EXT_VERSION("sql_patches") < "0.3.6") || (GET_EXT_VERSION("sql_patches") == "")) && (empty($salt))) { + if (((EXT_VERSION_IS_OLDER("sql_patches", "0.3.6")) || (GET_EXT_VERSION("sql_patches") == "")) && (empty($salt))) { // Extension sql_patches is missing/outdated so we return the plain text return $plainText; } // END - if @@ -2239,13 +2242,21 @@ function isSessionVariableSet($var) { } // Returns wether the value of the session variable or NULL if not set function get_session($var) { + global $cacheArray; + // Default is not found! ;-) $value = null; - // Is the variable there? - if (isSessionVariableSet($var)) { + // Is the variable there or cached values? + if (isset($cacheArray['session'][$var])) { + // Get cached value (skips a lot SQL_ESCAPE() calles! + $value = $cacheArray['session'][$var]; + } elseif (isSessionVariableSet($var)) { // Then get it secured! $value = SQL_ESCAPE($_SESSION[$var]); + + // Cache the value + $cacheArray['session'][$var] = $value; } // END - if // Return the value @@ -2337,9 +2348,9 @@ function RESET_ADD_INCLUDES () { global $_CONFIG; // Is the reset set or old sql_patches? - if ((!isBooleanConstantAndTrue('__DAILY_RESET')) || (GET_EXT_VERSION("sql_patches") < "0.4.5")) { + if ((!isBooleanConstantAndTrue('__DAILY_RESET')) || (EXT_VERSION_IS_OLDER("sql_patches", "0.4.5"))) { // Then abort here - return; + return array(); } // END - if // Get more daily reset scripts @@ -2510,6 +2521,26 @@ function REBUILD_CACHE ($cache, $inc="") { } // END - if } // END - if } +// Purge admin menu cache +function CACHE_PURGE_ADMIN_MENU ($id=0, $action="", $what="", $str="") { + global $_CONFIG, $cacheInstance; + + // Is the cache extension enabled or no cache instance or admin menu cache disabled? + if (!EXT_IS_ACTIVE("cache")) { + // Cache extension not active + return false; + } elseif (!is_object($cacheInstance)) { + // No cache instance! + DEBUG_LOG(__FUNCTION__.": No cache instance found."); + return false; + } elseif ((!isset($_CONFIG['cache_admin_menu'])) || ($_CONFIG['cache_admin_menu'] == "N")) { + // Caching disabled (currently experiemental!) + return false; + } + + // Experiemental feature! + trigger_error("You have to delete the admin_*.cache files by yourself at this point."); +} // ////////////////////////////////////////////////// // //