-
Notifications
You must be signed in to change notification settings - Fork 214
/
getfiles.php
51 lines (51 loc) · 1.2 KB
/
getfiles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
/**
* Get's files stored as requested
*
* PHP version 5
*
* @category Getfiles
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
/**
* Get's files stored as requested
*
* PHP version 5
*
* @category Getfiles
* @package FOGProject
* @author Tom Elliott <tommygunsster@gmail.com>
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link https://fogproject.org
*/
require '../commons/base.inc.php';
$decodedPath = urldecode($_REQUEST['path']);
$paths = explode(':', $decodedPath);
foreach ((array)$paths as &$decodedPath) {
if (!(is_dir($decodedPath)
&& file_exists($decodedPath)
&& is_readable($decodedPath))
) {
$files[] = json_encode(_('Path is unavailable'));
continue;
}
$replaced_dir_sep = preg_replace(
'#[\\/]#',
DIRECTORY_SEPARATOR,
$decodedPath
);
$glob_str = sprintf(
'%s%s*',
$replaced_dir_sep,
DIRECTORY_SEPARATOR
);
$files = FOGCore::fastmerge(
(array) $files,
(array) glob($glob_str)
);
}
echo json_encode($files);
exit;