\nOrder deny,allow\nDeny from all\n\n" ); file_put_contents( $dir . 'index.php', "\n\n" ); } /** * Recursively delete a directory that lies inside the backups folder. * * Containment is asserted before anything is removed, so a corrupted * option can never turn cleanup into arbitrary deletion. * * @param string $dir Directory to remove. * @return bool */ public static function delete_dir( $dir ) { $base = self::find_backups_dir(); if ( ! $base || ! is_dir( $dir ) || ! self::is_inside( $dir, $base ) || realpath( $dir ) === realpath( $base ) ) { return false; } $items = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $dir, \FilesystemIterator::SKIP_DOTS ), \RecursiveIteratorIterator::CHILD_FIRST ); foreach ( $items as $item ) { if ( $item->isDir() && ! $item->isLink() ) { @rmdir( $item->getPathname() ); } else { @unlink( $item->getPathname() ); } } return @rmdir( $dir ); } }