Example #1
0
function addNewFact($fact)
{
    global $tagSOUR, $ADVANCED_PLAC_FACTS;
    $FACT = safe_POST($fact, PGV_REGEX_UNSAFE);
    $DATE = safe_POST("{$fact}_DATE", PGV_REGEX_UNSAFE);
    $PLAC = safe_POST("{$fact}_PLAC", PGV_REGEX_UNSAFE);
    if ($DATE || $PLAC || $FACT && $FACT != 'Y') {
        if ($FACT && $FACT != 'Y') {
            $gedrec = "1 {$fact} {$FACT}\n";
        } else {
            $gedrec = "1 {$fact}\n";
        }
        if ($DATE) {
            $DATE = check_input_date($DATE);
            $gedrec .= "2 DATE {$DATE}\n";
        }
        if ($PLAC) {
            $gedrec .= "2 PLAC {$PLAC}\n";
            if (preg_match_all('/(' . PGV_REGEX_TAG . ')/', $ADVANCED_PLAC_FACTS, $match)) {
                foreach ($match[1] as $tag) {
                    $TAG = safe_POST("{$fact}_{$tag}", PGV_REGEX_UNSAFE);
                    if ($TAG) {
                        $gedrec .= "3 {$tag} {$TAG}\n";
                    }
                }
            }
            $LATI = safe_POST("{$fact}_LATI", PGV_REGEX_UNSAFE);
            $LONG = safe_POST("{$fact}_LONG", PGV_REGEX_UNSAFE);
            if ($LATI || $LONG) {
                $gedrec .= "3 MAP\n4 LATI {$LATI}\n4 LONG {$LONG}\n";
            }
        }
        if (safe_POST_bool("SOUR_{$fact}")) {
            return updateSOUR($gedrec, 2);
        } else {
            return $gedrec;
        }
    } elseif ($FACT == 'Y') {
        if (safe_POST_bool("SOUR_{$fact}")) {
            return updateSOUR("1 {$fact} Y\n", 2);
        } else {
            return "1 {$fact} Y\n";
        }
    } else {
        return '';
    }
}
Example #2
0
// TODO decide what validation is required on these input parameters
$pid = safe_REQUEST($_REQUEST, 'pid', PGV_REGEX_XREF);
$mid = safe_REQUEST($_REQUEST, 'mid', PGV_REGEX_XREF);
$gid = safe_REQUEST($_REQUEST, 'gid', PGV_REGEX_XREF);
$linktoid = safe_REQUEST($_REQUEST, 'linktoid', PGV_REGEX_XREF);
$action = safe_REQUEST($_REQUEST, 'action', PGV_REGEX_NOSCRIPT, 'showmediaform');
$folder = safe_REQUEST($_REQUEST, 'folder', PGV_REGEX_UNSAFE);
$oldFolder = safe_REQUEST($_REQUEST, 'oldFolder', PGV_REGEX_UNSAFE);
$filename = safe_REQUEST($_REQUEST, 'filename', PGV_REGEX_UNSAFE);
$oldFilename = safe_REQUEST($_REQUEST, 'oldFilename', PGV_REGEX_UNSAFE, $filename);
$level = safe_REQUEST($_REQUEST, 'level', PGV_REGEX_UNSAFE);
$text = safe_REQUEST($_REQUEST, 'text', PGV_REGEX_UNSAFE);
$tag = safe_REQUEST($_REQUEST, 'tag', PGV_REGEX_UNSAFE);
$islink = safe_REQUEST($_REQUEST, 'islink', PGV_REGEX_UNSAFE);
$glevels = safe_REQUEST($_REQUEST, 'glevels', PGV_REGEX_UNSAFE);
$update_CHAN = !safe_POST_bool('preserve_last_changed');
$filename = decrypt($filename);
$oldFilename = decrypt($oldFilename);
print_simple_header($pgv_lang["add_media_tool"]);
$disp = true;
if (empty($pid) && !empty($mid)) {
    $pid = $mid;
}
if (!empty($pid)) {
    if (!isset($pgv_changes[$pid . "_" . $GEDCOM])) {
        $gedrec = find_media_record($pid);
    } else {
        $gedrec = find_updated_record($pid);
    }
    $disp = displayDetailsById($pid, "OBJE");
}
 //------------------------------------------------------------------------------
 case 'addopfchildaction':
     if (PGV_DEBUG) {
         phpinfo(INFO_VARIABLES);
     }
     splitSOUR();
     // separate SOUR record from the rest
     $newindixref = get_new_xref('INDI');
     $newfamxref = get_new_xref('FAM');
     $gedrec = "0 @{$newindixref}@ INDI\n1 FAMC @{$newfamxref}@\n" . addNewName() . addNewSex();
     if (preg_match_all('/([A-Z0-9_]+)/', $QUICK_REQUIRED_FACTS, $matches)) {
         foreach ($matches[1] as $match) {
             $gedrec .= addNewFact($match);
         }
     }
     if (safe_POST_bool('SOUR_INDI')) {
         $gedrec = handle_updates($gedrec);
     } else {
         $gedrec = updateRest($gedrec);
     }
     $famrec = "0 @{$newfamxref}@ FAM\n1 CHIL @{$newindixref}@";
     $person = Person::getInstance($pid);
     if ($person->getSex() == 'F') {
         $famrec .= "\n1 WIFE @{$pid}@";
     } else {
         $famrec .= "\n1 HUSB @{$pid}@";
     }
     if (!isset($pgv_changes[$pid . "_" . PGV_GEDCOM])) {
         $indirec = find_gedcom_record($pid, PGV_GED_ID);
     } else {
         $indirec = find_updated_record($pid, PGV_GED_ID);