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 $eoltype = $_POST['eoltype'];
42 if (PMA_USR_OS
== 'Win') {
49 // Detect which CRLF to use
50 if ($eoltype == 'dos') {
52 } elseif ($eoltype == 'mac') {
58 if (isset($_POST['configuration']) && $action != 'clear') {
59 // Grab previous configuration, if it should not be cleared
60 $configuration = unserialize($_POST['configuration']);
62 // Start with empty configuration
63 $configuration = array();
66 // We rely on Servers array to exist, so create it here
67 if (!isset($configuration['Servers']) ||
!is_array($configuration['Servers'])) {
68 $configuration['Servers'] = array();
72 $now = gmdate('D, d M Y H:i:s') . ' GMT';
74 // General header for no caching
75 header('Expires: ' . $now); // rfc2616 - Section 14.21
76 header('Last-Modified: ' . $now);
77 header('Cache-Control: no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
78 header('Pragma: no-cache'); // HTTP/1.0
80 // whether to show html header?
81 if ($action != 'download') {
83 // Define the charset to be used
84 header('Content-Type: text/html; charset=utf-8');
86 // this needs to be echoed otherwise php with short tags complains
87 echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
89 <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
90 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
91 <html xmlns
="http://www.w3.org/1999/xhtml" xml
:lang
="en" lang
="en" dir
="ltr">
93 <link rel
="icon" href
="../favicon.ico" type
="image/x-icon" />
94 <link rel
="shortcut icon" href
="../favicon.ico" type
="image/x-icon" />
95 <title
>phpMyAdmin
<?php
echo $PMA_Config_Setup->get('PMA_VERSION'); ?
> setup
</title
>
96 <meta http
-equiv
="Content-Type" content
="text/html; charset=utf-8" />
98 <script type
="text/javascript">
100 // show this window in top frame
102 window
.top
.location
.href
=location
;
106 <style type
="text/css">
107 /* message boxes: warning, error, stolen from original theme */
110 background
-color
: #FFFFDD;
114 margin
: 0.5em
0 0.5em
0;
115 border
: 0.1em solid
#FFD700;
116 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_notice
.png
);
117 background
-repeat
: no
-repeat
;
118 background
-position
: 10px
50%
;
119 padding
: 10px
10px
10px
36px
;
122 border
-bottom
: 0.1em solid
#FFD700;
131 background
-color
: #FFFFCC;
135 margin
: 0.5em
0 0.5em
0;
136 border
: 0.1em solid
#CC0000;
137 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_warn
.png
);
138 background
-repeat
: no
-repeat
;
139 background
-position
: 10px
50%
;
140 padding
: 10px
10px
10px
36px
;
143 border
-bottom
: 0.1em solid
#cc0000;
151 background
-color
: #FFFFCC;
156 margin
: 0.5em
0 0.5em
0;
157 border
: 0.1em solid
#ff0000;
158 background
-image
: url(../<?php
echo $GLOBALS['cfg']['ThemePath']; ?
>/original
/img
/s_error
.png
);
159 background
-repeat
: no
-repeat
;
160 background
-position
: 10px
50%
;
161 padding
: 10px
10px
10px
36px
;
164 border
-bottom
: 0.1em solid
#ff0000;
171 fieldset
.toolbar form
.action
{
178 border
-right
: 1px solid black
;
180 fieldset
.toolbar form
.action input
, fieldset
.toolbar form
.action select
{
188 background
-color
: #dddddd;
193 background
-color
: #FFFFDD;
195 div
.buttons
, div
.opts
, fieldset
.optbox p
, fieldset
.overview div
.row
{
199 background
-color
: white
;
201 div
.opts
, fieldset
.optbox p
, fieldset
.overview div
.row
{
202 border
-bottom
: 1px dotted black
;
210 background
-color
: #FFFFDD;
213 background
-color
: #dddddd;
231 div
.desc
, label
.desc
, fieldset
.overview div
.desc
{
236 code
:before
, code
:after
{
243 margin
: 0 0.1em
0 0.1em
;
252 <h1
>phpMyAdmin
<?php
echo $PMA_Config_Setup->get('PMA_VERSION'); ?
> setup
</h1
>
254 } // end show html header
257 * Calculates numerical equivalent of phpMyAdmin version string
259 * @param string version
261 * @return mixed FALSE on failure, integer on success
263 function version_to_int($version) {
264 if (!preg_match('/^(\d+)\.(\d+)\.(\d+)((\.|-(pl|rc|dev|beta|alpha))(\d+)?)?$/', $version, $matches)) {
267 if (!empty($matches[6])) {
268 switch ($matches[6]) {
285 message('notice', 'Unknown version part: ' . htmlspecialchars($matches[5]));
290 $added = 50; // for final
292 if (!empty($matches[7])) {
293 $added = $added +
$matches[7];
295 return $matches[1] * 1000000 +
$matches[2] * 10000 +
$matches[3] * 100 +
$added;
299 * Returns link to documentation of some configuration directive
301 * @param string confguration directive name
303 * @return string HTML link to documentation
305 function get_cfg_doc($anchor) {
308 if (strncmp($anchor, 'Servers_', 8) == 0) {
309 $wiki = substr($anchor, 8);
312 '<span class="doc">' .
313 '<a href="../Documentation.html#cfg_' . $anchor . '" target="pma_doc" class="doc">' .
314 '<img class="icon" src="../' . $GLOBALS['cfg']['ThemePath'] . '/original/img/b_help.png" width="11" height="11" alt="Documentation" title="Documentation" />' .
316 '<a href="http://wiki.cihar.com/pma/Config#' . $wiki . '" target="pma_doc" class="doc">' .
317 '<img class="icon" src="../' . $GLOBALS['cfg']['ThemePath'] . '/original/img/b_info.png" width="11" height="11" alt="Wiki" title="Wiki" />' .
326 * @param string type of message (notice/warning/error)
327 * @param string text of message
328 * @param title optional title of message
332 function message($type, $text, $title = '') {
333 echo '<div class="' . $type . '">' . "\n";
334 if (!empty($title)) {
340 echo '</div>' . "\n";
344 * Creates hidden input required for keeping current configuraion
346 * @return string HTML with hidden inputs
348 function get_hidden_cfg() {
349 global $configuration, $eoltype;
351 $ret = '<input type="hidden" name="configuration" value="' . htmlspecialchars(serialize($configuration)) . '" />' . "\n";
352 $ret .= '<input type="hidden" name="eoltype" value="' . htmlspecialchars($eoltype) . '" />' . "\n";
358 * Returns needed hidden input for forms.
360 * @return string HTML with hidden inputs
362 function get_hidden_inputs() {
363 return '<input type="hidden" name="token" value="' . $_SESSION[' PMA_token '] . '" />';
367 * Creates form for some action
369 * @param string action name
370 * @param string form title
371 * @param string optional additional inputs
373 * @return string HTML with form
375 function get_action($name, $title, $added = '', $enabled = TRUE) {
377 $ret .= '<form class="action" method="post" action="">';
378 $ret .= get_hidden_inputs();
379 $ret .= '<input type="hidden" name="action" value="' . $name . '" />';
381 $ret .= '<input type="submit" value="' . $title . '"';
383 $ret .= ' disabled="disabled"';
386 $ret .= get_hidden_cfg();
393 * Creates form for going to some url
395 * @param string URL where to go
396 * @param string form title
397 * @param string optional array of parameters
399 * @return string HTML with form
401 function get_url_action($url, $title, $params = array()) {
403 $ret .= '<form class="action" method="get" action="' . $url . '" target="_blank">';
404 $ret .= get_hidden_inputs();
405 foreach ($params as $key => $val) {
406 $ret .= '<input type="hidden" name="' . $key . '" value="' . $val . '" />';
408 $ret .= '<input type="submit" value="' . $title . '" />';
415 * Terminates script and ends HTML
426 * Creates string describing server authentication method
428 * @param array server configuration
430 * @return string authentication method description
432 function get_server_auth($val) {
433 global $PMA_Config_Setup;
435 if (isset($val['auth_type'])) {
436 $auth = $val['auth_type'];
438 $auth = $PMA_Config_Setup->default_server
['auth_type'];
441 if ($auth == 'config') {
442 if (isset($val['user'])) {
443 $ret .= ':' . $val['user'];
445 $ret .= ':' . $PMA_Config_Setup->default_server
['user'];
452 * Creates nice string with server name
454 * @param array server configuration
455 * @param int optional server id
457 * @return string fancy server name
459 function get_server_name($val, $id = FALSE, $escape = true) {
460 if (!empty($val['verbose'])) {
461 $ret = $val['verbose'];
465 $ret .= ' (' . get_server_auth($val) . ')';
467 $ret .= ' [' . ($id +
1) . ']' ;
470 return htmlspecialchars($ret);
478 * Exports variable to PHP code, very limited version of var_export
480 * @param string data to export
484 * @return string PHP code containing variable value
486 function PMA_var_export($input) {
490 if (is_null($input)) {
492 } elseif (is_array($input)) {
493 $output .= 'array (' . $crlf;
494 foreach($input as $key => $value) {
495 $output .= PMA_var_export($key) . ' => ' . PMA_var_export($value);
496 $output .= ',' . $crlf;
499 } elseif (is_string($input)) {
500 $output .= '\'' . addslashes($input) . '\'';
501 } elseif (is_int($input) ||
is_double($input)) {
502 $output .= (string) $input;
503 } elseif (is_bool($input)) {
504 $output .= $input ?
'true' : 'false';
506 die('Unknown type for PMA_var_export: ' . $input);
512 * Creates configuration code for one variable
514 * @param string variable name
515 * @param mixed configuration
517 * @return string PHP code containing configuration
519 function get_cfg_val($name, $val) {
523 if (is_array($val)) {
525 foreach ($val as $k => $v) {
529 } elseif (is_int($k)) {
531 $ret .= $name . ' = array(' . $crlf;
533 // Something unknown...
534 $ret .= $name. ' = ' . PMA_var_export($val) . ';' . $crlf;
538 if ($type == 'string') {
539 $ret .= get_cfg_val($name . "['$k']", $v);
540 } elseif ($type == 'int') {
541 $ret .= ' ' . PMA_var_export($v) . ',' . $crlf;
546 $ret .= $name . ' = array();' . $crlf;
547 } elseif ($type == 'int') {
548 $ret .= ');' . $crlf;
553 $ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf;
559 * Creates configuration PHP code
561 * @param array configuration
563 * @return string PHP code containing configuration
565 function get_cfg_string($cfg) {
566 global $script_info, $script_version, $now, $crlf;
569 $ret = "<?php$crlf/*$crlf * Generated configuration file$crlf * Generated by: $script_info$crlf * Version: $script_version$crlf * Date: " . $now . $crlf . ' */' . $crlf . $crlf;
571 if (count($c['Servers']) > 0) {
572 $ret .= "/* Servers configuration */$crlf\$i = 0;" . $crlf;
573 foreach ($c['Servers'] as $cnt => $srv) {
574 $ret .= $crlf . '/* Server ' . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */$crlf\$i++;" . $crlf;
575 foreach ($srv as $key => $val) {
576 $ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);
579 $ret .= $crlf . '/* End of servers configuration */' . $crlf . $crlf;
581 unset($c['Servers']);
583 foreach ($c as $key => $val) {
584 $ret .= get_cfg_val("\$cfg['$key']", $val);
587 $ret .= '?>' . $crlf;
592 * Compresses server configuration to be indexed from 0 and contain no gaps
594 * @param array configuration
598 function compress_servers(&$cfg) {
600 foreach ($cfg['Servers'] as $val) {
601 if (!empty($val['host'])) {
605 $cfg['Servers'] = $ns;
609 * Grabs values from POST
611 * @param string list of values to grab, values are separated by ";",
612 * each can have defined type separated by ":", if no type
613 * is defined, string is assumed. Possible types: bool -
614 * boolean value, serialized - serialized value, int -
615 * integer, tristate - "TRUE"/"FALSE" converted to bool,
616 * other strings are kept.
618 * @return array array with grabbed values
620 function grab_values($list)
622 $a = split(';', $list);
624 foreach ($a as $val) {
625 $v = split(':', $val);
631 $res[$v[0]] = isset($_POST[$v[0]]);
634 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
635 $res[$v[0]] = unserialize($_POST[$v[0]]);
639 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
640 $res[$v[0]] = (int)$_POST[$v[0]];
644 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
645 $cur = $_POST[$v[0]];
646 if ($cur == 'TRUE') {
648 } elseif ($cur == 'FALSE') {
657 if (isset($_POST[$v[0]]) && strlen($_POST[$v[0]]) > 0) {
658 $res[$v[0]] = $_POST[$v[0]];
669 * @param string title of oveview
670 * @param array list of values to display (each element is array of two
671 * values - name and value)
672 * @param string optional buttons to be displayed
676 function show_overview($title, $list, $buttons = '') {
677 echo '<fieldset class="overview">' . "\n";
678 echo '<legend>' . $title . '</legend>' . "\n";
679 foreach ($list as $val) {
680 echo '<div class="row">';
681 echo '<div class="desc">';
684 echo '<div class="data">';
687 echo '</div>' . "\n";
689 if (!empty($buttons)) {
690 echo '<div class="buttons">';
691 echo '<div class="desc">Actions:</div>';
693 echo '</div>' . "\n";
695 echo '</fieldset>' . "\n";
700 * Displays configuration, fallback defaults are taken from global $PMA_Config_Setup
702 * @param array list of values to display (each element is array of two or
703 * three values - desription, name and optional type
704 * indicator). Type is determined by type of this parameter,
705 * array means select and array elements are items,
706 * 'password' means password input.
707 * @param string title of configuration
708 * @param string help string for this configuration
709 * @param array optional first level defaults
710 * @param string optional title for save button
711 * @param string optional prefix for documentation links
715 function show_config_form($list, $legend, $help, $defaults = array(), $save = '', $prefix = '') {
716 global $PMA_Config_Setup;
722 echo '<fieldset class="optbox">' . "\n";
723 echo '<legend>' . $legend . '</legend>' . "\n";
724 echo '<p>' . $help . '</p>' . "\n";
725 foreach ($list as $val) {
726 echo '<div class="opts">';
728 if (isset($val[3])) {
729 if (is_array($val[3])) {
731 } elseif (is_bool($val[3])) {
733 } elseif ($val[3] == 'password') {
740 echo '<label for="text_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
741 echo '<input type="' . $type . '" name="' . $val[1] . '" id="text_' . $val[1] . '" title="' . $val[2] . '" size="50"';
742 if (isset($defaults[$val[1]])) {
743 echo ' value="' . htmlspecialchars($defaults[$val[1]]) . '"';
745 echo ' value="' . htmlspecialchars($PMA_Config_Setup->get($val[1])) . '"';
750 echo '<input type="checkbox" name="' . $val[1] . '" value="something" id="checkbox_' . $val[1] . '" title="' . $val[2] . '"';
751 if (isset($defaults[$val[1]])) {
752 if ($defaults[$val[1]]) {
753 echo ' checked="checked"';
756 if ($PMA_Config_Setup->get($val[1])) {
757 echo ' checked="checked"';
761 echo '<label for="checkbox_' . $val[1] . '" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
764 echo '<label for="select_' . $val[1] . '" class="desc" title="' . $val[2] . '">' . $val[0] . get_cfg_doc($prefix . $val[1]) . '</label>';
765 echo '<select name="' . $val[1] . '" id="select_' . $val[1] . '" ' . ' title="' . $val[2] . '">';
766 foreach ($val[3] as $opt) {
767 echo '<option value="' . $opt . '"';
768 if (isset($defaults[$val[1]])) {
769 if (is_bool($defaults[$val[1]])) {
770 if (($defaults[$val[1]] && $opt == 'TRUE') ||
(!$defaults[$val[1]] && $opt == 'FALSE')) {
771 echo ' selected="selected"';
774 if ($defaults[$val[1]] == $opt) {
775 echo ' selected="selected"';
779 $def_val = $PMA_Config_Setup->get($val[1]);
781 if (($def_val && $opt == 'TRUE') ||
(!$def_val && $opt == 'FALSE')) {
782 echo ' selected="selected"';
785 if ($def_val == $opt) {
786 echo ' selected="selected"';
791 echo '>' . $opt . '</option>';
796 echo '</div>' . "\n";
798 echo '<div class="buttons">';
799 echo '<div class="desc">Actions:</div>';
800 echo '<input type="submit" name="submit_save" value="' . $save .'" class="save" />';
801 echo '<input type="submit" name="submit_ignore" value="Cancel" class="cancel" />';
802 echo '</div>' . "\n";
803 echo '</fieldset>' . "\n";
808 * Shows security options configuration form
810 * @param array optional defaults
814 function show_security_form($defaults = array()) {
816 <form method
="post" action
="">
817 <?php
echo get_hidden_inputs();?
>
818 <input type
="hidden" name
="action" value
="feat_security_real" />
820 echo get_hidden_cfg();
821 show_config_form(array(
822 array('Blowfish secret', 'blowfish_secret', 'Secret passphrase used for encrypting cookies'),
823 array('Force SSL connection', 'ForceSSL', 'Whether to force using secured connection while using phpMyAdmin', FALSE),
824 array('Show phpinfo output', 'ShowPhpInfo', 'Whether to allow users to see phpinfo() output', FALSE),
825 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),
826 array('Allow login to any MySQL server', 'AllowArbitraryServer', 'If enabled user can enter any MySQL server in login form for cookie auth.', FALSE),
827 array('Recall user name', 'LoginCookieRecall', 'Whether to recall user name on log in prompt while using cookie auth.', TRUE),
828 array('Login cookie validity', 'LoginCookieValidity', 'How long is login valid without performing any action.'),
830 'Configure security features',
831 'Please note that phpMyAdmin is just a user interface and it\'s features do not limit MySQL.',
839 * Shows MySQL manual configuration form
841 * @param array optional defaults
845 function show_manual_form($defaults = array()) {
847 <form method
="post" action
="">
848 <?php
echo get_hidden_inputs();?
>
849 <input type
="hidden" name
="action" value
="feat_manual_real" />
851 echo get_hidden_cfg();
852 show_config_form(array(
853 array('Type of MySQL documentation', 'MySQLManualType', 'These types are same as listed on MySQL download page', array('viewable', 'chapters', 'big', 'none')),
854 array('Base URL of MySQL documentation', 'MySQLManualBase', 'Where is MySQL documentation placed, this is usually top level directory.'),
856 'Configure MySQL manual links',
857 '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.',
865 * Shows charset options configuration form
867 * @param array optional defaults
871 function show_charset_form($defaults = array()) {
872 global $PMA_Config_Setup;
874 <form method
="post" action
="">
875 <?php
echo get_hidden_inputs();?
>
876 <input type
="hidden" name
="action" value
="feat_charset_real" />
878 echo get_hidden_cfg();
879 show_config_form(array(
880 array('Allow charset conversion', 'AllowAnywhereRecoding', 'If you want to use such functions.', FALSE),
881 array('Default charset', 'DefaultCharset', 'Default charset for conversion.', $PMA_Config_Setup->get('AvailableCharsets')),
882 array('Recoding engine', 'RecodingEngine', 'PHP can contain iconv and/or recode, select which one to use or keep autodetection.', array('auto', 'iconv', 'recode')),
883 array('Extra params for iconv', 'IconvExtraParams', 'Iconv can get some extra parameters for conversion see man iconv_open.'),
885 'Configure charset conversions',
886 'phpMyAdmin can perform charset conversions so that you can import and export in any charset you want.',
894 * Shows PHP extensions configuration form
896 * @param array optional defaults
900 function show_extensions_form($defaults = array()) {
902 <form method
="post" action
="">
903 <?php
echo get_hidden_inputs();?
>
904 <input type
="hidden" name
="action" value
="feat_extensions_real" />
906 echo get_hidden_cfg();
907 show_config_form(array(
908 array('GD 2 is available', 'GD2Available', 'Whether you have GD 2 or newer installed', array('auto', 'yes', 'no')),
910 'Configure extensions',
911 '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.',
919 * Shows MIME/relation/history configuration form
921 * @param array optional defaults
925 function show_relation_form($defaults = array()) {
926 global $PMA_Config_Setup;
928 <form method
="post" action
="">
929 <?php
echo get_hidden_inputs();?
>
930 <input type
="hidden" name
="action" value
="feat_relation_real" />
932 echo get_hidden_cfg();
933 show_config_form(array(
934 array('Permanent query history', 'QueryHistoryDB', 'Store history into database.', FALSE),
935 array('Maximal history size', 'QueryHistoryMax', 'How many queries are kept in history.'),
936 array('Use MIME transformations', 'BrowseMIME', 'Use MIME transformations while browsing.', TRUE),
937 array('PDF default page size', 'PDFDefaultPageSize', 'Default page size for PDF, you can change this while creating page.', $PMA_Config_Setup->get('PDFPageSizes')),
939 'Configure MIME/relation/history',
940 '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.',
948 * Shows upload/save configuration form
950 * @param array optional defaults
954 function show_upload_form($defaults = array()) {
956 <form method
="post" action
="">
957 <?php
echo get_hidden_inputs();?
>
958 <input type
="hidden" name
="action" value
="feat_upload_real" />
960 echo get_hidden_cfg();
961 show_config_form(array(
962 array('Upload directory', 'UploadDir', 'Directory on server where you can upload files for import'),
963 array('Save directory', 'SaveDir', 'Directory where exports can be saved on server'),
965 'Configure upload/save directories',
966 'Enter directories, either absolute path or relative to phpMyAdmin top level directory.',
974 * Shows server configuration form
976 * @param array optional defaults
980 function show_server_form($defaults = array(), $number = FALSE) {
982 <form method
="post" action
="">
983 <?php
echo get_hidden_inputs();?
>
984 <input type
="hidden" name
="action" value
="addserver_real" />
986 echo get_hidden_cfg();
987 if (!($number === FALSE)) {
988 echo '<input type="hidden" name="server" value="' . $number . '" />';
990 $hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'designer_coords', 'history', 'AllowDeny');
991 foreach ($hi as $k) {
992 if (isset($defaults[$k]) && (!is_string($defaults[$k]) ||
strlen($defaults[$k]) > 0)) {
993 echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars(serialize($defaults[$k])) . '" />';
996 show_config_form(array(
997 array('Server hostname', 'host', 'Hostname where MySQL server is running'),
998 array('Server port', 'port', 'Port on which MySQL server is listening, leave empty for default'),
999 array('Server socket', 'socket', 'Socket on which MySQL server is listening, leave empty for default'),
1000 array('Connection type', 'connect_type', 'How to connect to server, keep tcp if unsure', array('tcp', 'socket')),
1001 array('PHP extension to use', 'extension', 'What PHP extension to use, use mysqli if supported', array('mysql', 'mysqli')),
1002 array('Compress connection', 'compress', 'Whether to compress connection to MySQL server', FALSE),
1003 array('Authentication type', 'auth_type', 'Authentication method to use', array('cookie', 'http', 'config', 'signon')),
1004 array('User for config auth', 'user', 'Leave empty if not using config auth'),
1005 array('Password for config auth', 'password', 'Leave empty if not using config auth', 'password'),
1006 array('Only database to show', 'only_db', 'Limit listing of databases in left frame to this one'),
1007 array('Verbose name of this server', 'verbose', 'Name to display in server selection'),
1008 array('phpMyAdmin control user', 'controluser', 'User which phpMyAdmin can use for various actions'),
1009 array('phpMyAdmin control user password', 'controlpass', 'Password for user which phpMyAdmin can use for various actions', 'password'),
1010 array('phpMyAdmin database for advanced features', 'pmadb', 'phpMyAdmin will allow much more when you enable this. Table names are filled in automatically.'),
1011 array('Session name for signon auth', 'SignonSession', 'Leave empty if not using signon auth'),
1012 array('Login URL for signon auth', 'SignonURL', 'Leave empty if not using signon auth'),
1013 array('Logout URL', 'LogoutURL', 'Where to redirect user after logout'),
1016 ($number === FALSE) ?
'Enter new server connection parameters.' : 'Editing server ' . get_server_name($defaults, $number),
1017 $defaults, $number === FALSE ?
'Add' : '', 'Servers_');
1024 * Shows left frame configuration form
1026 * @param array optional defaults
1030 function show_left_form($defaults = array()) {
1032 <form method
="post" action
="">
1033 <?php
echo get_hidden_inputs();?
>
1034 <input type
="hidden" name
="action" value
="lay_navigation_real" />
1036 echo get_hidden_cfg();
1037 show_config_form(array(
1038 array('Use light version', 'LeftFrameLight', 'Disable this if you want to see all databases at one time.', TRUE),
1039 array('Display databases in tree', 'LeftFrameDBTree', 'Whether to display databases in tree (determined by separator defined lower)', TRUE),
1040 array('Databases tree separator', 'LeftFrameDBSeparator', 'String that separates databases into different tree level'),
1041 array('Table tree separator', 'LeftFrameTableSeparator', 'String that separates tables into different tree level'),
1042 array('Maximum table tree nesting', 'LeftFrameTableLevel', 'Maximum number of children in table tree'),
1043 array('Show logo', 'LeftDisplayLogo', 'Whether to show logo in left frame', TRUE),
1044 array('Display servers selection', 'LeftDisplayServers', 'Whether to show server selection in left frame', FALSE),
1045 array('Display servers as list', 'DisplayServersList', 'Whether to show server listing as list instead of drop down', FALSE),
1046 array('Display databases as list', 'DisplayDatabasesList', 'Whether to show database listing in navigation as list instead of drop down', array('auto', 'yes', 'no')),
1047 array('Enable pointer highlighting', 'LeftPointerEnable', 'Whether you want to highlight server under mouse', TRUE),
1049 'Configure navigation frame',
1050 'Customize the appears of the navigation frame.',
1058 * Shows tabs configuration form
1060 * @param array optional defaults
1064 function show_tabs_form($defaults = array()) {
1066 <form method
="post" action
="">
1067 <?php
echo get_hidden_inputs();?
>
1068 <input type
="hidden" name
="action" value
="lay_tabs_real" />
1070 echo get_hidden_cfg();
1071 show_config_form(array(
1072 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')),
1073 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')),
1074 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')),
1075 array('Use lighter tabs', 'LightTabs', 'If you want simpler tabs enable this', FALSE),
1078 'Choose how you want tabs to work.',
1086 * Shows icons configuration form
1088 * @param array optional defaults
1092 function show_icons_form($defaults = array()) {
1094 <form method
="post" action
="">
1095 <?php
echo get_hidden_inputs();?
>
1096 <input type
="hidden" name
="action" value
="lay_icons_real" />
1098 echo get_hidden_cfg();
1099 show_config_form(array(
1100 array('Icons on errors', 'ErrorIconic', 'Whether to use icons in error messages.', TRUE),
1101 array('Icons on main page', 'MainPageIconic', 'Whether to use icons on main page.', TRUE),
1102 array('Icons as help links', 'ReplaceHelpImg', 'Whether to use icons as help links.', TRUE),
1103 array('Navigation with icons', 'NavigationBarIconic', 'Whether to display navigation (eg. tabs) with icons.', array('TRUE', 'FALSE', 'both')),
1104 array('Properties pages with icons', 'PropertiesIconic', 'Whether to display properties (eg. table lists and structure) with icons.', array('TRUE', 'FALSE', 'both')),
1107 'Select whether you prefer text or icons. Both means that text and icons will be displayed.',
1115 * Shows browsing configuration form
1117 * @param array optional defaults
1121 function show_browse_form($defaults = array()) {
1123 <form method
="post" action
="">
1124 <?php
echo get_hidden_inputs();?
>
1125 <input type
="hidden" name
="action" value
="lay_browse_real" />
1127 echo get_hidden_cfg();
1128 show_config_form(array(
1129 array('Display of values', 'DefaultDisplay', 'How to list values while browsing', array('horizontal', 'vertical', 'horizontalflipped')),
1130 array('Hightlight pointer', 'BrowsePointerEnable', 'Whether to highlight row under mouse.', TRUE),
1131 array('Use row marker', 'BrowseMarkerEnable', 'Whether to highlight selected row.', TRUE),
1132 array('Action buttons on left', 'ModifyDeleteAtLeft', 'Show action buttons on left side of listing?', TRUE),
1133 array('Action buttons on right', 'ModifyDeleteAtRight', 'Show action buttons on right side of listing?', FALSE),
1134 array('Repeat heading', 'RepeatCells', 'After how many rows heading should be repeated.'),
1136 'Configure browsing',
1137 'Select desired browsing look and feel.',
1145 * Shows editing options configuration form
1147 * @param array optional defaults
1151 function show_edit_form($defaults = array()) {
1153 <form method
="post" action
="">
1154 <?php
echo get_hidden_inputs();?
>
1155 <input type
="hidden" name
="action" value
="lay_edit_real" />
1157 echo get_hidden_cfg();
1158 show_config_form(array(
1159 array('Display of properties while editing', 'DefaultPropDisplay', 'How to list properties (table structure or values) while editing', array('horizontal', 'vertical')),
1160 array('Number of inserted rows', 'InsertRows', 'How many rows can be inserted at once'),
1161 array('Move using Ctrl+arrows', 'CtrlArrowsMoving', 'Whether to enable moving using Ctrl+Arrows', TRUE),
1162 array('Autoselect text in textarea', 'TextareaAutoSelect', 'Whether to automatically select text in textarea on focus.', TRUE),
1163 array('Textarea columns', 'TextareaCols', 'Number of columns in textarea while editing TEXT fields'),
1164 array('Textarea rows', 'TextareaRows', 'Number of rows in textarea while editing TEXT fields'),
1165 array('Double textarea for LONGTEXT', 'LongtextDoubleTextarea', 'Whether to double textarea size for LONGTEXT fields', TRUE),
1166 array('Edit CHAR fields in textarea', 'CharEditing', 'Whether to edit CHAR fields in textarea', array('input', 'textarea')),
1167 array('CHAR textarea columns', 'CharTextareaCols', 'Number of columns in textarea while editing CHAR fields (must be enabled above)'),
1168 array('CHAR textarea rows', 'CharTextareaRows', 'Number of rows in textarea while editing CHAR fields (must be enabled above)'),
1170 'Configure editing',
1171 'Select desired editing look and feel.',
1179 * Shows query window configuration form
1181 * @param array optional defaults
1185 function show_window_form($defaults = array()) {
1187 <form method
="post" action
="">
1188 <?php
echo get_hidden_inputs();?
>
1189 <input type
="hidden" name
="action" value
="lay_window_real" />
1191 echo get_hidden_cfg();
1192 show_config_form(array(
1193 array('Edit SQL in window', 'EditInWindow', 'Whether edit links will edit in query window.', TRUE),
1194 array('Query window height', 'QueryWindowHeight', 'Height of query window'),
1195 array('Query window width', 'QueryWindowWidth', 'Width of query window'),
1196 array('Default tab', 'QueryWindowDefTab', 'Default tab on query window', array('sql', 'files', 'history', 'full')),
1198 'Configure query window',
1199 'Select desired query window look and feel.',
1207 * Creates selection with servers
1209 * @param array configuraion
1211 * @return string HTML for server selection
1213 function get_server_selection($cfg) {
1214 if (count($cfg['Servers']) == 0) {
1217 $ret = '<select name="server">';
1218 foreach ($cfg['Servers'] as $key => $val) {
1219 $ret .= '<option value="' . $key . '">' . get_server_name($val, $key) . '</option>';
1221 $ret .= '</select>';
1226 * Loads configuration from file
1228 * @param string filename
1230 * @return mixed FALSE on failure, new config array on success
1232 function load_config($config_file) {
1233 if (file_exists($config_file)) {
1234 $success_apply_user_config = FALSE;
1235 $old_error_reporting = error_reporting(0);
1236 if (function_exists('file_get_contents')) {
1237 $success_apply_user_config = eval('?>' . trim(file_get_contents($config_file)));
1239 $success_apply_user_config =
1240 eval('?>' . trim(implode("\n", file($config_file))));
1242 error_reporting($old_error_reporting);
1243 unset($old_error_reporting);
1244 if ($success_apply_user_config === FALSE) {
1245 message('error', 'Error while parsing configuration file!');
1246 } elseif (!isset($cfg) ||
count($cfg) == 0) {
1247 message('error', 'Config file seems to contain no configuration!');
1250 if (!isset($cfg['Servers'])) {
1251 $cfg['Servers'] = array();
1253 message('notice', 'Configuration loaded');
1254 compress_servers($cfg);
1258 message('error', 'Configuration file not found!');
1263 if ($action != 'download') {
1264 // Check whether we can write to configuration
1266 $fail_dir = $fail_dir ||
!is_dir('./config/');
1267 $fail_dir = $fail_dir ||
!is_writable('./config/');
1268 $fail_dir = $fail_dir ||
(file_exists('./config/config.inc.php') && !is_writable('./config/config.inc.php'));
1269 $config = @fopen
('./config/config.inc.php', 'a');
1270 $fail_dir = $fail_dir ||
($config === FALSE);
1275 * @var boolean whether to show configuration overview
1279 // Do the main work depending on selected action
1282 header('Content-Type: text/plain');
1283 header('Content-Disposition: attachment; filename="config.inc.php"');
1285 echo get_cfg_string($configuration);
1289 echo '<form method="none" action=""><textarea name="config" cols="50" rows="20" id="textconfig" wrap="off">' . "\n";
1290 echo htmlspecialchars(get_cfg_string($configuration));
1291 echo '</textarea></form>' . "\n";
1293 <script type
="text/javascript">
1295 var bodyWidth
=null; var bodyHeight
=null;
1296 if (document
.getElementById('textconfig')) {
1297 bodyWidth
= self
.innerWidth
;
1298 bodyHeight
= self
.innerHeight
;
1299 if(!bodyWidth
&& !bodyHeight
){
1300 if (document
.compatMode
&& document
.compatMode
== "BackCompat") {
1301 bodyWidth
= document
.body
.clientWidth
;
1302 bodyHeight
= document
.body
.clientHeight
;
1303 } else if (document
.compatMode
&& document
.compatMode
== "CSS1Compat") {
1304 bodyWidth
= document
.documentElement
.clientWidth
;
1305 bodyHeight
= document
.documentElement
.clientHeight
;
1308 document
.getElementById('textconfig').style
.width
=(bodyWidth
-50) +
'px';
1309 document
.getElementById('textconfig').style
.height
=(bodyHeight
-100) +
'px';
1316 $config = @fopen
('./config/config.inc.php', 'w');
1317 if ($config === FALSE) {
1318 message('error', 'Could not open config file for writing! Bad permissions?');
1321 $s = get_cfg_string($configuration);
1322 $r = fwrite($config, $s);
1323 if (!$r ||
$r != strlen($s)) {
1324 message('error', 'Could not write to config file! Not enough space?');
1327 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');
1334 message('error', 'Reading of configuration disabled because of permissions.');
1337 $new_cfg = load_config('./config/config.inc.php');
1338 if (!($new_cfg === FALSE)) {
1339 $configuration = $new_cfg;
1344 case 'addserver_real':
1345 if (isset($_POST['submit_save'])) {
1346 $new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable:serialized;relation:serialized;table_info:serialized;table_coords:serialized;pdf_pages:serialized;column_info:serialized;designer_coords:serialized;history:serialized;AllowDeny:serialized;SignonSession;SignonURL;LogoutURL');
1348 if (empty($new_server['host'])) {
1349 message('error', 'Empty hostname!');
1352 if ($new_server['auth_type'] == 'config' && empty($new_server['user'])) {
1353 message('error', 'Empty username while using config authentication method!');
1356 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonSession'])) {
1357 message('error', 'Empty signon session name while using signon authentication method!');
1360 if ($new_server['auth_type'] == 'signon' && empty($new_server['SignonURL'])) {
1361 message('error', 'Empty signon URL while using signon authentication method!');
1364 if (isset($new_server['pmadb']) && strlen($new_server['pmadb'])) {
1365 // Just use defaults, should be okay for most users
1367 $pmadb['bookmarktable'] = 'pma_bookmark';
1368 $pmadb['relation'] = 'pma_relation';
1369 $pmadb['table_info'] = 'pma_table_info';
1370 $pmadb['table_coords'] = 'pma_table_coords';
1371 $pmadb['pdf_pages'] = 'pma_pdf_pages';
1372 $pmadb['column_info'] = 'pma_column_info';
1373 $pmadb['designer_coords'] = 'pma_designer_coords';
1374 $pmadb['history'] = 'pma_history';
1376 $new_server = array_merge($pmadb, $new_server);
1378 if (empty($new_server['controluser'])) {
1379 message('error', 'Empty phpMyAdmin control user while using pmadb!');
1382 if (empty($new_server['controlpass'])) {
1383 message('error', 'Empty phpMyAdmin control user password while using pmadb!');
1386 /* Check whether we can connect as control user */
1387 if (!empty($new_server['controluser']) && !empty($new_server['controlpass'])) {
1388 if ($new_server['extension'] == 'mysql') {
1389 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
'' : ':' . $new_server['socket'];
1390 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
'' : ':' . $new_server['port'];
1391 $conn = @mysql_connect
($new_server['host'] . $socket . $port, $new_server['controluser'], $new_server['controlpass']);
1392 if ($conn === FALSE) {
1393 message('error', 'Could not connect as control user!');
1399 $socket = empty($new_server['socket']) ||
$new_server['connect_type'] == 'tcp' ?
NULL : $new_server['socket'];
1400 $port = empty($new_server['port']) ||
$new_server['connect_type'] == 'socket' ?
NULL : $new_server['port'];
1401 $conn = @mysqli_connect
($new_server['host'], $new_server['controluser'], $new_server['controlpass'], NULL, $port, $socket);
1402 if ($conn === FALSE) {
1403 message('error', 'Could not connect as control user!');
1406 mysqli_close($conn);
1411 message('warning', 'You didn\'t set phpMyAdmin database, so you can not use all phpMyAdmin features.');
1413 if ($new_server['auth_type'] == 'config') {
1414 message('warning', 'Remember to protect your installation while using config authentication method!');
1417 unset($new_server['user']);
1418 unset($new_server['password']);
1421 show_server_form($new_server, isset($_POST['server']) ?
$_POST['server'] : FALSE);
1423 if (isset($_POST['server'])) {
1424 $configuration['Servers'][$_POST['server']] = $new_server;
1425 message('notice', 'Changed server ' . get_server_name($new_server, $_POST['server']));
1427 $configuration['Servers'][] = $new_server;
1428 message('notice', 'New server added');
1431 if ($new_server['auth_type'] == 'cookie' && empty($configuration['blowfish_secret'])) {
1432 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');
1433 $configuration['blowfish_secret'] = uniqid('', TRUE);
1442 if (count($configuration['Servers']) == 0) {
1443 // First server will use defaults as in config.default.php
1444 $defaults = $PMA_Config_Setup->default_server
;
1445 unset($defaults['AllowDeny']); // Ignore this for now
1447 $defaults = array();
1450 // Guess MySQL extension to use, prefer mysqli
1451 if (!function_exists('mysql_get_client_info')) {
1454 if (!function_exists('mysqli_get_client_info')) {
1457 if (function_exists('mysqli_get_client_info')) {
1458 $defaults['extension'] = 'mysqli';
1459 } elseif (function_exists('mysql_get_client_info')) {
1460 $defaults['extension'] = 'mysql';
1462 message('warning', 'Could not load either mysql or mysqli extension, you might not be able to use phpMyAdmin! Check your PHP configuration.');
1464 if (isset($defaults['extension'])) {
1465 message('notice', 'Autodetected MySQL extension to use: ' . $defaults['extension']);
1469 show_server_form($defaults);
1472 if (!isset($_POST['server'])) {
1475 show_server_form($configuration['Servers'][$_POST['server']], $_POST['server']);
1477 case 'deleteserver':
1478 if (!isset($_POST['server'])) {
1481 message('notice', 'Deleted server ' . get_server_name($configuration['Servers'][$_POST['server']], $_POST['server']));
1482 unset($configuration['Servers'][$_POST['server']]);
1483 compress_servers($configuration);
1487 if (count($configuration['Servers']) == 0) {
1488 message('notice', 'No servers defined, so none can be shown');
1490 foreach ($configuration['Servers'] as $i => $srv) {
1492 if (!empty($srv['verbose'])) {
1493 $data[] = array('Verbose name', $srv['verbose']);
1495 $data[] = array('Host', $srv['host']);
1496 $data[] = array('MySQL extension', isset($srv['extension']) ?
$srv['extension'] : $PMA_Config_Setup->default_server
['extension']);
1497 $data[] = array('Authentication type', get_server_auth($srv));
1498 $data[] = array('phpMyAdmin advanced features', empty($srv['pmadb']) ||
empty($srv['controluser']) ||
empty($srv['controlpass']) ?
'disabled' : 'enabled, db: ' . $srv['pmadb'] . ', user: ' . $srv['controluser']);
1500 get_action('deleteserver', 'Delete', '<input type="hidden" name="server" value="' . $i . '" />') .
1501 get_action('editserver', 'Edit', '<input type="hidden" name="server" value="' . $i . '" />');
1502 show_overview('Server ' . get_server_name($srv, $i), $data, $buttons);
1507 case 'feat_upload_real':
1508 if (isset($_POST['submit_save'])) {
1509 $dirs = grab_values('UploadDir;SaveDir');
1511 if (!empty($dirs['UploadDir']) && !is_dir($dirs['UploadDir'])) {
1512 message('error', 'Upload directory ' . htmlspecialchars($dirs['UploadDir']) . ' does not exist!');
1515 if (!empty($dirs['SaveDir']) && !is_dir($dirs['SaveDir'])) {
1516 message('error', 'Save directory ' . htmlspecialchars($dirs['SaveDir']) . ' does not exist!');
1520 show_upload_form($dirs);
1522 $configuration = array_merge($configuration, $dirs);
1523 message('notice', 'Configuration changed');
1531 show_upload_form($configuration);
1534 case 'feat_security_real':
1535 if (isset($_POST['submit_save'])) {
1536 $vals = grab_values('blowfish_secret;ForceSSL:bool;ShowPhpInfo:bool;ShowChgPassword:bool;AllowArbitraryServer:bool;LoginCookieRecall:book;LoginCookieValidity:int');
1538 if (empty($vals['blowfish_secret'])) {
1539 message('warning', 'Blowfish secret is empty, you will not be able to use cookie authentication.');
1541 if ($vals['AllowArbitraryServer']) {
1542 message('warning', 'Arbitrary server connection might be dangerous as it might allow access to internal servers that are not reachable from outside.');
1544 if (isset($vals['LoginCookieValidity']) && $vals['LoginCookieValidity'] < 1) {
1545 message('error', 'Invalid cookie validity time');
1549 show_security_form($vals);
1551 $configuration = array_merge($configuration, $vals);
1552 message('notice', 'Configuration changed');
1559 case 'feat_security':
1560 show_security_form($configuration);
1563 case 'feat_manual_real':
1564 if (isset($_POST['submit_save'])) {
1565 $vals = grab_values('MySQLManualBase;MySQLManualType');
1567 if ($vals['MySQLManualType'] != 'none' && empty($vals['MySQLManualBase'])) {
1568 message('error', 'You need to set manual base URL or choose type \'none\'.');
1572 show_manual_form($vals);
1574 $configuration = array_merge($configuration, $vals);
1575 message('notice', 'Configuration changed');
1583 show_manual_form($configuration);
1586 case 'feat_charset_real':
1587 if (isset($_POST['submit_save'])) {
1588 $vals = grab_values('AllowAnywhereRecoding:bool;DefaultCharset;RecodingEngine;IconvExtraParams');
1591 show_charset_form($vals);
1593 $configuration = array_merge($configuration, $vals);
1594 message('notice', 'Configuration changed');
1601 case 'feat_charset':
1602 $d = $configuration;
1603 if (!isset($d['RecodingEngine'])) {
1604 if (@extension_loaded
('iconv')) {
1605 $d['RecodingEngine'] = 'iconv';
1606 } elseif (@extension_loaded
('recode')) {
1607 $d['RecodingEngine'] = 'recode';
1610 if (!@extension_loaded
('iconv')) {
1612 if (!@extension_loaded
('recode')) {
1613 message('warning', 'Neither recode nor iconv could be loaded so charset conversion will most likely not work.');
1615 $d['RecodingEngine'] = 'recode';
1618 $d['RecodingEngine'] = 'iconv';
1621 if (isset($d['RecodingEngine'])) {
1622 message('notice', 'Autodetected recoding engine: ' . $d['RecodingEngine']);
1625 show_charset_form($d);
1629 case 'feat_extensions_real':
1630 if (isset($_POST['submit_save'])) {
1631 $vals = grab_values('GD2Available');
1634 show_extensions_form($vals);
1636 $configuration = array_merge($configuration, $vals);
1637 message('notice', 'Configuration changed');
1644 case 'feat_extensions':
1645 $d = $configuration;
1646 if (!@extension_loaded
('mbstring')) {
1649 if (!@extension_loaded
('mbstring')) {
1650 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.');
1652 if (!isset($d['GD2Available'])) {
1653 if (PMA_IS_GD2
== 1) {
1654 message('notice', 'GD 2 or newer found.');
1655 $d['GD2Available'] = 'yes';
1657 message('warning', 'GD 2 or newer is not present.');
1658 $d['GD2Available'] = 'no';
1661 show_extensions_form($d);
1665 case 'feat_relation_real':
1666 if (isset($_POST['submit_save'])) {
1667 $vals = grab_values('QueryHistoryDB:bool;QueryHistoryMax:int;BrowseMIME:bool;PDFDefaultPageSize');
1669 if (isset($vals['QueryHistoryMax']) && $vals['QueryHistoryMax'] < 1) {
1670 message('error', 'Invalid value for query maximum history size!');
1674 show_relation_form($vals);
1676 $configuration = array_merge($configuration, $vals);
1677 message('notice', 'Configuration changed');
1684 case 'feat_relation':
1685 show_relation_form($configuration);
1688 case 'lay_navigation_real':
1689 if (isset($_POST['submit_save'])) {
1690 $vals = grab_values('LeftFrameLight:bool;LeftFrameDBTree:bool;LeftFrameDBSeparator;LeftFrameTableSeparator;LeftFrameTableLevel:int;LeftDisplayLogo:bool;LeftDisplayServers:bool;DisplayServersList:bool;DisplayDatabasesList;LeftPointerEnable:bool');
1692 if (isset($vals['DisplayDatabasesList'])) {
1693 if ($vals['DisplayDatabasesList'] == 'yes') {
1694 $vals['DisplayDatabasesList'] = true;
1695 } elseif ($vals['DisplayDatabasesList'] == 'no') {
1696 $vals['DisplayDatabasesList'] = false;
1699 if (isset($vals['LeftFrameTableLevel']) && $vals['LeftFrameTableLevel'] < 1) {
1700 message('error', 'Invalid value for maximum table nesting level!');
1704 show_left_form($vals);
1706 $configuration = array_merge($configuration, $vals);
1707 message('notice', 'Configuration changed');
1714 case 'lay_navigation':
1715 show_left_form($configuration);
1718 case 'lay_tabs_real':
1719 if (isset($_POST['submit_save'])) {
1720 $vals = grab_values('DefaultTabServer;DefaultTabDatabase;DefaultTabTable;LightTabs:bool');
1723 show_tabs_form($vals);
1725 $configuration = array_merge($configuration, $vals);
1726 message('notice', 'Configuration changed');
1734 show_tabs_form($configuration);
1737 case 'lay_icons_real':
1738 if (isset($_POST['submit_save'])) {
1739 $vals = grab_values('ErrorIconic:bool;MainPageIconic:bool;ReplaceHelpImg:bool;NavigationBarIconic:tristate;PropertiesIconic:tristate');
1742 show_icons_form($vals);
1744 $configuration = array_merge($configuration, $vals);
1745 message('notice', 'Configuration changed');
1753 show_icons_form($configuration);
1756 case 'lay_browse_real':
1757 if (isset($_POST['submit_save'])) {
1758 $vals = grab_values('BrowsePointerEnable:bool;BrowseMarkerEnable:bool;ModifyDeleteAtRight:bool;ModifyDeleteAtLeft:bool;RepeatCells:int;DefaultDisplay');
1760 if (isset($vals['RepeatCells']) && $vals['RepeatCells'] < 1) {
1761 message('error', 'Invalid value for header repeating!');
1764 if (!$vals['ModifyDeleteAtLeft'] && !$vals['ModifyDeleteAtRight']) {
1765 message('error', 'No action buttons enabled!');
1769 show_browse_form($vals);
1771 $configuration = array_merge($configuration, $vals);
1772 message('notice', 'Configuration changed');
1780 show_browse_form($configuration);
1783 case 'lay_edit_real':
1784 if (isset($_POST['submit_save'])) {
1785 $vals = grab_values('TextareaCols:int;TextareaRows:int;LongtextDoubleTextarea:bool;TextareaAutoSelect:bool;CharEditing;CharTextareaCols:int;CharTextareaRows:int;CtrlArrowsMoving:bool;DefaultPropDisplay;InsertRows:int');
1787 if (isset($vals['TextareaCols']) && $vals['TextareaCols'] < 1) {
1788 message('error', 'Invalid value for textarea columns!');
1791 if (isset($vals['TextareaRows']) && $vals['TextareaRows'] < 1) {
1792 message('error', 'Invalid value for textarea rows!');
1795 if (isset($vals['CharTextareaCols']) && $vals['CharTextareaCols'] < 1) {
1796 message('error', 'Invalid value for CHAR textarea columns!');
1799 if (isset($vals['CharTextareaRows']) && $vals['CharTextareaRows'] < 1) {
1800 message('error', 'Invalid value for CHAR textarea rows!');
1803 if (isset($vals['InsertRows']) && $vals['InsertRows'] < 1) {
1804 message('error', 'Invalid value for inserted rows count!');
1808 show_edit_form($vals);
1810 $configuration = array_merge($configuration, $vals);
1811 message('notice', 'Configuration changed');
1819 show_edit_form($configuration);
1822 case 'lay_window_real':
1823 if (isset($_POST['submit_save'])) {
1824 $vals = grab_values('EditInWindow:bool;QueryWindowHeight:int;QueryWindowWidth:int;QueryWindowDefTab');
1826 if (isset($vals['QueryWindowWidth']) && $vals['QueryWindowWidth'] < 1) {
1827 message('error', 'Invalid value for query window width!');
1830 if (isset($vals['QueryWindowHeight']) && $vals['QueryWindowHeight'] < 1) {
1831 message('error', 'Invalid value for query window height');
1835 show_window_form($vals);
1837 $configuration = array_merge($configuration, $vals);
1838 message('notice', 'Configuration changed');
1846 show_window_form($configuration);
1849 /* Template for new actions:
1851 if (isset($_POST['submit_save'])) {
1852 $vals = grab_values('value1:bool;value2');
1854 if (somechekcfails) {
1855 message('error', 'Invalid value for blah!');
1859 show_blah_form($vals);
1861 $configuration = array_merge($configuration, $vals);
1862 message('notice', 'Configuration changed');
1870 show_blah_form($configuration);
1873 case 'versioncheck': // Check for latest available version
1875 $url = 'http://phpmyadmin.net/home_page/version.php';
1877 $f = @fopen
($url, 'r');
1879 if (!function_exists('curl_init')) {
1880 message('error', 'Neither URL wrappers nor CURL are available. Version check is not possible.');
1884 $data = fread($f, 20);
1887 if (empty($data) && function_exists('curl_init')) {
1888 $ch = curl_init($url);
1889 curl_setopt($ch, CURLOPT_HEADER
, FALSE);
1890 curl_setopt($ch, CURLOPT_RETURNTRANSFER
, TRUE);
1891 $data = curl_exec($ch);
1895 message('error', 'Reading of version failed. Maybe you\'re offline or the upgrade server does not respond.');
1899 /* Format: version\ndate\n(download\n)* */
1900 $data_list = split("\n", $data);
1902 if (count($data_list) > 0) {
1903 $version = $data_list[0];
1908 $version_upstream = version_to_int($version);
1909 if ($version_upstream === FALSE) {
1910 message('error', 'Got invalid version string from server.');
1914 $version_local = version_to_int($PMA_Config_Setup->get('PMA_VERSION'));
1915 if ($version_local === FALSE) {
1916 message('error', 'Unparsable version string.');
1920 if ($version_upstream > $version_local) {
1921 message('notice', 'New version of phpMyAdmin is available, you should consider upgrade. New version is ' . htmlspecialchars($version) . '.');
1923 if ($version_local %
100 == 0) {
1924 message('notice', 'You are using subversion version, run <code>svn update</code> :-). However latest released version is ' . htmlspecialchars($version) . '.');
1926 message('notice', 'No newer stable version is available.');
1932 $eoltype = $_POST['neweol'];
1933 message('notice', 'End of line format changed.');
1934 case 'clear': // Actual clearing is done on beginning of this script
1940 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');
1942 if ($PMA_Config_Setup->get('PMA_PHP_INT_VERSION') < 40100) {
1943 message('warning', 'Please upgrade to PHP 4.1.0, it is required for phpMyAdmin.', 'Too old PHP');
1947 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');
1950 if (empty($_SERVER['HTTPS']) ||
strtolower($_SERVER['HTTPS']) == 'off') {
1951 if (empty($_SERVER['REQUEST_URI']) ||
empty($_SERVER['HTTP_HOST'])) {
1954 $redir = ' If your server is also configured to accept HTTPS request'
1955 . ' follow <a href="https://'
1956 . htmlspecialchars($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])
1957 . '">this link</a> to use secure connection.';
1959 message('warning', 'You are not using secure connection, all data (including sensitive, like passwords) are transfered unencrypted!' . $redir, 'Not secure connection');
1964 // Should we show information?
1967 $servers_text = 'Servers';
1968 if (count($configuration['Servers']) == 0) {
1969 message('warning', 'No servers defined, you probably want to add one.');
1972 $servers_text = 'Servers (' . count($configuration['Servers']) . ')';
1975 foreach ($configuration['Servers'] as $key => $val) {
1978 $servers .= get_server_name($val, $key);
1982 show_overview('Current configuration overview',
1984 array($servers_text, $servers),
1985 array('SQL files upload', empty($configuration['UploadDir']) ?
'disabled' : 'enabled'),
1986 array('Exported files on server', empty($configuration['SaveDir']) ?
'disabled' : 'enabled'),
1987 array('Charset conversion', isset($configuration['AllowAnywhereRecoding']) && $configuration['AllowAnywhereRecoding'] ?
'enabled' : 'disabled'),
1989 unset($servers_text, $servers);
1992 // And finally display all actions:
1993 echo '<p>Available global actions (please note that these will delete any changes you could have done above):</p>';
1995 echo '<fieldset class="toolbar"><legend>Servers</legend>' . "\n";
1996 echo get_action('addserver', 'Add');
1997 $servers = get_server_selection($configuration);
1998 if (!empty($servers)) {
1999 echo get_action('servers', 'List');
2000 echo get_action('deleteserver', 'Delete', $servers);
2001 echo get_action('editserver', 'Edit', $servers);
2003 echo '</fieldset>' . "\n\n";
2005 echo '<fieldset class="toolbar"><legend>Layout</legend>' . "\n";
2006 echo get_action('lay_navigation', 'Navigation frame');
2007 echo get_action('lay_tabs', 'Tabs');
2008 echo get_action('lay_icons', 'Icons');
2009 echo get_action('lay_browse', 'Browsing');
2010 echo get_action('lay_edit', 'Editing');
2011 echo get_action('lay_window', 'Query window');
2012 echo '</fieldset>' . "\n\n";
2014 echo '<fieldset class="toolbar"><legend>Features</legend>' . "\n";
2015 echo get_action('feat_upload', 'Upload/Download');
2016 echo get_action('feat_security', 'Security');
2017 echo get_action('feat_manual', 'MySQL manual');
2018 echo get_action('feat_charset', 'Charsets');
2019 echo get_action('feat_extensions', 'Extensions');
2020 echo get_action('feat_relation', 'MIME/Relation/History');
2021 echo '</fieldset>' . "\n\n";
2023 echo '<fieldset class="toolbar"><legend>Configuration</legend>' . "\n";
2024 echo get_action('main', 'Overview');
2025 echo get_action('display', 'Display');
2026 echo get_action('download', 'Download');
2027 echo get_action('save', 'Save', '', !$fail_dir);
2028 echo get_action('load', 'Load', '', !$fail_dir);
2029 echo get_action('clear', 'Clear');
2030 echo get_action('seteol', 'Change end of line',
2031 '<select name="neweol">' .
2032 '<option value="unix" ' . ($eoltype == 'unix' ?
' selected="selected"' : '') . '>UNIX/Linux (\\n)</option>' .
2033 '<option value="dos" ' . ($eoltype == 'dos' ?
' selected="selected"' : '') . '>DOS/Windows (\\r\\n)</option>' .
2034 '<option value="mac" ' . ($eoltype == 'mac' ?
' selected="selected"' : '') . '>Macintosh (\\r)</option>' . '
2036 echo '</fieldset>' . "\n\n";
2038 echo '<fieldset class="toolbar"><legend>Other actions</legend>' . "\n";
2039 echo get_action('versioncheck', 'Check for latest version');
2040 echo get_url_action('http://www.phpmyadmin.net/', 'Go to homepage');
2041 echo get_url_action('https://sourceforge.net/donate/index.php', 'Donate to phpMyAdmin', array('group_id' => 23067));
2042 echo '</fieldset>' . "\n\n";