bindParam(1, $fp, PDO::PARAM_LOB) //->bindParam(2, $gedcom_id, PDO::PARAM_INT) //->execute(); $max_allowed_packet=WT_DB::prepare("SELECT @@max_allowed_packet")->fetchOne(); WT_DB::prepare( "UPDATE `##gedcom`". " SET import_gedcom='', import_offset=1". " WHERE gedcom_id=?" )->execute(array($gedcom_id)); // The max_allowed_packet setting in MySQL puts a limit on the size of SQL // statements that can be received over the network. Due to a bug, it also // limits the size of blobs that can be processed on the server. // Setting this value has no effect on upload limits (so we must still // upload data in chunks smaller than this), but it will allow us to use // CONCAT(import_gedcom, ?) // See http://bugs.mysql.com/bug.php?id=22853 (Scheduled to be fixed in MySQL 6) try { WT_DB::exec("SET @@max_allowed_packet=".max($file_size*2, $max_allowed_packet)); } catch (PDOException $ex) { // We can only set this on MySQL 5.1.30 or earlier } while (!feof($fp)) { $data=fread($fp, $max_allowed_packet * 0.75); WT_DB::prepare( "UPDATE `##gedcom`". " SET import_gedcom=CONCAT(import_gedcom, ?)". " WHERE gedcom_id=?" )->execute(array($data, $gedcom_id)); } 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); } header('Location: editgedcoms.php');exit; 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 `##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']); } } } header('Location: editgedcoms.php');exit; 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']); } } } header('Location: editgedcoms.php');exit; 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); } header('Location: editgedcoms.php');exit; break; } $gedcoms=WT_DB::prepare( "SELECT gedcom_id, gedcom_name, import_offset". " FROM `##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 '
'; echo '', i18n::translate('This will delete all the genealogical data from %s and replace it with data from another GEDCOM.', $gedcom_name), '
'; echo ''; 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,
' '; } } // Options for creating new gedcoms and setting defaults if (WT_USER_IS_ADMIN) { echo '
'; // display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded if (count($gedcoms)==0 && get_user_count()==1) { echo ' ',
'',
i18n::translate('Click here for PhpGedView to webtrees transfer wizard'),
'',
help_link('PGV_WIZARD'),
' ';
}
}
print_footer();
|