function tr2($str, $lang)
{
    global $language;
    load_language_file($lang);
    if (@$language[$lang][$str]) {
        $ref =& $language[$lang][$str];
        if (strpos($ref, "{") !== false) {
            return tpl_do_replace($ref, true);
        } else {
            return $ref;
        }
    } else {
        return $str . "No translation available (identifier: {$str})-todo";
    }
}
require_once $rootpath . 'lib/language.inc.php';
require_once $rootpath . 'lib/settings.inc.php';
// load HTML specific includes
require_once $rootpath . 'lib/cookie.class.php';
if ($cookie->is_set('lang')) {
    $lang = $cookie->get('lang');
}
//language changed?
if (isset($_POST['lang'])) {
    $lang = $_POST['lang'];
}
if (isset($_GET['lang'])) {
    $lang = $_GET['lang'];
}
// load language settings
load_language_file($lang);
// set locale
// print "$lang<br><br>";
switch ($lang) {
    case 'pl':
        setlocale(LC_TIME, 'pl_PL.UTF-8');
        break;
    case 'nl':
        setlocale(LC_TIME, 'nl_NL.UTF-8');
        break;
    case 'fr':
        setlocale(LC_TIME, 'fr_FR.UTF-8');
        break;
    case 'de':
        setlocale(LC_TIME, 'de_DE.UTF-8');
        break;
Example #3
0
function translate_string($code, $args)
{
    global $lcm_lang;
    global $debug;
    global $debug_tr;
    $highlight = false;
    $key_only = false;
    if (isset($debug_tr)) {
        $highlight = $debug_tr == 1;
        $key_only = $debug_tr == 2;
    }
    if (isset($_REQUEST['debug_tr'])) {
        $highlight = $_REQUEST['debug_tr'] == 1;
        $key_only = $_REQUEST['debug_tr'] == 2;
    }
    if ($key_only) {
        return $code;
    }
    // list of modules to process (ex: "module:my_string")
    $modules = array('lcm');
    if (strpos($code, ':')) {
        if (preg_match("/^([a-z\\/]+):(.*)\$/i", $code, $regs)) {
            $modules = explode("/", $regs[1]);
            $code = $regs[2];
        }
    }
    // go thgough all the modules until we find our string
    $text = '';
    while (!$text and list(, $module) = each($modules)) {
        $var = "i18n_" . $module . "_" . $lcm_lang;
        $load = false;
        if (!isset($GLOBALS[$var])) {
            load_language_file($lcm_lang, $module);
        }
        if (isset($GLOBALS[$var][$code])) {
            $cache_lang[$lcm_lang][$code] = 1;
        }
        if (isset($GLOBALS[$var])) {
            if (array_key_exists($code, $GLOBALS[$var])) {
                $text = $GLOBALS[$var][$code];
            }
        }
    }
    //
    // Languages which are not finished or late  (...)
    //
    // The preg_match check for code starting with [a-z] is to weed out
    // text which should not be translated anyway.
    if ($lcm_lang != 'en') {
        $text = preg_replace("/^<(NEW|MODIF)>/", "", $text);
        if (!$text && preg_match("/^[a-z]/", $code)) {
            lcm_debug($code . ": not found, falling back on english");
            $lcm_lang_temp = $lcm_lang;
            $lcm_lang = 'en';
            $text = translate_string($code, $args);
            $lcm_lang = $lcm_lang_temp;
        }
    }
    if (empty($text) || $text == '') {
        if (preg_match("/[a-z]/", $code)) {
            lcm_debug("Warning: translation string -" . $code . "- has no text");
        }
        $text = $code;
    }
    // Insert the variables into the strings
    if ($args) {
        while (list($name, $value) = each($args)) {
            $text = str_replace("@{$name}@", $value, $text);
        }
    }
    // If requested, highlight the translated string to help find strings
    // not in the translation system
    if ($highlight) {
        $text = "<span style='color: #ff0000'>" . $text . "</span>";
    }
    return $text;
}
Example #4
0
function forum_search($forum_search, $offset)
{
    if (!($db_forum_search = db_connect())) {
        return false;
    }
    if (!is_numeric($offset)) {
        return false;
    }
    if (($uid = bh_session_get_value('UID')) === false) {
        return false;
    }
    $lang = load_language_file();
    // Array to hold our forums in.
    $forums_array = array();
    if (strlen(trim($forum_search)) > 0) {
        $forum_search_array = explode(";", $forum_search);
        $forum_search_array = array_map('forum_search_array_clean', $forum_search_array);
        $forum_search_webtag = implode("%' OR FORUMS.WEBTAG LIKE '%", $forum_search_array);
        $forum_search_svalue = implode("%' OR FORUM_SETTINGS.SVALUE LIKE '%", $forum_search_array);
        $sql = "SELECT SQL_CALC_FOUND_ROWS CONCAT(FORUMS.DATABASE_NAME, '.', FORUMS.WEBTAG, '_') AS PREFIX, ";
        $sql .= "FORUMS.FID, FORUMS.ACCESS_LEVEL, USER_FORUM.INTEREST FROM FORUM_SETTINGS ";
        $sql .= "LEFT JOIN USER_FORUM ON (USER_FORUM.FID = FORUM_SETTINGS.FID ";
        $sql .= "AND USER_FORUM.UID = '{$uid}') LEFT JOIN FORUMS ON (FORUMS.FID = FORUM_SETTINGS.FID) ";
        $sql .= "WHERE FORUMS.ACCESS_LEVEL > -1 AND (FORUMS.WEBTAG LIKE ";
        $sql .= "'%{$forum_search_webtag}%' OR FORUM_SETTINGS.SVALUE LIKE ";
        $sql .= "'%{$forum_search_svalue}%') GROUP BY FORUMS.FID ";
        $sql .= "LIMIT {$offset}, 10";
        if (!($result_forums = db_query($sql, $db_forum_search))) {
            return false;
        }
        // Fetch the number of total results
        $sql = "SELECT FOUND_ROWS() AS ROW_COUNT";
        if (!($result_count = db_query($sql, $db_forum_search))) {
            return false;
        }
        list($forums_count) = db_fetch_array($result_count, DB_RESULT_NUM);
        if (db_num_rows($result_forums) > 0) {
            while ($forum_data = db_fetch_array($result_forums)) {
                $forum_fid = $forum_data['FID'];
                $forum_settings = forum_get_settings_by_fid($forum_fid);
                foreach ($forum_settings as $key => $value) {
                    if (!isset($forum_data[strtoupper($key)])) {
                        $forum_data[strtoupper($key)] = $value;
                    }
                }
                // Check the forum name is set. If it isn't set it to 'A Beehive Forum'
                if (!isset($forum_data['FORUM_NAME']) || strlen(trim($forum_data['FORUM_NAME'])) < 1) {
                    $forum_data['FORUM_NAME'] = "A Beehive Forum";
                }
                // Check the forum description variable is set.
                if (!isset($forum_data['FORUM_DESC'])) {
                    $forum_data['FORUM_DESC'] = "";
                }
                // Unread cut-off stamp.
                $unread_cutoff_stamp = forum_process_unread_cutoff($forum_settings);
                // Get available folders for queries below
                $folders = folder_get_available_by_forum($forum_fid);
                // User relationship constants
                $user_ignored = USER_IGNORED;
                $user_ignored_completely = USER_IGNORED_COMPLETELY;
                // Get any unread messages
                if (is_numeric($unread_cutoff_stamp) && $unread_cutoff_stamp !== false) {
                    $sql = "SELECT SUM(THREAD.LENGTH) - SUM(COALESCE(USER_THREAD.LAST_READ, 0)) ";
                    $sql .= "AS UNREAD_MESSAGES FROM {$forum_data['PREFIX']}THREAD THREAD ";
                    $sql .= "LEFT JOIN {$forum_data['PREFIX']}USER_THREAD USER_THREAD ";
                    $sql .= "ON (USER_THREAD.TID = THREAD.TID AND USER_THREAD.UID = '{$uid}') ";
                    $sql .= "WHERE THREAD.FID IN ({$folders}) ";
                    $sql .= "AND (THREAD.MODIFIED > FROM_UNIXTIME(UNIX_TIMESTAMP(NOW()) - ";
                    $sql .= "{$unread_cutoff_stamp}) OR {$unread_cutoff_stamp} = 0) ";
                    if (!($result_unread_count = db_query($sql, $db_forum_search))) {
                        return false;
                    }
                    list($unread_messages) = db_fetch_array($result_unread_count, DB_RESULT_NUM);
                    $forum_data['UNREAD_MESSAGES'] = $unread_messages;
                } else {
                    $forum_data['UNREAD_MESSAGES'] = 0;
                }
                // Total number of messages
                $sql = "SELECT SUM(THREAD.LENGTH) AS NUM_MESSAGES ";
                $sql .= "FROM {$forum_data['PREFIX']}THREAD THREAD ";
                $sql .= "WHERE THREAD.FID IN ({$folders}) ";
                if (!($result_messages_count = db_query($sql, $db_forum_search))) {
                    return false;
                }
                $num_messages_data = db_fetch_array($result_messages_count);
                if (!isset($num_messages_data['NUM_MESSAGES']) || is_null($num_messages_data['NUM_MESSAGES'])) {
                    $forum_data['NUM_MESSAGES'] = 0;
                } else {
                    $forum_data['NUM_MESSAGES'] = $num_messages_data['NUM_MESSAGES'];
                }
                // Get unread to me message count
                $sql = "SELECT COUNT(POST.PID) AS UNREAD_TO_ME ";
                $sql .= "FROM {$forum_data['PREFIX']}THREAD THREAD ";
                $sql .= "LEFT JOIN {$forum_data['PREFIX']}POST POST ";
                $sql .= "ON (POST.TID = THREAD.TID) WHERE THREAD.FID IN ({$folders}) ";
                $sql .= "AND POST.TO_UID = '{$uid}' AND POST.VIEWED IS NULL ";
                if (!($result_unread_to_me = db_query($sql, $db_forum_search))) {
                    return false;
                }
                $post_count_data = db_fetch_array($result_unread_to_me);
                if (!isset($post_count_data['UNREAD_TO_ME']) || is_null($post_count_data['UNREAD_TO_ME'])) {
                    $forum_data['UNREAD_TO_ME'] = 0;
                } else {
                    $forum_data['UNREAD_TO_ME'] = $post_count_data['UNREAD_TO_ME'];
                }
                // Sometimes the USER_THREAD table might have a higher count that the thread
                // length due to table corruption. I've only seen this on the SF provided
                // webspace but none the less we do this check here anyway.
                if ($forum_data['NUM_MESSAGES'] < 0) {
                    $forum_data['NUM_MESSAGES'] = 0;
                }
                if ($forum_data['UNREAD_MESSAGES'] < 0) {
                    $forum_data['UNREAD_MESSAGES'] = 0;
                }
                if ($forum_data['UNREAD_TO_ME'] < 0) {
                    $forum_data['UNREAD_TO_ME'] = 0;
                }
                // Get Last Visited
                $sql = "SELECT UNIX_TIMESTAMP(LAST_VISIT) AS LAST_VISIT FROM USER_FORUM ";
                $sql .= "WHERE UID = '{$uid}' AND FID = '{$forum_fid}' ";
                $sql .= "AND LAST_VISIT IS NOT NULL AND LAST_VISIT > 0";
                if (!($result_last_visit = db_query($sql, $db_forum_search))) {
                    return false;
                }
                $user_last_visit_data = db_fetch_array($result_last_visit);
                if (!isset($user_last_visit_data['LAST_VISIT']) || is_null($user_last_visit_data['LAST_VISIT'])) {
                    $forum_data['LAST_VISIT'] = 0;
                } else {
                    $forum_data['LAST_VISIT'] = $user_last_visit_data['LAST_VISIT'];
                }
                $forums_array[] = $forum_data;
            }
        } else {
            if ($forums_count > 0) {
                $offset = floor(($forums_count - 1) / 10) * 10;
                return forum_search($forum_search, $offset);
            }
        }
    }
    return array('forums_array' => $forums_array, 'forums_count' => $forums_count);
}
Example #5
0
function check_language()
{
    if (isset($_COOKIE['language'])) {
        return load_language_file($_COOKIE['language'] . '.xml');
    } else {
        setcookie("language", "english", time() + 3600, "/");
        return load_language_file("english.xml");
    }
}
Example #6
0
function get_secret_questions($type = 'string', $notags = FALSE)
{
    // create our return array and load the secret questions language file
    $type == 'string' ? $return = '' : ($return = array());
    $vars = load_language_file('secret_questions');
    // Add option tags
    foreach ($vars as $key => $q) {
        if ($type == 'string') {
            $return .= "<option value='" . $key . "'>" . $q . "</option>\n";
        } else {
            if ($notags == TRUE) {
                $return[$key] = $q;
            } else {
                $return[$key] = "<option value='" . $key . "'>" . $q . "</option>";
            }
        }
    }
    // Return the questions
    return $return;
}
Example #7
0
 public function wowlib($id = 0, $instance_as = FALSE)
 {
     // Get our realm id if none is provieded
     if ($id === 0) {
         $id = config('default_realm_id');
     }
     // Make sure we havent loaded the lib already
     $Obj = \Registry::load('Wowlib_r' . $id);
     if ($Obj !== NULL) {
         return $Obj;
     }
     // Make sure the wowlib is initialized
     if (!class_exists('Wowlib', false)) {
         $this->_initWowlib();
     }
     // Load our driver name
     $DB = $this->database('DB', FALSE);
     $realm = $DB->query("SELECT `id`, `name`, `driver`, `char_db`, `world_db` FROM `pcms_realms` WHERE `id`=" . $id)->fetchRow();
     // Make sure we didnt get a false DB return
     if ($realm === FALSE) {
         $language = load_language_file('messages');
         $message = $language['wowlib_realm_doesnt_exist'];
         show_error($message, array($id), E_ERROR);
     }
     // Add debug tracer
     \Debug::trace('Loading Wowlib driver "' . $realm['driver'] . '"', __FILE__, __LINE__);
     // Unserialize our database information
     $char = unserialize($realm['char_db']);
     $world = unserialize($realm['world_db']);
     // Init the driver
     $class = \Wowlib::load($realm['driver'], $char, $world);
     // Store the class statically and return the class
     \Registry::store('Wowlib_r' . $id, $class);
     // Check to see if the user wants to instance
     if ($instance_as !== FALSE) {
         get_instance()->{$instance_as} = $class;
     }
     return $class;
 }