$userFormList->addRow(_('Password'), new CSpan(_s('Unavailable for users with %1$s.', authentication2str($data['auth_type']))));
}
// append languages to form list
$languageComboBox = new CComboBox('lang', $this->data['lang']);
$allLocalesAvailable = true;
foreach (getLocales() as $localeId => $locale) {
    if ($locale['display']) {
        // checking if this locale exists in the system. The only way of doing it is to try and set one
        // trying to set only the LC_MONETARY locale to avoid changing LC_NUMERIC
        $localeExists = setlocale(LC_MONETARY, zbx_locale_variants($localeId)) || $localeId == 'en_GB';
        $languageComboBox->addItem($localeId, $locale['name'], $localeId == $this->data['lang'] ? true : null, $localeExists);
        $allLocalesAvailable &= $localeExists;
    }
}
// restoring original locale
setlocale(LC_MONETARY, zbx_locale_variants(CWebUser::$data['lang']));
$languageError = '';
if (!function_exists('bindtextdomain')) {
    $languageError = 'Translations are unavailable because the PHP gettext module is missing.';
    $languageComboBox->attr('disabled', 'disabled');
} elseif (!$allLocalesAvailable) {
    $languageError = _('You are not able to choose some of the languages, because locales for them are not installed on the web server.');
}
$userFormList->addRow(_('Language'), $languageError ? array($languageComboBox, SPACE, new CSpan($languageError, 'red wrap')) : $languageComboBox);
// append themes to form list
$themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes());
$themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes);
$userFormList->addRow(_('Theme'), $themeComboBox);
// append auto-login & auto-logout to form list
$autologoutCheckBox = new CCheckBox('autologout_visible', isset($this->data['autologout']) ? 'yes' : 'no');
if (isset($this->data['autologout'])) {
Exemplo n.º 2
0
 /**
  * Initialize translations.
  */
 protected function initLocales()
 {
     init_mbstrings();
     $defaultLocales = array('C', 'POSIX', 'en', 'en_US', 'en_US.UTF-8', 'English_United States.1252', 'en_GB', 'en_GB.UTF-8');
     if (function_exists('bindtextdomain')) {
         // initializing gettext translations depending on language selected by user
         $locales = zbx_locale_variants(CWebUser::$data['lang']);
         $locale_found = false;
         foreach ($locales as $locale) {
             // since LC_MESSAGES may be unavailable on some systems, try to set all of the locales
             // and then revert some of them back
             putenv('LC_ALL=' . $locale);
             putenv('LANG=' . $locale);
             putenv('LANGUAGE=' . $locale);
             setlocale(LC_TIME, $locale);
             if (setlocale(LC_ALL, $locale)) {
                 $locale_found = true;
                 CWebUser::$data['locale'] = $locale;
                 break;
             }
         }
         // reset the LC_CTYPE locale so that case transformation functions would work correctly
         // it is also required for PHP to work with the Turkish locale (https://bugs.php.net/bug.php?id=18556)
         // WARNING: this must be done before executing any other code, otherwise code execution could fail!
         // this will be unnecessary in PHP 5.5
         setlocale(LC_CTYPE, $defaultLocales);
         if (!$locale_found && CWebUser::$data['lang'] != 'en_GB' && CWebUser::$data['lang'] != 'en_gb') {
             error('Locale for language "' . CWebUser::$data['lang'] . '" is not found on the web server. Tried to set: ' . implode(', ', $locales) . '. Unable to translate Zabbix interface.');
         }
         bindtextdomain('frontend', 'locale');
         bind_textdomain_codeset('frontend', 'UTF-8');
         textdomain('frontend');
     }
     // reset the LC_NUMERIC locale so that PHP would always use a point instead of a comma for decimal numbers
     setlocale(LC_NUMERIC, $defaultLocales);
     // should be after locale initialization
     require_once $this->getRootDir() . '/include/translateDefines.inc.php';
 }
Exemplo n.º 3
0
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
// get language translations
require_once dirname(__FILE__) . '/include/gettextwrapper.inc.php';
require_once dirname(__FILE__) . '/include/js.inc.php';
require_once dirname(__FILE__) . '/include/locales.inc.php';
// if we must provide language constants on language different from English
if (isset($_GET['lang'])) {
    if (function_exists('bindtextdomain')) {
        // initializing gettext translations depending on language selected by user
        $locales = zbx_locale_variants($_GET['lang']);
        foreach ($locales as $locale) {
            putenv('LC_ALL=' . $locale);
            putenv('LANG=' . $locale);
            putenv('LANGUAGE=' . $locale);
            if (setlocale(LC_ALL, $locale)) {
                break;
            }
        }
        bindtextdomain('frontend', 'locale');
        bind_textdomain_codeset('frontend', 'UTF-8');
        textdomain('frontend');
    }
    // numeric Locale to default
    setlocale(LC_NUMERIC, array('C', 'POSIX', 'en', 'en_US', 'en_US.UTF-8', 'English_United States.1252', 'en_GB', 'en_GB.UTF-8'));
}
    }
    require_once dirname(__FILE__) . '/db.inc.php';
    if (!defined('ZBX_PAGE_NO_AUTHORIZATION')) {
        define('ZBX_PAGE_NO_AUTHORIZATION', true);
    }
    define('ZBX_DISTRIBUTED', false);
    $show_setup = true;
}
if (!defined('ZBX_PAGE_NO_AUTHORIZATION') && !defined('ZBX_RPC_REQUEST')) {
    if (!CWebUser::checkAuthentication(get_cookie('zbx_sessionid'))) {
        include 'index.php';
        exit;
    }
    if (function_exists('bindtextdomain')) {
        // initializing gettext translations depending on language selected by user
        $locales = zbx_locale_variants(CWebUser::$data['lang']);
        $locale_found = false;
        foreach ($locales as $locale) {
            putenv('LC_ALL=' . $locale);
            putenv('LANG=' . $locale);
            putenv('LANGUAGE=' . $locale);
            if (setlocale(LC_ALL, $locale)) {
                $locale_found = true;
                CWebUser::$data['locale'] = $locale;
                break;
            }
        }
        if (!$locale_found && CWebUser::$data['lang'] != 'en_GB' && CWebUser::$data['lang'] != 'en_gb') {
            error('Locale for language "' . CWebUser::$data['lang'] . '" is not found on the web server. Tried to set: ' . implode(', ', $locales) . '. Unable to translate Zabbix interface.');
        }
        bindtextdomain('frontend', 'locale');
    $userFormList->addRow(_('Groups'), array($lstGroups, new CButton('add_group', _('Add'), 'return PopUp("popup_usrgrp.php?dstfrm=' . $userForm->getName() . '&list_name=user_groups_to_del[]&var_name=user_groups", 450, 450);', 'formlist'), BR(), count($this->data['user_groups']) > 0 ? new CSubmit('del_user_group', _('Delete selected'), null, 'formlist') : null));
}
// append languages to form list
$languageComboBox = new CComboBox('lang', $this->data['lang']);
$languages_unable_set = 0;
foreach ($ZBX_LOCALES as $loc_id => $loc_name) {
    // checking if this locale exists in the system. The only way of doing it is to try and set one
    // trying to set only the LC_MONETARY locale to avoid changing LC_NUMERIC
    $locale_exists = setlocale(LC_MONETARY, zbx_locale_variants($loc_id)) || $loc_id == 'en_GB' ? 'yes' : 'no';
    $selected = $loc_id == $this->data['lang'] ? true : null;
    $languageComboBox->addItem($loc_id, $loc_name, $selected, $locale_exists);
    if ($locale_exists != 'yes') {
        $languages_unable_set++;
    }
}
setlocale(LC_MONETARY, zbx_locale_variants($USER_DETAILS['lang']));
// restoring original locale
$lang_hint = $languages_unable_set > 0 ? _('You are not able to choose some of the languages, because locales for them are not installed on the web server.') : '';
$userFormList->addRow(_('Language'), array($languageComboBox, SPACE, new CSpan($lang_hint, 'red wrap')));
// append themes to form list
$themes = array_merge(array(THEME_DEFAULT => _('System default')), Z::getThemes());
$themeComboBox = new CComboBox('theme', $this->data['theme'], null, $themes);
$userFormList->addRow(_('Theme'), $themeComboBox);
// append auto-login & auto-logout to form list
$autologoutCheckBox = new CCheckBox('autologout_visible', $this->data['autologout'] == 0 ? 'no' : 'yes');
$autologoutTextBox = new CNumericBox('autologout', $this->data['autologout'] == 0 ? '900' : $this->data['autologout'], 4);
if (!$this->data['autologout']) {
    $autologoutTextBox->setAttribute('disabled', 'disabled');
}
$userFormList->addRow(_('Auto-login'), new CCheckBox('autologin', $this->data['autologin'], null, 1));
$userFormList->addRow(_('Auto-logout (min 90 seconds)'), array($autologoutCheckBox, $autologoutTextBox));
Exemplo n.º 6
0
 /**
  * Initilaize translations.
  */
 protected function initLocales()
 {
     init_mbstrings();
     if (function_exists('bindtextdomain')) {
         // initializing gettext translations depending on language selected by user
         $locales = zbx_locale_variants(CWebUser::$data['lang']);
         $locale_found = false;
         foreach ($locales as $locale) {
             putenv('LC_ALL=' . $locale);
             putenv('LANG=' . $locale);
             putenv('LANGUAGE=' . $locale);
             if (setlocale(LC_ALL, $locale)) {
                 $locale_found = true;
                 CWebUser::$data['locale'] = $locale;
                 break;
             }
         }
         if (!$locale_found && CWebUser::$data['lang'] != 'en_GB' && CWebUser::$data['lang'] != 'en_gb') {
             error('Locale for language "' . CWebUser::$data['lang'] . '" is not found on the web server. Tried to set: ' . implode(', ', $locales) . '. Unable to translate Zabbix interface.');
         }
         bindtextdomain('frontend', 'locale');
         bind_textdomain_codeset('frontend', 'UTF-8');
         textdomain('frontend');
     }
     // should be after locale initialization
     require_once $this->getRootDir() . '/include/translateDefines.inc.php';
     // numeric Locale to default
     setlocale(LC_NUMERIC, array('C', 'POSIX', 'en', 'en_US', 'en_US.UTF-8', 'English_United States.1252', 'en_GB', 'en_GB.UTF-8'));
 }