<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * User preferences management page * * @package PhpMyAdmin */ use PMA\libraries\config\ConfigFile; use PMA\libraries\config\FormDisplay; use PMA\libraries\Message; use PMA\libraries\Response; use PMA\libraries\Util; /** * Gets some core libraries and displays a top message if required */ require_once 'libraries/common.inc.php'; require_once 'libraries/user_preferences.lib.php'; require_once 'libraries/config/config_functions.lib.php'; require_once 'libraries/config/messages.inc.php'; require 'libraries/config/user_preferences.forms.php'; $cf = new ConfigFile($GLOBALS['PMA_Config']->base_settings); PMA_userprefsPageInit($cf); $error = ''; if (isset($_POST['submit_export']) && isset($_POST['export_type']) && $_POST['export_type'] == 'text_file' ) { // export to JSON file PMA\libraries\Response::getInstance()->disable(); $filename = 'phpMyAdmin-config-' . urlencode(PMA_getenv('HTTP_HOST')) . '.json'; PMA_downloadHeader($filename, 'application/json'); $settings = PMA_loadUserprefs(); echo json_encode($settings['config_data'], JSON_PRETTY_PRINT); exit; } else if (isset($_POST['submit_get_json'])) { $settings = PMA_loadUserprefs(); $response = PMA\libraries\Response::getInstance(); $response->addJSON('prefs', json_encode($settings['config_data'])); $response->addJSON('mtime', $settings['mtime']); exit; } else if (isset($_POST['submit_import'])) { // load from JSON file $json = ''; if (isset($_POST['import_type']) && $_POST['import_type'] == 'text_file' && isset($_FILES['import_file']) && $_FILES['import_file']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['import_file']['tmp_name']) ) { // read JSON from uploaded file $open_basedir = @ini_get('open_basedir'); $file_to_unlink = ''; $import_file = $_FILES['import_file']['tmp_name']; // If we are on a server with open_basedir, we must move the file // before opening it. The doc explains how to create the "./tmp" // directory if (!empty($open_basedir)) { $tmp_subdir = (PMA_IS_WINDOWS ? '.\\tmp\\' : 'tmp/'); if (@is_writable($tmp_subdir)) { $import_file_new = tempnam($tmp_subdir, 'prefs'); $file_to_unlink = $import_file_new; if (move_uploaded_file($import_file, $import_file_new)) { $import_file = $import_file_new; } } } $json = file_get_contents($import_file); if ($file_to_unlink) { unlink($file_to_unlink); } } else { // read from POST value (json) $json = isset($_POST['json']) ? $_POST['json'] : null; } // hide header message $_SESSION['userprefs_autoload'] = true; $config = json_decode($json, true); $return_url = isset($_POST['return_url']) ? $_POST['return_url'] : null; if (! is_array($config)) { $error = __('Could not import configuration'); } else { // sanitize input values: treat them as though // they came from HTTP POST request $form_display = new FormDisplay($cf); foreach ($forms as $formset_id => $formset) { foreach ($formset as $form_name => $form) { $form_display->registerForm($formset_id . ': ' . $form_name, $form); } } $new_config = $cf->getFlatDefaultConfig(); if (!empty($_POST['import_merge'])) { $new_config = array_merge($new_config, $cf->getConfigArray()); } $new_config = array_merge($new_config, $config); $_POST_bak = $_POST; foreach ($new_config as $k => $v) { $_POST[str_replace('/', '-', $k)] = $v; } $cf->resetConfigData(); $all_ok = $form_display->process(true, false); $all_ok = $all_ok && !$form_display->hasErrors(); $_POST = $_POST_bak; if (!$all_ok && isset($_POST['fix_errors'])) { $form_display->fixErrors(); $all_ok = true; } if (!$all_ok) { // mimic original form and post json in a hidden field include 'libraries/user_preferences.inc.php'; $msg = Message::error( __('Configuration contains incorrect data for some fields.') ); $msg->display(); echo '<div class="config-form">'; echo $form_display->displayErrors(); echo '</div>'; echo '<form action="prefs_manage.php" method="post">'; echo PMA_URL_getHiddenInputs() , "\n"; echo '<input type="hidden" name="json" value="' , htmlspecialchars($json) , '" />'; echo '<input type="hidden" name="fix_errors" value="1" />'; if (! empty($_POST['import_merge'])) { echo '<input type="hidden" name="import_merge" value="1" />'; } if ($return_url) { echo '<input type="hidden" name="return_url" value="' , htmlspecialchars($return_url) , '" />'; } echo '<p>'; echo __('Do you want to import remaining settings?'); echo '</p>'; echo '<input type="submit" name="submit_import" value="' , __('Yes') , '" />'; echo '<input type="submit" name="submit_ignore" value="' , __('No') , '" />'; echo '</form>'; exit; } // check for ThemeDefault and fontsize $params = array(); if (isset($config['ThemeDefault']) && $_SESSION['PMA_Theme_Manager']->theme->getId() != $config['ThemeDefault'] && $_SESSION['PMA_Theme_Manager']->checkTheme($config['ThemeDefault']) ) { $_SESSION['PMA_Theme_Manager']->setActiveTheme($config['ThemeDefault']); $_SESSION['PMA_Theme_Manager']->setThemeCookie(); } if (isset($config['fontsize']) && $config['fontsize'] != $GLOBALS['PMA_Config']->get('fontsize') ) { $params['set_fontsize'] = $config['fontsize']; } if (isset($config['lang']) && $config['lang'] != $GLOBALS['lang'] ) { $params['lang'] = $config['lang']; } if (isset($config['collation_connection']) && $config['collation_connection'] != $GLOBALS['collation_connection'] ) { $params['collation_connection'] = $config['collation_connection']; } // save settings $result = PMA_saveUserprefs($cf->getConfigArray()); if ($result === true) { if ($return_url) { $query = PMA\libraries\Util::splitURLQuery($return_url); $return_url = parse_url($return_url, PHP_URL_PATH); foreach ($query as $q) { $pos = mb_strpos($q, '='); $k = mb_substr($q, 0, $pos); if ($k == 'token') { continue; } $params[$k] = mb_substr($q, $pos + 1); } } else { $return_url = 'prefs_manage.php'; } // reload config $GLOBALS['PMA_Config']->loadUserPreferences(); PMA_userprefsRedirect($return_url, $params); exit; } else { $error = $result; } } } else if (isset($_POST['submit_clear'])) { $result = PMA_saveUserprefs(array()); if ($result === true) { $params = array(); if ($GLOBALS['PMA_Config']->get('fontsize') != '82%') { $GLOBALS['PMA_Config']->removeCookie('pma_fontsize'); } $GLOBALS['PMA_Config']->removeCookie('pma_collaction_connection'); $GLOBALS['PMA_Config']->removeCookie('pma_lang'); PMA_userprefsRedirect('prefs_manage.php', $params); exit; } else { $error = $result; } exit; } $response = Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('config.js'); require 'libraries/user_preferences.inc.php'; if ($error) { if (!$error instanceof Message) { $error = Message::error($error); } $error->display(); } ?> <script type="text/javascript"> <?php PMA_printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@')); ?> </script> <div id="maincontainer"> <div id="main_pane_left"> <div class="group"> <?php echo '<h2>' , __('Import') , '</h2>' , '<form class="group-cnt prefs-form disableAjax" name="prefs_import"' , ' action="prefs_manage.php" method="post" enctype="multipart/form-data">' , Util::generateHiddenMaxFileSize($GLOBALS['max_upload_size']) , PMA_URL_getHiddenInputs() , '<input type="hidden" name="json" value="" />' , '<input type="radio" id="import_text_file" name="import_type"' , ' value="text_file" checked="checked" />' , '<label for="import_text_file">' . __('Import from file') . '</label>' , '<div id="opts_import_text_file" class="prefsmanage_opts">' , '<label for="input_import_file">' , __('Browse your computer:') , '</label>' , '<input type="file" name="import_file" id="input_import_file" />' , '</div>' , '<input type="radio" id="import_local_storage" name="import_type"' , ' value="local_storage" disabled="disabled" />' , '<label for="import_local_storage">' , __('Import from browser\'s storage') , '</label>' , '<div id="opts_import_local_storage" class="prefsmanage_opts disabled">' , '<div class="localStorage-supported">' , __('Settings will be imported from your browser\'s local storage.') , '<br />' , '<div class="localStorage-exists">' , __('Saved on: @DATE@') , '</div>' , '<div class="localStorage-empty">'; Message::notice(__('You have no saved settings!'))->display(); echo '</div>' , '</div>' , '<div class="localStorage-unsupported">'; Message::notice( __('This feature is not supported by your web browser') )->display(); echo '</div>' , '</div>' , '<input type="checkbox" id="import_merge" name="import_merge" />' , '<label for="import_merge">' , __('Merge with current configuration') . '</label>' , '<br /><br />' , '<input type="submit" name="submit_import" value="' , __('Go') . '" />' , '</form>' , '</div>'; if (file_exists('setup/index.php')) { // show only if setup script is available, allows to disable this message // by simply removing setup directory ?> <div class="group"> <h2><?php echo __('More settings') ?></h2> <div class="group-cnt"> <?php echo sprintf( __( 'You can set more settings by modifying config.inc.php, eg. ' . 'by using %sSetup script%s.' ), '<a href="setup/index.php" target="_blank">', '</a>' ) , PMA\libraries\Util::showDocu('setup', 'setup-script'); ?> </div> </div> <?php } ?> </div> <div id="main_pane_right"> <div class="group"> <h2><?php echo __('Export'); ?></h2> <div class="click-hide-message group-cnt" style="display:none"> <?php Message::rawSuccess( __('Configuration has been saved.') )->display(); ?> </div> <form class="group-cnt prefs-form disableAjax" name="prefs_export" action="prefs_manage.php" method="post"> <?php echo PMA_URL_getHiddenInputs(); ?> <div style="padding-bottom:0.5em"> <input type="radio" id="export_text_file" name="export_type" value="text_file" checked="checked" /> <label for="export_text_file"> <?php echo __('Save as file'); ?> </label><br /> <input type="radio" id="export_local_storage" name="export_type" value="local_storage" disabled="disabled" /> <label for="export_local_storage"> <?php echo __('Save to browser\'s storage'); ?></label> </div> <div id="opts_export_local_storage" class="prefsmanage_opts disabled"> <span class="localStorage-supported"> <?php echo __( 'Settings will be saved in your browser\'s local ' . 'storage.' ); ?> <div class="localStorage-exists"> <b> <?php echo __( 'Existing settings will be overwritten!' ); ?> </b> </div> </span> <div class="localStorage-unsupported"> <?php Message::notice( __('This feature is not supported by your web browser') )->display(); ?> </div> </div> <br /> <?php echo '<input type="submit" name="submit_export" value="' , __( 'Go' ) , '" />'; ?> </form> </div> <div class="group"> <h2><?php echo __('Reset'); ?></h2> <form class="group-cnt prefs-form disableAjax" name="prefs_reset" action="prefs_manage.php" method="post"> <?php echo PMA_URL_getHiddenInputs() , __( 'You can reset all your settings and restore them to default ' . 'values.' ); ?> <br /><br /> <input type="submit" name="submit_clear" value="<?php echo __('Reset'); ?>"/> </form> </div> </div> <br class="clearfloat" /> </div> <?php if ($response->isAjax()) { $response->addJSON('_disableNaviSettings', true); } else { define('PMA_DISABLE_NAVI_SETTINGS', true); }
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
doc | Folder | 0755 |
|
|
js | Folder | 0755 |
|
|
libraries | Folder | 0755 |
|
|
locale | Folder | 0755 |
|
|
setup | Folder | 0755 |
|
|
sql | Folder | 0755 |
|
|
templates | Folder | 0755 |
|
|
themes | Folder | 0755 |
|
|
browse_foreigners.php | File | 1.55 KB | 0644 |
|
changelog.php | File | 5.18 KB | 0644 |
|
chk_rel.php | File | 758 B | 0644 |
|
config.sample.inc.php | File | 4.45 KB | 0644 |
|
db_central_columns.php | File | 5.25 KB | 0644 |
|
db_datadict.php | File | 5.76 KB | 0644 |
|
db_designer.php | File | 5.72 KB | 0644 |
|
db_events.php | File | 356 B | 0644 |
|
db_export.php | File | 4.85 KB | 0644 |
|
db_import.php | File | 1.02 KB | 0644 |
|
db_operations.php | File | 9.68 KB | 0644 |
|
db_qbe.php | File | 4.33 KB | 0644 |
|
db_routines.php | File | 465 B | 0644 |
|
db_search.php | File | 2.03 KB | 0644 |
|
db_sql.php | File | 1.07 KB | 0644 |
|
db_sql_autocomplete.php | File | 735 B | 0644 |
|
db_sql_format.php | File | 463 B | 0644 |
|
db_structure.php | File | 1.04 KB | 0644 |
|
db_tracking.php | File | 4.32 KB | 0644 |
|
db_triggers.php | File | 360 B | 0644 |
|
error_report.php | File | 4.48 KB | 0644 |
|
export.php | File | 17.17 KB | 0644 |
|
favicon.ico | File | 21.96 KB | 0644 |
|
file_echo.php | File | 856 B | 0644 |
|
gis_data_editor.php | File | 15.46 KB | 0644 |
|
import.php | File | 28.7 KB | 0644 |
|
import_status.php | File | 3.38 KB | 0644 |
|
index.php | File | 20.32 KB | 0644 |
|
license.php | File | 852 B | 0644 |
|
lint.php | File | 1.35 KB | 0644 |
|
logout.php | File | 247 B | 0644 |
|
navigation.php | File | 2.13 KB | 0644 |
|
normalization.php | File | 3.93 KB | 0644 |
|
phpinfo.php | File | 510 B | 0644 |
|
phpmyadmin.css.php | File | 1017 B | 0644 |
|
prefs_forms.php | File | 2.68 KB | 0644 |
|
prefs_manage.php | File | 14.35 KB | 0644 |
|
print.css | File | 1.18 KB | 0644 |
|
schema_export.php | File | 1.64 KB | 0644 |
|
server_binlog.php | File | 804 B | 0644 |
|
server_collations.php | File | 837 B | 0644 |
|
server_databases.php | File | 817 B | 0644 |
|
server_engines.php | File | 803 B | 0644 |
|
server_export.php | File | 1.2 KB | 0644 |
|
server_import.php | File | 793 B | 0644 |
|
server_plugins.php | File | 808 B | 0644 |
|
server_privileges.php | File | 13.66 KB | 0644 |
|
server_replication.php | File | 2.14 KB | 0644 |
|
server_sql.php | File | 847 B | 0644 |
|
server_status.php | File | 981 B | 0644 |
|
server_status_advisor.php | File | 940 B | 0644 |
|
server_status_monitor.php | File | 3.01 KB | 0644 |
|
server_status_processes.php | File | 1.89 KB | 0644 |
|
server_status_queries.php | File | 1.35 KB | 0644 |
|
server_status_variables.php | File | 1.58 KB | 0644 |
|
server_user_groups.php | File | 1.79 KB | 0644 |
|
server_variables.php | File | 817 B | 0644 |
|
show_config_errors.php | File | 1.02 KB | 0644 |
|
sql.php | File | 6.24 KB | 0644 |
|
tbl_addfield.php | File | 3.79 KB | 0644 |
|
tbl_change.php | File | 6.6 KB | 0644 |
|
tbl_chart.php | File | 990 B | 0644 |
|
tbl_create.php | File | 3.09 KB | 0644 |
|
tbl_export.php | File | 4.27 KB | 0644 |
|
tbl_find_replace.php | File | 1.01 KB | 0644 |
|
tbl_get_field.php | File | 1.64 KB | 0644 |
|
tbl_gis_visualization.php | File | 1.23 KB | 0644 |
|
tbl_import.php | File | 910 B | 0644 |
|
tbl_indexes.php | File | 1.4 KB | 0644 |
|
tbl_operations.php | File | 14.12 KB | 0644 |
|
tbl_recent_favorite.php | File | 455 B | 0644 |
|
tbl_relation.php | File | 2.47 KB | 0644 |
|
tbl_replace.php | File | 16.27 KB | 0644 |
|
tbl_row_action.php | File | 4.95 KB | 0644 |
|
tbl_select.php | File | 1.14 KB | 0644 |
|
tbl_sql.php | File | 1.24 KB | 0644 |
|
tbl_structure.php | File | 1.72 KB | 0644 |
|
tbl_tracking.php | File | 5.82 KB | 0644 |
|
tbl_triggers.php | File | 141 B | 0644 |
|
tbl_zoom_select.php | File | 1.06 KB | 0644 |
|
themes.php | File | 894 B | 0644 |
|
transformation_overview.php | File | 1.89 KB | 0644 |
|
transformation_wrapper.php | File | 4.67 KB | 0644 |
|
url.php | File | 1.29 KB | 0644 |
|
user_password.php | File | 9.29 KB | 0644 |
|
version_check.php | File | 1.04 KB | 0644 |
|
view_create.php | File | 9.2 KB | 0644 |
|
view_operations.php | File | 3.79 KB | 0644 |
|