bindParam(1, $fp, PDO::PARAM_LOB) ->bindParam(2, $gedcom_id, PDO::PARAM_INT) ->execute(); WT_DB::exec("COMMIT"); fclose($fp); } // Process GET actions switch (safe_GET('action')) { case 'delete': $ged=safe_GET('ged'); delete_gedcom(get_id_from_gedcom($ged)); break; } // Process POST actions switch (safe_POST('action')) { case 'setdefault': set_site_setting('DEFAULT_GEDCOM', safe_POST('default_ged')); break; case 'add_ged': $ged_name=basename(safe_POST('ged_name')); $gedcom_id=get_id_from_gedcom($ged_name); // check it doesn't already exist before we create it if (!$gedcom_id && file_exists($INDEX_DIRECTORY.$ged_name)) { $gedcom_id=get_id_from_gedcom($ged_name, true); import_gedcom_file($gedcom_id, $INDEX_DIRECTORY.$ged_name); } break; case 'new_ged': $ged_name=basename(safe_POST('ged_name')); $gedcom_id=get_id_from_gedcom($ged_name); // check it doesn't already exist before we create it if (!$gedcom_id) { $gedcom_id=get_id_from_gedcom($ged_name, true); // I18N: This should be a common/default/placeholder name of a person. Put slashes around the surname. $john_doe=i18n::translate('John /DOE/'); $note=i18n::translate('Edit this individual and replace their details with your own'); WT_DB::prepare( "UPDATE {$TBLPREFIX}gedcom". " SET import_gedcom=?, import_offset=1". " WHERE gedcom_id=?" )->execute(array("0 HEAD\n0 @I1@ INDI\n1 NAME {$john_doe}\n1 SEX M\n1 BIRT\n2 DATE 1 JAN 1850\n2 NOTE {$note}\n0 TRLR\n", $gedcom_id)); } break; case 'upload_ged': foreach ($_FILES as $FILE) { if ($FILE['error']==0 && is_readable($FILE['tmp_name'])) { $ged_name=$FILE['name']; $gedcom_id=get_id_from_gedcom($ged_name); // check it doesn't already exist before we create it if (!$gedcom_id) { $gedcom_id=get_id_from_gedcom($ged_name, true); import_gedcom_file($gedcom_id, $FILE['tmp_name']); } } } break; case 'replace_upload': $gedcom_id=safe_POST('gedcom_id'); // Make sure the gedcom still exists if (get_gedcom_from_id($gedcom_id)) { foreach ($_FILES as $FILE) { if ($FILE['error']==0 && is_readable($FILE['tmp_name'])) { import_gedcom_file($gedcom_id, $FILE['tmp_name']); } } } break; case 'replace_import': $gedcom_id=safe_POST('gedcom_id'); // Make sure the gedcom still exists if (get_gedcom_from_id($gedcom_id)) { $ged_name=basename(safe_POST('ged_name')); import_gedcom_file($gedcom_id, $INDEX_DIRECTORY.$ged_name); } break; } $gedcoms=WT_DB::prepare( "SELECT gedcom_id, gedcom_name, import_offset". " FROM {$TBLPREFIX}gedcom". " ORDER BY gedcom_name" )->fetchAll(); $all_gedcoms=array(); foreach ($gedcoms as $gedcom) { $all_gedcoms[$gedcom->gedcom_id]=$gedcom->gedcom_name; } print_header(i18n::translate('GEDCOM administration')); echo '

', i18n::translate('GEDCOM administration'), '

'; // Process GET actions switch (safe_GET('action')) { case 'uploadform': case 'importform': $gedcom_id=safe_GET('gedcom_id'); $gedcom_name=get_gedcom_from_id($gedcom_id); // Check it exists if (!$gedcom_name) { break; } echo '

', i18n::translate('This will delete all the genealogical data from %s and replace it with data from another GEDCOM.', $gedcom_name), '

'; echo '
'; echo ''; if (safe_GET('action')=='uploadform') { echo ''; echo ''; } else { echo ''; $d=opendir($INDEX_DIRECTORY); $files=array(); while (($f=readdir($d))!==false) { if (!is_dir($INDEX_DIRECTORY.$f) && is_readable($INDEX_DIRECTORY.$f)) { $fp=fopen($INDEX_DIRECTORY.$f, 'rb'); $header=fread($fp, 64); fclose($fp); if (preg_match('/^('.WT_UTF8_BOM.')?0 *HEAD/', $header)) { $files[]=$f; } } } if ($files) { echo $INDEX_DIRECTORY, ''; } else { echo '

', i18n::translate('No GEDCOM files found. You need to copy files to the %s directory on your server.', $INDEX_DIRECTORY); echo '

'; echo '

'; echo '
'; print_footer(); exit; } } echo '

'; echo i18n::translate('If you have created media objects in webtrees, and have edited your gedcom off-line using a program that deletes media objects, then tick this box to merge the current media objects with the new GEDCOM.'); echo '

'; echo ''; echo '
'; print_footer(); exit; } // List the gedcoms available to this user foreach ($gedcoms as $gedcom) { if (userGedcomAdmin(WT_USER_ID, $gedcom->gedcom_id)) { echo '', '
', i18n::translate('GEDCOM name'), '', htmlspecialchars($gedcom->gedcom_name), ' - ', htmlspecialchars(get_gedcom_setting($gedcom->gedcom_id, 'title')), '', '
', i18n::translate('GEDCOM administration'), ''; // The third row shows an optional progress bar and a list of maintenance options if ($gedcom->import_offset>0) { echo '
', WT_JS_START, '$("#import', $gedcom->gedcom_id, '").load("import.php?gedcom_id=', $gedcom->gedcom_id, '&keep_media=', safe_POST('keep_media'.$gedcom->gedcom_id), '");', WT_JS_END, ''; } else { echo ''; } echo '', // configuration '', // privacy '', // export '', // import '', // download '', // upload '', // delete '
', i18n::translate('Configuration'), '', help_link('gedcom_configfile'), '', i18n::translate('Privacy'), '', help_link('edit_privacy'), 'gedcom_name}"), '\', \'_blank\',\'left=50,top=50,width=500,height=500,resizable=1,scrollbars=1\');">', i18n::translate('Export'), '', help_link('export_gedcom.php'), '', i18n::translate('Import'), '', help_link('import_gedcom'), '', i18n::translate('Download'), '', help_link('download_gedcom'), '', i18n::translate('Upload'), '', help_link('help_uploadgedcom.php'), '', i18n::translate('Delete'), '', help_link('delete_gedcom'), '

'; } } // Options for creating new gedcoms and setting defaults if (WT_USER_IS_ADMIN) { echo '
', '', '', '', '', '', '', '', '', '', '
', i18n::translate('Default GEDCOM'), help_link('default_gedcom'), '', i18n::translate('Add a new GEDCOM'), help_link('help_addgedcom.php'), '', i18n::translate('Upload a new GEDCOM'), help_link('help_uploadgedcom.php'), '', i18n::translate('Create a new GEDCOM'), help_link('help_addnewgedcom.php'), '
', '
', '', '', '
', '
', $INDEX_DIRECTORY, '', '', '
', '
', '
', '', '', '
', '
', '
', '', '', ' ', '
', '

'; } print_footer();