From: Roland Häder Date: Fri, 15 Feb 2008 20:11:38 +0000 (+0000) Subject: Script stats added in footer X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=commitdiff_plain;h=c7f21c9eb494d8466447c1a199ec5621440d7ac8 Script stats added in footer --- diff --git a/.gitattributes b/.gitattributes index b9b6e70832..0c724543c3 100644 --- a/.gitattributes +++ b/.gitattributes @@ -985,6 +985,7 @@ templates/de/html/ext/ext_user.tpl -text templates/de/html/ext/ext_wernis.tpl -text templates/de/html/fatal_footer.tpl -text templates/de/html/fatal_header.tpl -text +templates/de/html/footer_stats.tpl -text templates/de/html/guest/.htaccess -text templates/de/html/guest/guest_active_none_row.tpl -text templates/de/html/guest/guest_active_row.tpl -text diff --git a/beg.php b/beg.php index 8ce9419818..b7bb846df5 100644 --- a/beg.php +++ b/beg.php @@ -35,7 +35,8 @@ require_once("inc/libs/security_functions.php"); // Init "action" and "what" -global $what, $action; +global $what, $action, $startTime; +$GLOBALS['startTime'] = microtime(true); $GLOBALS['what'] = ""; $GLOBALS['action'] = ""; // Set module diff --git a/doubler.php b/doubler.php index 356821765a..9d3a4432e6 100644 --- a/doubler.php +++ b/doubler.php @@ -35,7 +35,8 @@ require_once("inc/libs/security_functions.php"); // Init "action" and "what" -global $what, $action; +global $what, $action, $startTime; +$GLOBALS['startTime'] = microtime(true); $GLOBALS['what'] = ""; $GLOBALS['action'] = ""; // Set module diff --git a/inc/db/lib-mysql3.php b/inc/db/lib-mysql3.php index c463f8de30..03e2d736f2 100644 --- a/inc/db/lib-mysql3.php +++ b/inc/db/lib-mysql3.php @@ -49,8 +49,12 @@ function SQL_QUERY($sql_string, $F, $L) ".MYSQL_QUERY_STRING."
".$sql_string); - // Debug output - //* DEBUG: */ print "Query=".$sql_string.", affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n"; + // Count this query + if (!isset($CONFIG['sql_count'])) $CONFIG['sql_count'] = 0; + $CONFIG['sql_count']++; + + // Debug output + //* DEBUG: */ print "Query=".$sql_string.", affected=".SQL_AFFECTEDROWS().", numrows=".SQL_NUMROWS($result)."
\n"; if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL)) { diff --git a/inc/extensions/ext-sql_patches.php b/inc/extensions/ext-sql_patches.php index 0a2a307e92..c2c69b4494 100644 --- a/inc/extensions/ext-sql_patches.php +++ b/inc/extensions/ext-sql_patches.php @@ -39,13 +39,13 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF']))) } // Version number -$EXT_VERSION = "0.4.0"; +$EXT_VERSION = "0.4.1"; // Auto-set extension version if (!isset($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", "0.2.1", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.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", "0.2.2", "0.2.3", "0.2.4", "0.2.5", "0.2.6", "0.2.7", "0.2.8", "0.2.9", "0.3.0", "0.3.1", "0.3.2", "0.3.3", "0.3.4", "0.3.5", "0.3.6", "0.3.7", "0.3.8", "0.3.9", "0.4.0", "0.4.1"); switch ($EXT_LOAD_MODE) { @@ -515,10 +515,11 @@ PRIMARY KEY (id) break; case "0.4.1": // SQL queries for v0.4.1 - $SQLs[] = " ALTER TABLE `"._MYSQL_PREFIX."_user_data` DROP INDEX `status` , ADD INDEX `status` ( `status` , `max_mails` )"; + $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_user_data` DROP INDEX `status` , ADD INDEX `status` ( `status` , `max_mails` )"; + $SQLs[] = "ALTER TABLE `"._MYSQL_PREFIX."_config` ADD `show_timings` ENUM ('Y','N') NOT NULL DEFAULT 'Y'"; // Update notes (these will be set as task text!) - $UPDATE_NOTES = "Tabellen-Schlüssel neu gesetzt."; + $UPDATE_NOTES = "Tabellen-Schlüssel neu gesetzt und Parsing-Zeit im Footer eingeblendet."; break; } break; @@ -560,6 +561,7 @@ default: // Do stuff when extension is loaded $CONFIG['file_hash'] = trim($DUMMY['file_hash']); $CONFIG['master_salt'] = trim($DUMMY['master_salt']); $CONFIG['secret_key'] = ""; + $CONFIG['show_timings'] = $DUMMY['show_timings']; // Read key from secret file if ((empty($CONFIG['file_hash'])) || (empty($CONFIG['master_salt'])) || (empty($CONFIG['pass_scramble']))) diff --git a/inc/footer.php b/inc/footer.php index 42b4e4315d..440d1bc81f 100644 --- a/inc/footer.php +++ b/inc/footer.php @@ -52,6 +52,12 @@ if (($footer != "1") && ($footer != "2") && ($CSS != "1")) { LOAD_TEMPLATE("copyright"); } + // Shall we display the parsing time and number of queries? + if ($CONFIG['show_timings'] == "Y") { + // Then display it here + DISPLAY_PARSING_TIME_FOOTER(); + } + // Load page footer LOAD_TEMPLATE("page_footer"); diff --git a/inc/functions.php b/inc/functions.php index 6594d72fb6..021edbe879 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -182,7 +182,13 @@ function ADD_FATAL ($message, $extra="") // Load a template file and return it's content (only it's name; do not use ' or ") function LOAD_TEMPLATE($template, $return=false, $content="") { // Add more variables which you want to use in your template files - global $DATA, $username; + global $DATA, $CONFIG, $username; + + // Count the template load + if (!isset($CONFIG['num_templates'])) $CONFIG['num_templates'] = 0; + $CONFIG['num_templates']++; + + // Init some data $ACTION = SQL_ESCAPE($GLOBALS['action']); $WHAT = SQL_ESCAPE($GLOBALS['what']); $ret = ""; @@ -2028,6 +2034,36 @@ function mxchange_die ($msg) { // Exit explicitly exit; } + +// Display parsing time and number of SQL queries in footer +function DISPLAY_PARSING_TIME_FOOTER() { + global $startTime, $CONFIG; + $endTime = microtime(true); + + // Is the timer started? + if (!isset($GLOBALS['startTime'])) { + // Abort here + return false; + } + + // "Explode" both times + $start = explode(" ", $GLOBALS['startTime']); + $end = explode(" ", $endTime); + $runTime = $end[0] - $start[0]; + if ($runTime < 0) $runTime = 0; + $runTime = TRANSLATE_COMMA($runTime); + + // Prepare output + $content = array( + 'runtime' => $runTime, + 'numSQLs' => ($CONFIG['sql_count'] + 1), + 'numTemplates' => ($CONFIG['num_templates'] + 1) + ); + + // Load the template + LOAD_TEMPLATE("footer_stats", false, $content); +} + // ////////////////////////////////////////////// // // diff --git a/inc/language/de.php b/inc/language/de.php index 6bda938d21..b352132fcd 100644 --- a/inc/language/de.php +++ b/inc/language/de.php @@ -1096,6 +1096,10 @@ define('CONTACT_USER', "Mitglied kontaktieren"); define('ADMIN_USER_CONTACTED', "Das Mitglied wurde per EMail kontaktiert."); define('ADMIN_CONTACT_USER_SUBJECT', "Nachricht vom {!MT_WORD!} {!MAIN_TITLE!}"); define('MEMBER_CANNOT_LOAD_PROFILE', "Fehler beim Laden des Mitgliederprofiles. Bitte Support benachrichten."); +define('FOOTER_STATS_RUNTIME', "Laufzeit:"); +define('FOOTER_STATS_SQL_QUERIES', "SQL-Abfragen:"); +define('FOOTER_STATS_NUM_TEMPLATES', "Templates:"); +define('FOOTER_STATS_SECS', "Sek."); // ?> diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 1d87752921..ad4a3bdb69 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -1620,5 +1620,6 @@ function MODULE_HAS_MENU($mod) // Return status return $ret; } + // ?> diff --git a/lead-confirm.php b/lead-confirm.php index 76b2c9b455..e04ea259b5 100644 --- a/lead-confirm.php +++ b/lead-confirm.php @@ -35,7 +35,8 @@ require_once("inc/libs/security_functions.php"); // Init "action" and "what" -global $what, $action; +global $what, $action, $startTime; +$GLOBALS['startTime'] = microtime(true); $GLOBALS['what'] = ""; $GLOBALS['action'] = ""; // Set module diff --git a/modules.php b/modules.php index 52833e3ac4..1019638b45 100644 --- a/modules.php +++ b/modules.php @@ -38,10 +38,12 @@ require_once ("inc/libs/security_functions.php"); // Init "action" and "what" -global $what, $action; +global $what, $action, $startTime; +$GLOBALS['startTime'] = microtime(true); $CSS = 0; $GLOBALS['what'] = ""; $GLOBALS['action'] = ""; $GLOBALS['userid'] = 0; + if (!empty($_GET['action'])) $GLOBALS['action'] = secureString($_GET['action']); if (!empty($_GET['what'])) $GLOBALS['what'] = secureString($_GET['what']); if (empty($_GET['module'])) $_GET['module'] = "index"; diff --git a/show_bonus.php b/show_bonus.php index 2375215afc..caafa19b66 100644 --- a/show_bonus.php +++ b/show_bonus.php @@ -35,7 +35,8 @@ require_once("inc/libs/security_functions.php"); // Init "action" and "what" -global $what, $action; +global $what, $action, $startTime; +$GLOBALS['startTime'] = microtime(true); $GLOBALS['what'] = ""; $GLOBALS['action'] = ""; // Set this because we have no module in URI diff --git a/templates/de/html/footer_stats.tpl b/templates/de/html/footer_stats.tpl new file mode 100644 index 0000000000..66d78461b9 --- /dev/null +++ b/templates/de/html/footer_stats.tpl @@ -0,0 +1,13 @@ +
+ +
diff --git a/theme/business/css/general.css b/theme/business/css/general.css index bbcf9d8fe9..fa1b80f50d 100644 --- a/theme/business/css/general.css +++ b/theme/business/css/general.css @@ -584,11 +584,11 @@ DIV.admin_note { } .theme_box { - border : 1px solid #000000; - border-top : 0px; + border : 1px solid #000000; + border-top : 0px; width : 100%; height : 70px; - background-color : #FFFFFF; + background-color : #FFFFFF; } .theme_note { @@ -632,3 +632,32 @@ DIV.admin_note { .admin_message { margin-bottom : 15px; } + +#footer_stats_block { + margin-top : 5px; + tex-align : center; + border : solid 1px; + border-color : #000000; + background-color : #EEEEFF; + font-size : 10px; + vertical-align : middle; + width : 465px; + height : 22px; + z-index : 0; +} + +.footer_stats_column { + z-index : 10; + top : 3px; + background-color : #FFFFFF; + position : relative; + margin : 0px; + width : 150px; + display : block; + border : solid 1px; + border-color : #000000; +} + +.footer_stats_data { + font-weight : bold; +} diff --git a/theme/default/css/general.css b/theme/default/css/general.css index 01343bff5f..a8bf93ac87 100644 --- a/theme/default/css/general.css +++ b/theme/default/css/general.css @@ -650,3 +650,32 @@ DIV.admin_note { .admin_message { margin-bottom : 15px; } + +#footer_stats_block { + margin-top : 5px; + tex-align : center; + border : solid 1px; + border-color : #AA0044; + background-color : #ddeedd; + font-size : 10px; + vertical-align : middle; + width : 465px; + height : 22px; + z-index : 0; +} + +.footer_stats_column { + z-index : 10; + top : 3px; + background-color : #EEFFEE; + position : relative; + margin : 0px; + width : 150px; + display : block; + border : solid 1px; + border-color : #009900; +} + +.footer_stats_data { + font-weight : bold; +} diff --git a/theme/desert/css/general.css b/theme/desert/css/general.css index 504a7b3521..fc79ffac1a 100644 --- a/theme/desert/css/general.css +++ b/theme/desert/css/general.css @@ -1,7 +1,7 @@ body { background-color : #FFFFCC; - color : #880000; - font-family : Verdana, Arial, Geneva, Helvetica, sans-serif; + color : #880000; + font-family : Verdana, Arial, Geneva, Helvetica, sans-serif; font-size : 12px; letter-spacing : 1px; @@ -628,3 +628,32 @@ DIV.admin_note { .admin_message { margin-bottom : 15px; } + +#footer_stats_block { + margin-top : 5px; + tex-align : center; + border : solid 1px; + border-color : #880000; + background-color : #DDDDAA; + font-size : 10px; + vertical-align : middle; + width : 465px; + height : 22px; + z-index : 0; +} + +.footer_stats_column { + z-index : 10; + top : 3px; + background-color : #FFFFCC; + position : relative; + margin : 0px; + width : 150px; + display : block; + border : solid 1px; + border-color : #880000; +} + +.footer_stats_data { + font-weight : bold; +}