From 606e585919ff565b55fb3c2cdee4a80c4e61a9c6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Sat, 7 Nov 2009 21:25:26 +0000 Subject: [PATCH] Several fixes for module/action/what handling. --- inc/db/lib-mysql3.php | 9 +++------ inc/extensions/ext-sql_patches.php | 10 +++------- inc/functions.php | 14 ++++++-------- inc/modules/admin.php | 4 ---- inc/modules/admin/admin-inc.php | 2 +- inc/mysql-manager.php | 9 +++++++-- inc/wrapper-functions.php | 5 +---- modules.php | 10 ++++++++-- templates/de/html/admin/admin_menu_failed.tpl | 2 -- 9 files changed, 29 insertions(+), 36 deletions(-) diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index c00b59971d..8ed21c3218 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -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 . '
'); @@ -85,11 +85,8 @@ Query string:
' . $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:
// // 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"); diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index cb4fd3fe25..426bacca0c 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -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üssel in Admin-, Gast- und Mitgliedsmenü verbessert."); diff --git a/inc/functions.php b/inc/functions.php index 2052e4af83..c621cbc3f2 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -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 .= ''; + $code .= ''; // 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 diff --git a/inc/modules/admin.php b/inc/modules/admin.php index 1d01e202d5..d1b8d627b8 100644 --- a/inc/modules/admin.php +++ b/inc/modules/admin.php @@ -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 diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index d7a5170311..b61077330a 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -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 diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index e33b1b395e..1f3ea2d2d2 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1024,9 +1024,14 @@ function getModeAction ($mode, $what) { //* DEBUG: */ print(__LINE__.'='.$mode.'/'.$what.'/'.getAction()."=
"); 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 diff --git a/inc/wrapper-functions.php b/inc/wrapper-functions.php index 680c9c20ab..bac74d3755 100644 --- a/inc/wrapper-functions.php +++ b/inc/wrapper-functions.php @@ -558,14 +558,11 @@ function isModuleSet ($strict = false) { // Should we abort here? if (($strict === true) && ($isset === false)) { // Output backtrace - print 'Module not set!
';
-		debug_print_backtrace();
-		die('
-
-- 2.30.2