Check before commit!

This commit is contained in:
Michal Čihař
2006-11-17 08:49:30 +00:00
parent f0780e3129
commit fb9a3a598e
264 changed files with 12328 additions and 5376 deletions

View File

@@ -12,7 +12,7 @@
* @version Subversion $Id$
*/
/* $Id$ */
//vim: expandtab sw=4 ts=4 sts=4:
// vim: expandtab sw=4 ts=4 sts=4:
// Grab phpMyAdmin version and PMA_dl function
define( 'PMA_MINIMUM_COMMON', TRUE );
@@ -35,6 +35,26 @@ if (isset($_POST['action'])) {
$action = '';
}
// Grab wanted CRLF type
if (isset($_POST['eoltype'])) {
$eoltype = $_POST['eoltype'];
} else {
if (PMA_USR_OS == 'Win') {
$eoltype = 'dos';
} else {
$eoltype = 'unix';
}
}
// Detect which CRLF to use
if ($eoltype == 'dos') {
$crlf = "\r\n";
} elseif ($eoltype == 'mac') {
$crlf = "\r";
} else {
$crlf = "\n";
}
if (isset($_POST['configuration']) && $action != 'clear' ) {
// Grab previous configuration, if it should not be cleared
$configuration = unserialize($_POST['configuration']);
@@ -288,7 +308,7 @@ function get_cfg_doc($anchor) {
if (strncmp($anchor, 'Servers_', 8) == 0) {
$wiki = substr($anchor, 8);
}
return
return
'<span class="doc">' .
'<a href="../Documentation.html#cfg_' . $anchor . '" target="pma_doc" class="doc">' .
'<img class="icon" src="../' . $GLOBALS['cfg']['ThemePath'] . '/original/img/b_help.png" width="11" height="11" alt="Documentation" title="Documentation" />' .
@@ -326,9 +346,12 @@ function message($type, $text, $title = '') {
* @return string HTML with hidden inputs
*/
function get_hidden_cfg() {
global $configuration;
global $configuration, $eoltype;
return '<input type="hidden" name="configuration" value="' . htmlspecialchars(serialize($configuration)) . '" />' . "\n";
$ret = '<input type="hidden" name="configuration" value="' . htmlspecialchars(serialize($configuration)) . '" />' . "\n";
$ret .= '<input type="hidden" name="eoltype" value="' . htmlspecialchars($eoltype) . '" />' . "\n";
return $ret;
}
/**
@@ -461,14 +484,16 @@ function get_server_name($val, $id = FALSE, $escape = true) {
* @return string PHP code containing variable value
*/
function PMA_var_export($input) {
global $crlf;
$output = '';
if (is_null($input)) {
$output .= 'NULL';
} elseif (is_array($input)) {
$output .= "array (\n";
$output .= 'array (' . $crlf;
foreach($input as $key => $value) {
$output .= PMA_var_export($key) . ' => ' . PMA_var_export($value);
$output .= ",\n";
$output .= ',' . $crlf;
}
$output .= ')';
} elseif (is_string($input)) {
@@ -481,7 +506,7 @@ function PMA_var_export($input) {
die('Unknown type for PMA_var_export: ' . $input);
}
return $output;
}
}
/**
* Creates configuration code for one variable
@@ -492,38 +517,40 @@ function PMA_var_export($input) {
* @return string PHP code containing configuration
*/
function get_cfg_val($name, $val) {
global $crlf;
$ret = '';
if (is_array($val)) {
$ret .= "\n";
$ret .= $crlf;
foreach ($val as $k => $v) {
if (!isset($type)) {
if (is_string($k)) {
$type = 'string';
} elseif (is_int($k)) {
$type = 'int';
$ret .= $name . " = array(\n";
$ret .= $name . ' = array(' . $crlf;
} else {
// Something unknown...
$ret .= $name. ' = ' . PMA_var_export($val) . ";\n";
$ret .= $name. ' = ' . PMA_var_export($val) . ';' . $crlf;
break;
}
}
if ($type == 'string') {
$ret .= get_cfg_val($name . "['$k']", $v);
} elseif ($type == 'int') {
$ret .= " " . PMA_var_export($v) . ",\n";
$ret .= ' ' . PMA_var_export($v) . ',' . $crlf;
}
}
if (!isset($type)) {
/* Empty array */
$ret .= $name . " = array();\n";
$ret .= $name . ' = array();' . $crlf;
} elseif ($type == 'int') {
$ret .= ");\n";
$ret .= ');' . $crlf;
}
$ret .= "\n";
$ret .= $crlf;
unset($type);
} else {
$ret .= $name . ' = ' . PMA_var_export($val) . ";\n";
$ret .= $name . ' = ' . PMA_var_export($val) . ';' . $crlf;
}
return $ret;
}
@@ -536,20 +563,20 @@ function get_cfg_val($name, $val) {
* @return string PHP code containing configuration
*/
function get_cfg_string($cfg) {
global $script_info, $script_version, $now;
global $script_info, $script_version, $now, $crlf;
$c = $cfg;
$ret = "<?php\n/*\n * Generated configuration file\n * Generated by: $script_info\n * Version: $script_version\n * Date: " . $now . "\n */\n\n";
$ret = "<?php$crlf/*$crlf * Generated configuration file$crlf * Generated by: $script_info$crlf * Version: $script_version$crlf * Date: " . $now . $crlf . ' */' . $crlf . $crlf;
if (count($c['Servers']) > 0) {
$ret .= "/* Servers configuration */\n\$i = 0;\n";
$ret .= "/* Servers configuration */$crlf\$i = 0;" . $crlf;
foreach ($c['Servers'] as $cnt => $srv) {
$ret .= "\n/* Server " . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */\n\$i++;\n";
$ret .= $crlf . '/* Server ' . strtr(get_server_name($srv, $cnt, false), '*', '-') . " */$crlf\$i++;" . $crlf;
foreach ($srv as $key => $val) {
$ret .= get_cfg_val("\$cfg['Servers'][\$i]['$key']", $val);
}
}
$ret .= "\n/* End of servers configuration */\n\n";
$ret .= $crlf . '/* End of servers configuration */' . $crlf . $crlf;
}
unset($c['Servers']);
@@ -557,7 +584,7 @@ function get_cfg_string($cfg) {
$ret .= get_cfg_val("\$cfg['$key']", $val);
}
$ret .= "?>\n";
$ret .= '?>' . $crlf;
return $ret;
}
@@ -934,7 +961,6 @@ function show_upload_form($defaults = array()) {
show_config_form(array(
array('Upload directory', 'UploadDir', 'Directory on server where you can upload files for import'),
array('Save directory', 'SaveDir', 'Directory where exports can be saved on server'),
array('Directory with docSQL', 'docSQLDir', 'Directory on server where you can place docSQL files for import'),
),
'Configure upload/save directories',
'Enter directories, either absolute path or relative to phpMyAdmin top level directory.',
@@ -961,7 +987,7 @@ function show_server_form($defaults = array(), $number = FALSE) {
if (!($number === FALSE)) {
echo '<input type="hidden" name="server" value="' . $number . '" />';
}
$hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'history', 'AllowDeny');
$hi = array ('bookmarktable', 'relation', 'table_info', 'table_coords', 'pdf_pages', 'column_info', 'designer_coords', 'history', 'AllowDeny');
foreach ($hi as $k) {
if (isset($defaults[$k]) && (!is_string($defaults[$k]) || strlen($defaults[$k]) > 0)) {
echo '<input type="hidden" name="' . $k . '" value="' . htmlspecialchars(serialize($defaults[$k])) . '" />';
@@ -1016,6 +1042,8 @@ function show_left_form($defaults = array()) {
array('Maximum table tree nesting', 'LeftFrameTableLevel', 'Maximum number of children in table tree'),
array('Show logo', 'LeftDisplayLogo', 'Whether to show logo in left frame', TRUE),
array('Display servers selection', 'LeftDisplayServers', 'Whether to show server selection in left frame', FALSE),
array('Display servers as list', 'DisplayServersList', 'Whether to show server listing as list instead of drop down', FALSE),
array('Display databases as list', 'DisplayDatabasesList', 'Whether to show database listing in navigation as list instead of drop down', FALSE),
array('Enable pointer highlighting', 'LeftPointerEnable', 'Whether you want to highlight server under mouse', TRUE),
),
'Configure navigation frame',
@@ -1315,7 +1343,7 @@ switch ($action) {
case 'addserver_real':
if (isset($_POST['submit_save'])) {
$new_server = grab_values('host;extension;port;socket;connect_type;compress:bool;controluser;controlpass;auth_type;user;password;only_db;verbose;pmadb;bookmarktable:serialized;relation:serialized;table_info:serialized;table_coords:serialized;pdf_pages:serialized;column_info:serialized;history:serialized;AllowDeny:serialized;SignonSession;SignonURL;LogoutURL');
$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');
$err = FALSE;
if (empty($new_server['host'])) {
message('error', 'Empty hostname!');
@@ -1342,6 +1370,7 @@ switch ($action) {
$pmadb['table_coords'] = 'pma_table_coords';
$pmadb['pdf_pages'] = 'pma_pdf_pages';
$pmadb['column_info'] = 'pma_column_info';
$pmadb['designer_coords'] = 'pma_designer_coords';
$pmadb['history'] = 'pma_history';
$new_server = array_merge($pmadb, $new_server);
@@ -1453,7 +1482,7 @@ switch ($action) {
case 'feat_upload_real':
if (isset($_POST['submit_save'])) {
$dirs = grab_values('UploadDir;SaveDir;docSQLDir');
$dirs = grab_values('UploadDir;SaveDir');
$err = FALSE;
if (!empty($dirs['UploadDir']) && !is_dir($dirs['UploadDir'])) {
message('error', 'Upload directory ' . htmlspecialchars($dirs['UploadDir']) . ' does not exist!');
@@ -1463,10 +1492,6 @@ switch ($action) {
message('error', 'Save directory ' . htmlspecialchars($dirs['SaveDir']) . ' does not exist!');
$err = TRUE;
}
if (!empty($dirs['docSQLDir']) && !is_dir($dirs['docSQLDir'])) {
message('error', 'docSQL directory ' . htmlspecialchars($dirs['docSQLDir']) . ' does not exist!');
$err = TRUE;
}
if ($err) {
show_upload_form($dirs);
} else {
@@ -1638,7 +1663,7 @@ switch ($action) {
case 'lay_navigation_real':
if (isset($_POST['submit_save'])) {
$vals = grab_values('LeftFrameLight:bool;LeftFrameDBTree:bool;LeftFrameDBSeparator;LeftFrameTableSeparator;LeftFrameTableLevel:int;LeftDisplayLogo:bool;LeftDisplayServers:bool;LeftPointerEnable:bool');
$vals = grab_values('LeftFrameLight:bool;LeftFrameDBTree:bool;LeftFrameDBSeparator;LeftFrameTableSeparator;LeftFrameTableLevel:int;LeftDisplayLogo:bool;LeftDisplayServers:bool;DisplayServersList:bool;DisplayDatabasesList:bool;LeftPointerEnable:bool');
$err = FALSE;
if (isset($vals['LeftFrameTableLevel']) && $vals['LeftFrameTableLevel'] < 1) {
message('error', 'Invalid value for maximum table nesting level!');
@@ -1872,6 +1897,9 @@ switch ($action) {
}
break;
case 'seteol':
$eoltype = $_POST['neweol'];
message('notice', 'End of line format changed.');
case 'clear': // Actual clearing is done on beginning of this script
case 'main':
$show_info = TRUE;
@@ -1965,6 +1993,12 @@ echo get_action('download', 'Download');
echo get_action('save', 'Save', '', !$fail_dir);
echo get_action('load', 'Load', '', !$fail_dir);
echo get_action('clear', 'Clear');
echo get_action('seteol', 'Change end of line',
'<select name="neweol">' .
'<option value="unix" ' . ( $eoltype == 'unix' ? ' selected="selected"' : '' ) . '>UNIX/Linux (\\n)</option>' .
'<option value="dos" ' . ( $eoltype == 'dos' ? ' selected="selected"' : '' ) . '>DOS/Windows (\\r\\n)</option>' .
'<option value="mac" ' . ( $eoltype == 'mac' ? ' selected="selected"' : '' ) . '>Macintosh (\\r)</option>' . '
</select>');
echo '</fieldset>' . "\n\n";
echo '<fieldset class="toolbar"><legend>Other actions</legend>' . "\n";