setPageTitle(WT_I18N::translate('Download GEDCOM')) ->restrictAccess(Auth::isManager()); // Validate user parameters $action = WT_Filter::get('action', 'download'); $convert = WT_Filter::get('convert', 'yes|no', 'no'); $zip = WT_Filter::get('zip', 'yes|no', 'no'); $conv_path = WT_Filter::get('conv_path'); $privatize_export = WT_Filter::get('privatize_export', 'none|visitor|user|gedadmin'); if ($action == 'download') { $exportOptions = array( 'privatize' => $privatize_export, 'toANSI' => $convert, 'path' => $conv_path, ); // What to call the downloaded file $download_filename = WT_GEDCOM; if (strtolower(substr($download_filename, -4, 4)) != '.ged') { $download_filename .= '.ged'; } if ($zip == "yes") { require WT_ROOT.'library/pclzip.lib.php'; $temp_dir = WT_DATA_DIR . 'tmp-' . WT_GEDCOM . '-' . date("YmdHis") . '/'; $zip_file = $download_filename . ".zip"; if (!WT_File::mkdir($temp_dir)) { echo "Error : Could not create temporary path!"; exit; } // Create the unzipped GEDCOM on disk, so we can ZIP it. $stream = fopen($temp_dir . $download_filename, "w"); export_gedcom(WT_GEDCOM, $stream, $exportOptions); fclose($stream); // Create a ZIP file containing the GEDCOM file. $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("r") . "."; $archive = new PclZip($temp_dir . $zip_file); $v_list = $archive->add($temp_dir . $download_filename, PCLZIP_OPT_COMMENT, $comment, PCLZIP_OPT_REMOVE_PATH, $temp_dir); if ($v_list == 0) { echo "Error : " . $archive->errorInfo(true); } else { header('Content-Type: application/zip'); header('Content-Disposition: attachment; filename="' . $zip_file . '"'); header('Content-length: '.filesize($temp_dir . $zip_file)); readfile($temp_dir . $zip_file); WT_File::delete($temp_dir); } } else { Zend_Session::writeClose(); header('Content-Type: text/plain; charset=UTF-8'); header('Content-Disposition: attachment; filename="' . $download_filename . '"'); // Stream the GEDCOM file straight to the browser. // We could open "php://compress.zlib" to create a .gz file or "php://compress.bzip2" to create a .bz2 file $stream = fopen('php://output', 'w'); export_gedcom(WT_GEDCOM, $stream, $exportOptions); fclose($stream); } exit; } $controller->pageHeader(); ?>

getPageTitle(); ?> -