Several fixes for module/action/what handling.
authorRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2009 21:25:26 +0000 (21:25 +0000)
committerRoland Häder <roland@mxchange.org>
Sat, 7 Nov 2009 21:25:26 +0000 (21:25 +0000)
inc/db/lib-mysql3.php
inc/extensions/ext-sql_patches.php
inc/functions.php
inc/modules/admin.php
inc/modules/admin/admin-inc.php
inc/mysql-manager.php
inc/wrapper-functions.php
modules.php
templates/de/html/admin/admin_menu_failed.tpl

index c00b59971df0351ae72505547d74940f997aa217..8ed21c3218340cb79142db44896e4dbb535793b6 100644 (file)
@@ -75,7 +75,7 @@ function SQL_QUERY ($sqlString, $F, $L) {
        $sqlString = FILTER_COMPILE_CONFIG($sqlString, true);
 
        // Starting time
-       $querytimeBefore = array_sum(explode(' ', microtime()));
+       $querytimeBefore = microtime(true);
 
        // Run SQL command
        //* DEBUG: */ print('F=' . basename($F) . ',L=' . $L . 'sql=' . $sqlString . '<br />');
@@ -85,11 +85,8 @@ Query string:<br />
 ' . $sqlString);
        //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sqlString . ',numRows=' . SQL_NUMROWS($result) . ',affected=' . SQL_AFFECTEDROWS());
 
-       // Ending time
-       $querytimeAfter = array_sum(explode(' ', microtime()));
-
        // Calculate query time
-       $queryTime = $querytimeAfter - $querytimeBefore;
+       $queryTime = microtime(true) - $querytimeBefore;
 
        // Add this query to array including timing
        addSqlToDebug($result, $sqlString, $queryTime, $F, $L);
@@ -108,7 +105,7 @@ Query string:<br />
                //
                // Debugging stuff...
                //
-               $fp = fopen(getConfig('CACHE_PATH') . 'mysql.log', 'a') or app_die(__FILE__, __LINE__, "Cannot write mysql.log!");
+               $fp = fopen(getConfig('CACHE_PATH') . 'mysql.log', 'a') or app_die(__FILE__, __LINE__, 'Cannot write mysql.log!');
                if (!isset($GLOBALS['sql_first_entry'])) {
                        // Write first entry
                        fwrite($fp, 'Module=' . getModule() . "\n");
index cb4fd3fe2599e2fffea2c19bd947a3851e0fdb6d..426bacca0c6a6af699b671efac88aa665445b00e 100644 (file)
@@ -532,13 +532,9 @@ PRIMARY KEY (`id`)
                                addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_admin_menu` SET `what`=NULL WHERE `what`=''");
                                addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_guest_menu` SET `what`=NULL WHERE `what`=''");
                                addExtensionSql("UPDATE `{?_MYSQL_PREFIX?}_member_menu` SET `what`=NULL WHERE `what`=''");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` DROP INDEX `what`");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_admin_menu` ADD UNIQUE (`what`)");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` DROP INDEX `what`");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_guest_menu` ADD UNIQUE (`what`)");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD INDEX `action` (`action`)");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` DROP INDEX `what`");
-                               addExtensionSql("ALTER TABLE `{?_MYSQL_PREFIX?}_member_menu` ADD UNIQUE (`what`)");
+
+                               // Make this depending on ext-menu
+                               addExtensionUpdateDependency('menu');
 
                                // Update notes (these will be set as task text!)
                                setExtensionUpdateNotes("Schl&uuml;ssel in Admin-, Gast- und Mitgliedsmen&uuml; verbessert.");
index 2052e4af838925ea3679260c79f57d2d0d5e4329..c621cbc3f2cd730713c41464a8c925eb9d3a85cf 100644 (file)
@@ -997,16 +997,16 @@ function compileCode ($code, $simple = false, $constants = true, $full = true) {
        } // END - if
 
        // Start couting
-       $startCompile = explode(' ', microtime());
+       $startCompile = microtime(true);
 
        // Comile the code
        $code = compileRawCode($code, $simple, $constants, $full);
 
        // Get timing
-       $compiled = explode(' ', microtime());
+       $compiled = microtime(true);
 
        // Add timing
-       $code .= '<!-- Compilation time: ' . ((($compiled[1] + $compiled[0]) - ($startCompile[1] + $startCompile[0])) * 1000). 'ms //-->';
+       $code .= '<!-- Compilation time: ' . (($compiled - $startCompile) * 1000). 'ms //-->';
 
        // Return compiled code
        return $code;
@@ -1720,7 +1720,7 @@ function extractHostnameFromUrl (&$script) {
        if (substr(strtolower($script), 0, 7) == 'http://') {
                // But only if http:// is in front!
                $script = substr($script, (strlen($url) + 7));
-       } elseif (substr(strtolower($script), 0, 8) == "https://") {
+       } elseif (substr(strtolower($script), 0, 8) == 'https://') {
                // Does this work?!
                $script = substr($script, (strlen($url) + 8));
        }
@@ -2648,11 +2648,9 @@ function debug_report_bug ($message = '') {
        die($debug);
 }
 
-// Generates a ***weak*** seed (taken from de.php.net/mt_srand)
+// Generates a ***weak*** seed
 function generateSeed () {
-       list($usec, $sec) = explode(' ', microtime());
-       $microTime = (((float)$sec + (float)$usec)) * 100000;
-       return $microTime;
+       return microtime(true) * 100000;
 }
 
 // Converts a message code to a human-readable message
index 1d01e202d5f72dcd2b3d9e4259fe945a91becff3..d1b8d627b8a9658f705baa27c7ded25ccb2669ad 100644 (file)
@@ -278,10 +278,6 @@ if (!isAdminRegistered()) {
                        // Load message template
                        $content['login_message'] = loadTemplate('admin_login_msg', true, $loginMessage);
                        $content['pass_message']  = loadTemplate('admin_login_msg', true, $passwdMessage);
-
-                       // Reset variables
-                       unset($loginMessage);
-                       unset($passwdMessage);
                } // END - if
 
                // Load login form
index d7a51703112ed512da4ec8dc39bfe107416d4c34..b61077330aeb92fc765ba5ed331f4b7016474033 100644 (file)
@@ -313,7 +313,7 @@ LIMIT 1",
                }
        } else {
                // Invalid action/what pair found!
-               loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action.'/'.$what));
+               loadTemplate('admin_menu_failed', false, sprintf(getMessage('ADMIN_ACTION_INVALID'), $action . '/' . $what));
        }
 
        // Free memory
