- // Log unknown gender
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown gender %s detected.", $gender));
- break;
- }
-
- // Return translated gender
- return $ret;
-}
-
-//
-function FRAMETESTER ($URL) {
- // Prepare frametester URL
- $frametesterUrl = sprintf("%s/modules.php?module=frametester&url=%s",
- URL,
- encodeString(compileUriCode($URL))
- );
- return $frametesterUrl;
-}
-
-//
-function SELECTION_COUNT ($array) {
- $ret = 0;
- if (is_array($array)) {
- foreach ($array as $key => $selected) {
- if (!empty($selected)) $ret++;
- }
- }
- return $ret;
-}
-//
-function IMG_CODE ($code, $type, $DATA, $uid) {
- return "<IMG border=\"0\" alt=\"Code\" src=\"{!URL!}/mailid_top.php?uid=".$uid."&".$type."=".$DATA."&mode=img&code=".$code."\">";
-}
-//
-function TRANSLATE_STATUS ($status) {
- switch ($status)
- {
- case "UNCONFIRMED":
- case "CONFIRMED":
- case "LOCKED":
- $ret = getMessage(sprintf("ACCOUNT_%s", $status));
- break;
-
- case "":
- case null:
- $ret = getMessage('ACCOUNT_DELETED');
- break;
-
- default:
- DEBUG_LOG(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
- $ret = sprintf(getMessage('UNKNOWN_STATUS"'), $status);
- break;
- }
-
- // Return it
- return $ret;
-}
-//
-function GET_LANGUAGE() {
- // Set default return value to default language from config
- $ret = constant('DEFAULT_LANG');
-
- // Init variable
- $lang = "";
-
- // Is the variable set
- if (REQUEST_ISSET_GET(('mx_lang'))) {
- // Accept only first 2 chars
- $lang = substr(REQUEST_GET('mx_lang'), 0, 2);
- } elseif (isset($GLOBALS['cache_array']['language'])) {
- // Use cached
- $ret = $GLOBALS['cache_array']['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
- $GLOBALS['cache_array']['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, $_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)), __FUNCTION__, __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)), __FUNCTION__, __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