/** * These functions provide access to hitcounter for use in the HTML block. * * @param string $page_name * @param string[] $params * * @return string */ private function hitCountQuery($page_name, $params) { if (is_array($params) && isset($params[0]) && $params[0] != '') { $page_parameter = $params[0]; } else { $page_parameter = ''; } if ($page_name === null) { // index.php?ctype=gedcom $page_name = 'index.php'; $page_parameter = 'gedcom:' . ($page_parameter ? Tree::findByName($page_parameter)->getTreeId() : $this->tree->getTreeId()); } elseif ($page_name == 'index.php') { // index.php?ctype=user $user = User::findByIdentifier($page_parameter); $page_parameter = 'user:'******'<span class="odometer">' . I18N::digits(HitCounter::getCount($this->tree, $page_name, $page_parameter)) . '</span>'; }
$diff_lines = array(); foreach ($differences as $difference) { switch ($difference[1]) { case MyersDiff::DELETE: $diff_lines[] = '<del>' . $difference[0] . '</del>'; break; case MyersDiff::INSERT: $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; break; default: $diff_lines[] = $difference[0]; } } // Only convert valid xrefs to links $data[] = array($row->change_id, $row->change_time, I18N::translate($row->status), GedcomRecord::getInstance($row->xref, Tree::findByName($gedc)) ? "<a href='gedrecord.php?pid={$row->xref}&ged={$row->gedcom_name}'>{$row->xref}</a>" : $row->xref, '<div class="gedcom-data" dir="ltr">' . preg_replace_callback('/@(' . WT_REGEX_XREF . ')@/', function ($match) use($gedc) { return GedcomRecord::getInstance($match[1], Tree::findByName($gedc)) ? "<a href='#' onclick='return edit_raw(\"{$match[1]}\");'>{$match[0]}</a>" : $match[0]; }, implode("\n", $diff_lines)) . '</div>', $row->user_name, $row->gedcom_name); } header('Content-type: application/json'); // See http://www.datatables.net/usage/server-side echo json_encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data)); return; } $controller->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addExternalJavascript(WT_MOMENT_JS_URL)->addExternalJavascript(WT_BOOTSTRAP_DATETIMEPICKER_JS_URL)->addInlineJavascript(' jQuery(".table-site-changes").dataTable( { processing: true, serverSide: true, ajax: "' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=load_json&from=' . $from . '&to=' . $to . '&type=' . $type . '&oldged=' . rawurlencode($oldged) . '&newged=' . rawurlencode($newged) . '&xref=' . rawurlencode($xref) . '&user='******'&gedc=' . rawurlencode($gedc) . '", ' . I18N::datatablesI18N(array(10, 20, 50, 100, 500, 1000, -1)) . ', sorting: [[ 0, "desc" ]], pageLength: ' . Auth::user()->getPreference('admin_site_change_page_size', 10) . ',
$tree->importGedcomFile(WT_DATA_DIR . $basename, $basename); } else { FlashMessages::addMessage(I18N::translate('No GEDCOM file was received.'), 'danger'); } } header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME); return; case 'synchronize': if (Filter::checkCsrf()) { $basenames = array(); foreach ($gedcom_files as $gedcom_file) { $filemtime = filemtime($gedcom_file); // Only import files that have changed $basename = basename($gedcom_file); $basenames[] = $basename; $tree = Tree::findByName($basename); if (!$tree) { $tree = Tree::create($basename, $basename); } if ($tree->getPreference('filemtime') != $filemtime) { $tree->importGedcomFile($gedcom_file, $basename); $tree->setPreference('filemtime', $filemtime); FlashMessages::addMessage(I18N::translate('The GEDCOM file “%s” has been imported.', Filter::escapeHtml($basename)), 'success'); } } foreach (Tree::getAll() as $tree) { if (!in_array($tree->getName(), $basenames)) { FlashMessages::addMessage(I18N::translate('The family tree “%s” has been deleted.', $tree->getTitleHtml()), 'success'); $tree->delete(); } }
/** * Generate the HTML content of this block. * * @param int $block_id * @param bool $template * @param string[] $cfg * * @return string */ public function getBlock($block_id, $template = true, $cfg = array()) { global $ctype, $WT_TREE; $title = $this->getBlockSetting($block_id, 'title'); $html = $this->getBlockSetting($block_id, 'html'); $gedcom = $this->getBlockSetting($block_id, 'gedcom'); $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0'); $languages = $this->getBlockSetting($block_id, 'languages'); // Only show this block for certain languages if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) { return ''; } /* * Select GEDCOM */ switch ($gedcom) { case '__current__': $stats = new Stats($WT_TREE); break; case '__default__': $tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM')); if ($tree) { $stats = new Stats($tree); } else { $stats = new Stats($WT_TREE); } break; default: $tree = Tree::findByName($gedcom); if ($tree) { $stats = new Stats($tree); } else { $stats = new Stats($WT_TREE); } break; } /* * Retrieve text, process embedded variables */ if (strpos($title, '#') !== false || strpos($html, '#') !== false) { $title = $stats->embedTags($title); $html = $stats->embedTags($html); } /* * Start Of Output */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) { $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&ged=' . $WT_TREE->getNameHtml() . '&ctype=' . $ctype . '"></a>' . $title; } $content = $html; if ($show_timestamp) { $content .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET); } if ($template) { return Theme::theme()->formatBlock($id, $title, $class, $content); } else { return $content; } }
} try { $array = unserialize($setting->u_rootid); foreach ($array as $gedcom => $value) { $tree = Tree::findByName($gedcom); if ($tree !== null) { Database::prepare("INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)")->execute(array($setting->user_id, $tree->getTreeId(), 'rootid', $value)); } } } catch (\ErrorException $ex) { // Invalid serialized data? } try { $array = unserialize($setting->u_canedit); foreach ($array as $gedcom => $value) { $tree = Tree::findByName($gedcom); if ($tree !== null) { Database::prepare("INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)")->execute(array($setting->user_id, $tree->getTreeId(), 'canedit', $value)); } } } catch (\ErrorException $ex) { // Invalid serialized data? } } } define('PGV_PHPGEDVIEW', true); define('PGV_PRIV_PUBLIC', Auth::PRIV_PRIVATE); define('PGV_PRIV_USER', Auth::PRIV_USER); define('PGV_PRIV_NONE', Auth::PRIV_NONE); define('PGV_PRIV_HIDE', Auth::PRIV_HIDE); $PRIV_PUBLIC = Auth::PRIV_PRIVATE;
return true; }, function ($maxlifetime) { Database::prepare("DELETE FROM `##session` WHERE session_time < DATE_SUB(NOW(), INTERVAL ? SECOND)")->execute(array($maxlifetime)); return true; }); Session::start(array('gc_maxlifetime' => Site::getPreference('SESSION_TIME'), 'cookie_path' => parse_url(WT_BASE_URL, PHP_URL_PATH))); if (!Auth::isSearchEngine() && !Session::get('initiated')) { // A new session, so prevent session fixation attacks by choosing a new PHPSESSID. Session::regenerate(false); Session::put('initiated', true); } else { // An existing session } // Set the tree for the page; (1) the request, (2) the session, (3) the site default, (4) any tree foreach (array(Filter::post('ged'), Filter::get('ged'), Session::get('GEDCOM'), Site::getPreference('DEFAULT_GEDCOM')) as $tree_name) { $WT_TREE = Tree::findByName($tree_name); if ($WT_TREE) { Session::put('GEDCOM', $tree_name); break; } } // No chosen tree? Use any one. if (!$WT_TREE) { foreach (Tree::getAll() as $WT_TREE) { break; } } // With no parameters, init() looks to the environment to choose a language define('WT_LOCALE', I18N::init()); Session::put('locale', WT_LOCALE); // Note that the database/webservers may not be synchronised, so use DB time throughout.
foreach ($differences as $difference) { switch ($difference[1]) { case MyersDiff::DELETE: $diff_lines[] = '<del>' . $difference[0] . '</del>'; break; case MyersDiff::INSERT: $diff_lines[] = '<ins>' . $difference[0] . '</ins>'; break; default: $diff_lines[] = $difference[0]; } } // Only convert valid xrefs to links $record = GedcomRecord::getInstance($row->xref, Tree::findByName($gedc)); $data[] = array($row->change_id, $row->change_time, I18N::translate($row->status), $record ? '<a href="' . $record->getHtmlUrl() . '">' . $record->getXref() . '</a>' : $row->xref, '<div class="gedcom-data" dir="ltr">' . preg_replace_callback('/@(' . WT_REGEX_XREF . ')@/', function ($match) use($gedc) { $record = GedcomRecord::getInstance($match[1], Tree::findByName($gedc)); return $record ? '<a href="#" onclick="return edit_raw(\'' . $match[1] . '\');">' . $match[0] . '</a>' : $match[0]; }, implode("\n", $diff_lines)) . '</div>', $row->user_name, $row->gedcom_name); } header('Content-type: application/json'); // See http://www.datatables.net/usage/server-side echo json_encode(array('draw' => Filter::getInteger('draw'), 'recordsTotal' => $recordsTotal, 'recordsFiltered' => $recordsFiltered, 'data' => $data)); return; } $controller->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addExternalJavascript(WT_MOMENT_JS_URL)->addExternalJavascript(WT_BOOTSTRAP_DATETIMEPICKER_JS_URL)->addInlineJavascript(' jQuery(".table-site-changes").dataTable( { processing: true, serverSide: true, ajax: "' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=load_json&from=' . $from . '&to=' . $to . '&type=' . $type . '&oldged=' . rawurlencode($oldged) . '&newged=' . rawurlencode($newged) . '&xref=' . rawurlencode($xref) . '&user='******'&gedc=' . rawurlencode($gedc) . '", ' . I18N::datatablesI18N(array(10, 20, 50, 100, 500, 1000, -1)) . ', sorting: [[ 0, "desc" ]],
foreach ($array as $gedcom => $value) { try { $tree_id = Tree::findByName($gedcom)->getTreeId(); Database::prepare("INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)")->execute(array($setting->user_id, $tree_id, 'rootid', $value)); } catch (PDOException $ex) { // Invalid data? Reference to non-existing tree? } } } catch (\ErrorException $ex) { // Invalid serialized data? } try { $array = unserialize($setting->u_canedit); foreach ($array as $gedcom => $value) { try { $tree_id = Tree::findByName($gedcom)->getTreeId(); Database::prepare("INSERT IGNORE INTO `##user_gedcom_setting` (user_id, gedcom_id, setting_name, setting_value) VALUES (?, ?, ?, ?)")->execute(array($setting->user_id, $tree_id, 'canedit', $value)); } catch (PDOException $ex) { // Invalid data? Reference to non-existing tree? } } } catch (\ErrorException $ex) { // Invalid serialized data? } } } define('PGV_PHPGEDVIEW', true); define('PGV_PRIV_PUBLIC', Auth::PRIV_PRIVATE); define('PGV_PRIV_USER', Auth::PRIV_USER); define('PGV_PRIV_NONE', Auth::PRIV_NONE); define('PGV_PRIV_HIDE', Auth::PRIV_HIDE);