/**
 * Returns HTML code for the language selector
 *
 * @param boolean $use_fieldset whether to use fieldset for selection
 * @param boolean $show_doc     whether to show documentation links
 *
 * @return string
 *
 * @access  public
 */
function PMA_getLanguageSelectorHtml($use_fieldset = false, $show_doc = true)
{
    $retval = '';
    $available_languages = LanguageManager::getInstance()->sortedLanguages();
    // Display language selection only if there
    // is more than one language to choose from
    if (count($available_languages) > 1) {
        $retval .= '<form method="get" action="index.php" class="disableAjax">';
        $_form_params = array('db' => $GLOBALS['db'], 'table' => $GLOBALS['table']);
        $retval .= PMA_URL_getHiddenInputs($_form_params);
        // For non-English, display "Language" with emphasis because it's
        // not a proper word in the current language; we show it to help
        // people recognize the dialog
        $language_title = __('Language') . (__('Language') != 'Language' ? ' - <em>Language</em>' : '');
        if ($show_doc) {
            $language_title .= PMA\libraries\Util::showDocu('faq', 'faq7-2');
        }
        if ($use_fieldset) {
            $retval .= '<fieldset><legend lang="en" dir="ltr">' . $language_title . '</legend>';
        } else {
            $retval .= '<bdo lang="en" dir="ltr"><label for="sel-lang">' . $language_title . ': </label></bdo>';
        }
        $retval .= '<select name="lang" class="autosubmit" lang="en"' . ' dir="ltr" id="sel-lang">';
        foreach ($available_languages as $language) {
            //Is current one active?
            if ($language->isActive()) {
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $retval .= '<option value="' . strtolower($language->getCode()) . '"' . $selected . '>';
            $retval .= $language->getName();
            $retval .= '</option>';
        }
        $retval .= '</select>';
        if ($use_fieldset) {
            $retval .= '</fieldset>';
        }
        $retval .= '</form>';
    }
    return $retval;
}
 /**
  * Function called just after a connection to the MySQL database server has
  * been established. It sets the connection collation, and determines the
  * version of MySQL which is running.
  *
  * @param mixed $link mysql link resource|object
  *
  * @return void
  */
 public function postConnect($link)
 {
     if (!defined('PMA_MYSQL_INT_VERSION')) {
         $version = $this->fetchSingleRow('SELECT @@version, @@version_comment', 'ASSOC', $link);
         if ($version) {
             $match = explode('.', $version['@@version']);
             define('PMA_MYSQL_MAJOR_VERSION', (int) $match[0]);
             define('PMA_MYSQL_INT_VERSION', (int) sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
             define('PMA_MYSQL_STR_VERSION', $version['@@version']);
             define('PMA_MYSQL_VERSION_COMMENT', $version['@@version_comment']);
         } else {
             define('PMA_MYSQL_INT_VERSION', 50501);
             define('PMA_MYSQL_MAJOR_VERSION', 5);
             define('PMA_MYSQL_STR_VERSION', '5.05.01');
             define('PMA_MYSQL_VERSION_COMMENT', '');
         }
         /* Detect MariaDB */
         if (mb_strpos(PMA_MYSQL_STR_VERSION, 'MariaDB') !== false) {
             define('PMA_MARIADB', true);
         } else {
             define('PMA_MARIADB', false);
         }
     }
     if (PMA_MYSQL_INT_VERSION > 50503) {
         $default_charset = 'utf8mb4';
         $default_collation = 'utf8mb4_general_ci';
     } else {
         $default_charset = 'utf8';
         $default_collation = 'utf8_general_ci';
     }
     if (!empty($GLOBALS['collation_connection'])) {
         $this->query("SET CHARACTER SET '{$default_charset}';", $link, self::QUERY_STORE);
         /* Automatically adjust collation to mb4 variant */
         if ($default_charset == 'utf8mb4' && strncmp('utf8_', $GLOBALS['collation_connection'], 5) == 0) {
             $GLOBALS['collation_connection'] = 'utf8mb4_' . substr($GLOBALS['collation_connection'], 5);
         }
         $result = $this->tryQuery("SET collation_connection = '" . Util::sqlAddSlashes($GLOBALS['collation_connection']) . "';", $link, self::QUERY_STORE);
         if ($result === false) {
             trigger_error(__('Failed to set configured collation connection!'), E_USER_WARNING);
             $this->query("SET collation_connection = '" . Util::sqlAddSlashes($default_collation) . "';", $link, self::QUERY_STORE);
         }
     } else {
         $this->query("SET NAMES '{$default_charset}' COLLATE '{$default_collation}';", $link, self::QUERY_STORE);
     }
     /* Locale for messages */
     $locale = LanguageManager::getInstance()->getCurrentLanguage()->getMySQLLocale();
     if (!empty($locale)) {
         $this->query("SET lc_messages = '" . $locale . "';", $link, self::QUERY_STORE);
     }
 }
示例#3
0
 /**
  * Data provider to generate list of available locales.
  *
  * @return array with arrays of available locales
  */
 public function listLocales()
 {
     $ret = array();
     foreach (LanguageManager::getInstance()->availableLanguages() as $language) {
         $ret[] = array($language->getCode());
     }
     return $ret;
 }
示例#4
0
if (PMA_isValid($_REQUEST['sql_query'])) {
    $GLOBALS['sql_query'] = $_REQUEST['sql_query'];
}
//$_REQUEST['set_theme'] // checked later in this file LABEL_theme_setup
//$_REQUEST['server']; // checked later in this file
//$_REQUEST['lang'];   // checked by LABEL_loading_language_file
/******************************************************************************/
/* loading language file                       LABEL_loading_language_file    */
/**
 * Load gettext functions.
 */
require_once GETTEXT_INC;
/**
 * lang detection is done here
 */
$language = LanguageManager::getInstance()->selectLanguage();
$language->activate();
// Defines the cell alignment values depending on text direction
if ($GLOBALS['text_dir'] == 'ltr') {
    $GLOBALS['cell_align_left'] = 'left';
    $GLOBALS['cell_align_right'] = 'right';
} else {
    $GLOBALS['cell_align_left'] = 'right';
    $GLOBALS['cell_align_right'] = 'left';
}
/**
 * check for errors occurred while loading configuration
 * this check is done here after loading language files to present errors in locale
 */
$GLOBALS['PMA_Config']->checkPermissions();
if ($GLOBALS['PMA_Config']->error_config_file) {
示例#5
0
use PMA\libraries\config\ConfigFile;
use PMA\libraries\config\FormDisplay;
use PMA\libraries\config\ServerConfigChecks;
use PMA\libraries\LanguageManager;
use PMA\libraries\URL;
use PMA\libraries\Sanitize;
if (!defined('PHPMYADMIN')) {
    exit;
}
/**
 * Core libraries.
 */
require_once './setup/lib/index.lib.php';
require_once './libraries/config/FormDisplay.tpl.php';
// prepare unfiltered language list
$all_languages = LanguageManager::getInstance()->sortedLanguages();
/** @var ConfigFile $cf */
$cf = $GLOBALS['ConfigFile'];
$separator = URL::getArgSeparator('html');
// message handling
PMA_messagesBegin();
//
// Check phpMyAdmin version
//
if (isset($_GET['version_check'])) {
    PMA_versionCheck();
}
//
// Perform various security, compatibility and consistency checks
//
$configChecker = new ServerConfigChecks($GLOBALS['ConfigFile']);
示例#6
0
 /**
  * Activates given translation
  *
  * @return bool
  */
 public function activate()
 {
     $GLOBALS['lang'] = $this->code;
     // Set locale
     _setlocale(LC_MESSAGES, $this->code);
     _bindtextdomain('phpmyadmin', LOCALE_PATH);
     _bind_textdomain_codeset('phpmyadmin', 'UTF-8');
     _textdomain('phpmyadmin');
     /* Text direction for language */
     if ($this->isRTL()) {
         $GLOBALS['text_dir'] = 'rtl';
     } else {
         $GLOBALS['text_dir'] = 'ltr';
     }
     /* TCPDF */
     $GLOBALS['l'] = array();
     /* TCPDF settings */
     $GLOBALS['l']['a_meta_charset'] = 'UTF-8';
     $GLOBALS['l']['a_meta_dir'] = $GLOBALS['text_dir'];
     $GLOBALS['l']['a_meta_language'] = $this->code;
     /* TCPDF translations */
     $GLOBALS['l']['w_page'] = __('Page number:');
     /* Show possible warnings from langauge selection */
     LanguageManager::getInstance()->showWarnings();
 }
示例#7
0
        }
        // end if
        echo '    <li id="li_select_mysql_collation" class="no_bullets" >';
        echo '        <form method="post" action="index.php">', "\n" . URL::getHiddenInputs(null, null, 4, 'collation_connection') . '            <label for="select_collation_connection">' . "\n" . '                ' . PMA\libraries\Util::getImage('s_asci.png') . "&nbsp;" . __('Server connection collation') . "\n" . PMA\libraries\Util::showMySQLDocu('Charset-connection') . ': ' . "\n" . '            </label>' . "\n" . Charsets::getCollationDropdownBox('collation_connection', 'select_collation_connection', $collation_connection, true, true) . '        </form>' . "\n" . '    </li>' . "\n";
    }
    // end of if ($server > 0)
    echo '</ul>';
    echo '</div>';
}
echo '<div class="group">';
echo '<h2>', __('Appearance settings'), '</h2>';
echo '  <ul>';
// Displays language selection combo
if (empty($cfg['Lang'])) {
    echo '<li id="li_select_lang" class="no_bullets">';
    echo PMA\libraries\Util::getImage('s_lang.png'), " ", LanguageManager::getInstance()->getSelectorDisplay();
    echo '</li>';
}
// ThemeManager if available
if ($GLOBALS['cfg']['ThemeManager']) {
    echo '<li id="li_select_theme" class="no_bullets">';
    echo PMA\libraries\Util::getImage('s_theme.png'), " ", ThemeManager::getInstance()->getHtmlSelectBox();
    echo '</li>';
}
echo '<li id="li_select_fontsize">';
echo PMA\libraries\Config::getFontsizeForm();
echo '</li>';
echo '</ul>';
// User preferences
if ($server > 0) {
    echo '<ul>';
 /**
  * Displays authentication form
  *
  * this function MUST exit/quit the application
  *
  * @global string $conn_error the last connection error
  *
  * @return boolean|void
  */
 public function auth()
 {
     global $conn_error;
     $response = Response::getInstance();
     if ($response->isAjax()) {
         $response->setRequestStatus(false);
         // redirect_flag redirects to the login page
         $response->addJSON('redirect_flag', '1');
         if (defined('TESTSUITE')) {
             return true;
         } else {
             exit;
         }
     }
     // No recall if blowfish secret is not configured as it would produce
     // garbage
     if ($GLOBALS['cfg']['LoginCookieRecall'] && !empty($GLOBALS['cfg']['blowfish_secret'])) {
         $default_user = $GLOBALS['PHP_AUTH_USER'];
         $default_server = $GLOBALS['pma_auth_server'];
         $autocomplete = '';
     } else {
         $default_user = '';
         $default_server = '';
         // skip the IE autocomplete feature.
         $autocomplete = ' autocomplete="off"';
     }
     $response->getFooter()->setMinimal();
     $header = $response->getHeader();
     $header->setBodyId('loginform');
     $header->setTitle('phpMyAdmin');
     $header->disableMenuAndConsole();
     $header->disableWarnings();
     if (@file_exists(CUSTOM_HEADER_FILE)) {
         include CUSTOM_HEADER_FILE;
     }
     echo '
 <div class="container">
 <a href="';
     echo PMA_linkURL('https://www.phpmyadmin.net/');
     echo '" target="_blank" rel="noopener noreferrer" class="logo">';
     $logo_image = $GLOBALS['pmaThemeImage'] . 'logo_right.png';
     if (@file_exists($logo_image)) {
         echo '<img src="', $logo_image, '" id="imLogo" name="imLogo" alt="phpMyAdmin" border="0" />';
     } else {
         echo '<img name="imLogo" id="imLogo" src="', $GLOBALS['pmaThemeImage'], 'pma_logo.png', '" ', 'border="0" width="88" height="31" alt="phpMyAdmin" />';
     }
     echo '</a>
    <h1>';
     echo sprintf(__('Welcome to %s'), '<bdo dir="ltr" lang="en">phpMyAdmin</bdo>');
     echo "</h1>";
     // Show error message
     if (!empty($conn_error)) {
         Message::rawError($conn_error)->display();
     } elseif (isset($_GET['session_expired']) && intval($_GET['session_expired']) == 1) {
         Message::rawError(__('Your session has expired. Please log in again.'))->display();
     }
     echo "<noscript>\n";
     Message::error(__("Javascript must be enabled past this point!"))->display();
     echo "</noscript>\n";
     echo "<div class='hide js-show'>";
     // Displays the languages form
     if (empty($GLOBALS['cfg']['Lang'])) {
         // use fieldset, don't show doc link
         echo LanguageManager::getInstance()->getSelectorDisplay(true, false);
     }
     echo '</div>
 <br />
 <!-- Login form -->
 <form method="post" action="index.php" name="login_form"', $autocomplete, ' class="disableAjax login hide js-show">
     <fieldset>
     <legend>';
     echo __('Log in');
     echo Util::showDocu('index');
     echo '</legend>';
     if ($GLOBALS['cfg']['AllowArbitraryServer']) {
         echo '
         <div class="item">
             <label for="input_servername" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '">';
         echo __('Server:');
         echo '</label>
             <input type="text" name="pma_servername" id="input_servername"';
         echo ' value="';
         echo htmlspecialchars($default_server);
         echo '" size="24" class="textfield" title="';
         echo __('You can enter hostname/IP address and port separated by space.');
         echo '" />
         </div>';
     }
     echo '<div class="item">
             <label for="input_username">', __('Username:'******'</label>
             <input type="text" name="pma_username" id="input_username" ', 'value="', htmlspecialchars($default_user), '" size="24"', ' class="textfield"/>
         </div>
         <div class="item">
             <label for="input_password">', __('Password:'******'</label>
             <input type="password" name="pma_password" id="input_password"', ' value="" size="24" class="textfield" />
         </div>';
     if (count($GLOBALS['cfg']['Servers']) > 1) {
         echo '<div class="item">
             <label for="select_server">' . __('Server Choice:') . '</label>
             <select name="server" id="select_server"';
         if ($GLOBALS['cfg']['AllowArbitraryServer']) {
             echo ' onchange="document.forms[\'login_form\'].', 'elements[\'pma_servername\'].value = \'\'" ';
         }
         echo '>';
         include_once './libraries/select_server.lib.php';
         echo PMA_selectServer(false, false);
         echo '</select></div>';
     } else {
         echo '    <input type="hidden" name="server" value="', $GLOBALS['server'], '" />';
     }
     // end if (server choice)
     // Add captcha input field if reCaptcha is enabled
     if (!empty($GLOBALS['cfg']['CaptchaLoginPrivateKey']) && !empty($GLOBALS['cfg']['CaptchaLoginPublicKey'])) {
         // If enabled show captcha to the user on the login screen.
         echo '<script src="https://www.google.com/recaptcha/api.js?hl=', $GLOBALS['lang'], '" async defer></script>';
         echo '<div class="g-recaptcha" data-sitekey="', htmlspecialchars($GLOBALS['cfg']['CaptchaLoginPublicKey']), '"></div>';
     }
     echo '</fieldset>
     <fieldset class="tblFooters">
         <input value="', __('Go'), '" type="submit" id="input_go" />';
     $_form_params = array();
     if (!empty($GLOBALS['target'])) {
         $_form_params['target'] = $GLOBALS['target'];
     }
     if (!empty($GLOBALS['db'])) {
         $_form_params['db'] = $GLOBALS['db'];
     }
     if (!empty($GLOBALS['table'])) {
         $_form_params['table'] = $GLOBALS['table'];
     }
     // do not generate a "server" hidden field as we want the "server"
     // drop-down to have priority
     echo URL::getHiddenInputs($_form_params, '', 0, 'server');
     echo '</fieldset>
 </form>';
     if ($GLOBALS['error_handler']->hasDisplayErrors()) {
         echo '<div id="pma_errors">';
         $GLOBALS['error_handler']->dispErrors();
         echo '</div>';
     }
     echo '</div>';
     if (@file_exists(CUSTOM_FOOTER_FILE)) {
         include CUSTOM_FOOTER_FILE;
     }
     if (!defined('TESTSUITE')) {
         exit;
     } else {
         return true;
     }
 }
示例#9
0
 /**
  * Loads user preferences and merges them with current config
  * must be called after control connection has been established
  *
  * @return void
  */
 public function loadUserPreferences()
 {
     // index.php should load these settings, so that phpmyadmin.css.php
     // will have everything available in session cache
     $server = isset($GLOBALS['server']) ? $GLOBALS['server'] : (!empty($GLOBALS['cfg']['ServerDefault']) ? $GLOBALS['cfg']['ServerDefault'] : 0);
     $cache_key = 'server_' . $server;
     if ($server > 0 && !defined('PMA_MINIMUM_COMMON')) {
         $config_mtime = max($this->default_source_mtime, $this->source_mtime);
         // cache user preferences, use database only when needed
         if (!isset($_SESSION['cache'][$cache_key]['userprefs']) || $_SESSION['cache'][$cache_key]['config_mtime'] < $config_mtime) {
             // load required libraries
             include_once './libraries/user_preferences.lib.php';
             $prefs = PMA_loadUserprefs();
             $_SESSION['cache'][$cache_key]['userprefs'] = PMA_applyUserprefs($prefs['config_data']);
             $_SESSION['cache'][$cache_key]['userprefs_mtime'] = $prefs['mtime'];
             $_SESSION['cache'][$cache_key]['userprefs_type'] = $prefs['type'];
             $_SESSION['cache'][$cache_key]['config_mtime'] = $config_mtime;
         }
     } elseif ($server == 0 || !isset($_SESSION['cache'][$cache_key]['userprefs'])) {
         $this->set('user_preferences', false);
         return;
     }
     $config_data = $_SESSION['cache'][$cache_key]['userprefs'];
     // type is 'db' or 'session'
     $this->set('user_preferences', $_SESSION['cache'][$cache_key]['userprefs_type']);
     $this->set('user_preferences_mtime', $_SESSION['cache'][$cache_key]['userprefs_mtime']);
     // backup some settings
     $org_fontsize = '';
     if (isset($this->settings['fontsize'])) {
         $org_fontsize = $this->settings['fontsize'];
     }
     // load config array
     $this->settings = array_replace_recursive($this->settings, $config_data);
     $GLOBALS['cfg'] = array_replace_recursive($GLOBALS['cfg'], $config_data);
     if (defined('PMA_MINIMUM_COMMON')) {
         return;
     }
     // settings below start really working on next page load, but
     // changes are made only in index.php so everything is set when
     // in frames
     // save theme
     /** @var ThemeManager $tmanager */
     $tmanager = $_SESSION['PMA_Theme_Manager'];
     if ($tmanager->getThemeCookie() || isset($_REQUEST['set_theme'])) {
         if (!isset($config_data['ThemeDefault']) && $tmanager->theme->getId() != 'original' || isset($config_data['ThemeDefault']) && $config_data['ThemeDefault'] != $tmanager->theme->getId()) {
             // new theme was set in common.inc.php
             $this->setUserValue(null, 'ThemeDefault', $tmanager->theme->getId(), 'original');
         }
     } else {
         // no cookie - read default from settings
         if ($this->settings['ThemeDefault'] != $tmanager->theme->getId() && $tmanager->checkTheme($this->settings['ThemeDefault'])) {
             $tmanager->setActiveTheme($this->settings['ThemeDefault']);
             $tmanager->setThemeCookie();
         }
     }
     // save font size
     if (!isset($config_data['fontsize']) && $org_fontsize != '82%' || isset($config_data['fontsize']) && $org_fontsize != $config_data['fontsize']) {
         $this->setUserValue(null, 'fontsize', $org_fontsize, '82%');
     }
     // save language
     if (isset($_COOKIE['pma_lang']) || isset($_POST['lang'])) {
         if (!isset($config_data['lang']) && $GLOBALS['lang'] != 'en' || isset($config_data['lang']) && $GLOBALS['lang'] != $config_data['lang']) {
             $this->setUserValue(null, 'lang', $GLOBALS['lang'], 'en');
         }
     } else {
         // read language from settings
         if (isset($config_data['lang'])) {
             $language = LanguageManager::getInstance()->getLanguage($config_data['lang']);
             if ($language !== false) {
                 $language->activate();
                 $this->setCookie('pma_lang', $language->getCode());
             }
         }
     }
     // save connection collation
     $this->_saveConnectionCollation($config_data);
 }