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); }
if (is_dir(fixPath($path))) { if (!empty($_FILES['files']) && is_array($_FILES['files']['tmp_name'])) { $errors = $errorsExt = array(); foreach ($_FILES['files']['tmp_name'] as $k => $v) { $filename = $_FILES['files']['name'][$k]; $filename = RoxyFile::MakeUniqueFilename(fixPath($path), $filename); $filePath = fixPath($path) . '/' . $filename; if (!RoxyFile::CanUploadFile($filename)) { $errorsExt[] = $filename; } elseif (!move_uploaded_file($v, $filePath)) { $errors[] = $filename; } if (is_file($filePath)) { @chmod($filePath, octdec(FILEPERMISSIONS)); } if (RoxyFile::IsImage($filename) && (intval(MAX_IMAGE_WIDTH) > 0 || intval(MAX_IMAGE_HEIGHT) > 0)) { RoxyImage::Resize($filePath, $filePath, intval(MAX_IMAGE_WIDTH), intval(MAX_IMAGE_HEIGHT)); } } if ($errors && $errorsExt) { $res = getSuccessRes(t('E_UploadNotAll') . ' ' . t('E_FileExtensionForbidden')); } elseif ($errorsExt) { $res = getSuccessRes(t('E_FileExtensionForbidden')); } elseif ($errors) { $res = getSuccessRes(t('E_UploadNotAll')); } else { $res = getSuccessRes(); } } else { $res = getErrorRes(t('E_UploadNoFiles')); }
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;
$path = empty($_POST['d']) ? getFilesPath() : $_POST['d']; $type = empty($_POST['type']) ? '' : strtolower($_POST['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)); $w = 0; $h = 0; if (RoxyFile::IsImage($f)) { $tmp = @getimagesize(fixPath($fullPath)); 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; echo ']';