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(); } } } } } } }
function check_gedcom($gedrec, $chan = true) { global $pgv_lang; $gedrec = trim(stripslashes(stripLRMRLM($gedrec))); $ct = preg_match("/0 @(.*)@ (.*)/", $gedrec, $match); if ($ct == 0) { echo "ERROR 20: Invalid GEDCOM 5.5 format.\n"; AddToChangeLog("ERROR 20: Invalid GEDCOM 5.5 format.->" . PGV_USER_NAME . "<-"); if (PGV_DEBUG) { echo "<pre>{$gedrec}</pre>\n"; echo debug_print_backtrace(); } return false; } $gedrec = trim($gedrec); if ($chan) { $pos1 = strpos($gedrec, "1 CHAN"); if ($pos1 !== false) { $pos2 = strpos($gedrec, "\n1", $pos1 + 4); if ($pos2 === false) { $pos2 = strlen($gedrec); } $newgedrec = substr($gedrec, 0, $pos1); $newgedrec .= "1 CHAN\n2 DATE " . strtoupper(date("d M Y")) . "\n"; $newgedrec .= "3 TIME " . date("H:i:s") . "\n"; $newgedrec .= "2 _PGVU " . PGV_USER_NAME . "\n"; $newgedrec .= substr($gedrec, $pos2); $gedrec = $newgedrec; } else { $newgedrec = "\n1 CHAN\n2 DATE " . strtoupper(date("d M Y")) . "\n"; $newgedrec .= "3 TIME " . date("H:i:s") . "\n"; $newgedrec .= "2 _PGVU " . PGV_USER_NAME; $gedrec .= $newgedrec; } } $gedrec = preg_replace('/\\\\+/', "\\", $gedrec); //-- remove any empty lines $lines = explode("\n", $gedrec); $newrec = ""; foreach ($lines as $ind => $line) { //-- remove any whitespace $line = trim($line); if (!empty($line)) { $newrec .= $line . "\n"; } } $newrec = html_entity_decode($newrec, ENT_COMPAT, 'UTF-8'); return $newrec; }
$gedcom_privacy = "\${INDEX_DIRECTORY}" . $FILE . "_priv.php"; } $gedarray = array(); $gedarray["gedcom"] = $FILE; $gedarray["config"] = $gedcom_config; $gedarray["privacy"] = $gedcom_privacy; if (!empty($gedcom_title)) { $gedarray["title"] = $gedcom_title; } else { if (!empty($_POST["gedcom_title"])) { $gedarray["title"] = $_POST["gedcom_title"]; } else { $gedarray["title"] = str_replace("#GEDCOMFILE#", $GEDFILENAME, $pgv_lang["new_gedcom_title"]); } } $gedarray["title"] = stripLRMRLM($gedarray["title"]); $gedarray["path"] = $path . $GEDFILENAME; $gedarray["id"] = $gedcom_id; $gedarray["pgv_ver"] = $pgv_ver; // Check that add/remove common surnames are separated by [,;] blank $_POST["NEW_COMMON_NAMES_REMOVE"] = preg_replace("/[,;]\\b/", ", ", $_POST["NEW_COMMON_NAMES_REMOVE"]); $_POST["NEW_COMMON_NAMES_ADD"] = preg_replace("/[,;]\\b/", ", ", $_POST["NEW_COMMON_NAMES_ADD"]); $COMMON_NAMES_THRESHOLD = $_POST["NEW_COMMON_NAMES_THRESHOLD"]; $COMMON_NAMES_ADD = $_POST["NEW_COMMON_NAMES_ADD"]; $COMMON_NAMES_REMOVE = $_POST["NEW_COMMON_NAMES_REMOVE"]; $gedarray["commonsurnames"] = ""; $GEDCOMS[$FILE] = $gedarray; store_gedcoms(); require $INDEX_DIRECTORY . "gedcoms.php"; $boolarray = array(); $boolarray["yes"] = "true";
/** * create CONT lines * * Break input GEDCOM subrecord into pieces not more than 255 chars long, * with CONC and CONT lines as needed. Routine also pays attention to the * word wrapped Notes option. Routine also avoids splitting UTF-8 encoded * characters between lines. * * @param string $newline Input GEDCOM subrecord to be worked on * @return string $newged Output string with all necessary CONC and CONT lines */ function breakConts($newline) { global $WORD_WRAPPED_NOTES; // Determine level number of CONC and CONT lines $level = substr($newline, 0, 1); $tag = substr($newline, 1, 6); if ($tag != " CONC " && $tag != " CONT ") { $level++; } $newged = ""; $newlines = preg_split("/\r?\n/", rtrim(stripLRMRLM($newline))); for ($k = 0; $k < count($newlines); $k++) { if ($k > 0) { $newlines[$k] = "{$level} CONT " . $newlines[$k]; } if (strlen($newlines[$k]) > 255) { if ($WORD_WRAPPED_NOTES) { while (strlen($newlines[$k]) > 255) { // Make sure this piece ends on a blank, because one blank will be // added automatically when everything is put back together $lastBlank = strrpos(substr($newlines[$k], 0, 255), " "); $thisPiece = rtrim(substr($newlines[$k], 0, $lastBlank + 1)); $newged .= $thisPiece . "\n"; $newlines[$k] = substr($newlines[$k], strlen($thisPiece) + 1); $newlines[$k] = "{$level} CONC " . $newlines[$k]; } } else { while (strlen($newlines[$k]) > 255) { // Make sure this piece doesn't end on a blank // (Blanks belong at the start of the next piece) $thisPiece = rtrim(substr($newlines[$k], 0, 255)); // Make sure this piece doesn't end in the middle of a UTF-8 character $nextPieceFirstChar = substr($newlines[$k], strlen($thisPiece), 1); if (($nextPieceFirstChar & "À") == "€") { // Include all of the UTF-8 character in next piece while (true) { // Find the start of the UTF-8 encoded character $nextPieceFirstChar = substr($thisPiece, -1); $thisPiece = substr($thisPiece, 0, -1); if (($nextPieceFirstChar & "À") != "€") { break; } } // Make sure we didn't back up to a blank $thisPiece = rtrim($thisPiece); } $newged .= $thisPiece . "\n"; $newlines[$k] = substr($newlines[$k], strlen($thisPiece)); $newlines[$k] = "{$level} CONC " . $newlines[$k]; } } $newged .= trim($newlines[$k]) . "\n"; } else { $newged .= trim($newlines[$k]) . "\n"; } } return $newged; }
<input type="hidden" name="F<?php echo $i; ?> CDEL" value="" /></td> </tr> <?php foreach ($chil as $c => $child) { $person = Person::getInstance($child); echo "<tr><td class=\"optionbox\">"; $name = $person->getFullName(); if ($SHOW_ID_NUMBERS) { $name .= " (" . $child . ")"; } $name .= " [" . $pgv_lang["edit"] . "]"; echo "<a href=\"#\" onclick=\"return quickEdit('", $child, "', '', '", PGV_GEDCOM, "');\">"; echo PrintReady(stripLRMRLM($name)); echo "</a>"; echo "</td>\n<td class=\"optionbox center\">"; $sex = $person->getSex(); if ($sex == 'M') { echo Person::sexImage('M', 'small'), $pgv_lang['male']; } elseif ($sex == 'F') { echo Person::sexImage('F', 'small'), $pgv_lang['female']; } else { echo Person::sexImage('U', 'small'), $pgv_lang['unknown']; } echo "</td>\n<td class=\"optionbox\">"; echo $person->format_first_major_fact(PGV_EVENTS_BIRT, 2); echo "</td>\n"; ?> <td class="optionbox center">
if (!isset($_SESSION['exportConvPath'])) { $_SESSION['exportConvPath'] = $MEDIA_DIRECTORY; } if (!isset($_SESSION['exportConvSlashes'])) { $_SESSION['exportConvSlashes'] = 'forward'; } $ged = safe_GET('ged', get_all_gedcoms()); $action = safe_GET('action', 'download'); $remove = safe_GET('remove', 'yes', 'no'); $convert = safe_GET('convert', 'yes', 'no'); $zip = safe_GET('zip', 'yes', 'no'); $conv_path = safe_GET('conv_path', PGV_REGEX_NOSCRIPT, $_SESSION['exportConvPath']); $conv_slashes = safe_GET('conv_slashes', array('forward', 'backward'), $_SESSION['exportConvSlashes']); $privatize_export = safe_GET('privatize_export', array('none', 'visitor', 'user', 'gedadmin', 'admin')); $filetype = safe_GET('filetype', array('gedcom', 'gramps')); $conv_path = stripLRMRLM($conv_path); $_SESSION['exportConvPath'] = $conv_path; // remember this for the next Download $_SESSION['exportConvSlashes'] = $conv_slashes; if (!PGV_USER_GEDCOM_ADMIN || !$ged) { header("Location: editgedcoms.php"); exit; } if ($action == 'download') { $conv_path = rtrim(str_replace('\\', '/', trim($conv_path)), '/') . '/'; // make sure we have a trailing slash here if ($conv_path == '/') { $conv_path = ''; } $exportOptions = array(); $exportOptions['privatize'] = $privatize_export;
function print_user_messages($block = true, $config = "", $side, $index) { global $pgv_lang, $PGV_IMAGE_DIR, $TEXT_DIRECTION, $PGV_STORE_MESSAGES, $PGV_IMAGES; $usermessages = getUserMessages(PGV_USER_NAME); $id = "user_messages"; $title = print_help_link("mygedview_message_help", "qm", "", false, true); $title .= $pgv_lang["my_messages"] . " "; if ($TEXT_DIRECTION == "rtl") { $title .= getRLM(); } $title .= "(" . count($usermessages) . ")"; if ($TEXT_DIRECTION == "rtl") { $title .= getRLM(); } $content = ""; $content .= "<form name=\"messageform\" action=\"\" onsubmit=\"return confirm('" . $pgv_lang["confirm_message_delete"] . "');\">"; if (count($usermessages) == 0) { $content .= $pgv_lang["no_messages"] . "<br />"; } else { $content .= ' <script language="JavaScript" type="text/javascript"> <!-- function select_all() { '; foreach ($usermessages as $key => $message) { if (isset($message["id"])) { $key = $message["id"]; } $content .= ' var cb = document.getElementById("cb_message' . $key . '"); if (cb) { if (!cb.checked) cb.checked = true; else cb.checked = false; } '; } $content .= ' return false; } //--> </script> '; $content .= "<input type=\"hidden\" name=\"action\" value=\"deletemessage\" />"; $content .= "<table class=\"list_table\"><tr>"; $content .= "<td class=\"list_label\">" . $pgv_lang["delete"] . "<br /><a href=\"javascript:;\" onclick=\"return select_all();\">" . $pgv_lang["all"] . "</a></td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["message_subject"] . "</td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["date_created"] . "</td>"; $content .= "<td class=\"list_label\">" . $pgv_lang["message_from"] . "</td>"; $content .= "</tr>"; foreach ($usermessages as $key => $message) { if (isset($message["id"])) { $key = $message["id"]; } $content .= "<tr>"; $content .= "<td class=\"list_value_wrap\"><input type=\"checkbox\" id=\"cb_message{$key}\" name=\"message_id[]\" value=\"{$key}\" /></td>"; $showmsg = preg_replace("/(\\w)\\/(\\w)/", "\$1/<span style=\"font-size:1px;\"> </span>\$2", PrintReady($message["subject"])); $showmsg = str_replace("@", "@<span style=\"font-size:1px;\"> </span>", $showmsg); $content .= "<td class=\"list_value_wrap\"><a href=\"javascript:;\" onclick=\"expand_layer('message{$key}'); return false;\"><img id=\"message{$key}_img\" src=\"" . $PGV_IMAGE_DIR . "/" . $PGV_IMAGES["plus"]["other"] . "\" border=\"0\" alt=\"" . $pgv_lang["show_details"] . "\" title=\"" . $pgv_lang["show_details"] . "\" /> <b>" . $showmsg . "</b></a></td>"; if (!empty($message["created"])) { $time = strtotime($message["created"]); } else { $time = time(); } $content .= "<td class=\"list_value_wrap\">" . format_timestamp($time) . "</td>"; $content .= "<td class=\"list_value_wrap\">"; $user_id = get_user_id($message["from"]); if ($user_id) { $content .= PrintReady(getUserFullName($user_id)); if ($TEXT_DIRECTION == "ltr") { $content .= " " . getLRM() . " - " . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getLRM(); } else { $content .= " " . getRLM() . " - " . htmlspecialchars($user_id, ENT_COMPAT, 'UTF-8') . getRLM(); } } else { $content .= "<a href=\"mailto:" . $message["from"] . "\">" . str_replace("@", "@<span style=\"font-size:1px;\"> </span>", $message["from"]) . "</a>"; } $content .= "</td>"; $content .= "</tr>"; $content .= "<tr><td class=\"list_value_wrap\" colspan=\"5\"><div id=\"message{$key}\" style=\"display: none;\">"; $message["body"] = nl2br(htmlspecialchars($message["body"], ENT_COMPAT, 'UTF-8')); $message["body"] = expand_urls($message["body"]); $content .= PrintReady($message["body"]) . "<br /><br />"; if (strpos($message["subject"], "RE:") === false) { $message["subject"] = "RE:" . $message["subject"]; } if ($user_id) { $content .= "<a href=\"javascript:;\" onclick=\"reply('" . $user_id . "', '" . $message["subject"] . "'); return false;\">" . $pgv_lang["reply"] . "</a> | "; } $content .= "<a href=\"" . encode_url("index.php?action=deletemessage&message_id={$key}") . "\" onclick=\"return confirm('" . $pgv_lang["confirm_message_delete"] . "');\">" . $pgv_lang["delete"] . "</a></div></td></tr>"; } $content .= "</table>"; $content .= "<input type=\"submit\" value=\"" . $pgv_lang["delete_selected_messages"] . "\" /><br /><br />"; } if (get_user_count() > 1) { $content .= $pgv_lang["message"] . " <select name=\"touser\">"; if (PGV_USER_IS_ADMIN) { $content .= "<option value=\"all\">" . $pgv_lang["broadcast_all"] . "</option>"; $content .= "<option value=\"never_logged\">" . $pgv_lang["broadcast_never_logged_in"] . "</option>"; $content .= "<option value=\"last_6mo\">" . $pgv_lang["broadcast_not_logged_6mo"] . "</option>"; } foreach (get_all_users() as $user_id => $user_name) { if ($user_id != PGV_USER_ID && get_user_setting($user_id, 'verified_by_admin') == 'yes' && get_user_setting($user_id, 'contactmethod') != 'none') { $content .= "<option value=\"" . $user_name . "\">" . PrintReady(getUserFullName($user_id)) . " "; if ($TEXT_DIRECTION == "ltr") { $content .= stripLRMRLM(getLRM() . " - " . $user_name . getLRM()); } else { $content .= stripLRMRLM(getRLM() . " - " . $user_name . getRLM()); } $content .= "</option>"; } } $content .= "</select><input type=\"button\" value=\"" . $pgv_lang["send"] . "\" onclick=\"message(document.messageform.touser.options[document.messageform.touser.selectedIndex].value, 'messaging2', ''); return false;\" />"; } $content .= "</form>"; global $THEME_DIR; if ($block) { require $THEME_DIR . 'templates/block_small_temp.php'; } else { require $THEME_DIR . 'templates/block_main_temp.php'; } }
/** * Finish current span */ function finishCurrentSpan(&$result, $theEnd = false) { global $previousState, $currentState, $posSpanStart, $TEXT_DIRECTION, $waitingText; global $startLTR, $endLTR, $startRTL, $endRTL, $lenStart, $lenEnd; global $numbers, $punctuation; $textSpan = substr($result, $posSpanStart); $result = substr($result, 0, $posSpanStart); // Get rid of empty spans, so that our check for presence of RTL will work $result = str_replace(array($startLTR . $endLTR, $startRTL . $endRTL), '', $result); // Look for numeric strings that are times (hh:mm:ss). These have to be separated from surrounding numbers. $tempResult = ''; while ($textSpan != '') { $posColon = strpos($textSpan, ':'); if ($posColon === false) { break; } // No more possible time strings $posLRE = strpos($textSpan, WT_UTF8_LRE); if ($posLRE === false) { break; } // No more numeric strings $posPDF = strpos($textSpan, WT_UTF8_PDF, $posLRE); if ($posPDF === false) { break; } // No more numeric strings $tempResult .= substr($textSpan, 0, $posLRE + 3); // Copy everything preceding the numeric string $numericString = substr($textSpan, $posLRE + 3, $posPDF - $posLRE); // Separate the entire numeric string $textSpan = substr($textSpan, $posPDF + 3); $posColon = strpos($numericString, ':'); if ($posColon === false) { // Nothing that looks like a time here $tempResult .= $numericString; continue; } $posBlank = strpos($numericString . ' ', ' '); $posNbsp = strpos($numericString . ' ', ' '); if ($posBlank < $posNbsp) { $posSeparator = $posBlank; $lengthSeparator = 1; } else { $posSeparator = $posNbsp; $lengthSeparator = 6; } if ($posColon > $posSeparator) { // We have a time string preceded by a blank: Exclude that blank from the numeric string $tempResult .= substr($numericString, 0, $posSeparator); $tempResult .= WT_UTF8_PDF; $tempResult .= substr($numericString, $posSeparator, $lengthSeparator); $tempResult .= WT_UTF8_LRE; $numericString = substr($numericString, $posSeparator + $lengthSeparator); } $posBlank = strpos($numericString, ' '); $posNbsp = strpos($numericString, ' '); if ($posBlank === false && $posNbsp === false) { // The time string isn't followed by a blank $textSpan = $numericString . $textSpan; continue; } // We have a time string followed by a blank: Exclude that blank from the numeric string if ($posBlank === false) { $posSeparator = $posNbsp; $lengthSeparator = 6; } else { if ($posNbsp === false) { $posSeparator = $posBlank; $lengthSeparator = 1; } else { if ($posBlank < $posNbsp) { $posSeparator = $posBlank; $lengthSeparator = 1; } else { $posSeparator = $posNbsp; $lengthSeparator = 6; } } } $tempResult .= substr($numericString, 0, $posSeparator); $tempResult .= WT_UTF8_PDF; $tempResult .= substr($numericString, $posSeparator, $lengthSeparator); $posSeparator += $lengthSeparator; $numericString = substr($numericString, $posSeparator); $textSpan = WT_UTF8_LRE . $numericString . $textSpan; } $textSpan = $tempResult . $textSpan; $trailingBlanks = ''; $trailingBreaks = ''; /* ****************************** LTR text handling ******************************** */ if ($currentState == 'LTR') { // Move trailing numeric strings to the following RTL text. Include any blanks preceding or following the numeric text too. if ($TEXT_DIRECTION == 'rtl' && $previousState == 'RTL' && !$theEnd) { $trailingString = ''; $savedSpan = $textSpan; while ($textSpan != '') { // Look for trailing spaces and tentatively move them if (substr($textSpan, -1) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -3) != WT_UTF8_PDF) { // There is no trailing numeric string $textSpan = $savedSpan; break; } // We have a numeric string $posStartNumber = strrpos($textSpan, WT_UTF8_LRE); if ($posStartNumber === false) { $posStartNumber = 0; } $trailingString = substr($textSpan, $posStartNumber, strlen($textSpan) - $posStartNumber) . $trailingString; $textSpan = substr($textSpan, 0, $posStartNumber); // Look for more spaces and move them too while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } break; } $waitingText = $trailingString . $waitingText; break; } } $savedSpan = $textSpan; // Move any trailing <br>, optionally preceded or followed by blanks, outside this LTR span while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -1); continue; } if (substr('......' . $textSpan, -6) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -6); continue; } break; } while (substr($textSpan, -9) == '<LTRbr>') { $trailingBreaks = '<br>' . $trailingBreaks; // Plain <br> because it’s outside a span $textSpan = substr($textSpan, 0, -9); } if ($trailingBreaks != '') { while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingBreaks = ' ' . $trailingBreaks; $textSpan = substr($textSpan, 0, -1); continue; } if (substr('......' . $textSpan, -6) == ' ') { $trailingBreaks = ' ' . $trailingBreaks; $textSpan = substr($textSpan, 0, -6); continue; } break; } $waitingText = $trailingBlanks . $waitingText; // Put those trailing blanks inside the following span } else { $textSpan = $savedSpan; } $savedSpan = $textSpan; $trailingBlanks = ''; $trailingPunctuation = ''; $trailingID = ''; $trailingSeparator = ''; $leadingSeparator = ''; while ($TEXT_DIRECTION == 'rtl') { if (strpos($result, $startRTL) !== false) { // Remove trailing blanks for inclusion in a separate LTR span while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -1); continue; } break; } // Remove trailing punctuation for inclusion in a separate LTR span if ($textSpan == '') { $trailingChar = "\n"; } else { $trailingChar = substr($textSpan, -1); } if (strpos($punctuation, $trailingChar) !== false) { $trailingPunctuation = $trailingChar; $textSpan = substr($textSpan, 0, -1); } } // Remove trailing ID numbers that look like "(xnnn)" for inclusion in a separate LTR span while (true) { if (substr($textSpan, -1) != ')') { break; } // There is no trailing ')' $posLeftParen = strrpos($textSpan, '('); if ($posLeftParen === false) { break; } // There is no leading '(' $temp = stripLRMRLM(substr($textSpan, $posLeftParen)); // Get rid of UTF8 control codes // If the parenthesized text doesn't look like an ID number, // we don't want to touch it. // This check won’t work if somebody uses ID numbers with an unusual format. $offset = 1; $charArray = getchar($temp, $offset); // Get 1st character of parenthesized text if (strpos($numbers, $charArray['letter']) !== false) { break; } $offset += $charArray['length']; // Point at 2nd character of parenthesized text if (strpos($numbers, substr($temp, $offset, 1)) === false) { break; } // 1st character of parenthesized text is alpha, 2nd character is a digit; last has to be a digit too if (strpos($numbers, substr($temp, -2, 1)) === false) { break; } $trailingID = substr($textSpan, $posLeftParen); $textSpan = substr($textSpan, 0, $posLeftParen); break; } // Look for " - " or blank preceding the ID number and remove it for inclusion in a separate LTR span $savedSpan = $textSpan; if ($trailingID != '') { while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingSeparator = ' ' . $trailingSeparator; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingSeparator = ' ' . $trailingSeparator; $textSpan = substr($textSpan, 0, -6); continue; } if (substr($textSpan, -1) == '-') { $trailingSeparator = '-' . $trailingSeparator; $textSpan = substr($textSpan, 0, -1); continue; } break; } } // Look for " - " preceding the text and remove it for inclusion in a separate LTR span $foundSeparator = false; $savedSpan = $textSpan; while ($textSpan != '') { if (substr($textSpan, 0, 1) == ' ') { $leadingSeparator = ' ' . $leadingSeparator; $textSpan = substr($textSpan, 1); continue; } if (substr($textSpan, 0, 6) == ' ') { $leadingSeparator = ' ' . $leadingSeparator; $textSpan = substr($textSpan, 6); continue; } if (substr($textSpan, 0, 1) == '-') { $leadingSeparator = '-' . $leadingSeparator; $textSpan = substr($textSpan, 1); $foundSeparator = true; continue; } break; } if (!$foundSeparator) { $textSpan = $savedSpan; $leadingSeparator = ''; } break; } // We're done: finish the span $textSpan = starredName($textSpan, 'LTR'); // Wrap starred name in <u> and </u> tags while (true) { // Remove blanks that precede <LTRbr> if (strpos($textSpan, ' <LTRbr>') !== false) { $textSpan = str_replace(' <LTRbr>', '<LTRbr>', $textSpan); continue; } if (strpos($textSpan, ' <LTRbr>') !== false) { $textSpan = str_replace(' <LTRbr>', '<LTRbr>', $textSpan); continue; } break; } if ($leadingSeparator != '') { $result = $result . $startLTR . $leadingSeparator . $endLTR; } $result = $result . $textSpan . $endLTR; if ($trailingSeparator != '') { $result = $result . $startLTR . $trailingSeparator . $endLTR; } if ($trailingID != '') { $result = $result . $startLTR . $trailingID . $endLTR; } if ($trailingPunctuation != '') { $result = $result . $startLTR . $trailingPunctuation . $endLTR; } if ($trailingBlanks != '') { $result = $result . $startLTR . $trailingBlanks . $endLTR; } } /* ****************************** RTL text handling ******************************** */ if ($currentState == 'RTL') { $savedSpan = $textSpan; // Move any trailing <br>, optionally followed by blanks, outside this RTL span while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -1); continue; } if (substr('......' . $textSpan, -6) == ' ') { $trailingBlanks = ' ' . $trailingBlanks; $textSpan = substr($textSpan, 0, -6); continue; } break; } while (substr($textSpan, -9) == '<RTLbr>') { $trailingBreaks = '<br>' . $trailingBreaks; // Plain <br> because it’s outside a span $textSpan = substr($textSpan, 0, -9); } if ($trailingBreaks != '') { $waitingText = $trailingBlanks . $waitingText; // Put those trailing blanks inside the following span } else { $textSpan = $savedSpan; } // Move trailing numeric strings to the following LTR text. Include any blanks preceding or following the numeric text too. if (!$theEnd && $TEXT_DIRECTION != 'rtl') { $trailingString = ''; $savedSpan = $textSpan; while ($textSpan != '') { // Look for trailing spaces and tentatively move them if (substr($textSpan, -1) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -3) != WT_UTF8_PDF) { // There is no trailing numeric string $textSpan = $savedSpan; break; } // We have a numeric string $posStartNumber = strrpos($textSpan, WT_UTF8_LRE); if ($posStartNumber === false) { $posStartNumber = 0; } $trailingString = substr($textSpan, $posStartNumber, strlen($textSpan) - $posStartNumber) . $trailingString; $textSpan = substr($textSpan, 0, $posStartNumber); // Look for more spaces and move them too while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $trailingString = ' ' . $trailingString; $textSpan = substr($textSpan, 0, -1); continue; } break; } $waitingText = $trailingString . $waitingText; break; } } // Trailing " - " needs to be prefixed to the following span if (!$theEnd && substr('...' . $textSpan, -3) == ' - ') { $textSpan = substr($textSpan, 0, -3); $waitingText = ' - ' . $waitingText; } while ($TEXT_DIRECTION == 'rtl') { // Look for " - " preceding <RTLbr> and relocate it to the front of the string $posDashString = strpos($textSpan, ' - <RTLbr>'); if ($posDashString === false) { break; } $posStringStart = strrpos(substr($textSpan, 0, $posDashString), '<RTLbr>'); if ($posStringStart === false) { $posStringStart = 0; } else { $posStringStart += 9; } // Point to the first char following the last <RTLbr> $textSpan = substr($textSpan, 0, $posStringStart) . ' - ' . substr($textSpan, $posStringStart, $posDashString - $posStringStart) . substr($textSpan, $posDashString + 3); } // Strip leading spaces from the RTL text $countLeadingSpaces = 0; while ($textSpan != '') { if (substr($textSpan, 0, 1) == ' ') { $countLeadingSpaces++; $textSpan = substr($textSpan, 1); continue; } if (substr($textSpan, 0, 6) == ' ') { $countLeadingSpaces++; $textSpan = substr($textSpan, 6); continue; } break; } // Strip trailing spaces from the RTL text $countTrailingSpaces = 0; while ($textSpan != '') { if (substr($textSpan, -1) == ' ') { $countTrailingSpaces++; $textSpan = substr($textSpan, 0, -1); continue; } if (substr($textSpan, -6) == ' ') { $countTrailingSpaces++; $textSpan = substr($textSpan, 0, -6); continue; } break; } // Look for trailing " -", reverse it, and relocate it to the front of the string if (substr($textSpan, -2) == ' -') { $posDashString = strlen($textSpan) - 2; $posStringStart = strrpos(substr($textSpan, 0, $posDashString), '<RTLbr>'); if ($posStringStart === false) { $posStringStart = 0; } else { $posStringStart += 9; } // Point to the first char following the last <RTLbr> $textSpan = substr($textSpan, 0, $posStringStart) . '- ' . substr($textSpan, $posStringStart, $posDashString - $posStringStart) . substr($textSpan, $posDashString + 2); } if ($countLeadingSpaces != 0) { $newLength = strlen($textSpan) + $countLeadingSpaces; $textSpan = str_pad($textSpan, $newLength, ' ', $TEXT_DIRECTION == 'rtl' ? STR_PAD_LEFT : STR_PAD_RIGHT); } if ($countTrailingSpaces != 0) { if ($TEXT_DIRECTION == 'ltr') { if ($trailingBreaks == '') { // Move trailing RTL spaces to front of following LTR span $newLength = strlen($waitingText) + $countTrailingSpaces; $waitingText = str_pad($waitingText, $newLength, ' ', STR_PAD_LEFT); } } else { $newLength = strlen($textSpan) + $countTrailingSpaces; $textSpan = str_pad($textSpan, $newLength, ' ', STR_PAD_RIGHT); } } // We're done: finish the span $textSpan = starredName($textSpan, 'RTL'); // Wrap starred name in <u> and </u> tags $result = $result . $textSpan . $endRTL; } if ($currentState != 'LTR' && $currentState != 'RTL') { $result = $result . $textSpan; } $result .= $trailingBreaks; // Get rid of any waiting <br> return; }