Use file common file listing.

This commit is contained in:
Michal Čihař
2005-09-27 19:07:36 +00:00
parent 22ddb6cee2
commit ec2ac82b89
3 changed files with 14 additions and 25 deletions

View File

@@ -29,6 +29,7 @@ $Source$
* libraries/display_import.lib.php, libraries/file_listing.php: Sort file * libraries/display_import.lib.php, libraries/file_listing.php: Sort file
list on import tab, prepare generic framework to be used elsewhere (RFE list on import tab, prepare generic framework to be used elsewhere (RFE
#1303145). #1303145).
* tbl_change.php: Use file common file listing.
2005-09-26 Sebastian Mendel <cybot_tm@users.sourceforge.net> 2005-09-26 Sebastian Mendel <cybot_tm@users.sourceforge.net>
* libraries/database_interface.lib.php: fixed bug in PMA_DBI_fetch_*() * libraries/database_interface.lib.php: fixed bug in PMA_DBI_fetch_*()

View File

@@ -10,14 +10,14 @@
* @param string regullar expression to match files * @param string regullar expression to match files
* @returns array sorted file list on success, FALSE on failure * @returns array sorted file list on success, FALSE on failure
*/ */
function PMA_getDirContent($dir, $expression) { function PMA_getDirContent($dir, $expression = '') {
if ($handle = @opendir($dir)) { if ($handle = @opendir($dir)) {
$result = array(); $result = array();
if (substr($dir, -1) != '/') { if (substr($dir, -1) != '/') {
$dir .= '/'; $dir .= '/';
} }
while ($file = @readdir($handle)) { 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; $result[] = $file;
} }
} }
@@ -37,7 +37,7 @@ function PMA_getDirContent($dir, $expression) {
* @param string currently active choice * @param string currently active choice
* @returns array sorted file list on success, FALSE on failure * @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); $list = PMA_getDirContent($dir, $extensions);
if ($list === FALSE) return FALSE; if ($list === FALSE) return FALSE;
$result = ''; $result = '';

View File

@@ -9,6 +9,7 @@ require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'tbl_change.js'; $js_to_run = 'tbl_change.js';
require_once('./header.inc.php'); require_once('./header.inc.php');
require_once('./libraries/relation.lib.php'); // foreign keys 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 (!empty($cfg['UploadDir'])) {
if (substr($cfg['UploadDir'], -1) != '/') { $files = PMA_getFileSelectOptions($cfg['UploadDir']);
$cfg['UploadDir'] .= '/'; if ($files === FALSE) {
}
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 "<br />\n";
echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n";
echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . $vkey . '">' . "\n";
echo ' <option value="" selected="selected"></option>' . "\n";
} // end if (is_first)
echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
$is_first++;
} // end if (is_file)
} // end while
if ($is_first > 0) {
echo ' </select>' . "\n";
} // end if (isfirst > 0)
@closedir($handle);
} else {
echo ' <font color="red">' . $strError . '</font><br />' . "\n"; echo ' <font color="red">' . $strError . '</font><br />' . "\n";
echo ' ' . $strWebServerUploadDirectoryError . "\n"; echo ' ' . $strWebServerUploadDirectoryError . "\n";
} elseif (!empty($files)) {
echo "<br />\n";
echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n";
echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . $vkey . '">' . "\n";
echo ' <option value="" selected="selected"></option>' . "\n";
echo $files;
echo ' </select>' . "\n";
} }
} // end if (web-server upload directory) } // end if (web-server upload directory)