+
+// 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);
+ } elseif (!empty($value)) {
+ // Update session
+ $_SESSION[$var] = $value;
+ } else {
+ // Something bad happens!
+ return false; // Hope this doesn't make so much trouble???
+ }
+
+ // 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) {
+ // 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;
+}
+// Send notification to admin
+function SEND_ADMIN_NOTIFICATION($subject, $templateName, $content="", $uid="0") {
+ if (GET_EXT_VERSION("admins") >= "0.4.1") {
+ // Send new way
+ SEND_ADMIN_EMAILS_PRO($subject, $templateName, $content, $uid);
+ } else {
+ // Send outdated way
+ $msg = LOAD_EMAIL_TEMPLATE($templateName, $content, $uid);
+ SEND_ADMIN_EMAILS($subject, $msg);
+ }
+}
+// Destroy user session
+function destroy_user_session () {
+ // Remove all user data from session
+ return ((set_session("userid", "")) && (set_session("u_hash", "")) && (set_session("lifetime", "")));
+}
+// Merges an array together but only if both are arrays
+function merge_array ($array1, $array2) {
+ // Are both an array?
+ if ((is_array($array1)) && (is_array($array2))) {
+ // Merge all together
+ return array_merge($array1, $array2);
+ } elseif (is_array($array1)) {
+ // Return left array
+ return $array1;
+ }
+
+ // Something wired happened here...
+ print(__FUNCTION__.":<pre>");
+ debug_print_backtrace();
+ die("</pre>");
+}