Use common file listing in query window, remove no more used functions. Please note that file import from query windows is currently half rewritten, so compressed imports will not work.
This commit is contained in:
@@ -30,6 +30,11 @@ $Source$
|
||||
list on import tab, prepare generic framework to be used elsewhere (RFE
|
||||
#1303145).
|
||||
* tbl_change.php: Use file common file listing.
|
||||
* libraries/common.lib.php, libraries/display_import.lib.php,
|
||||
libraries/file_listing.php, libraries/sql_query_form.lib.php: Use common
|
||||
file listing in query window, remove no more used functions. Please note
|
||||
that file import from query windows is currently half rewritten, so
|
||||
compressed imports will not work.
|
||||
|
||||
2005-09-26 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||
* libraries/database_interface.lib.php: fixed bug in PMA_DBI_fetch_*()
|
||||
|
@@ -2526,34 +2526,6 @@ if (typeof(document.getElementById) != 'undefined'
|
||||
define('PMA_MULTIBYTE_ENCODING', 1);
|
||||
} // end if
|
||||
|
||||
/**
|
||||
* Function to check valid extension of file. It accepts entered
|
||||
* extensions and bz2 and gz if supported.
|
||||
*
|
||||
* @param string File name to be tested.
|
||||
* @param string Extension that is valid.
|
||||
*
|
||||
* @access public
|
||||
* @author Michal Cihar (nijel@users.sourceforge.net)
|
||||
* @return bool Whether extension is valid
|
||||
*/
|
||||
function PMA_checkFileExtensions($file, $extension) {
|
||||
if (substr($file, -1 * strlen($extension)) == $extension) {
|
||||
return TRUE;
|
||||
}
|
||||
if ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')) {
|
||||
if (substr($file, -3 - strlen($extension)) == $extension . '.gz') {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzdecompress')) {
|
||||
if (substr($file, -4 - strlen($extension)) == $extension . '.bz2') {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
} // end function
|
||||
|
||||
/**
|
||||
* Function to generate unique condition for specified row.
|
||||
*
|
||||
|
@@ -137,28 +137,12 @@ echo PMA_displayMaximumUploadSize($max_upload_size);
|
||||
echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
|
||||
|
||||
if (!empty($cfg['UploadDir'])) {
|
||||
if (substr($cfg['UploadDir'], -1) != '/') {
|
||||
$cfg['UploadDir'] .= '/';
|
||||
}
|
||||
$extensions = '';
|
||||
foreach($import_list as $key => $val) {
|
||||
if (!empty($extensions)) $extensions .= '|';
|
||||
$extensions .= $val['extension'];
|
||||
}
|
||||
$compressions = '';
|
||||
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'gz';
|
||||
}
|
||||
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'bz2';
|
||||
}
|
||||
if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'zip';
|
||||
}
|
||||
$matcher = '@\.(' . $extensions . ')(\.(' .$compressions . '))?$@';
|
||||
$matcher = '@\.(' . $extensions . ')(\.(' . PMA_supportedDecompressions() . '))?$@';
|
||||
|
||||
$files = PMA_getFileSelectOptions($cfg['UploadDir'], $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
|
||||
|
||||
|
@@ -50,3 +50,29 @@ function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') {
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get currently supported decompressions.
|
||||
*
|
||||
* @returns string | separated list of extensions usable in PMA_getDirContent
|
||||
*/
|
||||
function PMA_supportedDecompressions() {
|
||||
global $cfg;
|
||||
|
||||
$compressions = '';
|
||||
|
||||
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'gz';
|
||||
}
|
||||
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'bz2';
|
||||
}
|
||||
if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
|
||||
if (!empty($compressions)) $compressions .= '|';
|
||||
$compressions .= 'zip';
|
||||
}
|
||||
|
||||
return $compressions;
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@
|
||||
* @usedby querywindow.php
|
||||
*/
|
||||
|
||||
require_once('./libraries/file_listing.php'); // used for file listing
|
||||
|
||||
/**
|
||||
* prints the sql query boxes
|
||||
*
|
||||
@@ -452,45 +454,22 @@ function PMA_sqlQueryFormBookmark( $display_tab = 'full' ) {
|
||||
* @uses $GLOBALS['allow_recoding']
|
||||
* @uses $GLOBALS['charset']
|
||||
* @uses $GLOBALS['max_upload_size']
|
||||
* @uses PMA_checkFileExtensions()
|
||||
* @uses PMA_supportedDecompressions()
|
||||
* @uses PMA_getFileSelectOptions()
|
||||
* @uses PMA_displayMaximumUploadSize()
|
||||
* @uses PMA_generateCharsetDropdownBox()
|
||||
* @uses PMA_generateHiddenMaxFileSize()
|
||||
* @uses PMA_MYSQL_INT_VERSION
|
||||
* @uses PMA_CSDROPDOWN_CHARSET
|
||||
* @uses closedir()
|
||||
* @uses count()
|
||||
* @uses function_exists()
|
||||
* @uses htmlspecialchars()
|
||||
* @uses opendir()
|
||||
* @uses readdir()
|
||||
* @uses empty()
|
||||
* @param string $display_tab current tab displayed if in querywindow
|
||||
*/
|
||||
function PMA_sqlQueryFormUpload( $display_tab = 'full' ) {
|
||||
$uploaded_files = array();
|
||||
$errors = array();
|
||||
$is_gzip = ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen'));
|
||||
$is_bzip = ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzdecompress'));
|
||||
$errors = array ();
|
||||
|
||||
if ( ! empty( $GLOBALS['cfg']['UploadDir'] ) ) {
|
||||
if ( substr($GLOBALS['cfg']['UploadDir'], -1) != '/' ) {
|
||||
$GLOBALS['cfg']['UploadDir'] .= '/';
|
||||
}
|
||||
if ( $handle = @opendir( $GLOBALS['cfg']['UploadDir'] ) ) {
|
||||
while ( $file = @readdir( $handle ) ) {
|
||||
if ( is_file( $GLOBALS['cfg']['UploadDir'] . $file )
|
||||
&& PMA_checkFileExtensions( $file, '.sql' ) )
|
||||
{
|
||||
$uploaded_files[] = $file;
|
||||
}
|
||||
} // end while
|
||||
@closedir( $handle );
|
||||
}
|
||||
else {
|
||||
$errors[$GLOBALS['strError']] =
|
||||
$GLOBALS['strWebServerUploadDirectoryError'];
|
||||
}
|
||||
} // end if (web-server upload directory)
|
||||
$matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here
|
||||
|
||||
$files = PMA_getFileSelectOptions($GLOBALS['cfg']['UploadDir'], $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
|
||||
|
||||
// start output
|
||||
echo '<fieldset id="">';
|
||||
@@ -503,47 +482,18 @@ function PMA_sqlQueryFormUpload( $display_tab = 'full' ) {
|
||||
echo PMA_generateHiddenMaxFileSize( $GLOBALS['max_upload_size'] ) . "\n";
|
||||
echo '</div>';
|
||||
|
||||
if ( $is_bzip || $is_gzip ) {
|
||||
if ($files === FALSE) {
|
||||
$errors[$GLOBALS['strError']] = $GLOBALS['strWebServerUploadDirectoryError'];
|
||||
} elseif (!empty($files)) {
|
||||
echo '<div class="formelement">';
|
||||
echo $GLOBALS['strCompression'] . ': ' . "\n"
|
||||
.'<input type="radio" value=""'
|
||||
.' id="radio_sql_file_compression_auto"'
|
||||
.' name="sql_file_compression" checked="checked" />'
|
||||
.'<label for="radio_sql_file_compression_auto">'
|
||||
.$GLOBALS['strAutodetect'] . '</label>' . "\n"
|
||||
.'<input type="radio" id="radio_sql_file_compression_plain"'
|
||||
.' name="sql_file_compression" value="text/plain" />'
|
||||
.'<label for="radio_sql_file_compression_plain">'
|
||||
.$GLOBALS['strNone'] . '</label>' . "\n";
|
||||
if ( $is_gzip ) {
|
||||
echo '<input type="radio" id="radio_sql_file_compression_gzip"'
|
||||
.' name="sql_file_compression" value="application/x-gzip" />'
|
||||
.'<label for="radio_sql_file_compression_gzip">'
|
||||
.$GLOBALS['strGzip'] . '</label>' . "\n";
|
||||
}
|
||||
if ( $is_bzip ) {
|
||||
echo '<input type="radio" id="radio_sql_file_compression_bzip"'
|
||||
.' name="sql_file_compression" value="application/x-bzip" />'
|
||||
.'<label for="radio_sql_file_compression_bzip">'
|
||||
.$GLOBALS['strBzip'] . '</label>' . "\n";
|
||||
}
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<input type="hidden" name="sql_file_compression"'
|
||||
.' value="text/plain" />';
|
||||
}
|
||||
|
||||
if ( count( $uploaded_files ) > 0 ) {
|
||||
echo '<strong>' . $GLOBALS['strWebServerUploadDirectory']
|
||||
.':</strong>' . "\n";
|
||||
echo '<strong>' . $GLOBALS['strWebServerUploadDirectory'] .':</strong>' . "\n";
|
||||
echo '<select size="1" name="sql_localfile">' . "\n";
|
||||
echo '<option value="" selected="selected"></option>' . "\n";
|
||||
foreach ( $uploaded_files as $file ) {
|
||||
echo '<option value="' . htmlspecialchars( $file ) . '">'
|
||||
.htmlspecialchars( $file ) . '</option>' . "\n";
|
||||
}
|
||||
echo $files;
|
||||
echo '</select>' . "\n";
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="clearfloat"></div>' . "\n";
|
||||
echo '</fieldset>';
|
||||
|
||||
|
Reference in New Issue
Block a user