3 // vim: expandtab sw=4 ts=4 sts=4:
4 // Functions for listing directories
7 * Returns array of filtered file names
9 * @param string directory to list
10 * @param string regullar expression to match files
11 * @returns array sorted file list on success, FALSE on failure
13 function PMA_getDirContent($dir, $expression = '') {
14 if ($handle = @opendir
($dir)) {
16 if (substr($dir, -1) != '/') {
19 while ($file = @readdir
($handle)) {
20 if (is_file($dir . $file) && ($expression == '' ||
preg_match($expression, $file))) {
33 * Returns options of filtered file names
35 * @param string directory to list
36 * @param string regullar expression to match files
37 * @param string currently active choice
38 * @returns array sorted file list on success, FALSE on failure
40 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') {
41 $list = PMA_getDirContent($dir, $extensions);
42 if ($list === FALSE) return FALSE;
44 foreach($list as $key => $val) {
45 $result .= '<option value="'. htmlspecialchars($val) . '"';
46 if ($val == $active) {
47 $result .= ' selected="selected"';
49 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
55 * Get currently supported decompressions.
57 * @returns string | separated list of extensions usable in PMA_getDirContent
59 function PMA_supportedDecompressions() {
64 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
65 if (!empty($compressions)) $compressions .= '|';
66 $compressions .= 'gz';
68 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
69 if (!empty($compressions)) $compressions .= '|';
70 $compressions .= 'bz2';
72 if ($cfg['ZipDump'] && @function_exists
('gzinflate')) {
73 if (!empty($compressions)) $compressions .= '|';
74 $compressions .= 'zip';