Script stats added in footer
authorRoland Häder <roland@mxchange.org>
Fri, 15 Feb 2008 20:11:38 +0000 (20:11 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 15 Feb 2008 20:11:38 +0000 (20:11 +0000)
16 files changed:
.gitattributes
beg.php
doubler.php
inc/db/lib-mysql3.php
inc/extensions/ext-sql_patches.php
inc/footer.php
inc/functions.php
inc/language/de.php
inc/mysql-manager.php
lead-confirm.php
modules.php
show_bonus.php
templates/de/html/footer_stats.tpl [new file with mode: 0644]
theme/business/css/general.css
theme/default/css/general.css
theme/desert/css/general.css

index b9b6e7083233836001c0f7f02cccec14de093a6b..0c724543c3b4cbda0edbe0b79cdffd4f8fd5f24f 100644 (file)
@@ -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/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
 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 8ce941981883112c4e54aea02a84885a874ac099..b7bb846df547083fed4a93765da87a9a1c1d48a9 100644 (file)
--- a/beg.php
+++ b/beg.php
@@ -35,7 +35,8 @@
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 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
 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
 
 // Set module
index 356821765a6cce419cd0f9eac0c500458e503351..9d3a4432e6e505ac08e3aa9eaf91a8f8552a6031 100644 (file)
@@ -35,7 +35,8 @@
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 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
 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
 
 // Set module
index c463f8de30061e4f730a9fd20d85a687c57cc927..03e2d736f210b345261d705945717c45062c1a9e 100644 (file)
@@ -49,8 +49,12 @@ function SQL_QUERY($sql_string, $F, $L)
 ".MYSQL_QUERY_STRING."<br />
 ".$sql_string);
 
 ".MYSQL_QUERY_STRING."<br />
 ".$sql_string);
 
-       // Debug output
-       //* DEBUG: */ print "Query=<em>".$sql_string."</em>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
+        // Count this query
+        if (!isset($CONFIG['sql_count'])) $CONFIG['sql_count'] = 0;
+        $CONFIG['sql_count']++;
+
+        // Debug output
+        //* DEBUG: */ print "Query=<em>".$sql_string."</em>, affected=<b>".SQL_AFFECTEDROWS()."</b>, numrows=<b>".SQL_NUMROWS($result)."</b><br />\n";
 
        if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL))
        {
 
        if (($CSS != "1") && ($CSS != "-1") && (DEBUG_MODE) && (DEBUG_SQL))
        {
index 0a2a307e920f75e33dfe8c1e9a771eade31c3492..c2c69b44947a4548f5cbba3eb7d3a54d7b3701c0 100644 (file)
@@ -39,13 +39,13 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])))
 }
 
 // Version number
 }
 
 // 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)
 
 // 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)
 {
 
 switch ($EXT_LOAD_MODE)
 {
@@ -515,10 +515,11 @@ PRIMARY KEY (id)
                break;
 
        case "0.4.1": // SQL queries for v0.4.1
                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 (these will be set as task text!)
-               $UPDATE_NOTES = "Tabellen-Schl&uuml;ssel neu gesetzt.";
+               $UPDATE_NOTES = "Tabellen-Schl&uuml;ssel neu gesetzt und Parsing-Zeit im Footer eingeblendet.";
                break;
        }
        break;
                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['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'])))
 
                // Read key from secret file
                if ((empty($CONFIG['file_hash'])) || (empty($CONFIG['master_salt'])) || (empty($CONFIG['pass_scramble'])))
index 42b4e4315d91a81d1c3137dd3b5bb23e71b95c71..440d1bc81f877853e82594bb2636a02dca4f5120 100644 (file)
@@ -52,6 +52,12 @@ if (($footer != "1") && ($footer != "2") && ($CSS != "1")) {
                LOAD_TEMPLATE("copyright");
        }
 
                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");
 
        // Load page footer
        LOAD_TEMPLATE("page_footer");
 
index 6594d72fb6fe9dac0ebe7e76bf8cc9773b3a216a..021edbe8793423f4caec6d95b793a1c39304244e 100644 (file)
@@ -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
 // 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 = "";
        $ACTION = SQL_ESCAPE($GLOBALS['action']);
        $WHAT = SQL_ESCAPE($GLOBALS['what']);
        $ret = "";
