function getFilesNumber($path, $type)
{
    $files = 0;
    $dirs = 0;
    $tmp = listDirectory($path);
    foreach ($tmp as $ff) {
        if ($ff == '.' || $ff == '..' || $ff == 'index.php' || $ff == '.htaccess') {
            continue;
        } elseif (is_file($path . '/' . $ff) && ($type == '' || $type == 'image' && RoxyFile::IsImage($ff) || $type == 'flash' && RoxyFile::IsFlash($ff))) {
            $files++;
        } elseif (is_dir($path . '/' . $ff)) {
            $dirs++;
        }
    }
    return array('files' => $files, 'dirs' => $dirs);
}
Exemple #2
0
include 'functions.inc.php';
verifyAction('FILESLIST');
checkAccess('FILESLIST');
$path = empty($_GET['d']) ? getFilesPath() : $_GET['d'];
$type = empty($_GET['type']) ? '' : strtolower($_GET['type']);
if ($type != 'image' && $type != 'flash') {
    $type = '';
}
verifyPath($path);
$files = listDirectory(fixPath($path), 0);
natcasesort($files);
$str = '';
echo '[';
foreach ($files as $f) {
    $fullPath = $path . '/' . $f;
    if (!is_file(fixPath($fullPath)) || $type == 'image' && !RoxyFile::IsImage($f) || $type == 'flash' && !RoxyFile::IsFlash($f)) {
        continue;
    }
    $size = filesize(fixPath($fullPath));
    $time = filemtime(fixPath($fullPath));
    $tmp = @getimagesize(fixPath($fullPath));
    $w = 0;
    $h = 0;
    if ($tmp) {
        $w = $tmp[0];
        $h = $tmp[1];
    }
    $str .= '{"p":"' . mb_ereg_replace('"', '\\"', $fullPath) . '","s":"' . $size . '","t":"' . $time . '","w":"' . $w . '","h":"' . $h . '"},';
}
$str = mb_substr($str, 0, -1);
echo $str;