if ($pid && $linktoid != "") { $link = linkMedia($pid, $linktoid, $level); if ($link) { AddToChangeLog("Media ID " . $pid . " successfully added to {$linktoid}."); } } } if ($finalResult) { print $pgv_lang["update_successful"]; } } // **** end action "update" // **** begin action "delete" if ($action == "delete") { if (delete_gedrec($pid)) { AddToChangeLog("Media ID " . $pid . " successfully deleted."); print $pgv_lang["update_successful"]; } } // **** end action "delete" // **** begin action "showmediaform" if ($action == "showmediaform") { if (!isset($pid)) { $pid = ""; } if (empty($level)) { $level = 1; } if (!isset($linktoid)) { $linktoid = ""; }
/** * Add Debug Log * * This function adds debugging information to the log file * only if debugging output is enabled in session.php * @param string $logstr the string to add to the log */ function addDebugLog($logstr) { if (PGV_DEBUG) { AddToChangeLog($logstr); } }
/** * check file in * @param string $logline Log message * @param string $filename Filename * @param string $dirname Directory * @param boolean $bInsert Insert Log message * @return boolean whether the file was checked in */ function check_in($logline, $filename, $dirname, $bInsert = false) { global $COMMIT_COMMAND; $bRetSts = false; if (!empty($COMMIT_COMMAND) && ($COMMIT_COMMAND == 'svn' || $COMMIT_COMMAND == 'cvs') && $logline && $filename) { $cwd = getcwd(); if ($dirname) { chdir($dirname); } $cmdline = $COMMIT_COMMAND . ' commit -m ' . escapeshellarg($logline) . ' ' . escapeshellarg($filename); $output = ''; $retval = ''; exec($cmdline, $output, $retval); if (!empty($output)) { if ($bInsert) { AddToChangeLog($logline); } $outputstring = implode(' ', $output); AddToChangeLog('System Output :' . $outputstring . ', Return Value :' . $retval); $bRetSts = true; } if ($dirname) { chdir($cwd); } } return $bRetSts; }
} } $childrec .= "1 FAMC @{$famid}@\n"; $cxref = append_gedrec($childrec); $famrec .= "\n1 CHIL @{$cxref}@"; $famupdate = true; } if ($famupdate && $oldfamrec != $famrec) { $famrec = preg_replace("/0 @(.*)@/", "0 @" . $famid . "@", $famrec); replace_gedrec($famid, $famrec, $update_CHAN); } $i++; } if ($updated && empty($error)) { echo $pgv_lang["update_successful"], "<br />"; AddToChangeLog("Quick update for {$pid} by >" . PGV_USER_NAME . "<"); //echo "<pre>$gedrec</pre>"; if ($oldgedrec != $gedrec) { replace_gedrec($pid, $gedrec, $update_CHAN); } } if (!empty($error)) { echo "<span class=\"error\">", $error, "</span>"; } if ($closewin) { // autoclose window when update successful if ($EDIT_AUTOCLOSE && !PGV_DEBUG) { echo "\n<script type=\"text/javascript\">\n<!--\nif (window.opener.showchanges) window.opener.showchanges(); window.close();\n//-->\n</script>"; } echo "<center><br /><br /><br />"; echo "<a href=\"#\" onclick=\"if (window.opener.showchanges) window.opener.showchanges(); window.close();\">", $pgv_lang["close_window"], "</a><br /></center>\n";
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"); echo $pgv_lang["add_faq_item"], '</td></tr>';
function write_file() { global $fcontents, $GEDCOMS, $GEDCOM, $INDEX_DIRECTORY; if (empty($fcontents)) { return; } if (preg_match("/0 TRLR/", $fcontents) == 0) { $fcontents .= "0 TRLR\n"; } //-- write the gedcom file if (!is_writable($GEDCOMS[$GEDCOM]["path"])) { print "ERROR 5: GEDCOM file is not writable. Unable to complete request.\n"; AddToChangeLog("ERROR 5: GEDCOM file is not writable. Unable to complete request. ->" . PGV_USER_NAME . "<-"); return false; } //-- only allow one thread to write the file at a time // $mutex = new Mutex($GEDCOM); // $mutex->Wait(); //-- what to do if file changed while waiting $fp = fopen($GEDCOMS[$GEDCOM]["path"], "wb"); if ($fp === false) { print "ERROR 6: Unable to open GEDCOM file resource. Unable to complete request.\n"; AddToChangeLog("ERROR 6: Unable to open GEDCOM file resource. Unable to complete request. ->" . PGV_USER_NAME . "<-"); return false; } $fl = @flock($fp, LOCK_EX); if (!$fl) { AddToChangeLog("ERROR 7: Unable to obtain file lock. ->" . PGV_USER_NAME . "<-"); } $fw = fwrite($fp, $fcontents); if ($fw === false) { print "ERROR 7: Unable to write to GEDCOM file.\n"; AddToChangeLog("ERROR 7: Unable to write to GEDCOM file. ->" . PGV_USER_NAME . "<-"); $fl = @flock($fp, LOCK_UN); fclose($fp); return false; } $fl = @flock($fp, LOCK_UN); fclose($fp); //-- always release the mutex // $mutex->Release(); $logline = AddToLog($GEDCOMS[$GEDCOM]["path"] . " updated"); check_in($logline, basename($GEDCOMS[$GEDCOM]["path"]), dirname($GEDCOMS[$GEDCOM]["path"])); return true; }