Exemplo n.º 1
0
    // The filename for the USFM for this book.
    $filename = Export_Logic::baseBookFileName($book);
    $path = "{$usfmDirectoryFull}/{$filename}.usfm";
    // Save.
    file_put_contents($path, $bookUsfmDataFull);
}
// Compress USFM files into one zip file.
$zipfile = "{$usfmDirectoryFull}/" . Export_Logic::baseBookFileName(0) . ".zip";
@unlink($zipfile);
$archive = Filter_Archive::zip($usfmDirectoryFull);
rename($archive, $zipfile);
if ($database_config_bible->getSecureUsfmExport($bible)) {
    // Securing the full USFM export means that there will be one zip file secured with a password.
    // This zip file contains all exported USFM data.
    // All other files will be removed.
    // It uses the external zip binary.
    // PHP 5.6 supports password protected archives: ZipArchive::setPassword ($password).
    $files = scandir($usfmDirectoryFull);
    $files = Filter_Folders::cleanup($files);
    $basefile = basename($zipfile);
    foreach ($files as $file) {
        if ($file != $basefile) {
            unlink("{$usfmDirectoryFull}/{$file}");
        }
    }
    $directory = escapeshellarg($usfmDirectoryFull);
    $password = escapeshellarg($database_config_bible->getExportPassword($bible));
    $command = "cd {$directory}; zip -P {$password} bible.zip {$basefile}; rm {$basefile}";
    Tasks_Logic::save($command);
}
$database_logs->log($bible . ": " . Locale_Translate::_("Exported to USFM"), Filter_Roles::TRANSLATOR_LEVEL);