From ec2ac82b89e636c71bedb11871e838e23caf39e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 27 Sep 2005 19:07:36 +0000 Subject: [PATCH] Use file common file listing. --- ChangeLog | 1 + libraries/file_listing.php | 6 +++--- tbl_change.php | 32 ++++++++++---------------------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2ffffcb2a..e43ae1c96 100755 --- a/ChangeLog +++ b/ChangeLog @@ -29,6 +29,7 @@ $Source$ * libraries/display_import.lib.php, libraries/file_listing.php: Sort file list on import tab, prepare generic framework to be used elsewhere (RFE #1303145). + * tbl_change.php: Use file common file listing. 2005-09-26 Sebastian Mendel * libraries/database_interface.lib.php: fixed bug in PMA_DBI_fetch_*() diff --git a/libraries/file_listing.php b/libraries/file_listing.php index 40e96d8b7..ceed5f569 100644 --- a/libraries/file_listing.php +++ b/libraries/file_listing.php @@ -10,14 +10,14 @@ * @param string regullar expression to match files * @returns array sorted file list on success, FALSE on failure */ -function PMA_getDirContent($dir, $expression) { +function PMA_getDirContent($dir, $expression = '') { if ($handle = @opendir($dir)) { $result = array(); if (substr($dir, -1) != '/') { $dir .= '/'; } while ($file = @readdir($handle)) { - if (is_file($dir . $file) && preg_match($expression, $file)) { + if (is_file($dir . $file) && ($expression == '' || preg_match($expression, $file))) { $result[] = $file; } } @@ -37,7 +37,7 @@ function PMA_getDirContent($dir, $expression) { * @param string currently active choice * @returns array sorted file list on success, FALSE on failure */ -function PMA_getFileSelectOptions($dir, $extensions, $active = '') { +function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') { $list = PMA_getDirContent($dir, $extensions); if ($list === FALSE) return FALSE; $result = ''; diff --git a/tbl_change.php b/tbl_change.php index 4e3f186f6..19442fc96 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -9,6 +9,7 @@ require_once('./libraries/grab_globals.lib.php'); $js_to_run = 'tbl_change.js'; require_once('./header.inc.php'); require_once('./libraries/relation.lib.php'); // foreign keys +require_once('./libraries/file_listing.php'); // file listing /** @@ -766,30 +767,17 @@ foreach ($loop_array AS $vrowcount => $vrow) { } if (!empty($cfg['UploadDir'])) { - if (substr($cfg['UploadDir'], -1) != '/') { - $cfg['UploadDir'] .= '/'; - } - if ($handle = @opendir($cfg['UploadDir'])) { - $is_first = 0; - while ($file = @readdir($handle)) { - if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) { - if ($is_first == 0) { - echo "
\n"; - echo ' ' . $strOr . '' . ' ' . $strWebServerUploadDirectory . ':
' . "\n"; - echo ' ' . "\n"; - } // end if (isfirst > 0) - @closedir($handle); - } else { + $files = PMA_getFileSelectOptions($cfg['UploadDir']); + if ($files === FALSE) { echo ' ' . $strError . '
' . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n"; + } elseif (!empty($files)) { + echo "
\n"; + echo ' ' . $strOr . '' . ' ' . $strWebServerUploadDirectory . ':
' . "\n"; + echo ' ' . "\n"; } } // end if (web-server upload directory)