isDir()) { @rmdir($item->getPathname()); } else { @unlink($item->getPathname()); } } @rmdir($dir); } // Reads the first bytes of a file and reports whether they look like a ZIP // local file / empty archive / spanned archive header. function manageFileIsZip(string $path): bool { $handle = @fopen($path, "rb"); if ($handle === false) { return false; } $signature = fread($handle, 4); fclose($handle); return $signature === "PK\x03\x04" || $signature === "PK\x05\x06" || $signature === "PK\x07\x08"; }