Beispiel #1
0
 function setup($lang_set = false, $style = false)
 {
     global $db, $template, $theme, $board_config, $phpEx, $phpbb_root_path, $mvModules;
     global $nav_links;
     if ($this->data['user_id'] != ANONYMOUS) {
         $this->lang_name = file_exists($phpbb_root_path . 'language/lang_' . $this->data['user_lang'] . "/lang_main.{$phpEx}") ? $this->data['user_lang'] : $board_config['default_lang'];
         $this->date_format = $this->data['user_dateformat'];
         $this->timezone = $this->data['user_timezone'] * 3600;
         $this->dst = 0;
         // Here (Dave Leave Here)
     } else {
         $this->lang_name = $board_config['default_lang'];
         $this->date_format = $board_config['default_dateformat'];
         $this->timezone = $board_config['board_timezone'] * 3600;
         $this->dst = 0;
         // Here (Dave Leave Here)
     }
     $this->lang_path = $phpbb_root_path . 'language/lang_' . $this->lang_name . '/';
     $this->lang_module_path = $phpbb_root_path . 'modules/%s/language/lang_' . $this->lang_name . '/';
     if ($board_config['override_user_style'] || $this->data['user_id'] == ANONYMOUS) {
         // Force Default or we are a Guest
         $style = $board_config['default_style'];
     } elseif (isset($_GET['style']) && $_GET['style'] != $style) {
         // Style ID Passed via GET takes priority
         global $SID;
         $style = intval($_GET['style']);
         $SID .= '&style=' . $style;
     } elseif ($style === FALSE) {
         $style = $this->data['user_style'];
     }
     $inc_langs = array();
     // Languages We Need to Include.
     $inc_langs[] = 'main';
     // $inc_langs[] = 'rate'; // HOW UGLY!!!!!!!!!!!!!!!!!!!!!!!!!
     if (defined('IN_ADMIN')) {
         $inc_langs[] = 'admin';
     }
     if (defined('IN_CASHMOD')) {
         $inc_langs[] = 'cash';
     }
     foreach ($mvModules as $name => $value) {
         if ($value['state'] != 1 && $value['state'] != 5) {
             continue;
         }
         $inc_langs[] = "{$name}:main";
         if (defined('IN_ADMIN')) {
             $inc_langs[] = "{$name}:admin";
         }
     }
     $this->add_lang($inc_langs);
     $this->add_lang($lang_set);
     $this->lang_extend();
     $theme = $this->setup_style($style);
     global $mods, $list_yes_no;
     //  get all the mods settings
     $dir = @opendir($phpbb_root_path . 'includes/mods_settings');
     while (($file = @readdir($dir)) !== FALSE) {
         if (preg_match("/^mod_.*?\\." . $phpEx . "\$/", $file)) {
             include_once $phpbb_root_path . 'includes/mods_settings/' . $file;
         }
     }
     @closedir($dir);
     global $admin_level, $level_prior, $level_desc;
     global $values_list, $tables_linked, $classes_fields, $user_maps, $user_fields;
     global $list_yes_no;
     include_once $phpbb_root_path . 'profilcp/functions_profile.' . $phpEx;
     read_cookies($this->data);
     global $tree;
     if (!isset($tree['auth']) || empty($tree['auth'])) {
         get_user_tree($this->data);
     }
     $endtime = explode(' ', microtime());
     //echo (( $endtime[0] + $endtime[1] ) - $begin_t) . "<br />";
     //echo $db->num_queries - $b4;
     unset($endtime);
     //
     // Mozilla navigation bar
     // Default items that should be valid on all pages.
     // Defined here to correctly assign the Language Variables
     // and be able to change the variables within code.
     //
     $nav_links['top'] = array('url' => append_sid($phpbb_root_path . 'index.' . $phpEx), 'title' => sprintf($this->lang['Forum_Index'], $board_config['sitename']));
     $nav_links['search'] = array('url' => append_sid($phpbb_root_path . 'search.' . $phpEx), 'title' => $this->lang['Search']);
     $nav_links['help'] = array('url' => append_sid($phpbb_root_path . 'faq.' . $phpEx), 'title' => $this->lang['FAQ']);
     $nav_links['author'] = array('url' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx), 'title' => $this->lang['Memberlist']);
     return;
 }
