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 $k = preg_replace('/[^A-Za-z0-9_]/', '_', $k);
522 $ret .= get_cfg_val($name . "['$k']", $v);
523 } elseif ($type == 'int') {
524 $ret .= ' ' . PMA_var_export($v) . ',' . $crlf;
529 $ret .= $name . ' = array();' . $crlf;
530 } elseif ($type == 'int') {
531 $ret .= ');' . $crlf;
536 $ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf;
542 * Creates configuration PHP code
544 * @param array configuration
546 * @return string PHP code containing configuration
548 function get_cfg_string($cfg) {
549 global $script_info, $script_version, $now, $crlf;
552 $ret = "<?php$crlf/*$crlf * Generated configuration file$crlf * Generated by: $script_info$crlf * Version: $script_version$crlf * Date: " . $now . $crlf . ' */' . $crlf . $crlf;
554 if (count($c['Servers']) > 0) {
555 $ret .= "/* Servers configuration */$crlf\$i = 0;" . $crlf;
556 foreach ($c['Servers'] as $cnt => $srv) {
557 $ret .= $crlf . '/* Server ' . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */$crlf\$i++;" . $crlf;
558 foreach ($srv as $key => $val) {
559 $key = preg_replace('/[^A-Za-z0-9_]/', '_', $key);
560 $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);
563 $ret .= $crlf . '/* End of servers configuration */' . $crlf . $crlf;
565 unset($c['Servers']);
567 foreach ($c as $key => $val) {
568 $key = preg_replace('/[^A-Za-z0-9_]/', '_', $key);
569 $ret .= get_cfg_val("\$cfg['$key']", $val);
572 $ret .= '?>' . $crlf;
577 * Compresses server configuration to be indexed from 0 and contain no gaps
579 * @param array configuration
583 function compress_servers(&$cfg) {
585 foreach ($cfg['Servers'] as $val) {
586 if (!empty($val['host'])) {
590 $cfg['Servers'] = $ns;
594 * Grabs values from POST
596 * @param string list of values to grab, values are separated by ";",
597 * each can have defined type separated by ":", if no type
598 * is defined, string is assumed. Possible types: bool -
599 * boolean value, allow-deny - allow-deny rules, int -
600 * integer, tristate - "TRUE"/"FALSE" converted to bool,
601 * other strings are kept.
603 * @return array array with grabbed values
605 function grab_values($list)
607 $a = split(';', $list);
609 foreach ($a as $val) {
610 $v = split(':', $val);
616 $res[$v[0]] = isset($_POST[$v[0]]);
619 $res[$v[0]] = array();
620 if (isset($_POST[$v[0] . '_order']) && strlen($_POST[$v[0] . '_order']) > 0) {
621 $res[$v[0]]['order'] = $_POST[$v[0]];
623 $res[$v[0]]['order'] = '';
625 if (isset($_POST[$v[0] . '_rules']) && strlen($_POST[$v[0] . '_rules']) > 0) {
626 $res[$v[0]]['rules'] = split('|', $_POST[$v[0]]);
628 $res[$v[0]]['rules'] = array();
632 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
633 $res[$v[0]] = (int)$_POST[$v[0]];
637 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
638 $cur = $_POST[$v[0]];
639 if ($cur == 'TRUE') {
641 } elseif ($cur == 'FALSE') {
650 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
651 $res[$v[0]] = $_POST[$v[0]];
662 * @param string title of oveview
663 * @param array list of values to display (each element is array of two
664 * values - name and value)
665 * @param string optional buttons to be displayed
669 function show_overview($title, $list, $buttons = '') {
670 echo '<fieldset class="overview">' . "\n";
671 echo '<legend>' . $title . '</legend>' . "\n";
672 foreach ($list as $val) {
673 echo '<div class="row">';
674 echo '<div class="desc">';
677 echo '<div class="data">';
678 echo htmlspecialchars($val[1]);
680 echo '</div>' . "\n";
682 if (!empty($buttons)) {
683 echo '<div class="buttons">';
684 echo '<div class="desc">Actions:</div>';
686 echo '</div>' . "\n";
688 echo '</fieldset>' . "\n";
693 * Displays configuration, fallback defaults are taken from global $PMA_Config_Setup
695 * @param array list of values to display (each element is array of two or
696 * three values - desription, name and optional type
697 * indicator). Type is determined by type of this parameter,
698 * array means select and array elements are items,
699 * 'password' means password input.
700 * @param string title of configuration
701 * @param string help string for this configuration
702 * @param array optional first level defaults
703 * @param string optional title for save button
704 * @param string optional prefix for documentation links
708 function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {
709 global $PMA_Config_Setup;
715 echo '<fieldset class="optbox">' . "\n";
716 echo '<legend>' . $legend . '</legend>' . "\n";
717 echo '<p>' . $help . '</p>' . "\n";
718 foreach ($list as $val) {
719 echo '<div class="opts">';
721 if (isset($val[3])) {
722 if (is_array($val[3])) {
724 } elseif (is_bool($val[3])) {
726 } elseif ($val[3] == 'password') {
733 echo '<label for="text_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
734 echo '<input type="' . $type . '" name="' . $val[1] . '" id="text_' . $val[1] . '" title="' . $val[2] . '" size="50"';
735 if (isset($defaults[$val[1]])) {
736 echo ' value="' . htmlspecialchars($defaults[$val[1]]) . '"';
738 echo ' value="' . htmlspecialchars($PMA_Config_Setup->get($val[1])) . '"';
743 echo '<input type="checkbox" name="' . $val[1] . '" value="something" id="checkbox_' . $val[1] . '" title="' . $val[2] . '"';
744 if (isset($defaults[$val[1]])) {
745 if ($defaults[$val[1]]) {
746 echo ' checked="checked"';
749 if ($PMA_Config_Setup->get($val[1])) {
750 echo ' checked="checked"';
754 echo '<label for="checkbox_' . $val[1] . '" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
757 echo '<label for="select_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
758 echo '<select name="' . $val[1] . '" id="select_' . $val[1] . '" ' . ' title="' . $val[2] . '">';
759 foreach ($val[3] as $opt) {
760 echo '<option value="' . $opt . '"';
761 if (isset($defaults[$val[1]])) {
762 if (is_bool($defaults[$val[1]])) {
763 if (($defaults[$val[1]] && $opt == 'TRUE') ||
(!$defaults[$val[1]] && $opt == 'FALSE')) {
764 echo ' selected="selected"';
767 if ($defaults[$val[1]] == $opt) {
768 echo ' selected="selected"';
772 $def_val = $PMA_Config_Setup->get($val[1]);
774 if (($def_val && $opt == 'TRUE') ||
(!$def_val && $opt == 'FALSE')) {
775 echo ' selected="selected"';
778 if ($def_val == $opt) {
779 echo ' selected="selected"';
784 echo '>' . $opt . '</option>';
789 echo '</div>' . "\n";
791 echo '<div class="buttons">';
792 echo '<div class="desc">Actions:</div>';
793 echo '<input type="submit" name="submit_save" value="' . $save .'" class="save" />';
794 echo '<input type="submit" name="submit_ignore" value="Cancel" class="cancel" />';
795 echo '</div>' . "\n";
796 echo '</fieldset>' . "\n";
801 * Shows security options configuration form
803 * @param array optional defaults
807 function show_security_form($defaults = array()) {
809 <form method
="post" action
="">
810 <?php
echo get_hidden_inputs();?
>
811 <input type
="hidden" name
="action" value
="feat_security_real" />
813 show_config_form(array(
814 array('Blowfish secret', 'blowfish_secret', 'Secret passphrase used for encrypting cookies'),
815 array('Force SSL connection', 'ForceSSL', 'Whether to force using secured connection while using phpMyAdmin', FALSE),
816 array('Show phpinfo output', 'ShowPhpInfo', 'Whether to allow users to see phpinfo() output', FALSE),
817 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),
818 array('Allow login to any MySQL server', 'AllowArbitraryServer', 'If enabled user can enter any MySQL server in login form for cookie auth.', FALSE),
819 array('Recall user name', 'LoginCookieRecall', 'Whether to recall user name on log in prompt while using cookie auth.', TRUE),
820 array('Login cookie validity', 'LoginCookieValidity', 'How long is login valid without performing any action.'),
822 'Configure security features',
823 'Please note that phpMyAdmin is just a user interface and it\'s features do not limit MySQL.',
831 * Shows MySQL manual configuration form
833 * @param array optional defaults
837 function show_manual_form($defaults = array()) {
839 <form method
="post" action
="">
840 <?php
echo get_hidden_inputs();?
>
841 <input type
="hidden" name
="action" value
="feat_manual_real" />
843 show_config_form(array(
844 array('Type of MySQL documentation', 'MySQLManualType', 'These types are same as listed on MySQL download page', array('viewable', 'chapters', 'big', 'none')),
845 array('Base URL of MySQL documentation', 'MySQLManualBase', 'Where is MySQL documentation placed, this is usually top level directory.'),
847 'Configure MySQL manual links',
848 '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.',
856 * Shows charset options configuration form
858 * @param array optional defaults
862 function show_charset_form($defaults = array()) {
863 global $PMA_Config_Setup;
865 <form method
="post" action
="">
866 <?php
echo get_hidden_inputs();?
>
867 <input type
="hidden" name
="action" value
="feat_charset_real" />
869 show_config_form(array(
870 array('Allow charset conversion', 'AllowAnywhereRecoding', 'If you want to use such functions.', FALSE),
871 array('Default charset', 'DefaultCharset', 'Default charset for conversion.', $PMA_Config_Setup->get('AvailableCharsets')),
872 array('Recoding engine', 'RecodingEngine', 'PHP can contain iconv and/or recode, select which one to use or keep autodetection.', array('auto', 'iconv', 'recode')),
873 array('Extra params for iconv', 'IconvExtraParams', 'Iconv can get some extra parameters for conversion see man iconv_open.'),
875 'Configure charset conversions',
876 'phpMyAdmin can perform charset conversions so that you can import and export in any charset you want.',
884 * Shows PHP extensions configuration form
886 * @param array optional defaults
890 function show_extensions_form($defaults = array()) {
892 <form method
="post" action
="">
893 <?php
echo get_hidden_inputs();?
>
894 <input type
="hidden" name
="action" value
="feat_extensions_real" />
896 show_config_form(array(
897 array('GD 2 is available', 'GD2Available', 'Whether you have GD 2 or newer installed', array('auto', 'yes', 'no')),
899 'Configure extensions',
900 '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.',
908 * Shows MIME/relation/history configuration form
910 * @param array optional defaults
914 function show_relation_form($defaults = array()) {
915 global $PMA_Config_Setup;
917 <form method
="post" action
="">
918 <?php
echo get_hidden_inputs();?
>
919 <input type
="hidden" name
="action" value
="feat_relation_real" />
921 show_config_form(array(
922 array('Permanent query history', 'QueryHistoryDB', 'Store history into database.', FALSE),
923 array('Maximal history size', 'QueryHistoryMax', 'How many queries are kept in history.'),
924 array('Use MIME transformations', 'BrowseMIME', 'Use MIME transformations while browsing.', TRUE),
925 array('PDF default page size', 'PDFDefaultPageSize', 'Default page size for PDF, you can change this while creating page.', $PMA_Config_Setup->get('PDFPageSizes')),
927 'Configure MIME/relation/history',
928 '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.',
936 * Shows upload/save configuration form
938 * @param array optional defaults
942 function show_upload_form($defaults = array()) {
944 <form method
="post" action
="">
945 <?php
echo get_hidden_inputs();?
>
946 <input type
="hidden" name
="action" value
="feat_upload_real" />
948 show_config_form(array(
949 array('Upload directory', 'UploadDir', 'Directory on server where you can upload files for import'),
950 array('Save directory', 'SaveDir', 'Directory where exports can be saved on server'),
952 'Configure upload/save directories',
953 'Enter directories, either absolute path or relative to phpMyAdmin top level directory.',
961 * Shows server configuration form
963 * @param array optional defaults
967 function show_server_form($defaults = array(), $number = FALSE) {
969 <form method
="post" action
="">
970 <?php
echo get_hidden_inputs();?
>
971 <input type
="hidden" name
="action" value
="addserver_real" />
973 if (!($number === FALSE)) {
974 echo '<input type="hidden" name="server" value="' . $number . '" />';
976 $hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'designer_coords', 'history');
977 foreach ($hi as $k) {
978 if (isset($defaults[$k]) && is_string($defaults[$k]) && strlen($defaults[$k]) > 0) {
979 echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars($defaults[$k]) . '" />';
982 if (isset($defaults['AllowDeny'])) {
983 if (isset($defaults['AllowDeny']['order']) && is_string($defaults['AllowDeny']['order']) && strlen($defaults['AllowDeny']['order']) > 0) {
984 echo '<input type="hidden" name="AllowDeny_rules" value="' . htmlspecialchars($defaults['AllowDeny']['order']) . '" />';
986 if (isset($defaults['AllowDeny']['rules']) && is_array($defaults['AllowDeny']['rules']) && count($defaults['AllowDeny']['rules']) > 0) {
987 echo '<input type="hidden" name="AllowDeny_rules" value="' . htmlspecialchars(implode('|', $defaults['AllowDeny']['rules'])) . '" />';
990 show_config_form(array(
991 array('Server hostname', 'host', 'Hostname where MySQL server is running'),
992 array('Server port', 'port', 'Port on which MySQL server is listening, leave empty for default'),
993 array('Server socket', 'socket', 'Socket on which MySQL server is listening, leave empty for default'),
994 array('Connection type', 'connect_type', 'How to connect to server, keep tcp if unsure', array('tcp', 'socket')),
995 array('PHP extension to use', 'extension', 'What PHP extension to use, use mysqli if supported', array('mysql', 'mysqli')),
996 array('Compress connection', 'compress', 'Whether to compress connection to MySQL server', FALSE),
997 array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config', 'signon')),
998 array('User for config auth', 'user', 'Leave empty if not using config auth'),
999 array('Password for config auth', 'password', 'Leave empty if not using config auth', 'password'),
1000 array('Only database to show', 'only_db', 'Limit listing of databases in left frame to this one'),
1001 array('Verbose name of this server', 'verbose', 'Name to display in server selection'),
1002 array('phpMyAdmin control user', 'controluser', 'User which phpMyAdmin can use for various actions'),
1003 array('phpMyAdmin control user password', 'controlpass', 'Password for user which phpMyAdmin can use for various actions', 'password'),
1004 array('phpMyAdmin database for advanced features', 'pmadb', 'phpMyAdmin will allow much more when you enable this. Table names are filled in automatically.'),
1005 array('Session name for signon auth', 'SignonSession', 'Leave empty if not using signon auth'),
1006 array('Login URL for signon auth', 'SignonURL', 'Leave empty if not using signon auth'),
1007 array('Logout URL', 'LogoutURL', 'Where to redirect user after logout'),
1010 ($number === FALSE) ?
'Enter new server connection parameters.' : 'Editing server ' . get_server_name($defaults, $number),
1011 $defaults, $number === FALSE ?
'Add' : '', 'Servers_');
1018 * Shows left frame configuration form
1020 * @param array optional defaults
1024 function show_left_form($defaults = array()) {
1026 <form method
="post" action
="">
1027 <?php
echo get_hidden_inputs();?
>
1028 <input type
="hidden" name
="action" value
="lay_navigation_real" />
1030 show_config_form(array(
1031 array('Use light version', 'LeftFrameLight', 'Disable this if you want to see all databases at one time.', TRUE),
1032 array('Display databases in tree', 'LeftFrameDBTree', 'Whether to display databases in tree (determined by separator defined lower)', TRUE),
1033 array('Databases tree separator', 'LeftFrameDBSeparator', 'String that separates databases into different tree level'),
1034 array('Table tree separator', 'LeftFrameTableSeparator', 'String that separates tables into different tree level'),
1035 array('Maximum table tree nesting', 'LeftFrameTableLevel', 'Maximum number of children in table tree'),
1036 array('Show logo', 'LeftDisplayLogo', 'Whether to show logo in left frame', TRUE),
1037 array('Display servers selection', 'LeftDisplayServers', 'Whether to show server selection in left frame', FALSE),
1038 array('Display servers as list', 'DisplayServersList', 'Whether to show server listing as list instead of drop down', FALSE),
1039 array('Display databases as list', 'DisplayDatabasesList', 'Whether to show database listing in navigation as list instead of drop down', array('auto', 'yes', 'no')),
1040 array('Enable pointer highlighting', 'LeftPointerEnable', 'Whether you want to highlight server under mouse', TRUE),
1042 'Configure navigation frame',
1043 'Customize the appears of the navigation frame.',
1051 * Shows tabs configuration form
1053 * @param array optional defaults
1057 function show_tabs_form($defaults = array()) {
1059 <form method
="post" action
="">
1060 <?php
echo get_hidden_inputs();?
>
1061 <input type
="hidden" name
="action" value
="lay_tabs_real" />
1063 show_config_form(array(
1064 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')),
1065 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')),
1066 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')),
1067 array('Use lighter tabs', 'LightTabs', 'If you want simpler tabs enable this', FALSE),
1070 'Choose how you want tabs to work.',
1078 * Shows icons configuration form
1080 * @param array optional defaults
1084 function show_icons_form($defaults = array()) {
1086 <form method
="post" action
="">
1087 <?php
echo get_hidden_inputs();?
>
1088 <input type
="hidden" name
="action" value
="lay_icons_real" />
1090 show_config_form(array(
1091 array('Icons on errors', 'ErrorIconic', 'Whether to use icons in error messages.', TRUE),
1092 array('Icons on main page', 'MainPageIconic', 'Whether to use icons on main page.', TRUE),
1093 array('Icons as help links', 'ReplaceHelpImg', 'Whether to use icons as help links.', TRUE),
1094 array('Navigation with icons', 'NavigationBarIconic', 'Whether to display navigation (eg. tabs) with icons.', array('TRUE', 'FALSE', 'both')),
1095 array('Properties pages with icons', 'PropertiesIconic', 'Whether to display properties (eg. table lists and structure) with icons.', array('TRUE', 'FALSE', 'both')),
1098 'Select whether you prefer text or icons. Both means that text and icons will be displayed.',
1106 * Shows browsing configuration form
1108 * @param array optional defaults
1112 function show_browse_form($defaults = array()) {
1114 <form method
="post" action
="">
1115 <?php
echo get_hidden_inputs();?
>
1116 <input type
="hidden" name
="action" value
="lay_browse_real" />
1118 show_config_form(array(
1119 array('Display of values', 'DefaultDisplay', 'How to list values while browsing', array('horizontal', 'vertical', 'horizontalflipped')),
1120 array('Hightlight pointer', 'BrowsePointerEnable', 'Whether to highlight row under mouse.', TRUE),
1121 array('Use row marker', 'BrowseMarkerEnable', 'Whether to highlight selected row.', TRUE),
1122 array('Action buttons on left', 'ModifyDeleteAtLeft', 'Show action buttons on left side of listing?', TRUE),
1123 array('Action buttons on right', 'ModifyDeleteAtRight', 'Show action buttons on right side of listing?', FALSE),
1124 array('Repeat heading', 'RepeatCells', 'After how many rows heading should be repeated.'),
1126 'Configure browsing',
1127 'Select desired browsing look and feel.',
1135 * Shows editing options configuration form
1137 * @param array optional defaults
1141 function show_edit_form($defaults = array()) {
1143 <form method
="post" action
="">
1144 <?php
echo get_hidden_inputs();?
>
1145 <input type
="hidden" name
="action" value
="lay_edit_real" />
1147 show_config_form(array(
1148 array('Display of properties while editing', 'DefaultPropDisplay', 'How to list properties (table structure or values) while editing', array('horizontal', 'vertical')),
1149 array('Number of inserted rows', 'InsertRows', 'How many rows can be inserted at once'),
1150 array('Move using Ctrl+arrows', 'CtrlArrowsMoving', 'Whether to enable moving using Ctrl+Arrows', TRUE),
1151 array('Autoselect text in textarea', 'TextareaAutoSelect', 'Whether to automatically select text in textarea on focus.', TRUE),
1152 array('Textarea columns', 'TextareaCols', 'Number of columns in textarea while editing TEXT fields'),
1153 array('Textarea rows', 'TextareaRows', 'Number of rows in textarea while editing TEXT fields'),
1154 array('Double textarea for LONGTEXT', 'LongtextDoubleTextarea', 'Whether to double textarea size for LONGTEXT fields', TRUE),
1155 array('Edit CHAR fields in textarea', 'CharEditing', 'Whether to edit CHAR fields in textarea', array('input', 'textarea')),
1156 array('CHAR textarea columns', 'CharTextareaCols', 'Number of columns in textarea while editing CHAR fields (must be enabled above)'),
1157 array('CHAR textarea rows', 'CharTextareaRows', 'Number of rows in textarea while editing CHAR fields (must be enabled above)'),
1159 'Configure editing',
1160 'Select desired editing look and feel.',
1168 * Shows query window configuration form
1170 * @param array optional defaults
1174 function show_window_form($defaults = array()) {
1176 <form method
="post" action
="">
1177 <?php
echo get_hidden_inputs();?
>
1178 <input type
="hidden" name
="action" value
="lay_window_real" />
1180 show_config_form(array(
1181 array('Edit SQL in window', 'EditInWindow', 'Whether edit links will edit in query window.', TRUE),
1182 array('Query window height', 'QueryWindowHeight', 'Height of query window'),
1183 array('Query window width', 'QueryWindowWidth', 'Width of query window'),
1184 array('Default tab', 'QueryWindowDefTab', 'Default tab on query window', array('sql', 'files', 'history', 'full')),
1186 'Configure query window',
1187 'Select desired query window look and feel.',
1195 * Creates selection with servers
1197 * @param array configuraion
1199 * @return string HTML for server selection
1201 function get_server_selection($cfg) {
1202 if (count($cfg['Servers']) == 0) {
1205 $ret = '<select name="server">';
1206 foreach ($cfg['Servers'] as $key => $val) {
1207 $ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>';
1209 $ret .= '</select>';
1214 * Loads configuration from file
1216 * @param string filename
1218 * @return mixed FALSE on failure, new config array on success
1220 function load_config($config_file) {
1221 if (file_exists($config_file)) {
1222 $success_apply_user_config = FALSE;
1223 $old_error_reporting = error_reporting(0);
1224 if (function_exists('file_get_contents')) {
1225 $success_apply_user_config = eval('?>' . trim(file_get_contents($config_file)));
1227 $success_apply_user_config =
1228 eval('?>' . trim(implode("\n", file($config_file))));
1230 error_reporting($old_error_reporting);
1231 unset($old_error_reporting);
1232 if ($success_apply_user_config === FALSE) {
1233 message('error', 'Error while parsing configuration file!');
1234 } elseif (!isset($cfg) ||
count($cfg) == 0) {
1235 message('error', 'Config file seems to contain no configuration!');
1238 if (!isset($cfg['Servers'])) {
1239 $cfg['Servers'] = array();
1241 message('notice', 'Configuration loaded');
1242 compress_servers($cfg);
1246 message('error', 'Configuration file not found!');
1251 if ($action != 'download') {
1252 // Check whether we can write to configuration
1254 $fail_dir = $fail_dir ||
!is_dir('./config/');
1255 $fail_dir = $fail_dir ||
!is_writable('./config/');
1256 $fail_dir = $fail_dir ||
(file_exists('./config/config.inc.php') && !is_writable('./config/config.inc.php'));
1257 $config = @fopen
('./config/config.inc.php', 'a');
1258 $fail_dir = $fail_dir ||
($config === FALSE);
1263 * @var boolean whether to show configuration overview
1267 // Do the main work depending on selected action
1270 header('Content-Type: text/plain');
1271 header('Content-Disposition: attachment; filename="config.inc.php"');
1273 echo get_cfg_string($_SESSION['configuration']);
1277 echo '<form method="none" action=""><textarea name="config" cols="50" rows="20" id="textconfig" wrap="off">' . "\n";
1278 echo htmlspecialchars(get_cfg_string($_SESSION['configuration']));
1279 echo '</textarea></form>' . "\n";
1281 <script type
="text/javascript">
1283 var bodyWidth
=null; var bodyHeight
=null;
1284 if (document
.getElementById('textconfig')) {
1285 bodyWidth
= self
.innerWidth
;
1286 bodyHeight
= self
.innerHeight
;
1287 if(!bodyWidth
&& !bodyHeight
){
1288 if (document
.compatMode
&& document
.compatMode
== "BackCompat") {
1289 bodyWidth
= document
.body
.clientWidth
;
1290 bodyHeight
= document
.body
.clientHeight
;
1291 } else if (document
.compatMode
&& document
.compatMode
== "CSS1Compat") {
1292 bodyWidth
= document
.documentElement
.clientWidth
;
1293 bodyHeight
= document
.documentElement
.clientHeight
;
1296 document
.getElementById('textconfig').style
.width
=(bodyWidth
-50) +
'px';
1297 document
.getElementById('textconfig').style
.height
=(bodyHeight
-100) +
'px';
1304 $config = @fopen
('./config/config.inc.php', 'w');
1305 if ($config === FALSE) {
1306 message('error', 'Could not open config file for writing! Bad permissions?');
1309 $s = get_cfg_string($_SESSION['configuration']);
1310 $r = fwrite($config, $s);
1311 if (!$r ||
$r != strlen($s)) {
1312 message('error', 'Could not write to config file! Not enough space?');
1315 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');
1322 message('error', 'Reading of configuration disabled because of permissions.');
1325 $new_cfg = load_config('./config/config.inc.php');
1326 if (!($new_cfg === FALSE)) {
1327 $_SESSION['configuration'] = $new_cfg;
1332 case 'addserver_real':
1333 if (isset($_POST['submit_save'])) {
1334 $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');
1336 if (empty($new_server['host'])) {
1337 message('error', 'Empty hostname!');
1340 if ($new_server['auth_type'] == 'config' && empty($new_server['user'])) {
1341 message('error', 'Empty username while using config authentication method!');
1344 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonSession'])) {
1345 message('error', 'Empty signon session name while using signon authentication method!');
1348 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonURL'])) {
1349 message('error', 'Empty signon URL while using signon authentication method!');
1352 if (isset($new_server['pmadb']) && strlen($new_server['pmadb'])) {
1353 // Just use defaults, should be okay for most users
1355 $pmadb['bookmarktable'] = 'pma_bookmark';
1356 $pmadb['relation'] = 'pma_relation';
1357 $pmadb['table_info'] = 'pma_table_info';
1358 $pmadb['table_coords'] = 'pma_table_coords';
1359 $pmadb['pdf_pages'] = 'pma_pdf_pages';
1360 $pmadb['column_info'] = 'pma_column_info';
1361 $pmadb['designer_coords'] = 'pma_designer_coords';
1362 $pmadb['history'] = 'pma_history';
1364 $new_server = array_merge($pmadb, $new_server);
1366 if (empty($new_server['controluser'])) {
1367 message('error', 'Empty phpMyAdmin control user while using pmadb!');
1370 if (empty($new_server['controlpass'])) {
1371 message('error', 'Empty phpMyAdmin control user password while using pmadb!');
1374 /* Check whether we can connect as control user */
1375 if (!empty($new_server['controluser']) && !empty($new_server['controlpass'])) {
1376 if ($new_server['extension'] == 'mysql') {
1377 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
'' : ':' . $new_server['socket'];
1378 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
'' : ':' . $new_server['port'];
1379 $conn = @mysql_connect
($new_server['host'] . $socket . $port, $new_server['controluser'], $new_server['controlpass']);
1380 if ($conn === FALSE) {
1381 message('error', 'Could not connect as control user!');
1387 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
NULL : $new_server['socket'];
1388 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
NULL : $new_server['port'];
1389 $conn = @mysqli_connect
($new_server['host'], $new_server['controluser'], $new_server['controlpass'], NULL, $port, $socket);
1390 if ($conn === FALSE) {
1391 message('error', 'Could not connect as control user!');
1394 mysqli_close($conn);
1399 message('warning', 'You didn\'t set phpMyAdmin database, so you can not use all phpMyAdmin features.');
1401 if ($new_server['auth_type'] == 'config') {
1402 message('warning', 'Remember to protect your installation while using config authentication method!');
1405 unset($new_server['user']);
1406 unset($new_server['password']);
1409 show_server_form($new_server, isset($_POST['server']) ?
$_POST['server'] : FALSE);
1411 if (isset($_POST['server'])) {
1412 $_SESSION['configuration']['Servers'][$_POST['server']] = $new_server;
1413 message('notice', 'Changed server ' . get_server_name($new_server, $_POST['server']));
1415 $_SESSION['configuration']['Servers'][] = $new_server;
1416 message('notice', 'New server added');
1419 if ($new_server['auth_type'] == 'cookie' && empty($_SESSION['configuration']['blowfish_secret'])) {
1420 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');
1421 $_SESSION['configuration']['blowfish_secret'] = uniqid('', TRUE);
1430 if (count($_SESSION['configuration']['Servers']) == 0) {
1431 // First server will use defaults as in config.default.php
1432 $defaults = $PMA_Config_Setup->default_server
;
1433 unset($defaults['AllowDeny']); // Ignore this for now
1435 $defaults = array();
1438 // Guess MySQL extension to use, prefer mysqli
1439 if (!function_exists('mysql_get_client_info')) {
1442 if (!function_exists('mysqli_get_client_info')) {
1445 if (function_exists('mysqli_get_client_info')) {
1446 $defaults['extension'] = 'mysqli';
1447 } elseif (function_exists('mysql_get_client_info')) {
1448 $defaults['extension'] = 'mysql';
1450 message('warning', 'Could not load either mysql or mysqli extension, you might not be able to use phpMyAdmin! Check your PHP configuration.');
1452 if (isset($defaults['extension'])) {
1453 message('notice', 'Autodetected MySQL extension to use: ' . $defaults['extension']);
1457 show_server_form($defaults);
1460 if (!isset($_POST['server'])) {
1463 show_server_form($_SESSION['configuration']['Servers'][$_POST['server']], $_POST['server']);
1465 case 'deleteserver':
1466 if (!isset($_POST['server'])) {
1469 message('notice', 'Deleted server ' . get_server_name($_SESSION['configuration']['Servers'][$_POST['server']], $_POST['server']));
1470 unset($_SESSION['configuration']['Servers'][$_POST['server']]);
1471 compress_servers($_SESSION['configuration']);
1475 if (count($_SESSION['configuration']['Servers']) == 0) {
1476 message('notice', 'No servers defined, so none can be shown');
1478 foreach ($_SESSION['configuration']['Servers'] as $i => $srv) {
1480 if (!empty($srv['verbose'])) {
1481 $data[] = array('Verbose name', $srv['verbose']);
1483 $data[] = array('Host', $srv['host']);
1484 $data[] = array('MySQL extension', isset($srv['extension']) ?
$srv['extension'] : $PMA_Config_Setup->default_server
['extension']);
1485 $data[] = array('Authentication type', get_server_auth($srv));
1486 $data[] = array('phpMyAdmin advanced features', empty($srv['pmadb']) ||
empty($srv['controluser']) ||
empty($srv['controlpass']) ?
'disabled' : 'enabled, db: ' . $srv['pmadb'] . ', user: ' . $srv['controluser']);
1488 get_action('deleteserver', 'Delete', '<input type="hidden" name="server" value="' . $i . '" />') .
1489 get_action('editserver', 'Edit', '<input type="hidden" name="server" value="' . $i . '" />');
1490 show_overview('Server ' . get_server_name($srv, $i), $data, $buttons);
1495 case 'feat_upload_real':
1496 if (isset($_POST['submit_save'])) {
1497 $dirs = grab_values('UploadDir;SaveDir');
1499 if (!empty($dirs['UploadDir']) && !is_dir($dirs['UploadDir'])) {
1500 message('error', 'Upload directory ' . htmlspecialchars($dirs['UploadDir']) . ' does not exist!');
1503 if (!empty($dirs['SaveDir']) && !is_dir($dirs['SaveDir'])) {
1504 message('error', 'Save directory ' . htmlspecialchars($dirs['SaveDir']) . ' does not exist!');
1508 show_upload_form($dirs);
1510 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $dirs);
1511 message('notice', 'Configuration changed');
1519 show_upload_form($_SESSION['configuration']);
1522 case 'feat_security_real':
1523 if (isset($_POST['submit_save'])) {
1524 $vals = grab_values('blowfish_secret;ForceSSL:bool;ShowPhpInfo:bool;ShowChgPassword:bool;AllowArbitraryServer:bool;LoginCookieRecall:book;LoginCookieValidity:int');
1526 if (empty($vals['blowfish_secret'])) {
1527 message('warning', 'Blowfish secret is empty, you will not be able to use cookie authentication.');
1529 if ($vals['AllowArbitraryServer']) {
1530 message('warning', 'Arbitrary server connection might be dangerous as it might allow access to internal servers that are not reachable from outside.');
1532 if (isset($vals['LoginCookieValidity']) && $vals['LoginCookieValidity'] < 1) {
1533 message('error', 'Invalid cookie validity time');
1537 show_security_form($vals);
1539 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1540 message('notice', 'Configuration changed');
1547 case 'feat_security':
1548 show_security_form($_SESSION['configuration']);
1551 case 'feat_manual_real':
1552 if (isset($_POST['submit_save'])) {
1553 $vals = grab_values('MySQLManualBase;MySQLManualType');
1555 if ($vals['MySQLManualType'] != 'none' && empty($vals['MySQLManualBase'])) {
1556 message('error', 'You need to set manual base URL or choose type \'none\'.');
1560 show_manual_form($vals);
1562 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1563 message('notice', 'Configuration changed');
1571 show_manual_form($_SESSION['configuration']);
1574 case 'feat_charset_real':
1575 if (isset($_POST['submit_save'])) {
1576 $vals = grab_values('AllowAnywhereRecoding:bool;DefaultCharset;RecodingEngine;IconvExtraParams');
1579 show_charset_form($vals);
1581 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1582 message('notice', 'Configuration changed');
1589 case 'feat_charset':
1590 $d = $_SESSION['configuration'];
1591 if (!isset($d['RecodingEngine'])) {
1592 if (@extension_loaded
('iconv')) {
1593 $d['RecodingEngine'] = 'iconv';
1594 } elseif (@extension_loaded
('recode')) {
1595 $d['RecodingEngine'] = 'recode';
1598 if (!@extension_loaded
('iconv')) {
1600 if (!@extension_loaded
('recode')) {
1601 message('warning', 'Neither recode nor iconv could be loaded so charset conversion will most likely not work.');
1603 $d['RecodingEngine'] = 'recode';
1606 $d['RecodingEngine'] = 'iconv';
1609 if (isset($d['RecodingEngine'])) {
1610 message('notice', 'Autodetected recoding engine: ' . $d['RecodingEngine']);
1613 show_charset_form($d);
1617 case 'feat_extensions_real':
1618 if (isset($_POST['submit_save'])) {
1619 $vals = grab_values('GD2Available');
1622 show_extensions_form($vals);
1624 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1625 message('notice', 'Configuration changed');
1632 case 'feat_extensions':
1633 $d = $_SESSION['configuration'];
1634 if (!@extension_loaded
('mbstring')) {
1637 if (!@extension_loaded
('mbstring')) {
1638 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.');
1640 if (!isset($d['GD2Available'])) {
1641 if (PMA_IS_GD2
== 1) {
1642 message('notice', 'GD 2 or newer found.');
1643 $d['GD2Available'] = 'yes';
1645 message('warning', 'GD 2 or newer is not present.');
1646 $d['GD2Available'] = 'no';
1649 show_extensions_form($d);
1653 case 'feat_relation_real':
1654 if (isset($_POST['submit_save'])) {
1655 $vals = grab_values('QueryHistoryDB:bool;QueryHistoryMax:int;BrowseMIME:bool;PDFDefaultPageSize');
1657 if (isset($vals['QueryHistoryMax']) && $vals['QueryHistoryMax'] < 1) {
1658 message('error', 'Invalid value for query maximum history size!');
1662 show_relation_form($vals);
1664 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1665 message('notice', 'Configuration changed');
1672 case 'feat_relation':
1673 show_relation_form($_SESSION['configuration']);
1676 case 'lay_navigation_real':
1677 if (isset($_POST['submit_save'])) {
1678 $vals = grab_values('LeftFrameLight:bool;LeftFrameDBTree:bool;LeftFrameDBSeparator;LeftFrameTableSeparator;LeftFrameTableLevel:int;LeftDisplayLogo:bool;LeftDisplayServers:bool;DisplayServersList:bool;DisplayDatabasesList;LeftPointerEnable:bool');
1680 if (isset($vals['DisplayDatabasesList'])) {
1681 if ($vals['DisplayDatabasesList'] == 'yes') {
1682 $vals['DisplayDatabasesList'] = true;
1683 } elseif ($vals['DisplayDatabasesList'] == 'no') {
1684 $vals['DisplayDatabasesList'] = false;
1687 if (isset($vals['LeftFrameTableLevel']) && $vals['LeftFrameTableLevel'] < 1) {
1688 message('error', 'Invalid value for maximum table nesting level!');
1692 show_left_form($vals);
1694 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1695 message('notice', 'Configuration changed');
1702 case 'lay_navigation':
1703 show_left_form($_SESSION['configuration']);
1706 case 'lay_tabs_real':
1707 if (isset($_POST['submit_save'])) {
1708 $vals = grab_values('DefaultTabServer;DefaultTabDatabase;DefaultTabTable;LightTabs:bool');
1711 show_tabs_form($vals);
1713 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1714 message('notice', 'Configuration changed');
1722 show_tabs_form($_SESSION['configuration']);
1725 case 'lay_icons_real':
1726 if (isset($_POST['submit_save'])) {
1727 $vals = grab_values('ErrorIconic:bool;MainPageIconic:bool;ReplaceHelpImg:bool;NavigationBarIconic:tristate;PropertiesIconic:tristate');
1730 show_icons_form($vals);
1732 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1733 message('notice', 'Configuration changed');
1741 show_icons_form($_SESSION['configuration']);
1744 case 'lay_browse_real':
1745 if (isset($_POST['submit_save'])) {
1746 $vals = grab_values('BrowsePointerEnable:bool;BrowseMarkerEnable:bool;ModifyDeleteAtRight:bool;ModifyDeleteAtLeft:bool;RepeatCells:int;DefaultDisplay');
1748 if (isset($vals['RepeatCells']) && $vals['RepeatCells'] < 1) {
1749 message('error', 'Invalid value for header repeating!');
1752 if (!$vals['ModifyDeleteAtLeft'] && !$vals['ModifyDeleteAtRight']) {
1753 message('error', 'No action buttons enabled!');
1757 show_browse_form($vals);
1759 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1760 message('notice', 'Configuration changed');
1768 show_browse_form($_SESSION['configuration']);
1771 case 'lay_edit_real':
1772 if (isset($_POST['submit_save'])) {
1773 $vals = grab_values('TextareaCols:int;TextareaRows:int;LongtextDoubleTextarea:bool;TextareaAutoSelect:bool;CharEditing;CharTextareaCols:int;CharTextareaRows:int;CtrlArrowsMoving:bool;DefaultPropDisplay;InsertRows:int');
1775 if (isset($vals['TextareaCols']) && $vals['TextareaCols'] < 1) {
1776 message('error', 'Invalid value for textarea columns!');
1779 if (isset($vals['TextareaRows']) && $vals['TextareaRows'] < 1) {
1780 message('error', 'Invalid value for textarea rows!');
1783 if (isset($vals['CharTextareaCols']) && $vals['CharTextareaCols'] < 1) {
1784 message('error', 'Invalid value for CHAR textarea columns!');
1787 if (isset($vals['CharTextareaRows']) && $vals['CharTextareaRows'] < 1) {
1788 message('error', 'Invalid value for CHAR textarea rows!');
1791 if (isset($vals['InsertRows']) && $vals['InsertRows'] < 1) {
1792 message('error', 'Invalid value for inserted rows count!');
1796 show_edit_form($vals);
1798 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1799 message('notice', 'Configuration changed');
1807 show_edit_form($_SESSION['configuration']);
1810 case 'lay_window_real':
1811 if (isset($_POST['submit_save'])) {
1812 $vals = grab_values('EditInWindow:bool;QueryWindowHeight:int;QueryWindowWidth:int;QueryWindowDefTab');
1814 if (isset($vals['QueryWindowWidth']) && $vals['QueryWindowWidth'] < 1) {
1815 message('error', 'Invalid value for query window width!');
1818 if (isset($vals['QueryWindowHeight']) && $vals['QueryWindowHeight'] < 1) {
1819 message('error', 'Invalid value for query window height');
1823 show_window_form($vals);
1825 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1826 message('notice', 'Configuration changed');
1834 show_window_form($_SESSION['configuration']);
1837 /* Template for new actions:
1839 if (isset($_POST['submit_save'])) {
1840 $vals = grab_values('value1:bool;value2');
1842 if (somechekcfails) {
1843 message('error', 'Invalid value for blah!');
1847 show_blah_form($vals);
1849 $_SESSION['configuration'] = array_merge($_SESSION['configuration'], $vals);
1850 message('notice', 'Configuration changed');
1858 show_blah_form($_SESSION['configuration']);
1861 case 'versioncheck': // Check for latest available version
1863 $url = 'http://phpmyadmin.net/home_page/version.php';
1865 $f = @fopen
($url, 'r');
1867 if (!function_exists('curl_init')) {
1868 message('error', 'Neither URL wrappers nor CURL are available. Version check is not possible.');
1872 $data = fread($f, 20);
1875 if (empty($data) && function_exists('curl_init')) {
1876 $ch = curl_init($url);
1877 curl_setopt($ch, CURLOPT_HEADER
, FALSE);
1878 curl_setopt($ch, CURLOPT_RETURNTRANSFER
, TRUE);
1879 $data = curl_exec($ch);
1883 message('error', 'Reading of version failed. Maybe you\'re offline or the upgrade server does not respond.');
1887 /* Format: version\ndate\n(download\n)* */
1888 $data_list = split("\n", $data);
1890 if (count($data_list) > 0) {
1891 $version = $data_list[0];
1896 $version_upstream = version_to_int($version);
1897 if ($version_upstream === FALSE) {
1898 message('error', 'Got invalid version string from server.');
1902 $version_local = version_to_int($PMA_Config_Setup->get('PMA_VERSION'));
1903 if ($version_local === FALSE) {
1904 message('error', 'Unparsable version string.');
1908 if ($version_upstream > $version_local) {
1909 message('notice', 'New version of phpMyAdmin is available, you should consider upgrade. New version is ' . htmlspecialchars($version) . '.');
1911 if ($version_local %
100 == 0) {
1912 message('notice', 'You are using subversion version, run <code>svn update</code> :-). However latest released version is ' . htmlspecialchars($version) . '.');
1914 message('notice', 'No newer stable version is available.');
1920 $_SESSION['eoltype'] = $_POST['neweol'];
1921 message('notice', 'End of line format changed.');
1922 case 'clear': // Actual clearing is done on beginning of this script
1928 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');
1930 if ($PMA_Config_Setup->get('PMA_PHP_INT_VERSION') < 40100) {
1931 message('warning', 'Please upgrade to PHP 4.1.0, it is required for phpMyAdmin.', 'Too old PHP');
1935 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');
1938 if (empty($_SERVER['HTTPS']) ||
strtolower($_SERVER['HTTPS']) == 'off') {
1939 if (empty($_SERVER['REQUEST_URI']) ||
empty($_SERVER['HTTP_HOST'])) {
1942 $redir = ' If your server is also configured to accept HTTPS request'
1943 . ' follow <a href="https://'
1944 . htmlspecialchars($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])
1945 . '">this link</a> to use secure connection.';
1947 message('warning', 'You are not using secure connection, all data (including sensitive, like passwords) are transfered unencrypted!' . $redir, 'Not secure connection');
1952 // Should we show information?
1955 $servers_text = 'Servers';
1956 if (count($_SESSION['configuration']['Servers']) == 0) {
1957 message('warning', 'No servers defined, you probably want to add one.');
1960 $servers_text = 'Servers (' . count($_SESSION['configuration']['Servers']) . ')';
1963 foreach ($_SESSION['configuration']['Servers'] as $key => $val) {
1966 $servers .= get_server_name($val, $key);
1970 show_overview('Current configuration overview',
1972 array($servers_text, $servers),
1973 array('SQL files upload', empty($_SESSION['configuration']['UploadDir']) ?
'disabled' : 'enabled'),
1974 array('Exported files on server', empty($_SESSION['configuration']['SaveDir']) ?
'disabled' : 'enabled'),
1975 array('Charset conversion', isset($_SESSION['configuration']['AllowAnywhereRecoding']) && $_SESSION['configuration']['AllowAnywhereRecoding'] ?
'enabled' : 'disabled'),
1977 unset($servers_text, $servers);
1980 // And finally display all actions:
1981 echo '<p>Available global actions (please note that these will delete any changes you could have done above):</p>';
1983 echo '<fieldset class="toolbar"><legend>Servers</legend>' . "\n";
1984 echo get_action('addserver', 'Add');
1985 $servers = get_server_selection($_SESSION['configuration']);
1986 if (!empty($servers)) {
1987 echo get_action('servers', 'List');
1988 echo get_action('deleteserver', 'Delete', $servers);
1989 echo get_action('editserver', 'Edit', $servers);
1991 echo '</fieldset>' . "\n\n";
1993 echo '<fieldset class="toolbar"><legend>Layout</legend>' . "\n";
1994 echo get_action('lay_navigation', 'Navigation frame');
1995 echo get_action('lay_tabs', 'Tabs');
1996 echo get_action('lay_icons', 'Icons');
1997 echo get_action('lay_browse', 'Browsing');
1998 echo get_action('lay_edit', 'Editing');
1999 echo get_action('lay_window', 'Query window');
2000 echo '</fieldset>' . "\n\n";
2002 echo '<fieldset class="toolbar"><legend>Features</legend>' . "\n";
2003 echo get_action('feat_upload', 'Upload/Download');
2004 echo get_action('feat_security', 'Security');
2005 echo get_action('feat_manual', 'MySQL manual');
2006 echo get_action('feat_charset', 'Charsets');
2007 echo get_action('feat_extensions', 'Extensions');
2008 echo get_action('feat_relation', 'MIME/Relation/History');
2009 echo '</fieldset>' . "\n\n";
2011 echo '<fieldset class="toolbar"><legend>Configuration</legend>' . "\n";
2012 echo get_action('main', 'Overview');
2013 echo get_action('display', 'Display');
2014 echo get_action('download', 'Download');
2015 echo get_action('save', 'Save', '', !$fail_dir);
2016 echo get_action('load', 'Load', '', !$fail_dir);
2017 echo get_action('clear', 'Clear');
2018 echo get_action('seteol', 'Change end of line',
2019 '<select name="neweol">' .
2020 '<option value="unix" ' . ($_SESSION['eoltype'] == 'unix' ?
' selected="selected"' : '') . '>UNIX/Linux (\\n)</option>' .
2021 '<option value="dos" ' . ($_SESSION['eoltype'] == 'dos' ?
' selected="selected"' : '') . '>DOS/Windows (\\r\\n)</option>' .
2022 '<option value="mac" ' . ($_SESSION['eoltype'] == 'mac' ?
' selected="selected"' : '') . '>Macintosh (\\r)</option>' . '
2024 echo '</fieldset>' . "\n\n";
2026 echo '<fieldset class="toolbar"><legend>Other actions</legend>' . "\n";
2027 echo get_action('versioncheck', 'Check for latest version');
2028 echo get_url_action('http://www.phpmyadmin.net/', 'Go to homepage');
2029 echo get_url_action('https://sourceforge.net/donate/index.php', 'Donate to phpMyAdmin', array('group_id' => 23067));
2030 echo '</fieldset>' . "\n\n";