Some fixes in cache, GET_LANGUAGE() is now memory-cached, min age configurable
authorRoland Häder <roland@mxchange.org>
Sat, 6 Dec 2008 00:41:47 +0000 (00:41 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 6 Dec 2008 00:41:47 +0000 (00:41 +0000)
inc/databases.php
inc/db/lib-mysql3.php
inc/extensions/ext-other.php
inc/functions.php
inc/language/other_de.php
inc/libs/cache_functions.php
templates/de/html/admin/admin_config_other.tpl

index 47fac13c96648b84b12eba63d993e3f6a9e85be5..715dd6791ea7d1f70e5af236633632387f722a56 100644 (file)
@@ -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);
index 7b6f3fc915edfb020bb44a0ffc440401f77926df..dda331836a367bacc955cae726653cfa2b6d493e 100644 (file)
@@ -54,15 +54,15 @@ function SQL_QUERY($sql_string, $F, $L) {
 Query string:<br />
 ".$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']++;
index 5a1a2919e816156d4411f946076c21ac5f49fe21..23454d623b093fdc9451c01cd6e6a8457a8bafad 100644 (file)
@@ -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&auml;hrend der Best&auml;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;
 
index 5b3b3855c384f2dbf1d16755a509c00ece02148c..66324337f68d134e09d79940aba79f6620e04568 100644 (file)
@@ -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 .= "    <SELECT name=\"".$prefix."\" class=\"register_select\" size=\"1\">\n";
-       }
-        else
-       {
+       } else {
                // Begin with regular selection box here
                if (!empty($prefix)) $prefix .= "_";
                $type2 = $type;
                if ($id > 0) $type2 .= "[".$id."]";
                $OUT .= "    <SELECT name=\"".strtolower($prefix.$type2)."\" class=\"register_select\" size=\"1\">\n";
        }