Beispiel #2
0
function init_userprefs($userdata)
{
    global $db, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS;
    global $board_config, $theme, $images;
    global $template, $lang, $phpEx, $phpbb_root_path, $db;
    global $nav_links;
    if ($userdata['user_id'] != ANONYMOUS) {
        if (!empty($userdata['user_lang'])) {
            $default_lang = phpbb_ltrim(basename(phpbb_rtrim($userdata['user_lang'])), "'");
        }
        if (!empty($userdata['user_dateformat'])) {
            $board_config['default_dateformat'] = $userdata['user_dateformat'];
        }
        if (isset($userdata['user_timezone'])) {
            $board_config['board_timezone'] = $userdata['user_timezone'];
        }
        if (isset($userdata['user_use_rel_date'])) {
            $board_config['ty_use_rel_date'] = $userdata['user_use_rel_date'];
        }
        if (isset($userdata['user_use_rel_time'])) {
            $board_config['ty_use_rel_time'] = $userdata['user_use_rel_time'];
        }
    } else {
        $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
    }
    if (!file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.' . $phpEx))) {
        if ($userdata['user_id'] != ANONYMOUS) {
            // For logged in users, try the board default language next
            $default_lang = phpbb_ltrim(basename(phpbb_rtrim($board_config['default_lang'])), "'");
        } else {
            // For guests it means the default language is not present, try english
            // This is a long shot since it means serious errors in the setup to reach here,
            // but english is part of a new install so it's worth us trying
            $default_lang = 'french';
        }
        if (!file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $default_lang . '/lang_main.' . $phpEx))) {
            message_die(CRITICAL_ERROR, 'Could not locate valid language pack');
        }
    }
    // If we've had to change the value in any way then let's write it back to the database
    // before we go any further since it means there is something wrong with it
    if ($userdata['user_id'] != ANONYMOUS && $userdata['user_lang'] !== $default_lang) {
        $sql = 'UPDATE ' . USERS_TABLE . "\r\n\t\t\tSET user_lang = '" . $default_lang . "'\r\n\t\t\tWHERE user_lang = '" . $userdata['user_lang'] . "'";
        if (!($result = $db->sql_query($sql))) {
            message_die(CRITICAL_ERROR, 'Could not update user language info');
        }
        $board_config['default_lang'] = $default_lang;
        $userdata['user_lang'] = $default_lang;
    } elseif ($board_config['default_lang'] !== $default_lang) {
        $sql = 'UPDATE ' . CONFIG_TABLE . "\r\n\t\t\tSET config_value = '" . $default_lang . "'\r\n\t\t\tWHERE config_name = 'default_lang'";
        if (!($result = $db->sql_query($sql))) {
            message_die(CRITICAL_ERROR, 'Could not update user language info');
        }
        $board_config['default_lang'] = $default_lang;
    }
    include $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_main.' . $phpEx;
    include $phpbb_root_path . 'adr/language/lang_' . $board_config['default_lang'] . '/lang_adr_common_main.' . $phpEx;
    include $phpbb_root_path . 'adr/language/lang_' . $board_config['default_lang'] . '/lang_adr_TownMap_main.' . $phpEx;
    if (defined('IN_ADMIN')) {
        if (!file_exists(@phpbb_realpath($phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx))) {
            $board_config['default_lang'] = 'french';
        }
        include $phpbb_root_path . 'language/lang_' . $board_config['default_lang'] . '/lang_admin.' . $phpEx;
        include $phpbb_root_path . 'adr/language/lang_' . $board_config['default_lang'] . '/lang_adr_common_admin.' . $phpEx;
    }
    //MOD Keep_unread_2
    read_cookies($userdata);
    //-- mod : language settings ---------------------------------------------------
    //-- add
    include $phpbb_root_path . 'includes/lang_extend_mac.' . $phpEx;
    //-- fin mod : language settings -----------------------------------------------
    // Disable board if needed
    board_disable();
    if (!defined('NO_ATTACH_MOD')) {
        include_attach_lang();
    }
    //
    // Set up style
    //
    if (!$board_config['override_user_style']) {
        if (isset($HTTP_GET_VARS[STYLE_URL])) {
            $style = urldecode($HTTP_GET_VARS[STYLE_URL]);
            if ($theme = setup_style($style)) {
                if ($theme['themes_id'] == $userdata['user_style']) {
                    return;
                }
                if ($userdata['user_id'] != ANONYMOUS) {
                    // user logged in --> save new style ID in user profile
                    $sql = "UPDATE " . USERS_TABLE . " \r\n\t\t\t\t\t\tSET user_style = " . $theme['themes_id'] . "\r\n\t\t\t\t\t\tWHERE user_id = " . $userdata['user_id'];
                    if (!$db->sql_query($sql)) {
                        message_die(CRITICAL_ERROR, 'Error updating user style', '', __LINE__, __FILE__, $sql);
                    }
                    $userdata['user_style'] = $theme['themes_id'];
                } else {
                    // user not logged in --> save new style ID in cookie
                    setcookie($board_config['cookie_name'] . '_style', $style, time() + 31536000, $board_config['cookie_path'], $board_config['cookie_domain'], $board_config['cookie_secure']);
                }
                return;
            }
        }
        if ($userdata['user_id'] == ANONYMOUS && isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_style'])) {
            $style = $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_style'];
            if ($theme = setup_style($style)) {
                return;
            }
        }
        if ($userdata['user_id'] != ANONYMOUS && $userdata['user_style'] > 0) {
            if ($theme = setup_style($userdata['user_style'])) {
                return;
            }
        }
    }
    $theme = setup_style($board_config['default_style']);
    //
    // Mozilla navigation bar
    // Default items that should be valid on all pages.
    // Defined here to correctly assign the Language Variables
    // and be able to change the variables within code.
    //
    $nav_links['top'] = array('url' => append_sid($phpbb_root_path . 'index.' . $phpEx), 'title' => sprintf($lang['Forum_Index'], $board_config['sitename']));
    $nav_links['search'] = array('url' => append_sid($phpbb_root_path . 'search.' . $phpEx), 'title' => $lang['Search']);
    $nav_links['help'] = array('url' => append_sid($phpbb_root_path . 'faq.' . $phpEx), 'title' => $lang['FAQ']);
    $nav_links['author'] = array('url' => append_sid($phpbb_root_path . 'memberlist.' . $phpEx), 'title' => $lang['Memberlist']);
    return;
}