]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Script stats added in footer
[mailer.git] / inc / functions.php
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
-       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);
+}
+
 //
 //////////////////////////////////////////////
 //                                          //