2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * phpMyAdmin setup script
9 * @package phpMyAdmin-setup
10 * @author Michal Čihař <michal@cihar.com>
11 * @copyright 2006 Michal Čihař <michal@cihar.com>
12 * @license http://www.gnu.org/licenses/gpl.html GNU GPL 2.0
16 // Grab phpMyAdmin version and PMA_dl function
17 define('PMA_MINIMUM_COMMON', TRUE);
18 define('PMA_SETUP', TRUE);
20 require_once './libraries/common.inc.php';
22 // Grab configuration defaults
23 // Do not use $PMA_Config, it interferes with the one in $_SESSION
24 // on servers with register_globals enabled
25 $PMA_Config_Setup = new PMA_Config();
28 $script_info = 'phpMyAdmin ' . $PMA_Config_Setup->get('PMA_VERSION') . ' setup script by Michal Čihař <michal@cihar.com>';
29 $script_version = '$Id$';
32 if (isset($_POST['action'])) {
33 $action = $_POST['action'];
38 // Grab wanted CRLF type
39 if (isset($_POST['eoltype'])) {
40 $_SESSION['eoltype'] = $_POST['eoltype'];
42 if (PMA_USR_OS
== 'Win') {
43 $_SESSION['eoltype'] = 'dos';
45 $_SESSION['eoltype'] = 'unix';
49 // Detect which CRLF to use
50 if ($_SESSION['eoltype'] == 'dos') {
52 } elseif ($_SESSION['eoltype'] == 'mac') {
58 if (!isset($_SESSION['configuration']) ||
$action == 'clear') {
59 // Create empty configuration
60 $_SESSION['configuration'] = array();
63 // We rely on Servers array to exist, so create it here
64 if (!isset($_SESSION['configuration']['Servers']) ||
!is_array($_SESSION['configuration']['Servers'])) {
65 $_SESSION['configuration']['Servers'] = array();
69 $now = gmdate('D, d M Y H:i:s') . ' GMT';
71 // General header for no caching
72 header('Expires: ' . $now); // rfc2616 - Section 14.21
73 header('Last-Modified: ' . $now);
74 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
75 header('Pragma: no-cache'); // HTTP/1.0
77 // whether to show html header?
78 if ($action != 'download') {
80 // Define the charset to be used
81 header('Content-Type: text/html; charset=utf-8');
83 // this needs to be echoed otherwise php with short tags complains
84 echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
86 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
87 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
88 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
90 <link rel
="icon" href
="../favicon.ico" type
="image/x-icon" />
91 <link rel
="shortcut icon" href
="../favicon.ico" type
="image/x-icon" />
92 <title
>phpMyAdmin
<?php
echo $PMA_Config_Setup->get('PMA_VERSION'); ?
> setup
</title
>
93 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
95 <script type
="text/javascript">
97 // show this window in top frame
99 window
.top
.location
.href
=location
;
103 <style type
="text/css">
104 /* message boxes: warning, error, stolen from original theme */
107 background
-color
: #FFFFDD;
111 margin
: 0.5em
0 0.5em
0;
112 border
: 0.1em solid
#FFD700;
113 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_notice
.png
);
114 background
-repeat
: no
-repeat
;
115 background
-position
: 10px
50%
;
116 padding
: 10px
10px
10px
36px
;
119 border
-bottom
: 0.1em solid
#FFD700;
128 background
-color
: #FFFFCC;
132 margin
: 0.5em
0 0.5em
0;
133 border
: 0.1em solid
#CC0000;
134 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_warn
.png
);
135 background
-repeat
: no
-repeat
;
136 background
-position
: 10px
50%
;
137 padding
: 10px
10px
10px
36px
;
140 border
-bottom
: 0.1em solid
#cc0000;
148 background
-color
: #FFFFCC;
153 margin
: 0.5em
0 0.5em
0;
154 border
: 0.1em solid
#ff0000;
155 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_error
.png
);
156 background
-repeat
: no
-repeat
;
157 background
-position
: 10px
50%
;
158 padding
: 10px
10px
10px
36px
;
161 border
-bottom
: 0.1em solid
#ff0000;
168 fieldset
.toolbar form
.action
{
175 border
-right
: 1px solid black
;
177 fieldset
.toolbar form
.action input
, fieldset
.toolbar form
.action select
{
185 background
-color
: #dddddd;
190 background
-color
: #FFFFDD;
192 div
.buttons
, div
.opts
, fieldset
.optbox p
, fieldset
.overview div
.row
{
196 background
-color
: white
;
198 div
.opts
, fieldset
.optbox p
, fieldset
.overview div
.row
{
199 border
-bottom
: 1px dotted black
;
207 background
-color
: #FFFFDD;
210 background
-color
: #dddddd;
228 div
.desc
, label
.desc
, fieldset
.overview div
.desc
{
233 code
:before
, code
:after
{
240 margin
: 0 0.1em
0 0.1em
;
249 <h1
>phpMyAdmin
<?php
echo $PMA_Config_Setup->get('PMA_VERSION'); ?
> setup
</h1
>
251 } // end show html header
254 * Calculates numerical equivalent of phpMyAdmin version string
256 * @param string version
258 * @return mixed FALSE on failure, integer on success
260 function version_to_int($version) {
261 if (!preg_match('/^(\d+)\.(\d+)\.(\d+)((\.|-(pl|rc|dev|beta|alpha))(\d+)?)?$/', $version, $matches)) {
264 if (!empty($matches[6])) {
265 switch ($matches[6]) {
282 message('notice', 'Unknown version part: ' . htmlspecialchars($matches[5]));
287 $added = 50; // for final
289 if (!empty($matches[7])) {
290 $added = $added +
$matches[7];
292 return $matches[1] * 1000000 +
$matches[2] * 10000 +
$matches[3] * 100 +
$added;
296 * Returns link to documentation of some configuration directive
298 * @param string confguration directive name
300 * @return string HTML link to documentation
302 function get_cfg_doc($anchor) {
305 if (strncmp($anchor, 'Servers_', 8) == 0) {
306 $wiki = substr($anchor, 8);
309 '<span class="doc">' .
310 '<a href="../Documentation.html#cfg_' . $anchor . '" target="pma_doc" class="doc">' .
311 '<img class="icon" src="../' . $GLOBALS['cfg']['ThemePath'] . '/original/img/b_help.png" width="11" height="11" alt="Documentation" title="Documentation" />' .
313 '<a href="http://wiki.phpmyadmin.net/pma/Config#' . $wiki . '" target="pma_doc" class="doc">' .
314 '<img class="icon" src="../' . $GLOBALS['cfg']['ThemePath'] . '/original/img/b_info.png" width="11" height="11" alt="Wiki" title="Wiki" />' .
323 * @param string type of message (notice/warning/error)
324 * @param string text of message
325 * @param title optional title of message
329 function message($type, $text, $title = '') {
330 echo '<div class="' . $type . '">' . "\n";
331 if (!empty($title)) {
337 echo '</div>' . "\n";
341 * Returns needed hidden input for forms.
343 * @return string HTML with hidden inputs
345 function get_hidden_inputs() {
346 return '<input type="hidden" name="token" value="' . $_SESSION[' PMA_token '] . '" />';
350 * Creates form for some action
352 * @param string action name
353 * @param string form title
354 * @param string optional additional inputs
356 * @return string HTML with form
358 function get_action($name, $title, $added = '', $enabled = TRUE) {
360 $ret .= '<form class="action" method="post" action="">';
361 $ret .= get_hidden_inputs();
362 $ret .= '<input type="hidden" name="action" value="' . $name . '" />';
364 $ret .= '<input type="submit" value="' . $title . '"';
366 $ret .= ' disabled="disabled"';
375 * Creates form for going to some url
377 * @param string URL where to go
378 * @param string form title
379 * @param string optional array of parameters
381 * @return string HTML with form
383 function get_url_action($url, $title, $params = array()) {
385 $ret .= '<form class="action" method="get" action="' . $url . '" target="_blank">';
386 $ret .= get_hidden_inputs();
387 foreach ($params as $key => $val) {
388 $ret .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
390 $ret .= '<input type="submit" value="' . $title . '" />';
397 * Terminates script and ends HTML
408 * Creates string describing server authentication method
410 * @param array server configuration
412 * @return string authentication method description
414 function get_server_auth($val) {
415 global $PMA_Config_Setup;
417 if (isset($val['auth_type'])) {
418 $auth = $val['auth_type'];
420 $auth = $PMA_Config_Setup->default_server
['auth_type'];
423 if ($auth == 'config') {
424 if (isset($val['user'])) {
425 $ret .= ':' . $val['user'];
427 $ret .= ':' . $PMA_Config_Setup->default_server
['user'];
434 * Creates nice string with server name
436 * @param array server configuration
437 * @param int optional server id
439 * @return string fancy server name
441 function get_server_name($val, $id = FALSE, $escape = true) {
442 if (!empty($val['verbose'])) {
443 $ret = $val['verbose'];
447 $ret .= ' (' . get_server_auth($val) . ')';
449 $ret .= ' [' . ($id +
1) . ']' ;
452 return htmlspecialchars($ret);
460 * Exports variable to PHP code, very limited version of var_export
462 * @param string data to export
466 * @return string PHP code containing variable value
468 function PMA_var_export($input) {
472 if (is_null($input)) {
474 } elseif (is_array($input)) {
475 $output .= 'array (' . $crlf;
476 foreach($input as $key => $value) {
477 $output .= PMA_var_export($key) . ' => ' . PMA_var_export($value);
478 $output .= ',' . $crlf;
481 } elseif (is_string($input)) {
482 $output .= '\'' . addslashes($input) . '\'';
483 } elseif (is_int($input) ||
is_double($input)) {
484 $output .= (string) $input;
485 } elseif (is_bool($input)) {
486 $output .= $input ?
'true' : 'false';
488 die('Unknown type for PMA_var_export: ' . $input);
494 * Creates configuration code for one variable
496 * @param string variable name
497 * @param mixed configuration
499 * @return string PHP code containing configuration
501 function get_cfg_val($name, $val) {
505 if (is_array($val)) {
507 foreach ($val as $k => $v) {
511 } elseif (is_int($k)) {
513 $ret .= $name . ' = array(' . $crlf;
515 // Something unknown...
516 $ret .= $name. ' = ' . PMA_var_export($val) . ';' . $crlf;
520 if ($type == 'string') {
521 $ret .= get_cfg_val($name . "['$k']", $v);
522 } elseif ($type == 'int') {
523 $ret .= ' ' . PMA_var_export($v) . ',' . $crlf;
528 $ret .= $name . ' = array();' . $crlf;
529 } elseif ($type == 'int') {
530 $ret .= ');' . $crlf;
535 $ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf;
541 * Creates configuration PHP code
543 * @param array configuration
545 * @return string PHP code containing configuration
547 function get_cfg_string($cfg) {
548 global $script_info, $script_version, $now, $crlf;
551 $ret = "<?php$crlf/*$crlf * Generated configuration file$crlf * Generated by: $script_info$crlf * Version: $script_version$crlf * Date: " . $now . $crlf . ' */' . $crlf . $crlf;
553 if (count($c['Servers']) > 0) {
554 $ret .= "/* Servers configuration */$crlf\$i = 0;" . $crlf;
555 foreach ($c['Servers'] as $cnt => $srv) {
556 $ret .= $crlf . '/* Server ' . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */$crlf\$i++;" . $crlf;
557 foreach ($srv as $key => $val) {
558 $key = preg_replace('/[^A-Za-z0-9_]/', '_', $key);
559 $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);
562 $ret .= $crlf . '/* End of servers configuration */' . $crlf . $crlf;
564 unset($c['Servers']);
566 foreach ($c as $key => $val) {
567 $key = preg_replace('/[^A-Za-z0-9_]/', '_', $key);
568 $ret .= get_cfg_val("\$cfg['$key']", $val);
571 $ret .= '?>' . $crlf;
576 * Compresses server configuration to be indexed from 0 and contain no gaps
578 * @param array configuration
582 function compress_servers(&$cfg) {
584 foreach ($cfg['Servers'] as $val) {
585 if (!empty($val['host'])) {
589 $cfg['Servers'] = $ns;
593 * Grabs values from POST
595 * @param string list of values to grab, values are separated by ";",
596 * each can have defined type separated by ":", if no type
597 * is defined, string is assumed. Possible types: bool -
598 * boolean value, allow-deny - allow-deny rules, int -
599 * integer, tristate - "TRUE"/"FALSE" converted to bool,
600 * other strings are kept.
602 * @return array array with grabbed values
604 function grab_values($list)
606 $a = split(';', $list);
608 foreach ($a as $val) {
609 $v = split(':', $val);
615 $res[$v[0]] = isset($_POST[$v[0]]);
618 $res[$v[0]] = array();
619 if (isset($_POST[$v[0] . '_order']) && strlen($_POST[$v[0] . '_order']) > 0) {
620 $res[$v[0]]['order'] = $_POST[$v[0]];
622 $res[$v[0]]['order'] = '';
624 if (isset($_POST[$v[0] . '_rules']) && strlen($_POST[$v[0] . '_rules']) > 0) {
625 $res[$v[0]]['rules'] = split('|', $_POST[$v[0]]);
627 $res[$v[0]]['rules'] = array();
631 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
632 $res[$v[0]] = (int)$_POST[$v[0]];
636 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
637 $cur = $_POST[$v[0]];
638 if ($cur == 'TRUE') {
640 } elseif ($cur == 'FALSE') {
649 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
650 $res[$v[0]] = $_POST[$v[0]];
661 * @param string title of oveview
662 * @param array list of values to display (each element is array of two
663 * values - name and value)
664 * @param string optional buttons to be displayed
668 function show_overview($title, $list, $buttons = '') {
669 echo '<fieldset class="overview">' . "\n";
670 echo '<legend>' . $title . '</legend>' . "\n";
671 foreach ($list as $val) {
672 echo '<div class="row">';
673 echo '<div class="desc">';
676 echo '<div class="data">';
677 echo htmlspecialchars($val[1]);
679 echo '</div>' . "\n";
681 if (!empty($buttons)) {
682 echo '<div class="buttons">';
683 echo '<div class="desc">Actions:</div>';
685 echo '</div>' . "\n";
687 echo '</fieldset>' . "\n";
692 * Displays configuration, fallback defaults are taken from global $PMA_Config_Setup
694 * @param array list of values to display (each element is array of two or
695 * three values - desription, name and optional type
696 * indicator). Type is determined by type of this parameter,
697 * array means select and array elements are items,
698 * 'password' means password input.
699 * @param string title of configuration
700 * @param string help string for this configuration
701 * @param array optional first level defaults
702 * @param string optional title for save button
703 * @param string optional prefix for documentation links
707 function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {
708 global $PMA_Config_Setup;
714 echo '<fieldset class="optbox">' . "\n";
715 echo '<legend>' . $legend . '</legend>' . "\n";
716 echo '<p>' . $help . '</p>' . "\n";
717 foreach ($list as $val) {
718 echo '<div class="opts">';
720 if (isset($val[3])) {
721 if (is_array($val[3])) {
723 } elseif (is_bool($val[3])) {
725 } elseif ($val[3] == 'password') {
732 echo '<label for="text_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
733 echo '<input type="' . $type . '" name="' . $val[1] . '" id="text_' . $val[1] . '" title="' . $val[2] . '" size="50"';
734 if (isset($defaults[$val[1]])) {
735 echo ' value="' . htmlspecialchars($defaults[$val[1]]) . '"';
737 echo ' value="' . htmlspecialchars($PMA_Config_Setup->get($val[1])) . '"';
742 echo '<input type="checkbox" name="' . $val[1] . '" value="something" id="checkbox_' . $val[1] . '" title="' . $val[2] . '"';
743 if (isset($defaults[$val[1]])) {
744 if ($defaults[$val[1]]) {
745 echo ' checked="checked"';
748 if ($PMA_Config_Setup->get($val[1])) {
749 echo ' checked="checked"';
753 echo '<label for="checkbox_' . $val[1] . '" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
756 echo '<label for="select_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
757 echo '<select name="' . $val[1] . '" id="select_' . $val[1] . '" ' . ' title="' . $val[2] . '">';
758 foreach ($val[3] as $opt) {
759 echo '<option value="' . $opt . '"';
760 if (isset($defaults[$val[1]])) {
761 if (is_bool($defaults[$val[1]])) {
762 if (($defaults[$val[1]] && $opt == 'TRUE') ||
(!$defaults[$val[1]] && $opt == 'FALSE')) {
763 echo ' selected="selected"';
766 if ($defaults[$val[1]] == $opt) {
767 echo ' selected="selected"';
771 $def_val = $PMA_Config_Setup->get($val[1]);
773 if (($def_val && $opt == 'TRUE') ||
(!$def_val && $opt == 'FALSE')) {
774 echo ' selected="selected"';
777 if ($def_val == $opt) {
778 echo ' selected="selected"';
783 echo '>' . $opt . '</option>';
788 echo '</div>' . "\n";
790 echo '<div class="buttons">';
791 echo '<div class="desc">Actions:</div>';
792 echo '<input type="submit" name="submit_save" value="' . $save .'" class="save" />';
793 echo '<input type="submit" name="submit_ignore" value="Cancel" class="cancel" />';
794 echo '</div>' . "\n";
795 echo '</fieldset>' . "\n";
800 * Shows security options configuration form
802 * @param array optional defaults
806 function show_security_form($defaults = array()) {
808 <form method
="post" action
="">
809 <?php
echo get_hidden_inputs();?
>
810 <input type
="hidden" name
="action" value
="feat_security_real" />
812 show_config_form(array(
813 array('Blowfish secret', 'blowfish_secret', 'Secret passphrase used for encrypting cookies'),
814 array('Force SSL connection', 'ForceSSL', 'Whether to force using secured connection while using phpMyAdmin', FALSE),
815 array('Show phpinfo output', 'ShowPhpInfo', 'Whether to allow users to see phpinfo() output', FALSE),
816 array('Show password change form', 'ShowChgPassword', 'Whether to show form for changing password, this does not limit ability to execute the same command directly', FALSE),
817 array('Allow login to any MySQL server', 'AllowArbitraryServer', 'If enabled user can enter any MySQL server in login form for cookie auth.', FALSE),
818 array('Recall user name', 'LoginCookieRecall', 'Whether to recall user name on log in prompt while using cookie auth.', TRUE),
819 array('Login cookie validity', 'LoginCookieValidity', 'How long is login valid without performing any action.'),
821 'Configure security features',
822 'Please note that phpMyAdmin is just a user interface and it\'s features do not limit MySQL.',
830 * Shows MySQL manual configuration form
832 * @param array optional defaults
836 function show_manual_form($defaults = array()) {
838 <form method
="post" action
="">
839 <?php
echo get_hidden_inputs();?
>
840 <input type
="hidden" name
="action" value
="feat_manual_real" />
842 show_config_form(array(
843 array('Type of MySQL documentation', 'MySQLManualType', 'These types are same as listed on MySQL download page', array('viewable', 'chapters', 'big', 'none')),
844 array('Base URL of MySQL documentation', 'MySQLManualBase', 'Where is MySQL documentation placed, this is usually top level directory.'),
846 'Configure MySQL manual links',
847 'If you have local copy of MySQL documentation, you might want to use it in documentation links. Otherwise use <code>viewable</code> type and <code>http://dev.mysql.com/doc/refman</code> as manual base URL.',
855 * Shows charset options configuration form
857 * @param array optional defaults
861 function show_charset_form($defaults = array()) {
862 global $PMA_Config_Setup;
864 <form method
="post" action
="">
865 <?php
echo get_hidden_inputs();?
>
866 <input type
="hidden" name
="action" value
="feat_charset_real" />
868 show_config_form(array(
869 array('Allow charset conversion', 'AllowAnywhereRecoding', 'If you want to use such functions.', FALSE),
870 array('Default charset', 'DefaultCharset', 'Default charset for conversion.', $PMA_Config_Setup->get('AvailableCharsets')),
871 array('Recoding engine', 'RecodingEngine', 'PHP can contain iconv and/or recode, select which one to use or keep autodetection.', array('auto', 'iconv', 'recode')),
872 array('Extra params for iconv', 'IconvExtraParams', 'Iconv can get some extra parameters for conversion see man iconv_open.'),
874 'Configure charset conversions',
875 'phpMyAdmin can perform charset conversions so that you can import and export in any charset you want.',
883 * Shows PHP extensions configuration form
885 * @param array optional defaults
889 function show_extensions_form($defaults = array()) {
891 <form method
="post" action
="">
892 <?php
echo get_hidden_inputs();?
>
893 <input type
="hidden" name
="action" value
="feat_extensions_real" />
895 show_config_form(array(
896 array('GD 2 is available', 'GD2Available', 'Whether you have GD 2 or newer installed', array('auto', 'yes', 'no')),
898 'Configure extensions',
899 'phpMyAdmin can use several extensions, however here are configured only those that didn\'t fit elsewhere. MySQL extension is configured within server, charset conversion one on separate charsets page.',
907 * Shows MIME/relation/history configuration form
909 * @param array optional defaults
913 function show_relation_form($defaults = array()) {
914 global $PMA_Config_Setup;
916 <form method
="post" action
="">
917 <?php
echo get_hidden_inputs();?
>
918 <input type
="hidden" name
="action" value
="feat_relation_real" />
920 show_config_form(array(
921 array('Permanent query history', 'QueryHistoryDB', 'Store history into database.', FALSE),
922 array('Maximal history size', 'QueryHistoryMax', 'How many queries are kept in history.'),
923 array('Use MIME transformations', 'BrowseMIME', 'Use MIME transformations while browsing.', TRUE),
924 array('PDF default page size', 'PDFDefaultPageSize', 'Default page size for PDF, you can change this while creating page.', $PMA_Config_Setup->get('PDFPageSizes')),
926 'Configure MIME/relation/history',
927 'phpMyAdmin can provide additional features like MIME transformation, internal relations, permanent history and PDF pages generation. You have to configure the database and tables that will store this information on the server page. Behaviour of those functions is configured here.',
935 * Shows upload/save configuration form
937 * @param array optional defaults
941 function show_upload_form($defaults = array()) {
943 <form method
="post" action
="">
944 <?php
echo get_hidden_inputs();?
>
945 <input type
="hidden" name
="action" value
="feat_upload_real" />
947 show_config_form(array(
948 array('Upload directory', 'UploadDir', 'Directory on server where you can upload files for import'),
949 array('Save directory', 'SaveDir', 'Directory where exports can be saved on server'),
951 'Configure upload/save directories',
952 'Enter directories, either absolute path or relative to phpMyAdmin top level directory.',
960 * Shows server configuration form
962 * @param array optional defaults
966 function show_server_form($defaults = array(), $number = FALSE) {
968 <form method
="post" action
="">
969 <?php
echo get_hidden_inputs();?
>
970 <input type
="hidden" name
="action" value
="addserver_real" />
972 if (!($number === FALSE)) {
973 echo '<input type="hidden" name="server" value="' . $number . '" />';
975 $hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'designer_coords', 'history');
976 foreach ($hi as $k) {
977 if (isset($defaults[$k]) && is_string($defaults[$k]) && strlen($defaults[$k]) > 0) {
978 echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars($defaults[$k]) . '" />';
981 if (isset($defaults['AllowDeny'])) {
982 if (isset($defaults['AllowDeny']['order']) && is_string($defaults['AllowDeny']['order']) && strlen($defaults['AllowDeny']['order']) > 0) {
983 echo '<input type="hidden" name="AllowDeny_rules" value="' . htmlspecialchars($defaults['AllowDeny']['order']) . '" />';
985 if (isset($defaults['AllowDeny']['rules']) && is_array($defaults['AllowDeny']['rules']) && count($defaults['AllowDeny']['rules']) > 0) {
986 echo '<input type="hidden" name="AllowDeny_rules" value="' . htmlspecialchars(implode('|', $defaults['AllowDeny']['rules'])) . '" />';
989 show_config_form(array(
990 array('Server hostname', 'host', 'Hostname where MySQL server is running'),
991 array('Server port', 'port', 'Port on which MySQL server is listening, leave empty for default'),
992 array('Server socket', 'socket', 'Socket on which MySQL server is listening, leave empty for default'),
993 array('Connection type', 'connect_type', 'How to connect to server, keep tcp if unsure', array('tcp', 'socket')),
994 array('PHP extension to use', 'extension', 'What PHP extension to use, use mysqli if supported', array('mysql', 'mysqli')),
995 array('Compress connection', 'compress', 'Whether to compress connection to MySQL server', FALSE),
996 array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config', 'signon')),
997 array('User for config auth', 'user', 'Leave empty if not using config auth'),
998 array('Password for config auth', 'password', 'Leave empty if not using config auth', 'password'),
999 array('Only database to show', 'only_db', 'Limit listing of databases in left frame to this one'),
1000 array('Verbose name of this server', 'verbose', 'Name to display in server selection'),
1001 array('phpMyAdmin control user', 'controluser', 'User which phpMyAdmin can use for various actions'),
1002 array('phpMyAdmin control user password', 'controlpass', 'Password for user which phpMyAdmin can use for various actions', 'password'),
1003 array('phpMyAdmin database for advanced features', 'pmadb', 'phpMyAdmin will allow much more when you enable this. Table names are filled in automatically.'),
1004 array('Session name for signon auth', 'SignonSession', 'Leave empty if not using signon auth'),
1005 array('Login URL for signon auth', 'SignonURL', 'Leave empty if not using signon auth'),
1006 array('Logout URL', 'LogoutURL', 'Where to redirect user after logout'),
1009 ($number === FALSE) ?
'Enter new server connection parameters.' : 'Editing server ' . get_server_name($defaults, $number),
1010 $defaults, $number === FALSE ?
'Add' : '', 'Servers_');
1017 * Shows left frame configuration form
1019 * @param array optional defaults
1023 function show_left_form($defaults = array()) {
1025 <form method
="post" action
="">
1026 <?php
echo get_hidden_inputs();?
>
1027 <input type
="hidden" name
="action" value
="lay_navigation_real" />
1029 show_config_form(array(
1030 array('Use light version', 'LeftFrameLight', 'Disable this if you want to see all databases at one time.', TRUE),
1031 array('Display databases in tree', 'LeftFrameDBTree', 'Whether to display databases in tree (determined by separator defined lower)', TRUE),
1032 array('Databases tree separator', 'LeftFrameDBSeparator', 'String that separates databases into different tree level'),
1033 array('Table tree separator', 'LeftFrameTableSeparator', 'String that separates tables into different tree level'),
1034 array('Maximum table tree nesting', 'LeftFrameTableLevel', 'Maximum number of children in table tree'),
1035 array('Show logo', 'LeftDisplayLogo', 'Whether to show logo in left frame', TRUE),
1036 array('Display servers selection', 'LeftDisplayServers', 'Whether to show server selection in left frame', FALSE),
1037 array('Display servers as list', 'DisplayServersList', 'Whether to show server listing as list instead of drop down', FALSE),
1038 array('Display databases as list', 'DisplayDatabasesList', 'Whether to show database listing in navigation as list instead of drop down', array('auto', 'yes', 'no')),
1039 array('Enable pointer highlighting', 'LeftPointerEnable', 'Whether you want to highlight server under mouse', TRUE),
1041 'Configure navigation frame',
1042 'Customize the appears of the navigation frame.',
1050 * Shows tabs configuration form
1052 * @param array optional defaults
1056 function show_tabs_form($defaults = array()) {
1058 <form method
="post" action
="">
1059 <?php
echo get_hidden_inputs();?
>
1060 <input type
="hidden" name
="action" value
="lay_tabs_real" />
1062 show_config_form(array(
1063 array('Default tab for server', 'DefaultTabServer', 'Tab that is displayed when entering server', array('main.php', 'server_databases.php', 'server_status.php', 'server_variables.php', 'server_privileges.php', 'server_processlist.php')),
1064 array('Default tab for database', 'DefaultTabDatabase', 'Tab that is displayed when entering database', array('db_structure.php', 'db_sql.php', 'db_search.php', 'db_operations.php')),
1065 array('Default tab for table', 'DefaultTabTable', 'Tab that is displayed when entering table', array('tbl_structure.php', 'sql.php', 'tbl_sql.php', 'tbl_select.php', 'tbl_change.php')),
1066 array('Use lighter tabs', 'LightTabs', 'If you want simpler tabs enable this', FALSE),
1069 'Choose how you want tabs to work.',
1077 * Shows icons configuration form
1079 * @param array optional defaults
1083 function show_icons_form($defaults = array()) {
1085 <form method
="post" action
="">
1086 <?php
echo get_hidden_inputs();?
>
1087 <input type
="hidden" name
="action" value
="lay_icons_real" />
1089 show_config_form(array(
1090 array('Icons on errors', 'ErrorIconic', 'Whether to use icons in error messages.', TRUE),
1091 array('Icons on main page', 'MainPageIconic', 'Whether to use icons on main page.', TRUE),
1092 array('Icons as help links', 'ReplaceHelpImg', 'Whether to use icons as help links.', TRUE),
1093 array('Navigation with icons', 'NavigationBarIconic', 'Whether to display navigation (eg. tabs) with icons.', array('TRUE', 'FALSE', 'both')),
1094 array('Properties pages with icons', 'PropertiesIconic', 'Whether to display properties (eg. table lists and structure) with icons.', array('TRUE', 'FALSE', 'both')),
1097 'Select whether you prefer text or icons. Both means that text and icons will be displayed.',
1105 * Shows browsing configuration form
1107 * @param array optional defaults
1111 function show_browse_form($defaults = array()) {
1113 <form method
="post" action
="">
1114 <?php
echo get_hidden_inputs();?
>
1115 <input type
="hidden" name
="action" value
="lay_browse_real" />
1117 show_config_form(array(
1118 array('Display of values', 'DefaultDisplay', 'How to list values while browsing', array('horizontal', 'vertical', 'horizontalflipped')),
1119 array('Hightlight pointer', 'BrowsePointerEnable', 'Whether to highlight row under mouse.', TRUE),
1120 array('Use row marker', 'BrowseMarkerEnable', 'Whether to highlight selected row.', TRUE),
1121 array('Action buttons on left', 'ModifyDeleteAtLeft', 'Show action buttons on left side of listing?', TRUE),
1122 array('Action buttons on right', 'ModifyDeleteAtRight', 'Show action buttons on right side of listing?', FALSE),
1123 array('Repeat heading', 'RepeatCells', 'After how many rows heading should be repeated.'),
1125 'Configure browsing',
1126 'Select desired browsing look and feel.',
1134 * Shows editing options configuration form
1136 * @param array optional defaults
1140 function show_edit_form($defaults = array()) {
1142 <form method
="post" action
="">
1143 <?php
echo get_hidden_inputs();?
>
1144 <input type
="hidden" name
="action" value
="lay_edit_real" />
1146 show_config_form(array(
1147 array('Display of properties while editing', 'DefaultPropDisplay', 'How to list properties (table structure or values) while editing', array('horizontal', 'vertical')),
1148 array('Number of inserted rows', 'InsertRows', 'How many rows can be inserted at once'),
1149 array('Move using Ctrl+arrows', 'CtrlArrowsMoving', 'Whether to enable moving using Ctrl+Arrows', TRUE),
1150 array('Autoselect text in textarea', 'TextareaAutoSelect', 'Whether to automatically select text in textarea on focus.', TRUE),
1151 array('Textarea columns', 'TextareaCols', 'Number of columns in textarea while editing TEXT fields'),
1152 array('Textarea rows', 'TextareaRows', 'Number of rows in textarea while editing TEXT fields'),
1153 array('Double textarea for LONGTEXT', 'LongtextDoubleTextarea', 'Whether to double textarea size for LONGTEXT fields', TRUE),
1154 array('Edit CHAR fields in textarea', 'CharEditing', 'Whether to edit CHAR fields in textarea', array('input', 'textarea')),
1155 array('CHAR textarea columns', 'CharTextareaCols', 'Number of columns in textarea while editing CHAR fields (must be enabled above)'),
1156 array('CHAR textarea rows', 'CharTextareaRows', 'Number of rows in textarea while editing CHAR fields (must be enabled above)'),
1158 'Configure editing',
1159 'Select desired editing look and feel.',
1167 * Shows query window configuration form
1169 * @param array optional defaults
1173 function show_window_form($defaults = array()) {
1175 <form method
="post" action
="">
1176 <?php
echo get_hidden_inputs();?
>
1177 <input type
="hidden" name
="action" value
="lay_window_real" />
1179 show_config_form(array(
1180 array('Edit SQL in window', 'EditInWindow', 'Whether edit links will edit in query window.', TRUE),
1181 array('Query window height', 'QueryWindowHeight', 'Height of query window'),
1182 array('Query window width', 'QueryWindowWidth', 'Width of query window'),
1183 array('Default tab', 'QueryWindowDefTab', 'Default tab on query window', array('sql', 'files', 'history', 'full')),
1185 'Configure query window',
1186 'Select desired query window look and feel.',
1194 * Creates selection with servers
1196 * @param array configuraion
1198 * @return string HTML for server selection
1200 function get_server_selection($cfg) {
1201 if (count($cfg['Servers']) == 0) {
1204 $ret = '<select name="server">';
1205 foreach ($cfg['Servers'] as $key => $val) {
1206 $ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>';
1208 $ret .= '</select>';
1213 * Loads configuration from file
1215 * @param string filename
1217 * @return mixed FALSE on failure, new config array on success
1219 function load_config($config_file) {
1220 if (file_exists($config_file)) {
1221 $success_apply_user_config = FALSE;
1222 $old_error_reporting = error_reporting(0);
1223 if (function_exists('file_get_contents')) {
1224 $success_apply_user_config = eval('?>' . trim(file_get_contents($config_file)));
1226 $success_apply_user_config =
1227 eval('?>' . trim(implode("\n", file($config_file))));
1229 error_reporting($old_error_reporting);
1230 unset($old_error_reporting);
1231 if ($success_apply_user_config === FALSE) {
1232 message('error', 'Error while parsing configuration file!');
1233 } elseif (!isset($cfg) ||
count($cfg) == 0) {
1234 message('error', 'Config file seems to contain no configuration!');
1237 if (!isset($cfg['Servers'])) {
1238 $cfg['Servers'] = array();
1240 message('notice', 'Configuration loaded');
1241 compress_servers($cfg);
1245 message('error', 'Configuration file not found!');
1250 if ($action != 'download') {
1251 // Check whether we can write to configuration
1253 $fail_dir = $fail_dir ||
!is_dir('./config/');
1254 $fail_dir = $fail_dir ||
!is_writable('./config/');
1255 $fail_dir = $fail_dir ||
(file_exists('./config/config.inc.php') && !is_writable('./config/config.inc.php'));
1256 $config = @fopen
('./config/config.inc.php', 'a');
1257 $fail_dir = $fail_dir ||
($config === FALSE);
1262 * @var boolean whether to show configuration overview
1266 // Do the main work depending on selected action
1269 header('Content-Type: text/plain');
1270 header('Content-Disposition: attachment; filename="config.inc.php"');
1272 echo get_cfg_string($_SESSION['configuration']);
1276 echo '<form method="none" action=""><textarea name="config" cols="50" rows="20" id="textconfig" wrap="off">' . "\n";
1277 echo htmlspecialchars(get_cfg_string($_SESSION['configuration']));
1278 echo '</textarea></form>' . "\n";
1280 <script type
="text/javascript">
1282 var bodyWidth
=null; var bodyHeight
=null;
1283 if (document
.getElementById('textconfig')) {
1284 bodyWidth
= self
.innerWidth
;
1285 bodyHeight
= self
.innerHeight
;
1286 if(!bodyWidth
&& !bodyHeight
){
1287 if (document
.compatMode
&& document
.compatMode
== "BackCompat") {
1288 bodyWidth
= document
.body
.clientWidth
;
1289 bodyHeight
= document
.body
.clientHeight
;
1290 } else if (document
.compatMode
&& document
.compatMode
== "CSS1Compat") {
1291 bodyWidth
= document
.documentElement
.clientWidth
;
1292 bodyHeight
= document
.documentElement
.clientHeight
;
1295 document
.getElementById('textconfig').style
.width
=(bodyWidth
-50) +
'px';
1296 document
.getElementById('textconfig').style
.height
=(bodyHeight
-100) +
'px';
1303 $config = @fopen
('./config/config.inc.php', 'w');
1304 if ($config === FALSE) {
1305 message('error', 'Could not open config file for writing! Bad permissions?');
1308 $s = get_cfg_string($_SESSION['configuration']);
1309 $r = fwrite($config, $s);
1310 if (!$r ||
$r != strlen($s)) {
1311 message('error', 'Could not write to config file! Not enough space?');
1314 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');
1321 message('error', 'Reading of configuration disabled because of permissions.');
1324 $new_cfg = load_config('./config/config.inc.php');
1325 if (!($new_cfg === FALSE)) {
1326 $_SESSION['configuration'] = $new_cfg;
1331 case 'addserver_real':
1332 if (isset($_POST['submit_save'])) {
1333 $new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable;relation;table_info;table_coords;pdf_pages;column_info;designer_coords;history;AllowDeny:allow-deny;SignonSession;SignonURL;LogoutURL');
1335 if (empty($new_server['host'])) {
1336 message('error', 'Empty hostname!');
1339 if ($new_server['auth_type'] == 'config' && empty($new_server['user'])) {
1340 message('error', 'Empty username while using config authentication method!');
1343 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonSession'])) {
1344 message('error', 'Empty signon session name while using signon authentication method!');
1347 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonURL'])) {
1348 message('error', 'Empty signon URL while using signon authentication method!');
1351 if (isset($new_server['pmadb']) && strlen($new_server['pmadb'])) {
1352 // Just use defaults, should be okay for most users
1354 $pmadb['bookmarktable'] = 'pma_bookmark';
1355 $pmadb['relation'] = 'pma_relation';
1356 $pmadb['table_info'] = 'pma_table_info';
1357 $pmadb['table_coords'] = 'pma_table_coords';
1358 $pmadb['pdf_pages'] = 'pma_pdf_pages';
1359 $pmadb['column_info'] = 'pma_column_info';
1360 $pmadb['designer_coords'] = 'pma_designer_coords';
1361 $pmadb['history'] = 'pma_history';
1363 $new_server = array_merge($pmadb, $new_server);
1365 if (empty($new_server['controluser'])) {
1366 message('error', 'Empty phpMyAdmin control user while using pmadb!');
1369 if (empty($new_server['controlpass'])) {
1370 message('error', 'Empty phpMyAdmin control user password while using pmadb!');
1373 /* Check whether we can connect as control user */
1374 if (!empty($new_server['controluser']) && !empty($new_server['controlpass'])) {
1375 if ($new_server['extension'] == 'mysql') {
1376 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
'' : ':' . $new_server['socket'];
1377 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
'' : ':' . $new_server['port'];
1378 $conn = @mysql_connect
($new_server['host'] . $socket . $port, $new_server['controluser'], $new_server['controlpass']);
1379 if ($conn === FALSE) {
1380 message('error', 'Could not connect as control user!');
1386 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
NULL : $new_server['socket'];
1387 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
NULL : $new_server['port'];
1388 $conn = @mysqli_connect
($new_server['host'], $new_server['controluser'], $new_server['controlpass'], NULL, $port, $socket);
1389 if ($conn === FALSE) {
1390 message('error', 'Could not connect as control user!');
1393 mysqli_close($conn);
1398 message('warning', 'You didn\'t set phpMyAdmin database, so you can not use all phpMyAdmin features.');
1400 if ($new_server['auth_type'] == 'config') {
1401 message('warning', 'Remember to protect your installation while using config authentication method!');
1404 unset($new_server['user']);
1405 unset($new_server['password']);
1408 show_server_form($new_server, isset($_POST['server']) ?
$_POST['server'] : FALSE);
1410 if (isset($_POST['server'])) {
1411 $_SESSION['configuration']['Servers'][$_POST['server']] = $new_server;
1412 message('notice', 'Changed server ' . get_server_name($new_server, $_POST['server']));
1414 $_SESSION['configuration']['Servers'][] = $new_server;
1415 message('notice', 'New server added');
1418 if ($new_server['auth_type'] == 'cookie' && empty($_SESSION['configuration']['blowfish_secret'])) {
1419 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');
1420 $_SESSION['configuration']['blowfish_secret'] = uniqid('', TRUE);
1429 if (count($_SESSION['configuration']['Servers']) == 0) {
1430 // First server will use defaults as in config.default.php
1431 $defaults = $PMA_Config_Setup->default_server
;
1432 unset($defaults['AllowDeny']); // Ignore this for now
1434 $defaults = array();
1437 // Guess MySQL extension to use, prefer mysqli
1438 if (!function_exists('mysql_get_client_info')) {
1441 if (!function_exists('mysqli_get_client_info')) {
1444 if (function_exists('mysqli_get_client_info')) {
1445 $defaults['extension'] = 'mysqli';
1446 } elseif (function_exists('mysql_get_client_info')) {
1447 $defaults['extension'] = 'mysql';
1449 message('warning', 'Could not load either mysql or mysqli extension, you might not be able to use phpMyAdmin! Check your PHP configuration.');
1451 if (isset($defaults['extension'])) {
1452 message('notice', 'Autodetected MySQL extension to use: ' . $defaults['extension']);
1456 show_server_form($defaults);
1459 if (!isset($_POST['server'])) {
1462 show_server_form($_SESSION['configuration']['Servers'][$_POST['server']], $_POST['server']);
1464 case 'deleteserver':
1465 if (!isset($_POST['server'])) {
1468 message('notice', 'Deleted server ' . get_server_name($_SESSION['configuration']['Servers'][$_POST['server']], $_POST['server']));
1469 unset($_SESSION['configuration']['Servers'][$_POST['server']]);
1470 compress_servers($_SESSION['configuration']);
1474 if (count($_SESSION['configuration']['Servers']) == 0) {
1475 message('notice', 'No servers defined, so none can be shown');
1477 foreach ($_SESSION['configuration']['Servers'] as $i => $srv) {
1479 if (!empty($srv['verbose'])) {
1480 $data[] = array('Verbose name', $srv['verbose']);
1482 $data[] = array('Host', $srv['host']);
1483 $data[] = array('MySQL extension', isset($srv['extension']) ?
$srv['extension'] : $PMA_Config_Setup->default_server
['extension']);
1484 $data[] = array('Authentication type', get_server_auth($srv));
1485 $data[] = array('phpMyAdmin advanced features', empty($srv['pmadb']) ||
empty($srv['controluser']) ||
empty($srv['controlpass']) ?
'disabled' : 'enabled, db: ' . $srv['pmadb'] . ', user: ' . $srv['controluser']);
1487 get_action('deleteserver', 'Delete', '<input type="hidden" name="server" value="' . $i . '" />') .
1488 get_action('editserver', 'Edit', '<input type="hidden" name="server" value="' . $i . '" />');
1489 show_overview('Server ' . get_server_name($srv, $i), $data, $buttons);
1494 case 'feat_upload_real':
1495 if (isset($_POST['submit_save'])) {
1496 $dirs = grab_values('UploadDir;SaveDir');
1498 if (!empty($dirs['UploadDir']) && !is_dir($dirs['UploadDir'])) {
1499 message('error', 'Upload directory ' . htmlspecialchars($dirs['UploadDir']) . ' does not exist!');
1502 if (!empty($dirs['SaveDir']) && !is_dir($dirs['SaveDir'])) {
1503 message('error', 'Save directory ' . htmlspecialchars($dirs['SaveDir']) . ' does not exist!');
1507 show_upload_form($dirs);
1509 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $dirs);
1510 message('notice', 'Configuration changed');
1518 show_upload_form($_SESSION['configuration']);
1521 case 'feat_security_real':
1522 if (isset($_POST['submit_save'])) {
1523 $vals = grab_values('blowfish_secret;ForceSSL:bool;ShowPhpInfo:bool;ShowChgPassword:bool;AllowArbitraryServer:bool;LoginCookieRecall:book;LoginCookieValidity:int');
1525 if (empty($vals['blowfish_secret'])) {
1526 message('warning', 'Blowfish secret is empty, you will not be able to use cookie authentication.');
1528 if ($vals['AllowArbitraryServer']) {
1529 message('warning', 'Arbitrary server connection might be dangerous as it might allow access to internal servers that are not reachable from outside.');
1531 if (isset($vals['LoginCookieValidity']) && $vals['LoginCookieValidity'] < 1) {
1532 message('error', 'Invalid cookie validity time');
1536 show_security_form($vals);
1538 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1539 message('notice', 'Configuration changed');
1546 case 'feat_security':
1547 show_security_form($_SESSION['configuration']);
1550 case 'feat_manual_real':
1551 if (isset($_POST['submit_save'])) {
1552 $vals = grab_values('MySQLManualBase;MySQLManualType');
1554 if ($vals['MySQLManualType'] != 'none' && empty($vals['MySQLManualBase'])) {
1555 message('error', 'You need to set manual base URL or choose type \'none\'.');
1559 show_manual_form($vals);
1561 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1562 message('notice', 'Configuration changed');
1570 show_manual_form($_SESSION['configuration']);
1573 case 'feat_charset_real':
1574 if (isset($_POST['submit_save'])) {
1575 $vals = grab_values('AllowAnywhereRecoding:bool;DefaultCharset;RecodingEngine;IconvExtraParams');
1578 show_charset_form($vals);
1580 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1581 message('notice', 'Configuration changed');
1588 case 'feat_charset':
1589 $d = $_SESSION['configuration'];
1590 if (!isset($d['RecodingEngine'])) {
1591 if (@extension_loaded
('iconv')) {
1592 $d['RecodingEngine'] = 'iconv';
1593 } elseif (@extension_loaded
('recode')) {
1594 $d['RecodingEngine'] = 'recode';
1597 if (!@extension_loaded
('iconv')) {
1599 if (!@extension_loaded
('recode')) {
1600 message('warning', 'Neither recode nor iconv could be loaded so charset conversion will most likely not work.');
1602 $d['RecodingEngine'] = 'recode';
1605 $d['RecodingEngine'] = 'iconv';
1608 if (isset($d['RecodingEngine'])) {
1609 message('notice', 'Autodetected recoding engine: ' . $d['RecodingEngine']);
1612 show_charset_form($d);
1616 case 'feat_extensions_real':
1617 if (isset($_POST['submit_save'])) {
1618 $vals = grab_values('GD2Available');
1621 show_extensions_form($vals);
1623 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1624 message('notice', 'Configuration changed');
1631 case 'feat_extensions':
1632 $d = $_SESSION['configuration'];
1633 if (!@extension_loaded
('mbstring')) {
1636 if (!@extension_loaded
('mbstring')) {
1637 message('warning', 'Could not load <code>mbstring</code> extension, which is required for work with multibyte strings like UTF-8 ones. Please consider installing it.');
1639 if (!isset($d['GD2Available'])) {
1640 if (PMA_IS_GD2
== 1) {
1641 message('notice', 'GD 2 or newer found.');
1642 $d['GD2Available'] = 'yes';
1644 message('warning', 'GD 2 or newer is not present.');
1645 $d['GD2Available'] = 'no';
1648 show_extensions_form($d);
1652 case 'feat_relation_real':
1653 if (isset($_POST['submit_save'])) {
1654 $vals = grab_values('QueryHistoryDB:bool;QueryHistoryMax:int;BrowseMIME:bool;PDFDefaultPageSize');
1656 if (isset($vals['QueryHistoryMax']) && $vals['QueryHistoryMax'] < 1) {
1657 message('error', 'Invalid value for query maximum history size!');
1661 show_relation_form($vals);
1663 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1664 message('notice', 'Configuration changed');
1671 case 'feat_relation':
1672 show_relation_form($_SESSION['configuration']);
1675 case 'lay_navigation_real':
1676 if (isset($_POST['submit_save'])) {
1677 $vals = grab_values('LeftFrameLight:bool;LeftFrameDBTree:bool;LeftFrameDBSeparator;LeftFrameTableSeparator;LeftFrameTableLevel:int;LeftDisplayLogo:bool;LeftDisplayServers:bool;DisplayServersList:bool;DisplayDatabasesList;LeftPointerEnable:bool');
1679 if (isset($vals['DisplayDatabasesList'])) {
1680 if ($vals['DisplayDatabasesList'] == 'yes') {
1681 $vals['DisplayDatabasesList'] = true;
1682 } elseif ($vals['DisplayDatabasesList'] == 'no') {
1683 $vals['DisplayDatabasesList'] = false;
1686 if (isset($vals['LeftFrameTableLevel']) && $vals['LeftFrameTableLevel'] < 1) {
1687 message('error', 'Invalid value for maximum table nesting level!');
1691 show_left_form($vals);
1693 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1694 message('notice', 'Configuration changed');
1701 case 'lay_navigation':
1702 show_left_form($_SESSION['configuration']);
1705 case 'lay_tabs_real':
1706 if (isset($_POST['submit_save'])) {
1707 $vals = grab_values('DefaultTabServer;DefaultTabDatabase;DefaultTabTable;LightTabs:bool');
1710 show_tabs_form($vals);
1712 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1713 message('notice', 'Configuration changed');
1721 show_tabs_form($_SESSION['configuration']);
1724 case 'lay_icons_real':
1725 if (isset($_POST['submit_save'])) {
1726 $vals = grab_values('ErrorIconic:bool;MainPageIconic:bool;ReplaceHelpImg:bool;NavigationBarIconic:tristate;PropertiesIconic:tristate');
1729 show_icons_form($vals);
1731 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1732 message('notice', 'Configuration changed');
1740 show_icons_form($_SESSION['configuration']);
1743 case 'lay_browse_real':
1744 if (isset($_POST['submit_save'])) {
1745 $vals = grab_values('BrowsePointerEnable:bool;BrowseMarkerEnable:bool;ModifyDeleteAtRight:bool;ModifyDeleteAtLeft:bool;RepeatCells:int;DefaultDisplay');
1747 if (isset($vals['RepeatCells']) && $vals['RepeatCells'] < 1) {
1748 message('error', 'Invalid value for header repeating!');
1751 if (!$vals['ModifyDeleteAtLeft'] && !$vals['ModifyDeleteAtRight']) {
1752 message('error', 'No action buttons enabled!');
1756 show_browse_form($vals);
1758 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1759 message('notice', 'Configuration changed');
1767 show_browse_form($_SESSION['configuration']);
1770 case 'lay_edit_real':
1771 if (isset($_POST['submit_save'])) {
1772 $vals = grab_values('TextareaCols:int;TextareaRows:int;LongtextDoubleTextarea:bool;TextareaAutoSelect:bool;CharEditing;CharTextareaCols:int;CharTextareaRows:int;CtrlArrowsMoving:bool;DefaultPropDisplay;InsertRows:int');
1774 if (isset($vals['TextareaCols']) && $vals['TextareaCols'] < 1) {
1775 message('error', 'Invalid value for textarea columns!');
1778 if (isset($vals['TextareaRows']) && $vals['TextareaRows'] < 1) {
1779 message('error', 'Invalid value for textarea rows!');
1782 if (isset($vals['CharTextareaCols']) && $vals['CharTextareaCols'] < 1) {
1783 message('error', 'Invalid value for CHAR textarea columns!');
1786 if (isset($vals['CharTextareaRows']) && $vals['CharTextareaRows'] < 1) {
1787 message('error', 'Invalid value for CHAR textarea rows!');
1790 if (isset($vals['InsertRows']) && $vals['InsertRows'] < 1) {
1791 message('error', 'Invalid value for inserted rows count!');
1795 show_edit_form($vals);
1797 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1798 message('notice', 'Configuration changed');
1806 show_edit_form($_SESSION['configuration']);
1809 case 'lay_window_real':
1810 if (isset($_POST['submit_save'])) {
1811 $vals = grab_values('EditInWindow:bool;QueryWindowHeight:int;QueryWindowWidth:int;QueryWindowDefTab');
1813 if (isset($vals['QueryWindowWidth']) && $vals['QueryWindowWidth'] < 1) {
1814 message('error', 'Invalid value for query window width!');
1817 if (isset($vals['QueryWindowHeight']) && $vals['QueryWindowHeight'] < 1) {
1818 message('error', 'Invalid value for query window height');
1822 show_window_form($vals);
1824 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1825 message('notice', 'Configuration changed');
1833 show_window_form($_SESSION['configuration']);
1836 /* Template for new actions:
1838 if (isset($_POST['submit_save'])) {
1839 $vals = grab_values('value1:bool;value2');
1841 if (somechekcfails) {
1842 message('error', 'Invalid value for blah!');
1846 show_blah_form($vals);
1848 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1849 message('notice', 'Configuration changed');
1857 show_blah_form($_SESSION['configuration']);
1860 case 'versioncheck': // Check for latest available version
1862 $url = 'http://phpmyadmin.net/home_page/version.php';
1864 $f = @fopen
($url, 'r');
1866 if (!function_exists('curl_init')) {
1867 message('error', 'Neither URL wrappers nor CURL are available. Version check is not possible.');
1871 $data = fread($f, 20);
1874 if (empty($data) && function_exists('curl_init')) {
1875 $ch = curl_init($url);
1876 curl_setopt($ch, CURLOPT_HEADER
, FALSE);
1877 curl_setopt($ch, CURLOPT_RETURNTRANSFER
, TRUE);
1878 $data = curl_exec($ch);
1882 message('error', 'Reading of version failed. Maybe you\'re offline or the upgrade server does not respond.');
1886 /* Format: version\ndate\n(download\n)* */
1887 $data_list = split("\n", $data);
1889 if (count($data_list) > 0) {
1890 $version = $data_list[0];
1895 $version_upstream = version_to_int($version);
1896 if ($version_upstream === FALSE) {
1897 message('error', 'Got invalid version string from server.');
1901 $version_local = version_to_int($PMA_Config_Setup->get('PMA_VERSION'));
1902 if ($version_local === FALSE) {
1903 message('error', 'Unparsable version string.');
1907 if ($version_upstream > $version_local) {
1908 message('notice', 'New version of phpMyAdmin is available, you should consider upgrade. New version is ' . htmlspecialchars($version) . '.');
1910 if ($version_local %
100 == 0) {
1911 message('notice', 'You are using subversion version, run <code>svn update</code> :-). However latest released version is ' . htmlspecialchars($version) . '.');
1913 message('notice', 'No newer stable version is available.');
1919 $_SESSION['eoltype'] = $_POST['neweol'];
1920 message('notice', 'End of line format changed.');
1921 case 'clear': // Actual clearing is done on beginning of this script
1927 message('notice', 'You want to configure phpMyAdmin using web interface. Please note that this only allows basic setup, please read <a href="../Documentation.html#config">documentation</a> to see full description of all configuration directives.', 'Welcome');
1929 if ($PMA_Config_Setup->get('PMA_PHP_INT_VERSION') < 40100) {
1930 message('warning', 'Please upgrade to PHP 4.1.0, it is required for phpMyAdmin.', 'Too old PHP');
1934 message('warning', 'Please create web server writable folder config in phpMyAdmin toplevel directory as described in <a href="../Documentation.html#setup_script">documentation</a>. Otherwise you will be only able to download or display it.', 'Can not load or save configuration');
1937 if (empty($_SERVER['HTTPS']) ||
strtolower($_SERVER['HTTPS']) == 'off') {
1938 if (empty($_SERVER['REQUEST_URI']) ||
empty($_SERVER['HTTP_HOST'])) {
1941 $redir = ' If your server is also configured to accept HTTPS request'
1942 . ' follow <a href="https://'
1943 . htmlspecialchars($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])
1944 . '">this link</a> to use secure connection.';
1946 message('warning', 'You are not using secure connection, all data (including sensitive, like passwords) are transfered unencrypted!' . $redir, 'Not secure connection');
1951 // Should we show information?
1954 $servers_text = 'Servers';
1955 if (count($_SESSION['configuration']['Servers']) == 0) {
1956 message('warning', 'No servers defined, you probably want to add one.');
1959 $servers_text = 'Servers (' . count($_SESSION['configuration']['Servers']) . ')';
1962 foreach ($_SESSION['configuration']['Servers'] as $key => $val) {
1965 $servers .= get_server_name($val, $key);
1969 show_overview('Current configuration overview',
1971 array($servers_text, $servers),
1972 array('SQL files upload', empty($_SESSION['configuration']['UploadDir']) ?
'disabled' : 'enabled'),
1973 array('Exported files on server', empty($_SESSION['configuration']['SaveDir']) ?
'disabled' : 'enabled'),
1974 array('Charset conversion', isset($_SESSION['configuration']['AllowAnywhereRecoding']) && $_SESSION['configuration']['AllowAnywhereRecoding'] ?
'enabled' : 'disabled'),
1976 unset($servers_text, $servers);
1979 // And finally display all actions:
1980 echo '<p>Available global actions (please note that these will delete any changes you could have done above):</p>';
1982 echo '<fieldset class="toolbar"><legend>Servers</legend>' . "\n";
1983 echo get_action('addserver', 'Add');
1984 $servers = get_server_selection($_SESSION['configuration']);
1985 if (!empty($servers)) {
1986 echo get_action('servers', 'List');
1987 echo get_action('deleteserver', 'Delete', $servers);
1988 echo get_action('editserver', 'Edit', $servers);
1990 echo '</fieldset>' . "\n\n";
1992 echo '<fieldset class="toolbar"><legend>Layout</legend>' . "\n";
1993 echo get_action('lay_navigation', 'Navigation frame');
1994 echo get_action('lay_tabs', 'Tabs');
1995 echo get_action('lay_icons', 'Icons');
1996 echo get_action('lay_browse', 'Browsing');
1997 echo get_action('lay_edit', 'Editing');
1998 echo get_action('lay_window', 'Query window');
1999 echo '</fieldset>' . "\n\n";
2001 echo '<fieldset class="toolbar"><legend>Features</legend>' . "\n";
2002 echo get_action('feat_upload', 'Upload/Download');
2003 echo get_action('feat_security', 'Security');
2004 echo get_action('feat_manual', 'MySQL manual');
2005 echo get_action('feat_charset', 'Charsets');
2006 echo get_action('feat_extensions', 'Extensions');
2007 echo get_action('feat_relation', 'MIME/Relation/History');
2008 echo '</fieldset>' . "\n\n";
2010 echo '<fieldset class="toolbar"><legend>Configuration</legend>' . "\n";
2011 echo get_action('main', 'Overview');
2012 echo get_action('display', 'Display');
2013 echo get_action('download', 'Download');
2014 echo get_action('save', 'Save', '', !$fail_dir);
2015 echo get_action('load', 'Load', '', !$fail_dir);
2016 echo get_action('clear', 'Clear');
2017 echo get_action('seteol', 'Change end of line',
2018 '<select name="neweol">' .
2019 '<option value="unix" ' . ($_SESSION['eoltype'] == 'unix' ?
' selected="selected"' : '') . '>UNIX/Linux (\\n)</option>' .
2020 '<option value="dos" ' . ($_SESSION['eoltype'] == 'dos' ?
' selected="selected"' : '') . '>DOS/Windows (\\r\\n)</option>' .
2021 '<option value="mac" ' . ($_SESSION['eoltype'] == 'mac' ?
' selected="selected"' : '') . '>Macintosh (\\r)</option>' . '
2023 echo '</fieldset>' . "\n\n";
2025 echo '<fieldset class="toolbar"><legend>Other actions</legend>' . "\n";
2026 echo get_action('versioncheck', 'Check for latest version');
2027 echo get_url_action('http://www.phpmyadmin.net/', 'Go to homepage');
2028 echo get_url_action('https://sourceforge.net/donate/index.php', 'Donate to phpMyAdmin', array('group_id' => 23067));
2029 echo '</fieldset>' . "\n\n";