- // Set default return value to default language from config
- $ret = constant('DEFAULT_LANG');
-
- // Init variable
- $lang = "";
-
- // Is the variable set
- if (!empty($_GET['mx_lang'])) {
- // Accept only first 2 chars
- $lang = substr($_GET['mx_lang'], 0, 2);
- } elseif (isset($cacheArray['language'])) {
- // Use cached
- $ret = $cacheArray['language'];
- } elseif (!empty($lang)) {
- // Check if main language file does exist
- if (FILE_READABLE(constant('PATH')."inc/language/".$lang.".php")) {
- // Okay found, so let's update cookies
- SET_LANGUAGE($lang);
- }
- } elseif (!isSessionVariableSet('mx_lang')) {
- // Return stored value from cookie
- $ret = get_session('mx_lang');
-
- // Fixes a warning before the session has the mx_lang constant
- if (empty($ret)) $ret = constant('DEFAULT_LANG');
- }
-
- // Cache entry
- $cacheArray['language'] = $ret;
-
- // Return value
- return $ret;
-}
-//
-function SET_LANGUAGE ($lang) {
- // Accept only first 2 chars!
- $lang = substr(SQL_ESCAPE(strip_tags($lang)), 0, 2);
-
- // Set cookie
- set_session('mx_lang', $lang);
-}
-//
-function LOAD_EMAIL_TEMPLATE($template, $content=array(), $UID="0") {
- global $DATA, $REPLACER, $_CONFIG;
-
- // Make sure all template names are lowercase!
- $template = strtolower($template);
-
- // Default "nickname" if extension is not installed
- $nick = "---";
-
- // Prepare IP number and User Agent
- $REMOTE_ADDR = GET_REMOTE_ADDR();
- $HTTP_USER_AGENT = GET_USER_AGENT();
-
- // Default admin
- $ADMIN = constant('MAIN_TITLE');
-
- // Is the admin logged in?
- if (IS_ADMIN()) {
- // Get admin id
- $aid = GET_CURRENT_ADMIN_ID();
-
- // Load Admin data
- $ADMIN = GET_ADMIN_EMAIL($aid);
- } // END - if
-
- // Neutral email address is default
- $email = constant('WEBMASTER');
-
- // Expiration in a nice output format
- if (getConfig('auto_purge') == 0) {
- // Will never expire!
- $EXPIRATION = getMessage('MAIL_WILL_NEVER_EXPIRE');
- } else {
- // Create nice date string
- $EXPIRATION = CREATE_FANCY_TIME(getConfig('auto_purge'));
- }
-
- // Is content an array?
- if (is_array($content)) {
- // Add expiration to array, $EXPIRATION is now deprecated!
- $content['expiration'] = $EXPIRATION;
- } // END - if
-
- // Load user's data
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):UID={$UID},template={$template},content[]=".gettype($content)."<br />\n";
- if (($UID > 0) && (is_array($content))) {
- // If nickname extension is installed, fetch nickname as well
- if (EXT_IS_ACTIVE("nickname")) {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NICKNAME!<br />\n";
- // Load nickname
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email, nickname FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FILE__, __LINE__);
- } else {
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):NO-NICK!<br />\n";
- /// Load normal data
- $result = SQL_QUERY_ESC("SELECT surname, family, gender, email FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
- array(bigintval($UID)), __FILE__, __LINE__);
- }
-
- // Fetch and merge data
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - PRE<br />\n";
- $content = merge_array($content, SQL_FETCHARRAY($result));
- //* DEBUG: */ print __FUNCTION__."(<font color=\"#0000aa\">".__LINE__."</font>):content()=".count($content)." - AFTER<br />\n";
-
- // Free result
- SQL_FREERESULT($result);
- } // END - if
-
- // Translate M to male or F to female if present
- if (isset($content['gender'])) $content['gender'] = TRANSLATE_GENDER($content['gender']);
-
- // Overwrite email from data if present
- if (isset($content['email'])) $email = $content['email'];
-
- // Store email for some functions in global data array
- $DATA['email'] = $email;
-
- // Base directory
- $BASE = sprintf("%stemplates/%s/emails/", constant('PATH'), GET_LANGUAGE());
-
- // Check for admin/guest/member templates
- if (strpos($template, "admin_") > -1) {
- // Admin template found
- $FQFN = $BASE."admin/".$template.".tpl";
- } elseif (strpos($template, "guest_") > -1) {
- // Guest template found
- $FQFN = $BASE."guest/".$template.".tpl";
- } elseif (strpos($template, "member_") > -1) {
- // Member template found
- $FQFN = $BASE."member/".$template.".tpl";
- } else {
- // Test for extension
- $test = substr($template, 0, strpos($template, "_"));
- if (EXT_IS_ACTIVE($test)) {
- // Set extra path to extension's name
- $FQFN = $BASE.$test."/".$template.".tpl";
- } else {
- // No special filename
- $FQFN = $BASE.$template.".tpl";
- }
- }
-
- // Does the special template exists?
- if (!FILE_READABLE($FQFN)) {
- // Reset to default template
- $FQFN = $BASE.$template.".tpl";
- } // END - if
-
- // Now does the final template exists?
- $newContent = "";
- if (FILE_READABLE($FQFN)) {
- // The local file does exists so we load it. :)
- $tmpl_file = READ_FILE($FQFN);
- $tmpl_file = SQL_ESCAPE($tmpl_file);
-
- // Run code
- $tmpl_file = "\$newContent = decodeEntities(\"".COMPILE_CODE($tmpl_file)."\");";
- @eval($tmpl_file);
- } elseif (!empty($template)) {
- // Template file not found!
- $newContent = "{--TEMPLATE_404--}: ".$template."<br />
-{--TEMPLATE_CONTENT--}
-<pre>".print_r($content, true)."</pre>
-{--TEMPLATE_DATA--}
-<pre>".print_r($DATA, true)."</pre>
-<br /><br />";
-
- // Debug mode not active? Then remove the HTML tags
- if (!isBooleanConstantAndTrue('DEBUG_MODE')) $newContent = strip_tags($newContent);
- } else {
- // No template name supplied!
- $newContent = getMessage('NO_TEMPLATE_SUPPLIED');
- }
-
- // Is there some content?
- if (empty($newContent)) {
- // Compiling failed
- $newContent = "Compiler error for template {$template}!\nUncompiled content:\n".$tmpl_file;
- // Add last error if the required function exists
- if (function_exists('error_get_last')) $newContent .= "\n--------------------------------------\nDebug:\n".print_r(error_get_last(), true)."--------------------------------------\nPlease don't alter these informations!\nThanx.";
- } // END - if
-
- // Remove content and data
- unset($content);
- unset($DATA);
-
- // Return compiled content
- return COMPILE_CODE($newContent);
-}
-//
-function MAKE_TIME($H, $M, $S, $stamp) {
- // Extract day, month and year from given timestamp
- $DAY = date("d", $stamp);
- $MONTH = date("m", $stamp);
- $YEAR = date('Y', $stamp);