switch ($type) { case "INDI": $statement = PGV_DB::prepare("SELECT i_id FROM {$TBLPREFIX}individuals WHERE i_file=? ORDER BY i_id")->execute(array($GED_ID)); break; case "FAM": $statement = PGV_DB::prepare("SELECT f_id FROM {$TBLPREFIX}families WHERE f_file=? ORDER BY f_id")->execute(array($GED_ID)); break; case "SOUR": $statement = PGV_DB::prepare("SELECT s_id FROM {$TBLPREFIX}sources WHERE s_file=? ORDER BY s_id")->execute(array($GED_ID)); case "OBJE": $statement = PGV_DB::prepare("SELECT m_media FROM {$TBLPREFIX}media WHERE m_gedfile=? ORDER BY m_media")->execute(array($GED_ID)); case "OTHER": $statement = PGV_DB::prepare("SELECT o_id FROM {$TBLPREFIX}other WHERE o_file=? AND o_type NOT IN ('REPO', 'NOTE') ORDER BY o_id")->execute(array($GED_ID)); break; default: $statement = PGV_DB::prepare("SELECT o_id FROM {$TBLPREFIX}other WHERE o_file=? AND o_type=? ORDER BY o_id")->execute(array($GED_ID, $type)); } print "SUCCESS\n"; foreach ($statement->fetchOneColumn() as $id) { print "{$id}\n"; } addDebugLog($action . " type={$type} position={$position} "); break; case 'new': if (empty($_SESSION['readonly']) && PGV_USER_CAN_EDIT) { $gedrec = "0 @REF@ {$type}"; $xref = append_gedrec($gedrec); if ($xref) { addDebugLog($action . " type={$type} position={$position} SUCCESS\n{$xref}"); print "SUCCESS\n{$xref}\n"; }
function top10_pageviews($block = true, $config = "", $side, $index) { global $TBLPREFIX, $pgv_lang, $INDEX_DIRECTORY, $PGV_BLOCKS, $ctype, $PGV_IMAGES, $PGV_IMAGE_DIR, $SHOW_COUNTER, $SHOW_SOURCES, $TEXT_DIRECTION; if (empty($config)) { $config = $PGV_BLOCKS["top10_pageviews"]["config"]; } if (isset($config["count_placement"])) { $CountSide = $config["count_placement"]; } else { $CountSide = "left"; } $id = "top10hits"; $title = print_help_link("index_top10_pageviews_help", "qm", "", false, true); if ($PGV_BLOCKS["top10_pageviews"]["canconfig"]) { if ($ctype == "gedcom" && PGV_USER_GEDCOM_ADMIN || $ctype == "user" && PGV_USER_ID) { if ($ctype == "gedcom") { $name = PGV_GEDCOM; } else { $name = PGV_USER_NAME; } $title .= "<a href=\"javascript: configure block\" onclick=\"window.open('" . encode_url("index_edit.php?name={$name}&ctype={$ctype}&action=configure&side={$side}&index={$index}") . "', '_blank', 'top=50,left=50,width=600,height=350,scrollbars=1,resizable=1'); return false;\">"; $title .= "<img class=\"adminicon\" src=\"{$PGV_IMAGE_DIR}/" . $PGV_IMAGES["admin"]["small"] . "\" width=\"15\" height=\"15\" border=\"0\" alt=\"" . $pgv_lang["config_block"] . "\" /></a>"; } } $title .= $pgv_lang["top10_pageviews"]; $content = ""; // if the counter file does not exist then don't do anything if (!$SHOW_COUNTER) { if (PGV_USER_IS_ADMIN) { $content .= "<span class=\"error\">" . $pgv_lang["top10_pageviews_msg"] . "</span>"; } } else { // load the lines from the file $top10 = PGV_DB::prepareLimit("SELECT page_parameter, page_count" . " FROM {$TBLPREFIX}hit_counter" . " WHERE gedcom_id=? AND page_name IN ('individual.php','family.php','source.php','repo.php','note.php','mediaviewer.php')" . " ORDER BY page_count DESC", $config['num'])->execute(array(PGV_GED_ID))->FetchAssoc(); if ($top10) { if ($block) { $content .= "<table width=\"90%\">"; } else { $content .= "<table>"; } foreach ($top10 as $id => $count) { $record = GedcomRecord::getInstance($id); if ($record && $record->canDisplayDetails()) { $content .= '<tr valign="top">'; if ($CountSide == 'left') { $content .= '<td dir="ltr" align="right">[' . $count . ']</td>'; } $content .= '<td class="name2" ><a href="' . encode_url($record->getLinkUrl()) . '">' . PrintReady($record->getFullName()) . '</a></td>'; if ($CountSide == 'right') { $content .= '<td dir="ltr" align="right">[' . $count . ']</td>'; } $content .= '</tr>'; } } $content .= "</table>"; } else { $content .= "<b>" . $pgv_lang["top10_pageviews_nohits"] . "</b>"; } } global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
function indis_array($surn, $soundex_std, $soundex_dm) { global $TBLPREFIX; $sql = "SELECT DISTINCT n_id" . " FROM {$TBLPREFIX}name" . " WHERE n_file=?" . " AND n_type!=?" . " AND (n_surn=? OR n_surname=?"; $args = array(PGV_GED_ID, '_MARNM', $surn, $surn); if ($soundex_std) { $sql .= " OR n_soundex_surn_std=?"; $args[] = soundex_std($surn); } if ($soundex_dm) { $sql .= " OR n_soundex_surn_dm=?"; $args[] = soundex_dm($surn); } $sql .= ") ORDER BY n_sort"; $rows = PGV_DB::prepare($sql)->execute($args)->fetchAll(); // var_dump($sql); var_dump($rows); $data = array(); foreach ($rows as $row) { $data[$row->n_id] = Person::getInstance($row->n_id); } return $data; }
/** * Gets the news item for the given news id * * @param int $news_id the id of the news entry to get */ function getNewsItem($news_id) { global $TBLPREFIX; $row = PGV_DB::prepare("SELECT * FROM {$TBLPREFIX}news WHERE n_id=?")->execute(array($news_id))->fetchOneRow(); if ($row) { return array("id" => $row->n_id, "username" => $row->n_username, "date" => $row->n_date, "title" => $row->n_title, "text" => $row->n_text, "anchor" => "article" . $row->n_id); } else { return null; } }
$record = find_updated_record($id, PGV_GED_ID); } else { $record = fetch_gedcom_record($id, PGV_GED_ID); $record = $record['gedrec']; echo $pgv_lang["updating_linked"], " {$id}<br />\n"; $newrec = str_replace("@{$gid2}@", "@{$gid1}@", $record); $newrec = preg_replace('/(\\n1.*@.+@.*(?:(?:\\n[2-9].*)*))((?:\\n1.*(?:\\n[2-9].*)*)*\\1)/', '$2', $newrec); replace_gedrec($id, $newrec); } } // Merge hit counters $hits = PGV_DB::prepare("SELECT page_name, SUM(page_count)" . " FROM {$TBLPREFIX}hit_counter" . " WHERE gedcom_id=? AND page_parameter IN (?, ?)" . " GROUP BY page_name")->execute(array(PGV_GED_ID, $gid1, $gid2))->fetchAssoc(); foreach ($hits as $page_name => $page_count) { PGV_DB::prepare("UPDATE {$TBLPREFIX}hit_counter SET page_count=?" . " WHERE gedcom_id=? AND page_name=? AND page_parameter=?")->execute(array($page_count, PGV_GED_ID, $page_name, $gid1)); } PGV_DB::prepare("DELETE FROM {$TBLPREFIX}hit_counter" . " WHERE gedcom_id=? AND page_parameter=?")->execute(array(PGV_GED_ID, $gid2)); } $newgedrec = "0 @{$gid1}@ {$type1}\n"; for ($i = 0; $i < count($facts1) || $i < count($facts2); $i++) { if (isset($facts1[$i])) { if (in_array($i, $keep1)) { $newgedrec .= $facts1[$i]["subrec"] . "\n"; echo $pgv_lang["adding"], " ", $facts1[$i]["fact"], " ", $pgv_lang["from"], " ", $gid1, "<br />\n"; } } if (isset($facts2[$i])) { if (in_array($i, $keep2)) { $newgedrec .= $facts2[$i]["subrec"] . "\n"; echo $pgv_lang["adding"], " ", $facts2[$i]["fact"], " ", $pgv_lang["from"], " ", $gid2, "<br />\n"; } }
function advancedSearch($justSql = false, $table = "individuals", $prefix = "i") { global $TBLPREFIX, $gedcom_record_cache; DMsoundex("", "opencache"); $this->myindilist = array(); $fct = count($this->fields); if ($fct == 0) { return; } $namesTable = false; $datesTable = false; $placesTable = false; $famsTable = false; $famcTable = false; $sql = ''; if ($justSql) { $sqlfields = "SELECT DISTINCT {$prefix}_id, {$prefix}_file"; } else { $sqlfields = "SELECT i_id, i_gedcom, i_isdead, i_file, i_sex"; } $sqltables = " FROM " . $TBLPREFIX . $table; $sqlwhere = " WHERE " . $prefix . "_file=" . PGV_GED_ID; $keepfields = $this->fields; for ($i = 0; $i < $fct; $i++) { $field = $this->fields[$i]; if (empty($field)) { continue; } $value = ''; if (isset($this->values[$i])) { $value = $this->values[$i]; } if (empty($value)) { continue; } $parts = preg_split("/:/", $field); //-- handle names seperately if ($parts[0] == "NAME") { // The pgv_name table contains both names and soundex values if (!$namesTable) { $sqltables .= " JOIN {$TBLPREFIX}name ON (i_file=n_file AND i_id=n_id) "; $namesTable = true; } switch (end($parts)) { case 'SDX_STD': $sdx = explode(':', soundex_std($value)); foreach ($sdx as $k => $v) { if ($parts[1] == 'GIVN') { $sdx[$k] = 'n_soundex_givn_std ' . PGV_DB::$LIKE . " '%{$v}%'"; } else { $sdx[$k] = 'n_soundex_surn_std ' . PGV_DB::$LIKE . " '%{$v}%'"; } } $sqlwhere .= ' AND (' . implode(' OR ', $sdx) . ')'; break; case 'SDX': // SDX uses DM by default. // SDX uses DM by default. case 'SDX_DM': $sdx = explode(':', soundex_dm($value)); foreach ($sdx as $k => $v) { if ($parts[1] == 'GIVN') { $sdx[$k] = 'n_soundex_givn_dm ' . PGV_DB::$LIKE . " '%{$v}%'"; } else { $sdx[$k] = 'n_soundex_surn_dm ' . PGV_DB::$LIKE . " '%{$v}%'"; } } $sqlwhere .= ' AND (' . implode(' OR ', $sdx) . ')'; break; case 'EXACT': // Exact match. switch ($parts[1]) { case 'GIVN': // Allow for exact match on multiple given names. $sqlwhere .= ' AND (n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value) . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value} %") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value}") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value} %") . ")"; break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote($value); break; } break; case 'BEGINS': // "Begins with" match. switch ($parts[1]) { case 'GIVN': // Allow for match on start of multiple given names $sqlwhere .= ' AND (n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%") . " OR n_givn " . PGV_DB::$LIKE . " " . PGV_DB::quote("% {$value}%") . ")"; break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%"); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote("{$value}%"); break; } break; case 'CONTAINS': default: // Partial match. switch ($parts[1]) { case 'GIVN': $sqlwhere .= ' AND n_givn ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; case 'SURN': $sqlwhere .= ' AND n_surname ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; default: $sqlwhere .= ' AND n_full ' . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$value}%"); break; } break; } } else { if (isset($parts[1]) && $parts[1] == "DATE") { if (!$datesTable) { $sqltables .= ", " . $TBLPREFIX . "dates"; $sqlwhere .= " AND " . $prefix . "_file=d_file AND " . $prefix . "_id=d_gid"; $datesTable = true; } $sqlwhere .= " AND (d_fact='" . $parts[0] . "'"; $date = new GedcomDate($value); if ($date->isOK()) { $jd1 = $date->date1->minJD; if ($date->date2) { $jd2 = $date->date2->maxJD; } else { $jd2 = $date->date1->maxJD; } if (!empty($this->plusminus[$i])) { $adjd = $this->plusminus[$i] * 365; //print $jd1.":".$jd2.":".$adjd; $jd1 = $jd1 - $adjd; $jd2 = $jd2 + $adjd; } $sqlwhere .= " AND d_julianday1>=" . $jd1 . " AND d_julianday2<=" . $jd2; } $sqlwhere .= ") "; } else { if (isset($parts[1]) && $parts[1] == "PLAC") { if (!$placesTable) { $sqltables .= ", " . $TBLPREFIX . "places, " . $TBLPREFIX . "placelinks"; $sqlwhere .= " AND " . $prefix . "_file=p_file AND p_file=pl_file AND " . $prefix . "_id=pl_gid AND pl_p_id=p_id"; $placesTable = true; } //-- soundex search //if (end($parts)=="SDX") { $places = preg_split("/[, ]+/", $value); $parr = array(); for ($j = 0; $j < count($places); $j++) { $parr[$j] = DMsoundex($places[$j]); } $sqlwhere .= " AND ("; $fnc = 0; $field = "p_dm_soundex"; foreach ($parr as $name) { foreach ($name as $name1) { if ($fnc > 0) { $sqlwhere .= " OR "; } $fnc++; $sqlwhere .= $field . " " . PGV_DB::$LIKE . " " . PGV_DB::quote("%{$name1}%"); } } $sqlwhere .= ") "; //} } else { if ($parts[0] == 'FAMS') { if (!$famsTable) { $sqltables .= ", " . $TBLPREFIX . "families as FAMS"; $sqlwhere .= " AND i_file=FAMS.f_file"; $famsTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $sqlwhere .= " AND (FAMS.f_husb=i_id OR FAMS.f_wife=i_id)"; $subsql = $this->advancedSearch(true, "families", "f"); $sqlwhere .= " AND ROW(FAMS.f_id, FAMS.f_file) IN (" . $subsql . ")"; $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { if ($parts[0] == 'FAMC') { if (!$famcTable) { $sqltables .= ", " . $TBLPREFIX . "families as FAMC"; $sqlwhere .= " AND i_file=FAMC.f_file"; $famcTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $sqlwhere .= " AND (FAMC.f_chil " . PGV_DB::$LIKE . " CONCAT('%',i_id,';%'))"; $subsql = $this->advancedSearch(true, "families", "f"); $sqlwhere .= " AND ROW(FAMC.f_id, FAMC.f_file) IN (" . $subsql . ")"; $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { if ($parts[0] == 'HUSB' || $parts[0] == 'WIFE') { if (!$famsTable) { $sqltables .= ", " . $TBLPREFIX . "individuals"; $sqlwhere .= " AND i_file=f_file"; $famsTable = true; } //-- alter the fields and recurse to generate a subquery for spouse/parent fields $oldfields = $this->fields; for ($j = 0; $j < $fct; $j++) { //-- if it doesn't start with FAMS or FAMC then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) == 0) { $this->fields[$j] = ''; } else { $this->fields[$j] = preg_replace("/^" . $parts[0] . ":/", "", $this->fields[$j]); } } $subsql = $this->advancedSearch(true, "individuals", "i"); if ($parts[0] == 'HUSB') { $sqlwhere .= " AND ROW(f_husb, f_file) IN (" . $subsql . ")"; } if ($parts[0] == 'WIFE') { $sqlwhere .= " AND ROW(f_wife, f_file) IN (" . $subsql . ")"; } $this->fields = $oldfields; //-- remove all of the fam fields so they don't show up again for ($j = 0; $j < $fct; $j++) { //-- if it does start with HUSB or WIFE then remove that field if (preg_match("/^" . $parts[0] . ":/", $this->fields[$j]) > 0) { $this->fields[$j] = ''; } } } else { $sqlwhere .= " AND i_gedcom " . PGV_DB::$LIKE . " "; $ct = count($parts); $liketmp = ''; for ($j = 0; $j < $ct; $j++) { $liketmp .= "%" . ($j + 1) . " " . $parts[$j] . " %"; // if ($j<$ct-1) { // $sqlwhere .= "%"; // } else { $liketmp .= "%{$value}%"; // } } $sqlwhere .= PGV_DB::quote($liketmp); } } } } } } } $sql = $sqlfields . $sqltables . $sqlwhere; // print $sql; if ($justSql) { return $sql; } $rows = PGV_DB::prepare($sql)->fetchAll(PDO::FETCH_ASSOC); foreach ($rows as $row) { $row['xref'] = $row['i_id']; $row['ged_id'] = $row['i_file']; $row['type'] = 'INDI'; $row['gedrec'] = $row['i_gedcom']; $object = Person::getInstance($row); $this->myindilist[$row['i_id']] = $object; } $this->fields = $keepfields; }
if (isset($faqs[$id - 1])) { PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id, $faqs[$id - 1]["header"]["pid"], 'header')); PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id, $faqs[$id - 1]["body"]["pid"], 'body')); } PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id - 1, $pidh, 'header')); PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id - 1, $pidb, 'body')); AddToChangeLog("FAQ item has been moved up.<br />Header ID: " . $pidh . ".<br />Body ID: " . $pidb, $oldGEDCOM); break; case 'movedown': $faqs = get_faq_data(); if (isset($faqs[$id + 1])) { PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id, $faqs[$id + 1]["header"]["pid"], 'header')); PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id, $faqs[$id + 1]["body"]["pid"], 'body')); } PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id + 1, $pidh, 'header')); PGV_DB::prepare("UPDATE {$TBLPREFIX}blocks SET b_order=? WHERE b_id=? and b_location=?")->execute(array($id + 1, $pidb, 'body')); AddToChangeLog("FAQ item has been moved down.<br />Header ID: " . $pidh . ".<br />Body ID: " . $pidb, $GEDCOM); break; } $action = "show"; } if ($action == "add") { $i = 1; echo '<form name="addfaq" method="post" action="faq.php">'; echo '<input type="hidden" name="action" value="commit" />'; echo '<input type="hidden" name="type" value="add" />'; echo '<input type="hidden" name="oldGEDCOM" value="" />'; echo '<input type="hidden" name="oldOrder" value="" />'; echo '<table class="center list_table ', $TEXT_DIRECTION, '">'; echo '<tr><td class="topbottombar" colspan="2">'; print_help_link("add_faq_item_help", "qm", "add_faq_item");