diff --git a/ChangeLog b/ChangeLog index a590718f9..918d39734 100755 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,11 @@ $Source$ Allow to limit list of shown languages (RFE #1328003). * libraries/common.lib.php: Fix URL detection when not called from top level directory (eg. transformations overview). + * Documentation.html, config.default.php, export.php, import.php, + tbl_change.php, tbl_replace_fields.php, libraries/common.lib.php, + libraries/display_export.lib.php, libraries/display_import.lib.php, + libraries/sql_query_form.lib.php: Support for user specific upload and + save directories (RFE #1260039). 2005-10-18 Sebastian Mendel * querywindow.php: wrong handling of linebreaks in query: bug #1243888 diff --git a/Documentation.html b/Documentation.html index 3fabc0d11..007d518d6 100755 --- a/Documentation.html +++ b/Documentation.html @@ -1661,6 +1661,9 @@ Defaults to FALSE (drop-down).
under a drop-down box when you click the database name, then the SQL tab.

+ If you want different directory for each user, %u will be replaced + with username. +

Please note that the file names must have the suffix ".sql" (or ".sql.bz2" or ".sql.gz" if support for compressed formats is enabled). @@ -1689,6 +1692,9 @@ Defaults to FALSE (drop-down).
The name of the directory, where dumps can be saved.

+ If you want different directory for each user, %u will be replaced + with username. +

Please note that the directory has to be writable for user running webserver.

diff --git a/config.default.php b/config.default.php index 65a43d535..4985dd172 100644 --- a/config.default.php +++ b/config.default.php @@ -620,10 +620,11 @@ $cfg['SQLQuery']['Refresh'] = TRUE; // Refresh the results page */ $cfg['UploadDir'] = ''; // Directory for uploaded files that can be executed by // phpMyAdmin. For example './upload'. Leave empty for - // no upload directory support + // no upload directory support. Use %u for username + // inclusion. $cfg['SaveDir'] = ''; // Directory where phpMyAdmin can save exported data on // server. For example './save'. Leave empty for no save - // directory support. + // directory support. Use %u for username inclusion. $cfg['docSQLDir'] = ''; // Directory for docSQL imports, phpMyAdmin can import // docSQL files from that directory. For example // './docSQL'. Leave empty for no docSQL import support. diff --git a/export.php b/export.php index 3b11c2de2..f66a2df83 100644 --- a/export.php +++ b/export.php @@ -265,10 +265,7 @@ if ($asfile) { // Open file on server if needed if ($save_on_server) { - if (substr($cfg['SaveDir'], -1) != '/') { - $cfg['SaveDir'] .= '/'; - } - $save_filename = $cfg['SaveDir'] . preg_replace('@[/\\\\]@','_',$filename); + $save_filename = PMA_userDir($cfg['SaveDir']) . preg_replace('@[/\\\\]@','_',$filename); unset($message); if (file_exists($save_filename) && empty($onserverover)) { $message = sprintf($strFileAlreadyExists, htmlspecialchars($save_filename)); diff --git a/import.php b/import.php index fe3368569..59b1bde08 100644 --- a/import.php +++ b/import.php @@ -184,11 +184,7 @@ if (!empty($local_import_file) && !empty($cfg['UploadDir'])) { // sanitize $local_import_file as it comes from a POST $local_import_file = PMA_securePath($local_import_file); - if (substr($cfg['UploadDir'], -1) != '/') { - $cfg['UploadDir'] .= '/'; - } - - $import_file = $cfg['UploadDir'] . $local_import_file; + $import_file = PMA_userDir($cfg['UploadDir']) . $local_import_file; } else if (empty($import_file) || !is_uploaded_file($import_file)) { $import_file = 'none'; } diff --git a/libraries/common.lib.php b/libraries/common.lib.php index d39045f75..e6846ec90 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -2933,6 +2933,16 @@ window.parent.updateTableTitle( '', ' diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index 113af8678..74228b0f9 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -754,7 +754,7 @@ function show_checked_option() { onclick="document.getElementById('checkbox_dump_asfile').checked = true;" /> ,
' . "\n"; if ($files === FALSE) { echo '
' . "\n"; diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php index cc2db821c..86462dd2f 100644 --- a/libraries/sql_query_form.lib.php +++ b/libraries/sql_query_form.lib.php @@ -469,7 +469,7 @@ function PMA_sqlQueryFormUpload() { $matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here if (!empty($GLOBALS['cfg']['UploadDir'])) { - $files = PMA_getFileSelectOptions($GLOBALS['cfg']['UploadDir'], $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : ''); + $files = PMA_getFileSelectOptions(PMA_userDir($GLOBALS['cfg']['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : ''); } else { $files = ''; } diff --git a/tbl_change.php b/tbl_change.php index 2be9f10ee..e5f12b428 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -768,7 +768,7 @@ foreach ($loop_array AS $vrowcount => $vrow) { } if (!empty($cfg['UploadDir'])) { - $files = PMA_getFileSelectOptions($cfg['UploadDir']); + $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir'])); if ($files === FALSE) { echo ' ' . $strError . '
' . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n"; diff --git a/tbl_replace_fields.php b/tbl_replace_fields.php index ceaec85ee..06d02f465 100644 --- a/tbl_replace_fields.php +++ b/tbl_replace_fields.php @@ -62,10 +62,7 @@ if (isset(${'me_fields_upload_' . $encoded_key}) && ${'me_fields_upload_' . $enc } } elseif (!empty(${'me_fields_uploadlocal_' . $encoded_key})) { - if (substr($cfg['UploadDir'], -1) != '/') { - $cfg['UploadDir'] .= '/'; - } - $file_to_upload = $cfg['UploadDir'] . preg_replace('@\.\.*@', '.', ${'me_fields_uploadlocal_' . $encoded_key}); + $file_to_upload = PMA_userDir($cfg['UploadDir']) . preg_replace('@\.\.*@', '.', ${'me_fields_uploadlocal_' . $encoded_key}); // A local file will be uploaded. $open_basedir = @ini_get('open_basedir');