📄 setup.php
字号:
* @param array optional defaults * * @return nothing */function show_browse_form($defaults = array()) { ?><form method="post" action=""> <input type="hidden" name="token" value="<?php echo $_SESSION['PMA_token']; ?>" /> <input type="hidden" name="action" value="lay_browse_real" /> <?php echo get_hidden_cfg(); show_config_form(array( array('Display of values', 'DefaultDisplay', 'How to list values while browsing', array('horizontal', 'vertical', 'horizontalflipped')), array('Hightlight pointer', 'BrowsePointerEnable', 'Whether to highlight row under mouse.', TRUE), array('Use row marker', 'BrowseMarkerEnable', 'Whether to highlight selected row.', TRUE), array('Action buttons on left', 'ModifyDeleteAtLeft', 'Show action buttons on left side of listing?', TRUE), array('Action buttons on right', 'ModifyDeleteAtRight', 'Show action buttons on right side of listing?', FALSE), array('Repeat heading', 'RepeatCells', 'After how many rows heading should be repeated.'), ), 'Configure browsing', 'Select desired browsing look and feel.', $defaults); ?></form> <?php}/** * Shows editing options configuration form * * @param array optional defaults * * @return nothing */function show_edit_form($defaults = array()) { ?><form method="post" action=""> <input type="hidden" name="token" value="<?php echo $_SESSION['PMA_token']; ?>" /> <input type="hidden" name="action" value="lay_edit_real" /> <?php echo get_hidden_cfg(); show_config_form(array( array('Display of properties while editing', 'DefaultPropDisplay', 'How to list properties (table structure or values) while editing', array('horizontal', 'vertical')), array('Number of inserted rows', 'InsertRows', 'How many rows can be inserted at once'), array('Move using Ctrl+arrows', 'CtrlArrowsMoving', 'Whether to enable moving using Ctrl+Arrows', TRUE), array('Autoselect text in textarea', 'TextareaAutoSelect', 'Whether to automatically select text in textarea on focus.', TRUE), array('Textarea columns', 'TextareaCols', 'Number of columns in textarea while editing TEXT fields'), array('Textarea rows', 'TextareaRows', 'Number of rows in textarea while editing TEXT fields'), array('Double textarea for LONGTEXT', 'LongtextDoubleTextarea', 'Whether to double textarea size for LONGTEXT fields', TRUE), array('Edit CHAR fields in textarea', 'CharEditing', 'Whether to edit CHAR fields in textaread', array('input', 'textarea')), array('CHAR textarea columns', 'CharTextareaCols', 'Number of columns in textarea while editing CHAR fields (must be enabled above)'), array('CHAR textarea rows', 'CharTextareaRows', 'Number of rows in textarea while editing CHAR fields (must be enabled above)'), ), 'Configure editing', 'Select desired editing look and feel.', $defaults); ?></form> <?php}/** * Shows query window configuration form * * @param array optional defaults * * @return nothing */function show_window_form($defaults = array()) { ?><form method="post" action=""> <input type="hidden" name="token" value="<?php echo $_SESSION['PMA_token']; ?>" /> <input type="hidden" name="action" value="lay_window_real" /> <?php echo get_hidden_cfg(); show_config_form(array( array('Edit SQL in window', 'EditInWindow', 'Whether edit links will edit in query window.', TRUE), array('Query window height', 'QueryWindowHeight', 'Height of query window'), array('Query window width', 'QueryWindowWidth', 'Width of query window'), array('Default tab', 'QueryWindowDefTab', 'Default tab on query window', array('sql', 'files', 'history', 'full')), ), 'Configure query window', 'Select desired query window look and feel.', $defaults); ?></form> <?php}/** * Creates selection with servers * * @param array configuraion * * @return string HTML for server selection */function get_server_selection($cfg) { if (count($cfg['Servers']) == 0) { return ''; } $ret = '<select name="server">'; foreach ($cfg['Servers'] as $key => $val) { $ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>'; } $ret .= '</select>'; return $ret;}/** * Loads configuration from file * * @param string filename * * @return mixed FALSE on failure, new config array on success */function load_config($config_file) { if ( file_exists( $config_file ) ) { $success_apply_user_config = FALSE; $old_error_reporting = error_reporting( 0 ); if ( function_exists( 'file_get_contents' ) ) { $success_apply_user_config = eval('?>' . trim(file_get_contents($config_file))); } else { $success_apply_user_config = eval('?>' . trim(implode("\n", file($config_file)))); } error_reporting( $old_error_reporting ); unset( $old_error_reporting ); if ($success_apply_user_config === FALSE) { message('error', 'Error while parsing configuration file!'); } elseif (!isset($cfg) || count($cfg) == 0) { message('error', 'Config file seems to contain no configuration!'); } else { // This must be set if (!isset($cfg['Servers'])) { $cfg['Servers'] = array(); } message('notice', 'Configuration loaded'); compress_servers($cfg); return $cfg; } } else { message('error', 'Configuration file not found!'); } return FALSE;}if ($action != 'download') { // Check whether we can write to configuration $fail_dir = FALSE; $fail_dir = $fail_dir || !is_dir('./config/'); $fail_dir = $fail_dir || !is_writable('./config/'); $fail_dir = $fail_dir || (file_exists('./config/config.inc.php') && !is_writable('./config/config.inc.php')); $config = @fopen('./config/config.inc.php', 'a'); $fail_dir = $fail_dir || ($config === FALSE); @fclose($config);}/** * @var boolean whether to show configuration overview */$show_info = FALSE;// Do the main work depending on selected actionswitch ($action) { case 'download': header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="config.inc.php"'); echo get_cfg_string($configuration); exit; break; case 'display': echo '<form method="none" action=""><textarea name="config" cols="50" rows="20" id="textconfig" wrap="off">' . "\n"; echo htmlspecialchars(get_cfg_string($configuration)); echo '</textarea></form>' . "\n"; ?><script type="text/javascript" language="javascript">//<![CDATA[ var bodyWidth=null; var bodyHeight=null; if (document.getElementById('textconfig')) { bodyWidth = self.innerWidth; bodyHeight = self.innerHeight; if(!bodyWidth && !bodyHeight){ if (document.compatMode && document.compatMode == "BackCompat") { bodyWidth = document.body.clientWidth; bodyHeight = document.body.clientHeight; } else if (document.compatMode && document.compatMode == "CSS1Compat") { bodyWidth = document.documentElement.clientWidth; bodyHeight = document.documentElement.clientHeight; } } document.getElementById('textconfig').style.width=(bodyWidth-50) + 'px'; document.getElementById('textconfig').style.height=(bodyHeight-100) + 'px'; }//]]></script> <?php break; case 'save': $config = @fopen('./config/config.inc.php', 'w'); if ($config === FALSE) { message('error', 'Could not open config file for writing! Bad permissions?'); break; } $s = get_cfg_string($configuration); $r = fwrite($config, $s); if (!$r || $r != strlen($s)) { message('error', 'Could not write to config file! Not enough space?'); break; } else { message('notice', 'Configuration saved to file config/config.inc.php in phpMyAdmin top level directory, copy it to top level one and delete directory config to use it.', 'File saved'); } unset($r, $s); fclose($config); break; case 'load': if ($fail_dir) { message('error', 'Reading of configuration disabled because of permissions.'); break; } $new_cfg = load_config('./config/config.inc.php'); if (!($new_cfg === FALSE)) { $configuration = $new_cfg; } $show_info = TRUE; break; case 'addserver_real': if (isset($_POST['submit_save'])) { $new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable:serialized;relation:serialized;table_info:serialized;table_coords:serialized;pdf_pages:serialized;column_info:serialized;history:serialized;AllowDeny:serialized'); $err = FALSE; if (empty($new_server['host'])) { message('error', 'Empty hostname!'); $err = TRUE; } if ($new_server['auth_type'] == 'config' && empty($new_server['user'])) { message('error', 'Empty username while using config authentication method!'); $err = TRUE; } if ( isset($new_server['pmadb']) && strlen($new_server['pmadb'])) { // Just use defaults, should be okay for most users $pmadb = array(); $pmadb['bookmarktable'] = 'pma_bookmark'; $pmadb['relation'] = 'pma_relation'; $pmadb['table_info'] = 'pma_table_info'; $pmadb['table_coords'] = 'pma_table_coords'; $pmadb['pdf_pages'] = 'pma_pdf_pages'; $pmadb['column_info'] = 'pma_column_info'; $pmadb['history'] = 'pma_history'; $new_server = array_merge($pmadb, $new_server); unset($pmadb); if (empty($new_server['controluser'])) { message('error', 'Empty phpMyAdmin control user while using pmadb!'); $err = TRUE; } if (empty($new_server['controlpass'])) { message('error', 'Empty phpMyAdmin control user password while using pmadb!'); $err = TRUE; } } else { message('warning', 'You didn\'t set phpMyAdmin database, so you can not use all phpMyAdmin features.'); } if ($new_server['auth_type'] == 'config') { message('warning', 'Remember to protect your installation while using config authentication method!'); } else { // Not needed: unset($new_server['user']); unset($new_server['password']); } if ($err) { show_server_form($new_server, isset($_POST['server']) ? $_POST['server'] : FALSE); } else { if (isset($_POST['server'])) { $configuration['Servers'][$_POST['server']] = $new_server; message('notice', 'Changed server ' . get_server_name($new_server, $_POST['server'])); } else { $configuration['Servers'][] = $new_server; message('notice', 'New server added'); } $show_info = TRUE; if ($new_server['auth_type'] == 'cookie' && empty($configuration['blowfish_secret'])) { message('notice', 'You did not have configured blowfish secret and you want to use cookie authentication so I generated blowfish secret for you. It is used to encrypt cookies.', 'Blowfish secret generated'); $configuration['blowfish_secret'] = uniqid('', TRUE); } } unset($new_server); } else { $show_info = TRUE; } break; case 'addserver': if (count($configuration['Servers']) == 0) { // First server will use defaults as in config.default.php $defaults = $PMA_Config->default_server; unset($defaults['AllowDeny']); // Ignore this for now } else { $defaults = array(); } // Guess MySQL extension to use, prefer mysqli if (!function_exists('mysql_get_client_info')) { PMA_dl('mysql'); } if (!function_exists('mysqli_get_client_info')) { PMA_dl('mysqli'); } if (function_exists('mysqli_get_client_info')) { $defaults['extension'] = 'mysqli'; } elseif (function_exists('mysql_get_client_info')) { $defaults['extension'] = 'mysql'; } else { message('warning', 'Could not load neither mysql nor mysqli extension, you might not be able to use phpMyAdmin!'); } if (isset($defaults['extension'])) { message('notice', 'Autodetected MySQL extension to use: ' . $defaults['extension']); } // Display form show_server_form($defaults); break; case 'editserver': if (!isset($_POST['server'])) { footer(); } show_server_form($configuration['Servers'][$_POST['server']], $_POST['server']); break; case 'deleteserver': if (!isset($_POST['server'])) { footer(); } message('notice', 'Deleted server ' . get_server_name($configuration['Servers'][$_POST['server']], $_POST['server'])); unset($configuration['Servers'][$_POST['server']]); compress_servers($configuration); $show_info = TRUE; break; case 'servers': if (count($configuration['Servers']) == 0) { message('notice', 'No servers defined, so none can be shown'); } else { foreach ($configuration['Servers'] as $i => $srv) { $data = array(); if (!empty($srv['verbose'])) { $data[] = array('Verbose name', $srv['verbose']); } $data[] = array('Host', $srv['host']); $data[] = array('MySQL extension', isset($srv['extension']) ? $srv['extension'] : $PMA_Config->default_server['extension']); $data[] = array('Authentication type', get_server_auth($srv)); $data[] = array('phpMyAdmin advanced features', empty($srv['pmadb']) || empty($srv['controluser']) || empty($srv['controlpass']) ? 'disabled' : 'enabled, db: ' . $srv['pmadb'] . ', user: ' . $srv['controluser']);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -