(string $folder, string $user, array $perms)
| 353 | } |
| 354 | |
| 355 | private static function countVisibleRemote(string $folder, string $user, array $perms): array |
| 356 | { |
| 357 | $storage = self::storage(); |
| 358 | |
| 359 | $canViewFolder = ACL::isAdmin($perms) |
| 360 | || ACL::canRead($user, $perms, $folder) |
| 361 | || ACL::canReadOwn($user, $perms, $folder); |
| 362 | if (!$canViewFolder) { |
| 363 | return ['folders' => 0, 'files' => 0, 'bytes' => 0]; |
| 364 | } |
| 365 | |
| 366 | $hasFullRead = ACL::isAdmin($perms) || ACL::canRead($user, $perms, $folder); |
| 367 | |
| 368 | $base = rtrim(self::uploadRoot(), "/\\"); |
| 369 | if ($base === '') { |
| 370 | return ['folders' => 0, 'files' => 0, 'bytes' => 0]; |
| 371 | } |
| 372 | |
| 373 | $dirPath = ($folder === 'root') |
| 374 | ? $base |
| 375 | : $base . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $folder); |
| 376 | |
| 377 | $entries = $storage->list($dirPath); |
| 378 | if (!$entries) { |
| 379 | return ['folders' => 0, 'files' => 0, 'bytes' => 0]; |
| 380 | } |
| 381 | |
| 382 | $SKIP = FS::SKIP(); |
| 383 | |
| 384 | $folderCount = 0; |
| 385 | $fileCount = 0; |
| 386 | $totalBytes = 0; |
| 387 | $earliestUploaded = null; |
| 388 | $latestMtime = null; |
| 389 | |
| 390 | foreach ($entries as $name) { |
| 391 | if ($name === '.' || $name === '..' || $name === '') { |
| 392 | continue; |
| 393 | } |
| 394 | if ($name[0] === '.') { |
| 395 | continue; |
| 396 | } |
| 397 | if (FS::shouldIgnoreEntry($name, $folder)) { |
| 398 | continue; |
| 399 | } |
| 400 | if (!FS::isSafeSegment($name)) { |
| 401 | continue; |
| 402 | } |
| 403 | if (in_array(strtolower($name), $SKIP, true)) { |
| 404 | continue; |
| 405 | } |
| 406 | |
| 407 | $full = $dirPath . DIRECTORY_SEPARATOR . $name; |
| 408 | $stat = $storage->stat($full); |
| 409 | if (!$stat) { |
| 410 | continue; |
| 411 | } |
| 412 |
no test coverage detected