index e33b1b395e995c187edbccd29b2fbde77684f250..1f3ea2d2d287f5f7e47ba2b92e39efa2b490eb62 100644 (file)
@@ -1024,9 +1024,14 @@ function getModeAction ($mode, $what) {
        //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=<br />");
        if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) {
                // sql_patches is missing so choose depending on mode
-               if ($mode == 'admin') {
+               if (isWhatSet()) {
+                       // Use setted what
+                       $what = getWhat();
+               } elseif ($mode == 'admin') {
+                       // Admin area
                        $what = 'overview';
                } else {
+                       // Everywhere else
                        $what = 'welcome';
                }
        } elseif ((empty($what)) && ($mode != 'admin')) {
@@ -1070,7 +1075,7 @@ function getModeAction ($mode, $what) {
 
                // Free memory
                SQL_FREERESULT($result);
-       } elseif ((!isExtensionInstalled('sql_patches')) && ($mode != 'admin')) {
+       } elseif ((!isExtensionInstalled('sql_patches')) && (($mode != 'admin') && ($mode != 'unknown'))) {
                // No sql_patches installed, but maybe we need to register an admin?
                if (isAdminRegistered()) {
                        // Redirect to admin area
index 680c9c20abe2aeb7c8f597c0a42c82863e7ae0c3..bac74d3755979cc9fb9caeaab1164665eda5d234 100644 (file)
@@ -558,14 +558,11 @@ function isModuleSet ($strict =  false) {
        // Should we abort here?
        if (($strict === true) && ($isset === false)) {
                // Output backtrace
-               print 'Module not set!<pre>';
-               debug_print_backtrace();
-               die('</pre');
                debug_report_bug('module is empty.');
        } // END - if
 
        // Return it
-       return $isset;
+       return (($isset === true) && ($GLOBALS['module'] != 'unknown')) ;
 }
 
 // Getter for 'output_mode' value
index 7e8a0b2ea9657d6cbacc8cd7557a5c0a0ac96b90..201f4cea38975f4dc895629353222dc2eed5e121 100644 (file)
@@ -47,7 +47,7 @@ $GLOBALS['startTime'] = microtime(true);
 
 // Init output mode and module
 $GLOBALS['output_mode'] = '0';
-$GLOBALS['module'] = '';
+$GLOBALS['module'] = 'unknown';
 
 // Needed include files
 require('inc/config-global.php');
@@ -56,7 +56,13 @@ require('inc/config-global.php');
 setContentType('text/html');
 
 // Fix missing module to 'index'
-if (!isGetRequestElementSet('module')) setRequestGetElement('module', 'index');
+if (!isGetRequestElementSet('module')) {
+       // Set element
+       setRequestGetElement('module', 'index');
+
+       // ... and module
+       setModule('index');
+} // END - if
 
 // The header file
 loadIncludeOnce('inc/header.php');
index b88ef036b4e20e0e198e538ae37a172f66325d92..e59dd6ef963bd889cce43d11f567a6113ec7833d 100644 (file)
@@ -1,5 +1,3 @@
-<br />
-<br />
 <table border="0" cellspacing="0" cellpadding="0" class="admin_table dashed">
        <tr>
                <td align="center" height="40" class="admin_title bottom2">