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 regular expression to match files
14 * @returns array sorted file list on success, FALSE on failure
16 function PMA_getDirContent($dir, $expression = '')
18 if (file_exists($dir) && $handle = @opendir
($dir)) {
20 if (substr($dir, -1) != '/') {
23 while ($file = @readdir
($handle)) {
24 // for PHP < 5.2.4, is_file() gives a warning when using open_basedir
25 // and verifying '..' or '.'
26 if ('.' != $file && '..' != $file && is_file($dir . $file) && ($expression == '' ||
preg_match($expression, $file))) {
39 * Returns options of filtered file names
41 * @param string directory to list
42 * @param string regullar expression to match files
43 * @param string currently active choice
44 * @returns array sorted file list on success, FALSE on failure
46 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
48 $list = PMA_getDirContent($dir, $extensions);
49 if ($list === FALSE) {
53 foreach ($list as $key => $val) {
54 $result .= '<option value="'. htmlspecialchars($val) . '"';
55 if ($val == $active) {
56 $result .= ' selected="selected"';
58 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
64 * Get currently supported decompressions.
66 * @returns string | separated list of extensions usable in PMA_getDirContent
68 function PMA_supportedDecompressions()
74 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
75 if (!empty($compressions)) {
78 $compressions .= 'gz';
80 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
81 if (!empty($compressions)) {
84 $compressions .= 'bz2';
86 if ($cfg['ZipDump'] && @function_exists
('gzinflate')) {
87 if (!empty($compressions)) {
90 $compressions .= 'zip';