Files
root df0f2fccb8 ARGUS WordPress Defence 1.0.0 — first production release
Automatic WordPress security: local firewall, malware and file-integrity
scanning, vulnerability protection, quarantine, scheduled backups, an
optional page cache, and automatic global threat intelligence.

See README.md for installation, update, and uninstall instructions.
2026-08-09 13:40:16 +00:00

38 lines
1.1 KiB
PHP
Executable File

<?php
array_shift( $argv );
list( $source_dir, $dest_zip, $root_name ) = $argv + array( null, null, null );
if ( ! $source_dir || ! $dest_zip || ! $root_name || ! is_dir( $source_dir ) ) {
fwrite( STDERR, "Usage: php zip-directory.php <source-dir> <dest-zip> <root-name-in-zip>\n" );
exit( 1 );
}
if ( ! class_exists( 'ZipArchive' ) ) {
fwrite( STDERR, "PHP's zip extension is not available on this host -- cannot build the release archive here.\n" );
exit( 1 );
}
$zip = new ZipArchive();
if ( true !== $zip->open( $dest_zip, ZipArchive::CREATE | ZipArchive::OVERWRITE ) ) {
fwrite( STDERR, "Could not create {$dest_zip}\n" );
exit( 1 );
}
$source_dir = rtrim( $source_dir, '/' );
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $source_dir, FilesystemIterator::SKIP_DOTS ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ( $iterator as $item ) {
$relative = $root_name . '/' . ltrim( str_replace( $source_dir, '', $item->getPathname() ), '/' );
if ( $item->isDir() ) {
$zip->addEmptyDir( $relative );
} else {
$zip->addFile( $item->getPathname(), $relative );
}
}
$zip->close();
echo "Wrote {$dest_zip}\n";