@@ -2028,6 +2034,36 @@ function mxchange_die ($msg) {
        // Exit explicitly
        exit;
 }
        // 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);
+}
+
 //
 //////////////////////////////////////////////
 //                                          //
 //
 //////////////////////////////////////////////
 //                                          //
index 6bda938d2118583e30a90ac653b62397577b109e..b352132fcdd487e832a78c07c8fda6b6c0bc7c64 100644 (file)
@@ -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('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.");
 
 //
 ?>
 
 //
 ?>
index 1d87752921cfa0fab7d0b9b37cfc618e05ccb2e8..ad4a3bdb69e99b36e9b42a7b503324ac344921ac 100644 (file)
@@ -1620,5 +1620,6 @@ function MODULE_HAS_MENU($mod)
        // Return status
        return $ret;
 }
        // Return status
        return $ret;
 }
+
 //
 ?>
 //
 ?>
index 76b2c9b45544425e90b654c86857ca36777de03c..e04ea259b5c6ba0b8b0f2bdb56aa5cc000e3ed49 100644 (file)
@@ -35,7 +35,8 @@
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 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
 $GLOBALS['what'] = ""; $GLOBALS['action'] = "";
 
 // Set module
index 52833e3ac429b73b9d8fe5f20cac48cc0ea17299..1019638b45a0e932a7e34e120ffb2c8e35ea7bd5 100644 (file)
 require_once ("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 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;
 $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";
 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";
index 2375215afcf0dd47b15f0965eb15fb95ff5c8dc0..caafa19b66f3c0d1adbab71e918a775cdf524763 100644 (file)
@@ -35,7 +35,8 @@
 require_once("inc/libs/security_functions.php");
 
 // Init "action" and "what"
 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
 $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 (file)
index 0000000..66d7846
--- /dev/null
@@ -0,0 +1,13 @@
+<DIV align="center">
+       <DIV id="footer_stats_block">
+               <DIV class="footer_stats_column" style="float:right; margin-right: 2px">
+                       {--FOOTER_STATS_NUM_TEMPLATES--}&nbsp;<SPAN class="footer_stats_data">$content[numTemplates]</SPAN>
+               </DIV>
+               <DIV class="footer_stats_column" style="float: left; margin-left: 2px">
+                       {--FOOTER_STATS_RUNTIME--}&nbsp;<SPAN class="footer_stats_data">$content[runtime]</SPAN>&nbsp;{--FOOTER_STATS_SECS--}
+               </DIV>
+               <DIV class="footer_stats_column" align="center">
+                       {--FOOTER_STATS_SQL_QUERIES--}&nbsp;<SPAN class="footer_stats_data">$content[numSQLs]</SPAN>
+               </DIV>
+       </DIV>
+</DIV>
index bbcf9d8fe9eb06aface9efe69b86ccdc0da3ebdb..fa1b80f50d1701749a7c2c76faf78977350e9300 100644 (file)
@@ -584,11 +584,11 @@ DIV.admin_note {
 }
 
 .theme_box {
 }
 
 .theme_box {
-     border              : 1px solid #000000;
-     border-top          : 0px;
+       border              : 1px solid #000000;
+       border-top          : 0px;
        width               : 100%;
        height              : 70px;
        width               : 100%;
        height              : 70px;
-     background-color    : #FFFFFF;
+       background-color    : #FFFFFF;
 }
 
 .theme_note {
 }
 
 .theme_note {
@@ -632,3 +632,32 @@ DIV.admin_note {
 .admin_message {
        margin-bottom   : 15px;
 }
 .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;
+}
index 01343bff5f4a03e137b201981b3734d3d3942f9a..a8bf93ac8775940303c0e3f1e5eb373fc70d6909 100644 (file)
@@ -650,3 +650,32 @@ DIV.admin_note {
 .admin_message {
        margin-bottom   : 15px;
 }
 .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;
+}
index 504a7b3521934877ae529954fb8de2448296783b..fc79ffac1a5da4947ab5c8ecbecf66f310979132 100644 (file)
@@ -1,7 +1,7 @@
 body {
        background-color        : #FFFFCC;
 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;
 
        font-size                       : 12px;
        letter-spacing      : 1px;
 
@@ -628,3 +628,32 @@ DIV.admin_note {
 .admin_message {
        margin-bottom   : 15px;
 }
 .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;
+}