", i18n::translate('Access Denied
You do not have access to this resource.'), "";
print_footer();
exit;
}
if ($action!="choose") {
if ($gid1==$gid2 && $GEDCOM==$ged2) {
$action="choose";
echo "", i18n::translate('You entered the same IDs. You cannot merge the same records.'), "\n";
} else {
$gedrec1 = find_gedcom_record($gid1, WT_GED_ID, true);
$gedrec2 = find_gedcom_record($gid2, get_id_from_gedcom($ged2), true);
// Fetch the original XREF - may differ in case from the supplied value
$tmp=new Person($gedrec1); $gid1=$tmp->getXref();
$tmp=new Person($gedrec2); $gid2=$tmp->getXref();
if (empty($gedrec1)) {
echo '', i18n::translate('Unable to find record with ID'), ': ', $gid1, ', ', $ged;
$action="choose";
} elseif (empty($gedrec2)) {
echo '', i18n::translate('Unable to find record with ID'), ': ', $gid2, ', ', $ged2;
$action="choose";
} else {
$type1 = "";
$ct = preg_match("/0 @$gid1@ (.*)/", $gedrec1, $match);
if ($ct>0) {
$type1 = trim($match[1]);
}
$type2 = "";
$ct = preg_match("/0 @$gid2@ (.*)/", $gedrec2, $match);
if ($ct>0) $type2 = trim($match[1]);
if (!empty($type1) && ($type1!=$type2)) {
echo "", i18n::translate('Records are not the same type. Cannot merge records that are not the same type.'), "\n";
$action="choose";
} else {
$facts1 = array();
$facts2 = array();
$prev_tags = array();
$ct = preg_match_all('/\n1 (\w+)/', $gedrec1, $match, PREG_SET_ORDER);
for($i=0; $i<$ct; $i++) {
$fact = trim($match[$i][1]);
if (isset($prev_tags[$fact])) {
$prev_tags[$fact]++;
} else {
$prev_tags[$fact] = 1;
}
$subrec = get_sub_record(1, "1 $fact", $gedrec1, $prev_tags[$fact]);
$facts1[] = array("fact"=>$fact, "subrec"=>trim($subrec));
}
$prev_tags = array();
$ct = preg_match_all('/\n1 (\w+)/', $gedrec2, $match, PREG_SET_ORDER);
for($i=0; $i<$ct; $i++) {
$fact = trim($match[$i][1]);
if (isset($prev_tags[$fact])) {
$prev_tags[$fact]++;
} else {
$prev_tags[$fact] = 1;
}
$subrec = get_sub_record(1, "1 $fact", $gedrec2, $prev_tags[$fact]);
$facts2[] = array("fact"=>$fact, "subrec"=>trim($subrec));
}
if ($action=="select") {
echo "