2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Functions for listing directories
8 if (! defined('PHPMYADMIN')) {
13 * Returns array of filtered file names
15 * @param string $dir directory to list
16 * @param string $expression regular expression to match files
18 * @return array sorted file list on success, false on failure
20 function PMA_getDirContent($dir, $expression = '')
22 if (file_exists($dir) && $handle = @opendir
($dir)) {
24 if (substr($dir, -1) != '/') {
27 while ($file = @readdir
($handle)) {
28 if (is_file($dir . $file)
29 && ($expression == '' ||
preg_match($expression, $file))
43 * Returns options of filtered file names
45 * @param string $dir directory to list
46 * @param string $extensions regullar expression to match files
47 * @param string $active currently active choice
49 * @return array sorted file list on success, false on failure
51 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
53 $list = PMA_getDirContent($dir, $extensions);
54 if ($list === false) {
58 foreach ($list as $val) {
59 $result .= '<option value="'. htmlspecialchars($val) . '"';
60 if ($val == $active) {
61 $result .= ' selected="selected"';
63 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
69 * Get currently supported decompressions.
71 * @return string | separated list of extensions usable in PMA_getDirContent
73 function PMA_supportedDecompressions()
79 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
80 if (!empty($compressions)) {
83 $compressions .= 'gz';
85 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
86 if (!empty($compressions)) {
89 $compressions .= 'bz2';
91 if ($cfg['ZipDump'] && @function_exists
('gzinflate')) {
92 if (!empty($compressions)) {
95 $compressions .= 'zip';