Support displaying in UTC (RFE #1440386).
[phpmyadmin/last10db.git] / libraries / file_listing.php
blobd54b29aba650e82f1a8e63f3076f9a2d81cec69c
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
4 // Functions for listing directories
6 /**
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 = '')
15 if ($handle = @opendir($dir)) {
16 $result = array();
17 if (substr($dir, -1) != '/') {
18 $dir .= '/';
20 while ($file = @readdir($handle)) {
21 if (is_file($dir . $file) && ($expression == '' || preg_match($expression, $file))) {
22 $result[] = $file;
25 @closedir($handle);
26 asort($result);
27 return $result;
28 } else {
29 return FALSE;
33 /**
34 * Returns options of filtered file names
36 * @param string directory to list
37 * @param string regullar expression to match files
38 * @param string currently active choice
39 * @returns array sorted file list on success, FALSE on failure
41 function PMA_getFileSelectOptions($dir, $extensions = '', $active = '')
43 $list = PMA_getDirContent($dir, $extensions);
44 if ($list === FALSE) {
45 return FALSE;
47 $result = '';
48 foreach ($list as $key => $val) {
49 $result .= '<option value="'. htmlspecialchars($val) . '"';
50 if ($val == $active) {
51 $result .= ' selected="selected"';
53 $result .= '>' . htmlspecialchars($val) . '</option>' . "\n";
55 return $result;
58 /**
59 * Get currently supported decompressions.
61 * @returns string | separated list of extensions usable in PMA_getDirContent
63 function PMA_supportedDecompressions()
65 global $cfg;
67 $compressions = '';
69 if ($cfg['GZipDump'] && @function_exists('gzopen')) {
70 if (!empty($compressions)) {
71 $compressions .= '|';
73 $compressions .= 'gz';
75 if ($cfg['BZipDump'] && @function_exists('bzopen')) {
76 if (!empty($compressions)) {
77 $compressions .= '|';
79 $compressions .= 'bz2';
81 if ($cfg['ZipDump'] && @function_exists('gzinflate')) {
82 if (!empty($compressions)) {
83 $compressions .= '|';
85 $compressions .= 'zip';
88 return $compressions;