setPageTitle(WT_I18N::translate('Download GEDCOM')) ->requireManagerLogin(); require_once WT_ROOT.'includes/functions/functions_export.php'; // Validate user parameters $ged = safe_GET('ged', preg_quote_array(get_all_gedcoms())); $action = safe_GET('action', 'download'); $convert = safe_GET('convert', 'yes', 'no'); $zip = safe_GET('zip', 'yes', 'no'); $conv_path = safe_GET('conv_path', WT_REGEX_NOSCRIPT); $conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), 'forward'); $privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin')); if ($action == 'download') { $conv_path = rtrim(str_replace('\\', '/', trim($conv_path)), '/').'/'; // make sure we have a trailing slash here if ($conv_path=='/') $conv_path = ''; $exportOptions = array(); $exportOptions['privatize'] = $privatize_export; $exportOptions['toANSI'] = $convert; $exportOptions['path'] = $conv_path; $exportOptions['slashes'] = $conv_slashes; } if ($action == "download" && $zip == "yes") { require WT_ROOT.'library/pclzip.lib.php'; $temppath = get_site_setting('INDEX_DIRECTORY') . "tmp/"; $fileName = $ged; $zipname = "dl" . date("YmdHis") . $fileName . ".zip"; $zipfile = get_site_setting('INDEX_DIRECTORY') . $zipname; $gedname = $temppath . $fileName; $removeTempDir = false; if (!is_dir(filename_decode($temppath))) { $res = mkdir(filename_decode($temppath)); if ($res !== true) { echo "Error : Could not create temporary path!"; exit; } $removeTempDir = true; } $gedout = fopen(filename_decode($gedname), "w"); export_gedcom($GEDCOM, $gedout, $exportOptions); fclose($gedout); $comment = "Created by ".WT_WEBTREES." ".WT_VERSION_TEXT." on " . date("r") . "."; $archive = new PclZip(filename_decode($zipfile)); $v_list = $archive->create(filename_decode($gedname), PCLZIP_OPT_COMMENT, $comment, PCLZIP_OPT_REMOVE_PATH, filename_decode($temppath)); if ($v_list == 0) echo "Error : " . $archive->errorInfo(true); else { unlink(filename_decode($gedname)); if ($removeTempDir) rmdir(filename_decode($temppath)); header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH."downloadbackup.php?fname=".$zipname); exit; } exit; } if ($action == "download") { header('Content-Type: text/plain; charset=UTF-8'); // We could open "php://compress.zlib" to create a .gz file or "php://compress.bzip2" to create a .bz2 file $gedout = fopen('php://output', 'w'); if (strtolower(substr($ged, -4, 4))!='.ged') { $ged.='.ged'; } header('Content-Disposition: attachment; filename="'.$ged.'"'); export_gedcom($GEDCOM, $gedout, $exportOptions); fclose($gedout); exit; } $controller->pageHeader(); ?>

-

  
  
  
  
>  
>