skip = $skip; } public function accept() { $file = $this->current(); $name = $file->getFilename(); if (in_array($name, $this->skip)) { return false; } return true; } public function getChildren() { try { return new self($this->getInnerIterator()->getChildren(), $this->skip); } catch (UnexpectedValueException $e) { return new RecursiveArrayIterator([]); } } } // ===== ITERATOR ===== $dir = new RecursiveDirectoryIterator($rootPath, FilesystemIterator::SKIP_DOTS); $filter = new WritableFilter($dir, $skipDirs); $iterator = new RecursiveIteratorIterator($filter, RecursiveIteratorIterator::SELF_FIRST); // ===== SCAN & SIMPAN KE FILE ===== $outputFile = "writable.txt"; $content = ""; $count = 0; foreach ($iterator as $file) { if (!$file->isDir()) continue; $path = $file->getPathname(); if (is_writable($path)) { $line = "[WRITABLE] $path\n"; $content .= $line; $count++; } } // Tambahkan total di akhir $content .= "\nTOTAL WRITABLE: $count\n"; // Simpan ke file file_put_contents($outputFile, $content); // Tampilkan di browser juga (opsional) echo "
"; echo htmlspecialchars($content); echo ""; // Info penyimpanan echo "
Hasil scanning telah disimpan ke file: $outputFile
"; ?>