+
+// 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("show_timings", false, $content);
+}
+
+// Unset/set session variables
+function set_session ($var, $value) {
+ global $CSS;
+ // Abort in CSS mode here
+ if ($CSS == 1) return true;
+
+ // Trim value and session variable
+ $var = trim(SQL_ESCAPE($var)); $value = trim($value);
+
+ // Is the session variable set?
+ if (("".$value."" == "") && (isSessionVariableSet($var))) {
+ // Remove the session
+ //* DEBUG: */ echo "UNSET:".$var."=".get_session($var)."<br />\n";
+ unset($_SESSION[$var]);
+ return session_unregister($var);
+ } elseif (("".$value."" != '') && (!isSessionVariableSet($var))) {
+ // Set session
+ //* DEBUG: */ echo "SET:".$var."=".$value."<br />\n";
+ $_SESSION[$var] = $value;
+ return session_register($var);
+ }
+
+ // Return always true if the session variable is already set.
+ // Keept me busy for a longer while...
+ //* DEBUG: */ echo "IGNORED:".$var."=".$value."<br />\n";
+ return true;
+}
+// Check wether a boolean constant is set
+// Taken from user comments in PHP documentation for function constant()
+function isBooleanConstantAndTrue($constname) { // : Boolean
+ $res = false;
+ if (defined($constname)) $res = (constant($constname) === true);
+ return($res);
+}
+
+// Check wether a session variable is set
+function isSessionVariableSet($var) {
+ return (isset($_SESSION[$var]));
+}
+
+// Returns wether the value of the session variable or NULL if not set
+function get_session($var) {
+ if (!isset($_SESSION)) session_start();
+
+ // Default is not found! ;-)
+ $value = null;
+
+ // Is the variable there?
+ if (isSessionVariableSet($var)) {
+ // Then get it secured!
+ $value = SQL_ESCAPE($_SESSION[$var]);
+ }
+
+ // Return the value
+ return $value;
+}
+