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 // for PHP < 5.2.4, is_file() gives a warning when using open_basedir
29 // and verifying '..' or '.'
32 && is_file($dir . $file)
33 && ($expression == '' ||
preg_match($expression, $file))
47 * Returns options of filtered file names
49 * @param string $dir directory to list
50 * @param string $extensions regullar expression to match files
51 * @param string $active currently active choice
53 * @return array sorted file list on success, false on failure
55 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
57 $list = PMA_getDirContent($dir, $extensions);
58 if ($list === false) {
62 foreach ($list as $val) {
63 $result .= '<option value="'. htmlspecialchars($val) . '"';
64 if ($val == $active) {
65 $result .= ' selected="selected"';
67 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
73 * Get currently supported decompressions.
75 * @return string | separated list of extensions usable in PMA_getDirContent
77 function PMA_supportedDecompressions()
83 if ($cfg['GZipDump'] && @function_exists
('gzopen')) {
84 if (!empty($compressions)) {
87 $compressions .= 'gz';
89 if ($cfg['BZipDump'] && @function_exists
('bzopen')) {
90 if (!empty($compressions)) {
93 $compressions .= 'bz2';
95 if ($cfg['ZipDump'] && @function_exists
('gzinflate')) {
96 if (!empty($compressions)) {
99 $compressions .= 'zip';
102 return $compressions;