-       switch ($type)
-       {
+
+       switch ($type) {
        case "day": // Day
-               for ($idx = 1; $idx < 32; $idx++)
-               {
+               for ($idx = 1; $idx < 32; $idx++) {
                        $OUT .= "<OPTION value=\"".$idx."\"";
                        if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
                        $OUT .= ">".$idx."</OPTION>\n";
-               }
+               } // END - for
                break;
 
        case "month": // Month
-               foreach ($MONTH_DESCR as $month => $descr)
-               {
+               foreach ($MONTH_DESCR as $month => $descr) {
                        $OUT .= "<OPTION value=\"".$month."\"";
                        if ($DEFAULT == $month) $OUT .= " selected=\"selected\"";
                        $OUT .= ">".$descr."</OPTION>\n";
-               }
+               } // END - for
                break;
 
        case "year": // Year
@@ -1136,28 +1140,22 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0")
                $YEAR = date('Y', time());
 
                // Check if the default value is larger than minimum and bigger than actual year
-               if (($DEFAULT > 1930) && ($DEFAULT >= $YEAR))
-               {
-                       for ($idx = $YEAR; $idx < ($YEAR + 11); $idx++)
-                       {
+               if (($DEFAULT > 1930) && ($DEFAULT >= $YEAR)) {
+                       for ($idx = $YEAR; $idx < ($YEAR + 11); $idx++) {
                                $OUT .= "<OPTION value=\"".$idx."\"";
                                if ($DEFAULT == $idx) $OUT .= " selected=\"selected\"";
                                $OUT .= ">".$idx."</OPTION>\n";
-                       }
-               }
-                elseif ($DEFAULT == -1)
-               {
+                       } // END - for
+               } elseif ($DEFAULT == -1) {
                        // Current year minus 1
                        for ($idx = 2003; $idx <= ($YEAR + 1); $idx++)
                        {
                                $OUT .= "<OPTION value=\"".$idx."\">".$idx."</OPTION>\n";
                        }
-               }
-                else
-               {
-                       // Get current year and subtract 16 (for erotic content)
+               } else {
+                       // Get current year and subtract the configured minimum age
                        $OUT .= "<OPTION value=\"1929\">&lt;1930</OPTION>\n";
-                       $YEAR = date('Y', time()) - 16;
+                       $YEAR = date('Y', time()) - $_CONFIG['min_age'];
                        for ($idx = 1930; $idx <= $YEAR; $idx++)
                        {
                                $OUT .= "<OPTION value=\"".$idx."\"";
@@ -2298,23 +2296,23 @@ function set_session ($var, $value) {
 // Check wether a boolean constant is set
 // Taken from user comments in PHP documentation for function constant()
 function isBooleanConstantAndTrue($constName) { // : Boolean
-       global $constCache;
+       global $cacheArray;
 
        // Failed by default
        $res = false;
 
        // In cache?
-       if (isset($constCache[$constName])) {
+       if (isset($cacheArray['const'][$constName])) {
                // Use cache
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-CACHE!<br />\n";
-               $res = $constCache[$constName];
+               $res = $cacheArray['const'][$constName];
        } else {
                // Check constant
                //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$constName."-RESOLVE!<br />\n";
                if (defined($constName)) $res = (constant($constName) === true);
 
                // Set cache
-               $constCache[$constName] = $res;
+               $cacheArray['const'][$constName] = $res;
        }
        //* DEBUG: */ var_dump($res);
 
@@ -2323,12 +2321,12 @@ function isBooleanConstantAndTrue($constName) { // : Boolean
 }
 
 // Check wether a session variable is set
-function isSessionVariableSet($var) {
+function isSessionVariableSet ($var) {
        //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):var={$var}<br />\n";
        return (isset($_SESSION[$var]));
 }
 // Returns wether the value of the session variable or NULL if not set
-function get_session($var) {
+function get_session ($var) {
        global $cacheArray;
 
        // Default is not found! ;-)
@@ -2337,9 +2335,11 @@ function get_session($var) {
        // Is the variable there or cached values?
        if (isset($cacheArray['session'][$var])) {
                // Get cached value (skips a lot SQL_ESCAPE() calles!
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$var."-CACHE!<br />\n";
                $value = $cacheArray['session'][$var];
        } elseif (isSessionVariableSet($var)) {
                // Then  get it secured!
+               //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>): ".$var."-RESOLVE!<br />\n";
                $value = SQL_ESCAPE($_SESSION[$var]);
 
                // Cache the value
index 6bb195647bcc07414384bc5b03ba92ad26aac067..cf611772f3c7ca3ca34ce0897247e371509406dc 100644 (file)
@@ -81,6 +81,7 @@ define('ADMIN_OPTION_MT_WORD3', "Art Ihres Tausches (1. Fall, Plural)");
 define('ADMIN_OPTION_REJECT_URL', "Standart-URL bei Ablehnung der Mailbuchung");
 define('ADMIN_OPTION_SHOW_TIMINGS', "Skript-Statistiken im Seitenfuss einblenden (n&uuml;tzlich zum Debuggen)");
 define('ADMIN_OPTION_SHOW_POINTS_UNCONFIRMED', "{!POINTS!} in unbest&auml;tige Mails im Mitgliedsbereich anzeigen?");
+define('ADMIN_OPTION_MINIMUM_AGE', "Ab welchem Mindestalter d&uuml;rfen sich Ihre Mitglieder anmelden?");
 
 //
 ?>
index b28d1b41fef73604a199dc8faaf2cbb3aa2df50c..f1356910d97398e23b953594039edd0e149640ff 100644 (file)
@@ -259,7 +259,7 @@ class mxchange_cache
                        }
                } else {
                        // Does not exist!
-                       ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_CANNOT_UNLINK_1.$this->cache_inc.CACHE_CANNOT_UNLINK_2);
+                       ADD_FATAL(__FILE__."(<font color=\"#0000aa\">".__LINE__."</font>): ".CACHE_PROBLEMS_DETECTED);
                }
        }
 
index ee34382d9f0a03114be731ba6c1869965b923be7..3fbb7df0f7ac03c5431a7105e4c340a34a8acdbc 100644 (file)
@@ -1,8 +1,5 @@
-<FORM action="{!URL!}/modules.php?module=admin&amp;what=config_other"
-       method="POST">
-<TABLE border="0" cellspacing="0" cellpadding="0" align="center"
-       width="520" class="admin_table dashed">
-
+<FORM action="{!URL!}/modules.php?module=admin&amp;what=config_other" method="POST">
+<TABLE border="0" cellspacing="0" cellpadding="0" align="center" width="520" class="admin_table dashed">
        <TR>
                <TD colspan="5" height="7" class="seperator admin_title">&nbsp;</TD>
        </TR>
        <TR>
                <TD width="10" class="seperator">&nbsp;</TD>
                <TD align="right" width="340">
-               {--ADMIN_OPTION_ACTIVATE_EXCHANGE--}:</TD>
+                       {--ADMIN_OPTION_ACTIVATE_EXCHANGE--}:
+               </TD>
+               <TD width="10" class="seperator">&nbsp;</TD>
+               <TD>
+                       <INPUT type="text" name="activate_xchange" class="admin_normal" size="10" maxlength="10" value="{--_CFG_ACT_SYSTEM--}" />
+               </TD>
+               <TD width="10" class="seperator">&nbsp;</TD>
+       </TR>
+
+       <TR>
+               <TD colspan="5" height="7" class="seperator">&nbsp;</TD>
+       </TR>
+
+       <TR>
+               <TD width="10" class="seperator">&nbsp;</TD>
+               <TD align="right" width="340">
+                       {--ADMIN_OPTION_MINIMUM_AGE--}:
+               </TD>
                <TD width="10" class="seperator">&nbsp;</TD>
-               <TD><INPUT type="text" name="activate_xchange"
-                       class="admin_normal" size="10" maxlength="10"
-                       value="{--_CFG_ACT_SYSTEM--}"></TD>
+               <TD>
+                       <INPUT type="text" name="min_age" class="admin_normal" size="3" maxlength="3" value="{--_CFG_MIN_AGE--}" />
+               </TD>
                <TD width="10" class="seperator">&nbsp;</TD>
        </TR>