2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Functions for listing directories
10 * Returns array of filtered file names
12 * @param string directory to list
13 * @param string regullar expression to match files
14 * @returns array sorted file list on success, FALSE on failure
16 function PMA_getDirContent($dir, $expression = '')
18 if ($handle = @opendir
($dir)) {
20 if (substr($dir, -1) != '/') {
23 while ($file = @readdir
($handle)) {
24 if (is_file($dir . $file) && ($expression == '' ||
preg_match($expression, $file))) {
37 * Returns options of filtered file names
39 * @param string directory to list
40 * @param string regullar expression to match files
41 * @param string currently active choice
42 * @returns array sorted file list on success, FALSE on failure
44 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
46 $list = PMA_getDirContent($dir, $extensions);
47 if ($list === FALSE) {
51 foreach ($list as $key => $val) {
52 $result .= '<option value="'. htmlspecialchars($val) . '"';
53 if ($val == $active) {
54 $result .= ' selected="selected"';
56 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
62 * Get currently supported decompressions.
64 * @returns string | separated list of extensions usable in PMA_getDirContent
66 function PMA_supportedDecompressions()
72 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
73 if (!empty($compressions)) {
76 $compressions .= 'gz';
78 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
79 if (!empty($compressions)) {
82 $compressions .= 'bz2';
84 if ($cfg['ZipDump'] && @function_exists
('gzinflate')) {
85 if (!empty($compressions)) {
88 $compressions .= 'zip';