function init() { global $PRIV_HIDE, $PRIV_PUBLIC, $ENABLE_CLIPPINGS_CART, $SCRIPT_NAME, $pgv_lang, $SERVER_URL, $CONTACT_EMAIL, $HOME_SITE_TEXT, $HOME_SITE_URL, $MEDIA_DIRECTORY; global $GEDCOM, $CHARACTER_SET, $cart; if (!isset($ENABLE_CLIPPINGS_CART)) { $ENABLE_CLIPPINGS_CART = $PRIV_HIDE; } if ($ENABLE_CLIPPINGS_CART === true) { $ENABLE_CLIPPING_CART = $PRIV_PUBLIC; } if ($ENABLE_CLIPPINGS_CART < PGV_USER_ACCESS_LEVEL) { header("Location: index.php"); exit; } if (!isset($_SESSION['exportConvPath'])) { $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY; } if (!isset($_SESSION['exportConvSlashes'])) { $_SESSION['exportConvSlashes'] = 'forward'; } $this->action = safe_GET("action"); $this->id = safe_GET('id'); $remove = safe_GET('remove', "", "no"); $convert = safe_GET('convert', "", "no"); $this->Zip = safe_GET('Zip'); $this->IncludeMedia = safe_GET('IncludeMedia'); $this->conv_path = safe_GET('conv_path', PGV_REGEX_NOSCRIPT, $_SESSION['exportConvPath']); $this->conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), $_SESSION['exportConvSlashes']); $this->privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin', 'admin')); $this->filetype = safe_GET('filetype'); $this->level1 = safe_GET('level1'); $this->level2 = safe_GET('level2'); $this->level3 = safe_GET('level3'); if (empty($this->filetype)) { $this->filetype = "gedcom"; } $others = safe_GET('others'); $item = safe_GET('item'); if (!isset($cart)) { $cart = $_SESSION['cart']; } $this->type = safe_GET('type'); $this->conv_path = stripLRMRLM($this->conv_path); $_SESSION['exportConvPath'] = $this->conv_path; // remember this for the next Download $_SESSION['exportConvSlashes'] = $this->conv_slashes; if ($this->action == 'add') { if (empty($this->type) && !empty($this->id)) { $this->type = ""; $obj = GedcomRecord::getInstance($this->id); if (is_null($obj)) { $this->id = ""; $this->action = ""; } else { $this->type = strtolower($obj->getType()); } } else { if (empty($this->id)) { $this->action = ""; } } if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') { $this->action = 'add1'; } } if ($this->action == 'add1') { $clipping = array(); $clipping['type'] = $this->type; $clipping['id'] = $this->id; $clipping['gedcom'] = $GEDCOM; $ret = $this->add_clipping($clipping); if ($ret) { if ($this->type == 'sour') { if ($others == 'linked') { foreach (fetch_linked_indi($this->id, 'SOUR', PGV_GED_ID) as $indi) { if ($indi->canDisplayName()) { $this->add_clipping(array('type' => 'indi', 'id' => $indi->getXref())); } } foreach (fetch_linked_fam($this->id, 'SOUR', PGV_GED_ID) as $fam) { if ($fam->canDisplayName()) { $this->add_clipping(array('type' => 'fam', 'id' => $fam->getXref())); } } } } if ($this->type == 'fam') { if ($others == 'parents') { $parents = find_parents($this->id); if (!empty($parents["HUSB"])) { $clipping = array(); $clipping['type'] = "indi"; $clipping['id'] = $parents["HUSB"]; $ret = $this->add_clipping($clipping); } if (!empty($parents["WIFE"])) { $clipping = array(); $clipping['type'] = "indi"; $clipping['id'] = $parents["WIFE"]; $ret = $this->add_clipping($clipping); } } else { if ($others == "members") { $this->add_family_members($this->id); } else { if ($others == "descendants") { $this->add_family_descendancy($this->id); } } } } else { if ($this->type == 'indi') { if ($others == 'parents') { $famids = find_family_ids($this->id); foreach ($famids as $indexval => $famid) { $clipping = array(); $clipping['type'] = "fam"; $clipping['id'] = $famid; $ret = $this->add_clipping($clipping); if ($ret) { $this->add_family_members($famid); } } } else { if ($others == 'ancestors') { $this->add_ancestors_to_cart($this->id, $this->level1); } else { if ($others == 'ancestorsfamilies') { $this->add_ancestors_to_cart_families($this->id, $this->level2); } else { if ($others == 'members') { $famids = find_sfamily_ids($this->id); foreach ($famids as $indexval => $famid) { $clipping = array(); $clipping['type'] = "fam"; $clipping['id'] = $famid; $ret = $this->add_clipping($clipping); if ($ret) { $this->add_family_members($famid); } } } else { if ($others == 'descendants') { $famids = find_sfamily_ids($this->id); foreach ($famids as $indexval => $famid) { $clipping = array(); $clipping['type'] = "fam"; $clipping['id'] = $famid; $ret = $this->add_clipping($clipping); if ($ret) { $this->add_family_descendancy($famid, $this->level3); } } } } } } } } } } } else { if ($this->action == 'remove') { $ct = count($cart); for ($i = $item + 1; $i < $ct; $i++) { $cart[$i - 1] = $cart[$i]; } unset($cart[$ct - 1]); } else { if ($this->action == 'empty') { $cart = array(); $_SESSION["cart"] = $cart; } else { if ($this->action == 'download') { usort($cart, "same_group"); if ($this->filetype == "gedcom") { $path = substr($SCRIPT_NAME, 0, strrpos($SCRIPT_NAME, "/")); if (empty($path)) { $path = "/"; } if ($path[strlen($path) - 1] != "/") { $path .= "/"; } if ($SERVER_URL[strlen($SERVER_URL) - 1] == "/") { $dSERVER_URL = substr($SERVER_URL, 0, strlen($SERVER_URL) - 1); } else { $dSERVER_URL = $SERVER_URL; } $media = array(); $mediacount = 0; $ct = count($cart); $filetext = "0 HEAD\n1 SOUR " . PGV_PHPGEDVIEW . "\n2 NAME " . PGV_PHPGEDVIEW . "\n2 VERS " . PGV_VERSION_TEXT . "\n1 DEST DISKETTE\n1 DATE " . date("j M Y") . "\n2 TIME " . date("H:i:s") . "\n"; $filetext .= "1 GEDC\n2 VERS 5.5\n2 FORM LINEAGE-LINKED\n1 CHAR {$CHARACTER_SET}\n"; $head = find_gedcom_record("HEAD"); $placeform = trim(get_sub_record(1, "1 PLAC", $head)); if (!empty($placeform)) { $filetext .= $placeform . "\n"; } else { $filetext .= "1 PLAC\n2 FORM " . "City, County, State/Province, Country" . "\n"; } if ($convert == "yes") { $filetext = preg_replace("/UTF-8/", "ANSI", $filetext); $filetext = utf8_decode($filetext); } $tempUserID = '#ExPoRt#'; if ($this->privatize_export != 'none') { // Create a temporary userid $export_user_id = createTempUser($tempUserID, $this->privatize_export, $GEDCOM); // Create a temporary userid // Temporarily become this user $_SESSION["org_user"] = $_SESSION["pgv_user"]; $_SESSION["pgv_user"] = $tempUserID; } for ($i = 0; $i < $ct; $i++) { $clipping = $cart[$i]; if ($clipping['gedcom'] == $GEDCOM) { $record = find_gedcom_record($clipping['id']); $savedRecord = $record; // Save this for the "does this file exist" check if ($clipping['type'] == 'obje') { $record = convert_media_path($record, $this->conv_path, $this->conv_slashes); } $record = privatize_gedcom($record); $record = remove_custom_tags($record, $remove); if ($convert == "yes") { $record = utf8_decode($record); } switch ($clipping['type']) { case 'indi': $ft = preg_match_all("/1 FAMC @(.*)@/", $record, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { if (!id_in_cart($match[$k][1])) { $record = preg_replace("/1 FAMC @" . $match[$k][1] . "@.*/", "", $record); } } $ft = preg_match_all("/1 FAMS @(.*)@/", $record, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { if (!id_in_cart($match[$k][1])) { $record = preg_replace("/1 FAMS @" . $match[$k][1] . "@.*/", "", $record); } } $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1])); if (file_exists($filename)) { $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename); $mediacount++; } // $record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record); } $filetext .= trim($record) . "\n"; $filetext .= "1 SOUR @SPGV1@\n"; $filetext .= "2 PAGE " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n"; $filetext .= "2 DATA\n"; $filetext .= "3 TEXT " . $pgv_lang["indi_downloaded_from"] . "\n"; $filetext .= "4 CONT " . $dSERVER_URL . "/individual.php?pid=" . $clipping['id'] . "\n"; break; case 'fam': $ft = preg_match_all("/1 CHIL @(.*)@/", $record, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { if (!id_in_cart($match[$k][1])) { /* if the child is not in the list delete the record of it */ $record = preg_replace("/1 CHIL @" . $match[$k][1] . "@.*/", "", $record); } } $ft = preg_match_all("/1 HUSB @(.*)@/", $record, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { if (!id_in_cart($match[$k][1])) { /* if the husband is not in the list delete the record of him */ $record = preg_replace("/1 HUSB @" . $match[$k][1] . "@.*/", "", $record); } } $ft = preg_match_all("/1 WIFE @(.*)@/", $record, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { if (!id_in_cart($match[$k][1])) { /* if the wife is not in the list delete the record of her */ $record = preg_replace("/1 WIFE @" . $match[$k][1] . "@.*/", "", $record); } } $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1])); if (file_exists($filename)) { $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename); $mediacount++; } // $record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record); } $filetext .= trim($record) . "\n"; $filetext .= "1 SOUR @SPGV1@\n"; $filetext .= "2 PAGE " . $dSERVER_URL . $path . "family.php?famid=" . $clipping['id'] . "\n"; $filetext .= "2 DATA\n"; $filetext .= "3 TEXT " . $pgv_lang["family_downloaded_from"] . "\n"; $filetext .= "4 CONT " . $dSERVER_URL . "/family.php?famid=" . $clipping['id'] . "\n"; break; case 'source': $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1])); if (file_exists($filename)) { $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename); $mediacount++; } // $record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record); } $filetext .= trim($record) . "\n"; $filetext .= "1 NOTE " . $pgv_lang["source_downloaded_from"] . "\n"; $filetext .= "2 CONT " . $dSERVER_URL . "/source.php?sid=" . $clipping['id'] . "\n"; break; default: $ft = preg_match_all("/\\d FILE (.*)/", $savedRecord, $match, PREG_SET_ORDER); for ($k = 0; $k < $ft; $k++) { $filename = $MEDIA_DIRECTORY . extract_filename(trim($match[$k][1])); if (file_exists($filename)) { $media[$mediacount] = array(PCLZIP_ATT_FILE_NAME => $filename); $mediacount++; } // $record = preg_replace("|(\d FILE )" . addslashes($match[$k][1]) . "|", "$1" . $filename, $record); } $filetext .= trim($record) . "\n"; break; } } } if ($this->privatize_export != 'none') { $_SESSION["pgv_user"] = $_SESSION["org_user"]; delete_user($export_user_id); AddToLog("deleted dummy user -> {$tempUserID} <-"); } if ($this->IncludeMedia == "yes") { $this->media_list = $media; } $filetext .= "0 @SPGV1@ SOUR\n"; if ($user_id = get_user_id($CONTACT_EMAIL)) { $filetext .= "1 AUTH " . getUserFullName($user_id) . "\n"; } $filetext .= "1 TITL " . $HOME_SITE_TEXT . "\n"; $filetext .= "1 ABBR " . $HOME_SITE_TEXT . "\n"; $filetext .= "1 PUBL " . $HOME_SITE_URL . "\n"; $filetext .= "0 TRLR\n"; //-- make sure the preferred line endings are used $filetext = preg_replace("/[\r\n]+/", PGV_EOL, $filetext); $this->download_data = $filetext; $this->download_clipping(); } else { if ($this->filetype == "gramps") { // Sort the clippings cart because the export works better when the cart is sorted usort($cart, "same_group"); require_once "includes/classes/class_geclippings.php"; $gramps_Exp = new GEClippings(); $gramps_Exp->begin_xml(); $ct = count($cart); usort($cart, "same_group"); for ($i = 0; $i < $ct; $i++) { $clipping = $cart[$i]; switch ($clipping['type']) { case 'indi': $rec = find_person_record($clipping['id']); $rec = remove_custom_tags($rec, $remove); if ($this->privatize_export != 'none') { $rec = privatize_gedcom($rec); } $gramps_Exp->create_person($rec, $clipping['id']); break; case 'fam': $rec = find_family_record($clipping['id']); $rec = remove_custom_tags($rec, $remove); if ($this->privatize_export != 'none') { $rec = privatize_gedcom($rec); } $gramps_Exp->create_family($rec, $clipping['id']); break; case 'source': $rec = find_source_record($clipping['id']); $rec = remove_custom_tags($rec, $remove); if ($this->privatize_export != 'none') { $rec = privatize_gedcom($rec); } $gramps_Exp->create_source($rec, $clipping['id']); break; } } $this->download_data = $gramps_Exp->dom->saveXML(); if ($convert) { $this->download_data = utf8_decode($this->download_data); } $this->media_list = $gramps_Exp->get_all_media(); $this->download_clipping(); } } } } } } }
} else { addDebugLog($action . " ERROR 3: No gedcom id specified. Please specify a xref."); print "ERROR 3: No gedcom id specified. Please specify a xref.\n"; } exit; case 'getprev': $xref = safe_REQUEST($_REQUEST, 'xref', PGV_REGEX_XREF); if ($xref) { $xref1 = get_prev_xref($xref, $GED_ID); $gedrec = find_updated_record($xref1); if (!$gedrec) { $gedrec = find_gedcom_record($xref1); } if (!displayDetailsById($xref1)) { //-- do not have full access to this record, so privatize it $gedrec = privatize_gedcom($gedrec); } addDebugLog($action . " xref={$xref} SUCCESS\n" . trim($gedrec)); print "SUCCESS\n" . trim($gedrec); } else { addDebugLog($action . " ERROR 3: No gedcom id specified. Please specify a xref."); print "ERROR 3: No gedcom id specified. Please specify a xref.\n"; } exit; case 'search': $query = safe_REQUEST($_REQUEST, 'query'); if ($query) { $sindilist = search_indis(array($query), array(PGV_GED_ID), 'AND', true); print "SUCCESS\n"; addDebugLog($action . " query={$query} SUCCESS"); foreach ($sindilist as $indi) {
/** * get a singleton instance of the results * returned by the soapClient search method * * @param string $query - the query to search on * @param integer $start - the start index of the results to return * @param integer $max - the maximum number of results to return */ function &search($query, $start = 0, $max = 100) { //$this->authenticate(); //$result = $this->soapClient->search($this->SID, $query, $start, $max); $search_results = search_indis(array($query), array($this->gedfile), 'AND', true); // loop thru the returned result of the method call foreach ($search_results as $gid => $indi) { // privatize the gedcoms returned $gedrec = privatize_gedcom($indi["gedcom"]); //AddToLog(substr($gedrec,0,50)); // set the fields that exist and return all the results that are not private if (preg_match("~" . $query . "~i", $gedrec) > 0) { $person = new SOAP_Value('person', 'person', ""); $person->PID = $gid; $person->gedcomName = get_gedcom_value("NAME", 1, $gedrec, '', false); $person->birthDate = get_gedcom_value("BIRT:DATE", 1, $gedrec, '', false); $person->birthPlace = get_gedcom_value("BIRT:PLAC", 1, $gedrec, '', false); $person->deathDate = get_gedcom_value("DEAT:DATE", 1, $gedrec, '', false); $person->deathPlace = get_gedcom_value("DEAT:PLAC", 1, $gedrec, '', false); $person->gender = get_gedcom_value("SEX", 1, $gedrec, '', false); //$search_result_element['gedcom'] = $gedrec; $results_array[] = $person; } } // AddToLog('Found '.count($results_array).' after privatizing'); // set the number of possible results //$results[0]['totalResults'] = count($results_array); $results_array = array_slice($results_array, $start, $max); //$results[0]['persons'] = $results_array; $return = new SOAP_Value('searchResult', 'searchResult', ""); $return->totalResults = count($results_array); $return->persons = $results_array; return $return; }
<head> <meta http-equiv="Content-Type" content="text/html; charset=<?php print $CHARACTER_SET; ?> " /> <title><?php print "{$pid} Record"; ?> </title> </head> <body><?php if (!$SHOW_GEDCOM_RECORD && !PGV_USER_CAN_ACCEPT) { print "<span class=\"error\">" . $pgv_lang["ged_noshow"] . "</span>\n"; print "</body></html>"; exit; } $obj = GedcomRecord::getInstance($pid); if (is_null($obj) || !$obj->canDisplayDetails()) { print_privacy_error($CONTACT_EMAIL); print "</body></html>"; exit; } if (!isset($fromfile)) { $indirec = $obj->getGedcomRecord(); } else { $indirec = find_updated_record($pid); $indirec = privatize_gedcom($indirec); } $indirec = preg_replace("/@(\\w+)@/", "@<a href=\"gedrecord.php?pid=\$1\">\$1</a>@", $indirec); print "<pre>{$indirec}</pre>"; print "</body></html>";
function GedcomRecord($data, $simple = false) { if (is_array($data)) { // Construct from a row from the database $this->xref = $data['xref']; $this->type = $data['type']; $this->ged_id = $data['ged_id']; $this->gedrec = $data['gedrec']; } else { // Construct from raw GEDCOM data $this->gedrec = $data; if (preg_match('/^0 (?:@(' . PGV_REGEX_XREF . ')@ )?(' . PGV_REGEX_TAG . ')/', $data, $match)) { $this->xref = $match[1]; $this->type = $match[2]; } } //-- lookup the record from another gedcom $remoterfn = get_gedcom_value('RFN', 1, $this->gedrec); if (!empty($remoterfn)) { $parts = explode(':', $remoterfn); if (count($parts) == 2) { $servid = $parts[0]; $aliaid = $parts[1]; if (!empty($servid) && !empty($aliaid)) { $serviceClient = ServiceClient::getInstance($servid); if (!is_null($serviceClient)) { if (!$simple || $serviceClient->type == 'local') { $this->gedrec = $serviceClient->mergeGedcomRecord($aliaid, $this->gedrec, true); } } } } } //-- set the gedcom record a privatized version $this->gedrec = privatize_gedcom($this->gedrec); if ($this->xref && $this->type) { $this->disp = displayDetailsById($this->xref, $this->type); } }