From 0b0f1ec06f8dda4617f231a208ee30204e041e07 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 6 Dec 2008 00:41:47 +0000 Subject: [PATCH] Some fixes in cache, GET_LANGUAGE() is now memory-cached, min age configurable --- inc/databases.php | 2 +- inc/db/lib-mysql3.php | 6 +- inc/extensions/ext-other.php | 11 ++- inc/functions.php | 88 +++++++++---------- inc/language/other_de.php | 1 + inc/libs/cache_functions.php | 2 +- .../de/html/admin/admin_config_other.tpl | 32 +++++-- 7 files changed, 82 insertions(+), 60 deletions(-) diff --git a/inc/databases.php b/inc/databases.php index 47fac13c96..715dd6791e 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "604"); +define('CURR_SVN_REVISION', "605"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index 7b6f3fc915..dda331836a 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -54,15 +54,15 @@ function SQL_QUERY($sql_string, $F, $L) { Query string:
".$sql_string); - // Save last successfull query - $_CONFIG['db_last_query'] = $sql_string; - // Ending time $querytimeAfter = array_sum(explode(' ', microtime())); // Calculate query time $queryTime = $querytimeAfter - $querytimeBefore; + // Save last successfull query + $_CONFIG['db_last_query'] = $sql_string; + // Count this query if (!isset($_CONFIG['sql_count'])) $_CONFIG['sql_count'] = 0; $_CONFIG['sql_count']++; diff --git a/inc/extensions/ext-other.php b/inc/extensions/ext-other.php index 5a1a2919e8..23454d623b 100644 --- a/inc/extensions/ext-other.php +++ b/inc/extensions/ext-other.php @@ -38,13 +38,13 @@ if (!defined('__SECURITY')) { } // Version number -$EXT_VERSION = "0.2.0"; +$EXT_VERSION = "0.2.1"; // Auto-set extension version if (empty($EXT_VER)) $EXT_VER = $EXT_VERSION; // Version history array (add more with , "0.1" and so on) -$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0"); +$EXT_VER_HISTORY = array("0.0", "0.0.1", "0.0.2", "0.0.3", "0.0.4", "0.0.5", "0.0.6", "0.0.7", "0.0.8", "0.0.9", "0.1.0", "0.1.1", "0.1.2", "0.1.3", "0.1.4", "0.1.5", "0.1.6", "0.1.7", "0.1.8", "0.1.9", "0.2.0", "0.2.1"); switch ($EXT_LOAD_MODE) { @@ -187,6 +187,13 @@ case "update": // Update an extension // Update notes (these will be set as task text!) $UPDATE_NOTES = "Bei fehlerhafter Mail während der Bestätigung kann wahlweise zur Hauptseite weitergeleitet oder auf die eingestellte Ablehnungsseite umgeleitet werden."; break; + + case "0.2.1": // SQL queries for v0.2.1 + $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` `min_age` TINYINT(3) UNSIGNED NOT NULL DEFAULT 16"; + + // Update notes (these will be set as task text!) + $UPDATE_NOTES = "Minimumalter ist nun konfigurierbar."; + break; } break; diff --git a/inc/functions.php b/inc/functions.php index 5b3b3855c3..66324337f6 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -706,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 @@ -731,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; } // @@ -1094,41 +1102,37 @@ 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) + } else { + // Get current year and subtract the configured minimum age $OUT .= "\n"; - $YEAR = date('Y', time()) - 16; + $YEAR = date('Y', time()) - $_CONFIG['min_age']; for ($idx = 1930; $idx <= $YEAR; $idx++) { $OUT .= "