Beispiel #1
0
 public static function getPhraseInfo($languageId, $phraseGroups = array())
 {
     self::$phraseGroups = array_merge(self::$phraseGroups, $phraseGroups);
     $params[vB_dB_Query::TYPE_KEY] = vB_dB_Query::QUERY_METHOD;
     $params['languageid'] = $languageId;
     $params['phrasegroups'] = self::$phraseGroups;
     self::$phraseGroups = array();
     ksort($params);
     $cacheKey = md5(json_encode($params));
     $ret = self::getPhraseCache($cacheKey);
     if (!$ret) {
         $result = vB::getDbAssertor()->assertQuery('fetchLanguage', $params);
         if ($result and $result->valid()) {
             $current = $result->current();
             if (isset($current['phrasegroup_global'])) {
                 vB_Phrase::addPhrases(array('global' => unserialize($current['phrasegroup_global'])));
             }
             self::setPhraseCache($cacheKey, $current);
             $ret = $current;
         }
     }
     return $ret;
 }
Beispiel #2
0
 /** Loads basic language information
  */
 public function loadLanguage()
 {
     $allLanguages = vB::getDatastore()->getValue('languagecache');
     if (is_array($allLanguages) and !array_key_exists($this->vars['languageid'], $allLanguages)) {
         if (!empty($this->userinfo['languageid']) and array_key_exists($this->userinfo['languageid'], $allLanguages)) {
             $this->vars['languageid'] = $this->userinfo['languageid'];
         } else {
             if (vB::getDatastore()->getOption('languageid')) {
                 $this->vars['languageid'] = vB::getDatastore()->getOption('languageid');
             } else {
                 $this->vars['languageid'] = 1;
             }
         }
     }
     $language = vB_Language::getPhraseInfo($this->vars['languageid']);
     if (isset($language['lang_options']) and !is_array($language['lang_options'])) {
         //convert bitfields to arrays for external clients.
         $bitfields = vB::getDatastore()->getValue('bf_misc_languageoptions');
         if (is_array($bitfields)) {
             $lang_options = $language['lang_options'];
             $language['lang_options'] = array();
             foreach ($bitfields as $key => $value) {
                 $language['lang_options'][$key] = (bool) ($lang_options & $value);
             }
         }
     }
     if (!empty($language)) {
         if (!empty($this->userinfo)) {
             foreach ($language as $_arrykey => $_arryval) {
                 $this->userinfo[$_arrykey] = $_arryval;
             }
         } else {
             foreach ($language as $_arrykey => $_arryval) {
                 $this->vars[$_arrykey] = $_arryval;
             }
         }
     } else {
         if (!defined('VB_UNITTEST')) {
             trigger_error('The requested language does not exist, reset via tools.php.', E_USER_ERROR);
         }
     }
 }
Beispiel #3
0
    $cwd = getcwd();
    if (is_link($cwd)) {
        $cwd = dirname(dirname($_SERVER["SCRIPT_FILENAME"]));
    } else {
        if (empty($cwd)) {
            $cwd = '.';
        }
    }
    define('CWD', $cwd);
}
if (!defined('VB_API')) {
    define('VB_API', false);
}
require_once CWD . '/includes/init.php';
require_once DIR . '/includes/adminfunctions.php';
vB_Language::preloadPhraseGroups($phrasegroups);
//Force load of the user information
vB::getCurrentSession()->loadPhraseGroups();
$vb5_config =& vB::getConfig();
$assertor = vB::getDbAssertor();
// ###################### Start headers (send no-cache) #######################
exec_nocache_headers();
if ($vbulletin->userinfo['cssprefs'] != '') {
    $vbulletin->options['cpstylefolder'] = $vbulletin->userinfo['cssprefs'];
}
# cache full permissions so scheduled tasks will have access to them
$permissions = cache_permissions($vbulletin->userinfo);
$vbulletin->userinfo['permissions'] =& $permissions;
if (!vB::getUserContext()->hasAdminPermission('cancontrolpanel') and !vB::getUserContext()->hasPermission('adminpermissions', 'cancontrolpanel')) {
    $checkpwd = 1;
}