示例#1
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_access.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->addExternalJavascript(WT_JQUERY_JEDITABLE_URL)->setPageTitle(WT_I18N::translate('Site access rules'));
$action = WT_Filter::get('action');
switch ($action) {
    case 'delete':
        $user_access_rule_id = WT_Filter::getInteger('site_access_rule_id');
        WT_DB::prepare("DELETE FROM `##site_access_rule` WHERE site_access_rule_id=?")->execute(array($user_access_rule_id));
        break;
    case 'allow':
    case 'deny':
    case 'robot':
        $user_access_rule_id = WT_Filter::getInteger('site_access_rule_id');
        WT_DB::prepare("UPDATE `##site_access_rule` SET rule=? WHERE site_access_rule_id=?")->execute(array($action, $user_access_rule_id));
        break;
    case 'load_rules':
        Zend_Session::writeClose();
        // AJAX callback for datatables
示例#2
0
}
$latest_version_html = '<span dir="ltr">' . $latest_version . '</span>';
$download_url_html = '<b dir="auto"><a href="' . WT_Filter::escapeHtml($download_url) . '">' . WT_Filter::escapeHtml($download_url) . '</a></b>';
// Show a friendly message while the site is being upgraded
$lock_file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'offline.txt';
$lock_file_html = '<span dir="ltr">' . WT_Filter::escapeHtml($lock_file) . '</span>';
$lock_file_text = WT_I18N::translate('This site is being upgraded.  Try again in a few minutes.') . PHP_EOL . format_timestamp(WT_TIMESTAMP) . WT_I18N::translate('UTC');
// Success/failure indicators
$icon_success = '<i class="icon-yes"></i>';
$icon_failure = '<i class="icon-failure"></i>';
// Need confirmation for various actions
$continue = WT_Filter::post('continue', '1') && WT_Filter::checkCsrf();
$modules_action = WT_Filter::post('modules', 'ignore|disable');
$themes_action = WT_Filter::post('themes', 'ignore|disable');
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Upgrade wizard'))->pageHeader();
// Flush output as it happens - only effective on some webserver configurations.
ob_implicit_flush(true);
if (ob_get_level()) {
    ob_end_flush();
}
echo '<h2>', $controller->getPageTitle(), '</h2>';
if ($latest_version == '') {
    echo '<p>', WT_I18N::translate('No upgrade information is available.'), '</p>';
    exit;
}
if (version_compare(WT_VERSION, $latest_version) >= 0) {
    echo '<p>', WT_I18N::translate('This is the latest version of webtrees.  No upgrade is available.'), '</p>';
    exit;
}
echo '<form method="POST" action="admin_site_upgrade.php">';
示例#3
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\User;
define('WT_SCRIPT_NAME', 'admin_site_logs.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Logs'));
require WT_ROOT . 'includes/functions/functions_edit.php';
$earliest = WT_DB::prepare("SELECT DATE(MIN(log_time)) FROM `##log`")->execute(array())->fetchOne();
$latest = WT_DB::prepare("SELECT DATE(MAX(log_time)) FROM `##log`")->execute(array())->fetchOne();
// Filtering
$action = WT_Filter::get('action');
$from = WT_Filter::get('from', '\\d\\d\\d\\d-\\d\\d-\\d\\d', $earliest);
$to = WT_Filter::get('to', '\\d\\d\\d\\d-\\d\\d-\\d\\d', $latest);
$type = WT_Filter::get('type', 'auth|change|config|debug|edit|error|media|search');
$text = WT_Filter::get('text');
$ip = WT_Filter::get('ip');
$user = WT_Filter::get('user');
$search = WT_Filter::get('search');
$search = isset($search['value']) ? $search['value'] : null;
if (Auth::isAdmin()) {
    // Administrators can see all logs
示例#4
0
 private function admin()
 {
     $controller = new WT_Controller_Page();
     $controller->restrictAccess(Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
     // Save the updated preferences
     if (WT_Filter::post('action') == 'save') {
         foreach (WT_Tree::getAll() as $tree) {
             set_gedcom_setting($tree->tree_id, 'include_in_sitemap', WT_Filter::postBool('include' . $tree->tree_id));
         }
         // Clear cache and force files to be regenerated
         WT_DB::prepare("DELETE FROM `##module_setting` WHERE setting_name LIKE 'sitemap%'")->execute();
     }
     $include_any = false;
     echo '<h3>', $this->getTitle(), '</h3>', '<p>', WT_I18N::translate('Sitemaps are a way for webmasters to tell search engines about the pages on a website that are available for crawling.  All major search engines support sitemaps.  For more information, see <a href="http://www.sitemaps.org/">www.sitemaps.org</a>.') . '</p>', '<p>', WT_I18N::translate('Which family trees should be included in the sitemaps?'), '</p>', '<form method="post" action="module.php?mod=' . $this->getName() . '&amp;mod_action=admin">', '<input type="hidden" name="action" value="save">';
     foreach (WT_Tree::getAll() as $tree) {
         echo '<p><input type="checkbox" name="include', $tree->tree_id, '"';
         if (get_gedcom_setting($tree->tree_id, 'include_in_sitemap')) {
             echo ' checked="checked"';
             $include_any = true;
         }
         echo '>', $tree->tree_title_html, '</p>';
     }
     echo '<input type="submit" value="', WT_I18N::translate('save'), '">', '</form>', '<hr>';
     if ($include_any) {
         $site_map_url1 = WT_SERVER_NAME . WT_SCRIPT_PATH . 'module.php?mod=' . $this->getName() . '&amp;mod_action=generate&amp;file=sitemap.xml';
         $site_map_url2 = rawurlencode(WT_SERVER_NAME . WT_SCRIPT_PATH . 'module.php?mod=' . $this->getName() . '&mod_action=generate&file=sitemap.xml');
         echo '<p>', WT_I18N::translate('To tell search engines that sitemaps are available, you should add the following line to your robots.txt file.'), '</p>';
         echo '<pre>Sitemap: ', $site_map_url1, '</pre>', '<hr>', '<p>', WT_I18N::translate('To tell search engines that sitemaps are available, you can use the following links.'), '</p>', '<ul>', '<li><a target="_blank" href="http://www.bing.com/webmaster/ping.aspx?siteMap=' . $site_map_url2 . '">Bing</a></li>', '<li><a target="_blank" href="http://www.google.com/webmasters/tools/ping?sitemap=' . $site_map_url2 . '">Google</a></li>', '</ul>';
     }
 }
示例#5
0
        }
        $html .= '</ul>';
    } else {
        $html .= '<div class="error">' . WT_I18N::translate('This media object is not linked to any other record.') . '</div>';
    }
    return $html;
}
////////////////////////////////////////////////////////////////////////////////
// Start here
////////////////////////////////////////////////////////////////////////////////
// Preserver the pagination/filtering/sorting between requests, so that the
// browser’s back button works.  Pagination is dependent on the currently
// selected folder.
$table_id = md5($files . $media_folder . $media_path . $subfolders);
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Media'))->addExternalJavascript(WT_JQUERY_DATATABLES_URL)->pageHeader()->addInlineJavascript('
	jQuery("#media-table-' . $table_id . '").dataTable({
		dom: \'<"H"pf<"dt-clear">irl>t<"F"pl>\',
		processing: true,
		serverSide: true,
		ajax: "' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '?action=load_json&files=' . $files . '&media_folder=' . $media_folder . '&media_path=' . $media_path . '&subfolders=' . $subfolders . '",
		' . WT_I18N::datatablesI18N(array(5, 10, 20, 50, 100, 500, 1000, -1)) . ',
		jQueryUI: true,
		autoWidth:false,
		pageLength: 10,
		pagingType: "full_numbers",
		stateSave: true,
		stateDuration: 300,
		columns: [
			{},
			{ sortable: false },
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_module_sidebar.php');
require 'includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Module administration'))->pageHeader()->addInlineJavascript('
    jQuery("#sidebars_table").sortable({items: ".sortme", forceHelperSize: true, forcePlaceholderSize: true, opacity: 0.7, cursor: "move", axis: "y"});

    //-- update the order numbers after drag-n-drop sorting is complete
    jQuery("#sidebars_table").bind("sortupdate", function(event, ui) {
			jQuery("#"+jQuery(this).attr("id")+" input").each(
				function (index, value) {
					value.value = index+1;
				}
			);
		});
	');
$modules = WT_Module::getActiveSidebars(WT_GED_ID, WT_PRIV_HIDE);
$action = WT_Filter::post('action');
if ($action == 'update_mods' && WT_Filter::checkCsrf()) {
    foreach ($modules as $module_name => $module) {
示例#7
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\User;
define('WT_SCRIPT_NAME', 'admin_trees_config.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Family tree configuration'));
require WT_ROOT . 'includes/functions/functions_edit.php';
$PRIVACY_CONSTANTS = array('none' => WT_I18N::translate('Show to visitors'), 'privacy' => WT_I18N::translate('Show to members'), 'confidential' => WT_I18N::translate('Show to managers'), 'hidden' => WT_I18N::translate('Hide from everyone'));
switch (WT_Filter::post('action')) {
    case 'delete':
        if (!WT_Filter::checkCsrf()) {
            break;
        }
        WT_DB::prepare("DELETE FROM `##default_resn` WHERE default_resn_id=?")->execute(array(WT_Filter::post('default_resn_id')));
        // Reload the page, so that the new privacy restrictions are reflected in the header
        header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . WT_SCRIPT_NAME . '#privacy');
        exit;
    case 'add':
        if (!WT_Filter::checkCsrf()) {
            break;
        }
示例#8
0
// UI for online updating of the config file.
//
// webtrees: Web based Family History software
// Copyright (C) 2014 webtrees development team.
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use Michelf\MarkdownExtra;
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_readme.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('README documentation'))->pageHeader();
?>
<div class="markdown" dir="ltr" lang="en">
	<?php 
echo MarkdownExtra::defaultTransform(file_get_contents('README.md'));
?>
</div>
示例#9
0
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\Log;
define('WT_SCRIPT_NAME', 'admin_media_upload.php');
require './includes/session.php';
require_once WT_ROOT . 'includes/functions/functions_mediadb.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Upload media files'));
$action = WT_Filter::post('action');
if ($action == "upload") {
    for ($i = 1; $i < 6; $i++) {
        if (!empty($_FILES['mediafile' . $i]["name"]) || !empty($_FILES['thumbnail' . $i]["name"])) {
            $folder = WT_Filter::post('folder' . $i);
            // Validate the media folder
            $folderName = str_replace('\\', '/', $folder);
            $folderName = trim($folderName, '/');
            if ($folderName == '.') {
                $folderName = '';
            }
            if ($folderName) {
                $folderName .= '/';
                // Not allowed to use “../”
                if (strpos('/' . $folderName, '/../') !== false) {
示例#10
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_config.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->addExternalJavascript(WT_JQUERY_JEDITABLE_URL)->addInlineJavascript('jQuery("#tabs").tabs();')->setPageTitle(WT_I18N::translate('Site configuration'))->pageHeader();
// Lists of options for <select> controls.
$SMTP_SSL_OPTIONS = array('none' => WT_I18N::translate('none'), 'ssl' => WT_I18N::translate('ssl'), 'tls' => WT_I18N::translate('tls'));
$SMTP_ACTIVE_OPTIONS = array('internal' => WT_I18N::translate('Use PHP mail to send messages'), 'external' => WT_I18N::translate('Use SMTP to send messages'));
$WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => WT_I18N::translate('No predefined text'), 1 => WT_I18N::translate('Predefined text that states all users can request a user account'), 2 => WT_I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => WT_I18N::translate('Predefined text that states only family members can request a user account'), 4 => WT_I18N::translate('Choose user defined welcome text typed below'));
?>
<div id="site-config">
	<div id="tabs">
		<ul>
			<li>
				<a href="#site"><span><?php 
echo WT_I18N::translate('Site configuration');
?>
</span></a>
			</li>
			<li>
示例#11
0
        $record = WT_Family::getInstance($row->xref, $row->gedcom_id, $row->gedcom);
        foreach ($record->getFacts() as $fact) {
            $old_place = $fact->getAttribute('PLAC');
            if (preg_match('/(^|, )' . preg_quote($search, '/') . '$/i', $old_place)) {
                $new_place = preg_replace('/(^|, )' . preg_quote($search, '/') . '$/i', '$1' . $replace, $old_place);
                $changes[$old_place] = $new_place;
                if ($confirm == 'update') {
                    $gedcom = preg_replace('/(\\n2 PLAC (?:.*, )*)' . preg_quote($search, '/') . '(\\n|$)/i', '$1' . $replace . '$2', $fact->getGedcom());
                    $record->updateFact($fact->getFactId(), $gedcom, false);
                }
            }
        }
    }
}
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Administration - place edit'))->pageHeader();
?>

<h2>
	<?php 
echo WT_I18N::translate('Update all the place names in a family tree');
?>
</h2>

<p>
	<?php 
echo WT_I18N::translate('This will update the highest-level part or parts of the place name.  For example, “Mexico” will match “Quintana Roo, Mexico”, but not “Santa Fe, New Mexico”.');
?>
</p>

<form method="post">
示例#12
0
// at your discretion, any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_trees_check.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Check for errors'))->pageHeader();
echo '<form method="get" action="', WT_SCRIPT_NAME, '">';
echo '<input type="hidden" name="go" value="1">';
echo select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM);
echo '<input type="submit" value="', $controller->getPageTitle(), '">';
echo '</form>';
if (!WT_Filter::get('go')) {
    exit;
}
// We need to work with raw GEDCOM data, as we are looking for errors
// which may prevent the WT_GedcomRecord objects from working...
$rows = WT_DB::prepare("SELECT i_id AS xref, 'INDI' AS type, i_gedcom AS gedrec FROM `##individuals` WHERE i_file=?" . " UNION " . "SELECT f_id AS xref, 'FAM'  AS type, f_gedcom AS gedrec FROM `##families`    WHERE f_file=?" . " UNION " . "SELECT s_id AS xref, 'SOUR' AS type, s_gedcom AS gedrec FROM `##sources`     WHERE s_file=?" . " UNION " . "SELECT m_id AS xref, 'OBJE' AS type, m_gedcom AS gedrec FROM `##media`       WHERE m_file=?" . " UNION " . "SELECT o_id AS xref, o_type AS type, o_gedcom AS gedrec FROM `##other`       WHERE o_file=? AND o_type NOT IN ('HEAD', 'TRLR')")->execute(array(WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID))->fetchAll();
$records = array();
foreach ($rows as $row) {
    $records[$row->xref] = $row;
}
示例#13
0
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_other.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Add unlinked records'))->pageHeader();
?>
<div id="other">
	<p>
		<?php 
echo WT_I18N::translate('Add unlinked records');
?>
	</p>
	<p>
		<form method="post" action="?" name="tree">
			<?php 
echo select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM, ' onchange="tree.submit();"');
?>
		</form>
	</p>
	<table id="other">
示例#14
0
// the Free Software Foundation; either version 2 of the License or,
// at your discretion, any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_trees_renumber.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Renumber family tree'))->pageHeader();
// Every XREF used by this tree and also used by some other tree
$xrefs = WT_DB::prepare("SELECT xref, type FROM (" . " SELECT i_id AS xref, 'INDI' AS type FROM `##individuals` WHERE i_file = ?" . "  UNION " . " SELECT f_id AS xref, 'FAM' AS type FROM `##families` WHERE f_file = ?" . "  UNION " . " SELECT s_id AS xref, 'SOUR' AS type FROM `##sources` WHERE s_file = ?" . "  UNION " . " SELECT m_id AS xref, 'OBJE' AS type FROM `##media` WHERE m_file = ?" . "  UNION " . " SELECT o_id AS xref, o_type AS type FROM `##other` WHERE o_file = ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS this_tree JOIN (" . " SELECT xref FROM `##change` WHERE gedcom_id <> ?" . "  UNION " . " SELECT i_id AS xref FROM `##individuals` WHERE i_file <> ?" . "  UNION " . " SELECT f_id AS xref FROM `##families` WHERE f_file <> ?" . "  UNION " . " SELECT s_id AS xref FROM `##sources` WHERE s_file <> ?" . "  UNION " . " SELECT m_id AS xref FROM `##media` WHERE m_file <> ?" . "  UNION " . " SELECT o_id AS xref FROM `##other` WHERE o_file <> ? AND o_type NOT IN ('HEAD', 'TRLR')" . ") AS other_trees USING (xref)")->execute(array(WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID, WT_GED_ID))->fetchAssoc();
echo '<h2>', $controller->getPageTitle(), ' — ', $WT_TREE->tree_title_html, '</h2>';
if (WT_Filter::get('go')) {
    foreach ($xrefs as $old_xref => $type) {
        WT_DB::exec("START TRANSACTION");
        WT_DB::exec("LOCK TABLE `##individuals` WRITE," . " `##families` WRITE," . " `##sources` WRITE," . " `##media` WRITE," . " `##other` WRITE," . " `##name` WRITE," . " `##placelinks` WRITE," . " `##change` WRITE," . " `##next_id` WRITE," . " `##dates` WRITE," . " `##default_resn` WRITE," . " `##hit_counter` WRITE," . " `##link` WRITE," . " `##user_gedcom_setting` WRITE");
        $new_xref = get_new_xref($type);
        switch ($type) {
            case 'INDI':
                WT_DB::prepare("UPDATE `##individuals` SET i_id = ?, i_gedcom = REPLACE(i_gedcom, ?, ?) WHERE i_id = ? AND i_file = ?")->execute(array($new_xref, "0 @{$old_xref}@ INDI\n", "0 @{$new_xref}@ INDI\n", $old_xref, WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'HUSB') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " HUSB @{$old_xref}@", " HUSB @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'WIFE') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " WIFE @{$old_xref}@", " WIFE @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'CHIL') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " CHIL @{$old_xref}@", " CHIL @{$new_xref}@", WT_GED_ID));
                WT_DB::prepare("UPDATE `##families` JOIN `##link` ON (l_file = f_file AND l_to = ? AND l_type = 'ASSO') SET f_gedcom = REPLACE(f_gedcom, ?, ?) WHERE f_file = ?")->execute(array($old_xref, " ASSO @{$old_xref}@", " ASSO @{$new_xref}@", WT_GED_ID));
示例#15
0
 private function fetchFriendList()
 {
     global $WT_SESSION, $controller;
     $controller = new WT_Controller_Page();
     $controller->addInlineJavaScript("\n            \$('head').append('<link rel=\"stylesheet\" href=\"" . WT_MODULES_DIR . $this->getName() . "/facebook.css?v=" . WT_FACEBOOK_VERSION . "\" />');", WT_Controller_Page::JS_PRIORITY_LOW);
     $preApproved = unserialize($this->getSetting('preapproved'));
     if (WT_Filter::postArray('preApproved') && WT_Filter::checkCsrf()) {
         $roleRows = WT_Filter::postArray('preApproved');
         $fbUsernames = WT_Filter::postArray('facebook_username', WT_REGEX_USERNAME);
         foreach ($fbUsernames as $facebook_username) {
             $facebook_username = $this->cleanseFacebookUsername($facebook_username);
             $this->appendPreapproved($preApproved, $facebook_username, $roleRows);
         }
         $this->setSetting('preapproved', serialize($preApproved));
         WT_FlashMessages::addMessage(WT_I18N::translate('Users successfully imported from Facebook'));
         header("Location: module.php?mod=" . $this->getName() . "&mod_action=admin");
         exit;
     }
     if (empty($WT_SESSION->facebook_access_token)) {
         $this->error_page(WT_I18N::translate("You must <a href='%s'>login to the site via Facebook</a> in order to import friends from Facebook", "index.php?logout=1"));
     }
     $graph_url = "https://graph.facebook.com/" . self::api_dir . "me/friends?fields=first_name,last_name,name,username&access_token=" . $WT_SESSION->facebook_access_token;
     $friendsResponse = $this->fetch_url($graph_url);
     if ($friendsResponse === FALSE) {
         $this->error_page(WT_I18N::translate("Could not fetch your friends from Facebook. Note that this feature won't work for Facebook Apps created after 2014-04-30 due to a Facebook policy change."));
     }
     $controller->restrictAccess(\WT\Auth::isAdmin())->setPageTitle($this->getTitle())->pageHeader();
     $friends = json_decode($friendsResponse);
     if (empty($friends->data)) {
         $this->error_page(WT_I18N::translate("No friend data"));
         return;
     }
     function nameSort($a, $b)
     {
         return strcmp($a->last_name . " " . $a->first_name, $b->last_name . " " . $b->first_name);
     }
     usort($friends->data, "nameSort");
     echo "<form id='facebook_friend_list' method='post' action=''>";
     require_once WT_ROOT . 'includes/functions/functions_edit.php';
     // for select_edit_control
     $index = 0;
     foreach (WT_Tree::getAll() as $tree) {
         $class = $index++ % 2 ? 'odd' : 'even';
         echo "<label>" . $tree->tree_name_html . " - " . WT_I18N::translate('Role') . help_link('role') . ": " . select_edit_control('preApproved[' . $tree->tree_id . '][canedit]', $this->get_edit_options(), NULL, NULL) . "</label>";
     }
     foreach ($friends->data as $friend) {
         $facebook_username = $this->cleanseFacebookUsername(isset($friend->username) ? $friend->username : $friend->id);
         // Exclude friends who are already pre-approved or are current users
         if (isset($preApproved[$facebook_username]) || $this->get_user_id_from_facebook_username($facebook_username)) {
             continue;
         }
         echo "<label><input name='facebook_username[]' type='checkbox' value='" . $facebook_username . "'/>" . $friend->name . "</label>";
     }
     echo WT_Filter::getCsrf();
     echo "<button>Select Friends</button></form>";
 }
示例#16
0
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\User;
define('WT_SCRIPT_NAME', 'admin_pgv_to_wt.php');
require './includes/session.php';
//require WT_ROOT.'includes/functions/functions_edit.php';
// We can only import into an empty system, so deny access if we have already created a gedcom or added users.
if (WT_GED_ID || count(User::all()) > 1) {
    header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH);
    exit;
}
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('PhpGedView to webtrees transfer wizard'));
$error = '';
$warning = '';
$PGV_PATH = WT_Filter::post('PGV_PATH');
if ($PGV_PATH) {
    if (!is_dir($PGV_PATH) || !is_readable($PGV_PATH . '/config.php')) {
        $error = WT_I18N::translate('The specified directory does not contain an installation of PhpGedView');
    } else {
        // Load the configuration settings
        $config_php = file_get_contents($PGV_PATH . '/config.php');
        // The easiest way to do this is to exec() the file - but not lines containing require or PHP tags
        $config_php = preg_replace(array('/^\\s*(include|require).*/m', '/.*<\\?php.*/', '/.*\\?>.*/'), '', $config_php);
        eval($config_php);
        // $INDEX_DIRECTORY can be either absolute or relative to the PhpGedView root.
        if (preg_match('/^(\\/|\\|[A-Z]:)/', $INDEX_DIRECTORY)) {
            $INDEX_DIRECTORY = realpath($INDEX_DIRECTORY);
示例#17
0
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\User;
define('WT_SCRIPT_NAME', 'admin.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->addInlineJavascript('jQuery("#x").accordion({heightStyle: "content"});')->addInlineJavascript('jQuery("#tree_stats").accordion();')->addInlineJavascript('jQuery("#changes").accordion();')->addInlineJavascript('jQuery("#content_container").css("visibility", "visible");')->setPageTitle(WT_I18N::translate('Administration'))->pageHeader();
// Check for updates
$latest_version_txt = fetch_latest_version();
if (preg_match('/^[0-9.]+\\|[0-9.]+\\|/', $latest_version_txt)) {
    list($latest_version, $earliest_version, $download_url) = explode('|', $latest_version_txt);
} else {
    // Cannot determine the latest version
    $latest_version = '';
}
// Delete old files (if we can).
$old_files = array();
foreach (old_paths() as $path) {
    if (file_exists($path)) {
        delete_recursively($path);
        // we may not have permission to delete.  Is it still there?
        if (file_exists($path)) {
示例#18
0
    private function adminPlaces()
    {
        require WT_ROOT . 'includes/functions/functions_edit.php';
        $action = WT_Filter::get('action');
        $parent = WT_Filter::get('parent');
        $inactive = WT_Filter::getBool('inactive');
        $deleteRecord = WT_Filter::get('deleteRecord');
        if (!isset($parent)) {
            $parent = 0;
        }
        $controller = new WT_Controller_Page();
        $controller->restrictAccess(Auth::isAdmin());
        if ($action == 'ExportFile' && Auth::isAdmin()) {
            Zend_Session::writeClose();
            $tmp = $this->placeIdToHierarchy($parent);
            $maxLevel = $this->getHighestLevel();
            if ($maxLevel > 8) {
                $maxLevel = 8;
            }
            $tmp[0] = 'places';
            $outputFileName = preg_replace('/[:;\\/\\\\(\\)\\{\\}\\[\\] $]/', '_', implode('-', $tmp)) . '.csv';
            header('Content-Type: application/octet-stream');
            header('Content-Disposition: attachment; filename="' . $outputFileName . '"');
            echo '"', WT_I18N::translate('Level'), '";"', WT_I18N::translate('Country'), '";';
            if ($maxLevel > 0) {
                echo '"', WT_I18N::translate('State'), '";';
            }
            if ($maxLevel > 1) {
                echo '"', WT_I18N::translate('County'), '";';
            }
            if ($maxLevel > 2) {
                echo '"', WT_I18N::translate('City'), '";';
            }
            if ($maxLevel > 3) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 4) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 5) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 6) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            if ($maxLevel > 7) {
                echo '"', WT_I18N::translate('Place'), '";';
            }
            echo '"', WT_I18N::translate('Longitude'), '";"', WT_I18N::translate('Latitude'), '";';
            echo '"', WT_I18N::translate('Zoom level'), '";"', WT_I18N::translate('Icon'), '";', WT_EOL;
            $this->outputLevel($parent);
            exit;
        }
        $controller->setPageTitle(WT_I18N::translate('Google Maps™'))->pageHeader();
        ?>
		<table id="gm_config">
			<tr>
				<th>
					<a href="module.php?mod=googlemap&amp;mod_action=admin_config">
						<?php 
        echo WT_I18N::translate('Google Maps™ preferences');
        ?>
					</a>
				</th>
				<th>
					<a class="current" href="module.php?mod=googlemap&amp;mod_action=admin_places">
						<?php 
        echo WT_I18N::translate('Geographic data');
        ?>
					</a>
				</th>
				<th>
					<a href="module.php?mod=googlemap&amp;mod_action=admin_placecheck">
						<?php 
        echo WT_I18N::translate('Place check');
        ?>
					</a>
				</th>
			</tr>
		</table>
		<?php 
        if ($action == 'ImportGedcom') {
            $placelist = array();
            $j = 0;
            $gedcom_records = WT_DB::prepare("SELECT i_gedcom FROM `##individuals` WHERE i_file=? UNION ALL SELECT f_gedcom FROM `##families` WHERE f_file=?")->execute(array(WT_GED_ID, WT_GED_ID))->fetchOneColumn();
            foreach ($gedcom_records as $gedrec) {
                $i = 1;
                $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i);
                while (!empty($placerec)) {
                    if (preg_match("/2 PLAC (.+)/", $placerec, $match)) {
                        $placelist[$j] = array();
                        $placelist[$j]['place'] = trim($match[1]);
                        if (preg_match("/4 LATI (.*)/", $placerec, $match)) {
                            $placelist[$j]['lati'] = trim($match[1]);
                            if ($placelist[$j]['lati'][0] != 'N' && $placelist[$j]['lati'][0] != 'S') {
                                if ($placelist[$j]['lati'] < 0) {
                                    $placelist[$j]['lati'][0] = 'S';
                                } else {
                                    $placelist[$j]['lati'] = 'N' . $placelist[$j]['lati'];
                                }
                            }
                        } else {
                            $placelist[$j]['lati'] = NULL;
                        }
                        if (preg_match("/4 LONG (.*)/", $placerec, $match)) {
                            $placelist[$j]['long'] = trim($match[1]);
                            if ($placelist[$j]['long'][0] != 'E' && $placelist[$j]['long'][0] != 'W') {
                                if ($placelist[$j]['long'] < 0) {
                                    $placelist[$j]['long'][0] = 'W';
                                } else {
                                    $placelist[$j]['long'] = 'E' . $placelist[$j]['long'];
                                }
                            }
                        } else {
                            $placelist[$j]['long'] = NULL;
                        }
                        $j = $j + 1;
                    }
                    $i = $i + 1;
                    $placerec = get_sub_record(2, '2 PLAC', $gedrec, $i);
                }
            }
            asort($placelist);
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $highestIndex = $this->getHighestIndex();
            $default_zoom_level = array(4, 7, 10, 12);
            foreach ($placelistUniq as $k => $place) {
                $parent = preg_split('/ *, */', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    if (!isset($default_zoom_level[$i])) {
                        $default_zoom_level[$i] = $default_zoom_level[$i - 1];
                    }
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ?")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if ($i < count($parent) - 1) {
                        // Create higher-level places, if necessary
                        if (empty($row)) {
                            $highestIndex++;
                            WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom) VALUES (?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $default_zoom_level[$i]));
                            echo WT_Filter::escapeHtml($escparent), '<br>';
                            $parent_id = $highestIndex;
                        } else {
                            $parent_id = $row->pl_id;
                        }
                    } else {
                        // Create lowest-level place, if necessary
                        if (empty($row->pl_id)) {
                            $highestIndex++;
                            WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom) VALUES (?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $default_zoom_level[$i]));
                            echo WT_Filter::escapeHtml($escparent), '<br>';
                        } else {
                            if (empty($row->pl_long) && empty($row->pl_lati) && $place['lati'] != '0' && $place['long'] != '0') {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $row->pl_id));
                                echo WT_Filter::escapeHtml($escparent), '<br>';
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action == 'ImportFile') {
            $placefiles = array();
            $this->findFiles(WT_MODULES_DIR . 'googlemap/extra');
            sort($placefiles);
            ?>
		<form method="post" enctype="multipart/form-data" id="importfile" name="importfile" action="module.php?mod=googlemap&amp;mod_action=admin_places&amp;action=ImportFile2">
			<table class="gm_plac_edit">
				<tr>
					<th><?php 
            echo WT_I18N::translate('File containing places (CSV)');
            ?>
</th>
					<td><input type="file" name="placesfile" size="50"></td>
				</tr>
				<?php 
            if (count($placefiles) > 0) {
                ?>
				<tr>
					<th><?php 
                echo WT_I18N::translate('Server file containing places (CSV)'), help_link('PLIF_LOCALFILE', 'googlemap');
                ?>
</th>
					<td>
						<select name="localfile">
							<option></option>
							<?php 
                foreach ($placefiles as $p => $placefile) {
                    ?>
							<option value="<?php 
                    echo WT_Filter::escapeHtml($placefile);
                    ?>
"><?php 
                    if (substr($placefile, 0, 1) == "/") {
                        echo substr($placefile, 1);
                    } else {
                        echo $placefile;
                    }
                    ?>
</option>
							<?php 
                }
                ?>
						</select>
					</td>
				</tr>
				<?php 
            }
            ?>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Delete all existing geographic data before importing the file.');
            ?>
</th>
					<td><input type="checkbox" name="cleardatabase"></td>
				</tr>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Do not create new locations, just import coordinates for existing locations.');
            ?>
</th>
					<td><input type="checkbox" name="updateonly"></td>
				</tr>
				<tr>
					<th><?php 
            echo WT_I18N::translate('Overwrite existing coordinates.');
            ?>
</th>
					<td><input type="checkbox" name="overwritedata"></td>
				</tr>
			</table>
			<input id="savebutton" type="submit" value="<?php 
            echo WT_I18N::translate('Continue adding');
            ?>
"><br>
		</form>
		<?php 
            exit;
        }
        if ($action == 'ImportFile2') {
            $country_names = array();
            foreach (WT_Stats::iso3166() as $key => $value) {
                $country_names[$key] = WT_I18N::translate($key);
            }
            if (isset($_POST['cleardatabase'])) {
                WT_DB::exec("DELETE FROM `##placelocation` WHERE 1=1");
            }
            if (!empty($_FILES['placesfile']['tmp_name'])) {
                $lines = file($_FILES['placesfile']['tmp_name']);
            } elseif (!empty($_REQUEST['localfile'])) {
                $lines = file(WT_MODULES_DIR . 'googlemap/extra' . $_REQUEST['localfile']);
            }
            // Strip BYTE-ORDER-MARK, if present
            if (!empty($lines[0]) && substr($lines[0], 0, 3) == WT_UTF8_BOM) {
                $lines[0] = substr($lines[0], 3);
            }
            asort($lines);
            $highestIndex = $this->getHighestIndex();
            $placelist = array();
            $j = 0;
            $maxLevel = 0;
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if ($fieldrec[0] > $maxLevel) {
                    $maxLevel = $fieldrec[0];
                }
            }
            $fields = count($fieldrec);
            $set_icon = true;
            if (!is_dir(WT_MODULES_DIR . 'googlemap/places/flags/')) {
                $set_icon = false;
            }
            foreach ($lines as $p => $placerec) {
                $fieldrec = explode(';', $placerec);
                if (is_numeric($fieldrec[0]) && $fieldrec[0] <= $maxLevel) {
                    $placelist[$j] = array();
                    $placelist[$j]['place'] = '';
                    for ($ii = $fields - 4; $ii > 1; $ii--) {
                        if ($fieldrec[0] > $ii - 2) {
                            $placelist[$j]['place'] .= $fieldrec[$ii] . ',';
                        }
                    }
                    foreach ($country_names as $countrycode => $countryname) {
                        if ($countrycode == strtoupper($fieldrec[1])) {
                            $fieldrec[1] = $countryname;
                            break;
                        }
                    }
                    $placelist[$j]['place'] .= $fieldrec[1];
                    $placelist[$j]['long'] = $fieldrec[$fields - 4];
                    $placelist[$j]['lati'] = $fieldrec[$fields - 3];
                    $placelist[$j]['zoom'] = $fieldrec[$fields - 2];
                    if ($set_icon) {
                        $placelist[$j]['icon'] = trim($fieldrec[$fields - 1]);
                    } else {
                        $placelist[$j]['icon'] = '';
                    }
                    $j = $j + 1;
                }
            }
            $prevPlace = '';
            $prevLati = '';
            $prevLong = '';
            $placelistUniq = array();
            $j = 0;
            foreach ($placelist as $k => $place) {
                if ($place['place'] != $prevPlace) {
                    $placelistUniq[$j] = array();
                    $placelistUniq[$j]['place'] = $place['place'];
                    $placelistUniq[$j]['lati'] = $place['lati'];
                    $placelistUniq[$j]['long'] = $place['long'];
                    $placelistUniq[$j]['zoom'] = $place['zoom'];
                    $placelistUniq[$j]['icon'] = $place['icon'];
                    $j = $j + 1;
                } elseif ($place['place'] == $prevPlace && ($place['lati'] != $prevLati || $place['long'] != $prevLong)) {
                    if ($placelistUniq[$j - 1]['lati'] == 0 || $placelistUniq[$j - 1]['long'] == 0) {
                        $placelistUniq[$j - 1]['lati'] = $place['lati'];
                        $placelistUniq[$j - 1]['long'] = $place['long'];
                        $placelistUniq[$j - 1]['zoom'] = $place['zoom'];
                        $placelistUniq[$j - 1]['icon'] = $place['icon'];
                    } elseif ($place['lati'] != '0' || $place['long'] != '0') {
                        echo 'Difference: previous value = ', $prevPlace, ', ', $prevLati, ', ', $prevLong, ' current = ', $place['place'], ', ', $place['lati'], ', ', $place['long'], '<br>';
                    }
                }
                $prevPlace = $place['place'];
                $prevLati = $place['lati'];
                $prevLong = $place['long'];
            }
            $default_zoom_level = array();
            $default_zoom_level[0] = 4;
            $default_zoom_level[1] = 7;
            $default_zoom_level[2] = 10;
            $default_zoom_level[3] = 12;
            foreach ($placelistUniq as $k => $place) {
                $parent = explode(',', $place['place']);
                $parent = array_reverse($parent);
                $parent_id = 0;
                for ($i = 0; $i < count($parent); $i++) {
                    $escparent = $parent[$i];
                    if ($escparent == '') {
                        $escparent = 'Unknown';
                    }
                    $row = WT_DB::prepare("SELECT pl_id, pl_long, pl_lati, pl_zoom, pl_icon FROM `##placelocation` WHERE pl_level=? AND pl_parent_id=? AND pl_place LIKE ? ORDER BY pl_place")->execute(array($i, $parent_id, $escparent))->fetchOneRow();
                    if (empty($row)) {
                        // this name does not yet exist: create entry
                        if (!isset($_POST['updateonly'])) {
                            $highestIndex = $highestIndex + 1;
                            if ($i + 1 == count($parent)) {
                                $zoomlevel = $place['zoom'];
                            } elseif (isset($default_zoom_level[$i])) {
                                $zoomlevel = $default_zoom_level[$i];
                            } else {
                                $zoomlevel = $this->getSetting('GM_MAX_ZOOM');
                            }
                            if ($place['lati'] == '0' || $place['long'] == '0' || $i + 1 < count($parent)) {
                                WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $zoomlevel, $place['icon']));
                            } else {
                                //delete leading zero
                                $pl_lati = str_replace(array('N', 'S', ','), array('', '-', '.'), $place['lati']);
                                $pl_long = str_replace(array('E', 'W', ','), array('', '-', '.'), $place['long']);
                                if ($pl_lati >= 0) {
                                    $place['lati'] = 'N' . abs($pl_lati);
                                } elseif ($pl_lati < 0) {
                                    $place['lati'] = 'S' . abs($pl_lati);
                                }
                                if ($pl_long >= 0) {
                                    $place['long'] = 'E' . abs($pl_long);
                                } elseif ($pl_long < 0) {
                                    $place['long'] = 'W' . abs($pl_long);
                                }
                                WT_DB::prepare("INSERT INTO `##placelocation` (pl_id, pl_parent_id, pl_level, pl_place, pl_long, pl_lati, pl_zoom, pl_icon) VALUES (?, ?, ?, ?, ?, ?, ?, ?)")->execute(array($highestIndex, $parent_id, $i, $escparent, $place['long'], $place['lati'], $zoomlevel, $place['icon']));
                            }
                            $parent_id = $highestIndex;
                        }
                    } else {
                        $parent_id = $row->pl_id;
                        if (isset($_POST['overwritedata']) && $i + 1 == count($parent)) {
                            WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=?, pl_zoom=?, pl_icon=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $place['zoom'], $place['icon'], $parent_id));
                        } else {
                            if (($row->pl_long == '0' || $row->pl_long == null) && ($row->pl_lati == '0' || $row->pl_lati == null)) {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_lati=?, pl_long=? WHERE pl_id=?")->execute(array($place['lati'], $place['long'], $parent_id));
                            }
                            if (empty($row->pl_icon) && !empty($place['icon'])) {
                                WT_DB::prepare("UPDATE `##placelocation` SET pl_icon=? WHERE pl_id=?")->execute(array($place['icon'], $parent_id));
                            }
                        }
                    }
                }
            }
            $parent = 0;
        }
        if ($action == 'DeleteRecord') {
            $exists = WT_DB::prepare("SELECT 1 FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($deleteRecord))->fetchOne();
            if (!$exists) {
                WT_DB::prepare("DELETE FROM `##placelocation` WHERE pl_id=?")->execute(array($deleteRecord));
            } else {
                echo '<table class="facts_table"><tr><td>', WT_I18N::translate('Location not removed: this location contains sub-locations'), '</td></tr></table>';
            }
        }
        ?>
		<script>
		function updateList(inactive) {
			window.location.href='<?php 
        if (strstr($_SERVER['REQUEST_URI'], '&inactive', true)) {
            $uri = strstr($_SERVER['REQUEST_URI'], '&inactive', true);
        } else {
            $uri = $_SERVER['REQUEST_URI'];
        }
        echo $uri, '&inactive=';
        ?>
'+inactive;
		}

		function edit_place_location(placeid) {
			window.open('module.php?mod=googlemap&mod_action=places_edit&action=update&placeid='+placeid, '_blank', gmap_window_specs);
			return false;
		}

		function add_place_location(placeid) {
			window.open('module.php?mod=googlemap&mod_action=places_edit&action=add&placeid='+placeid, '_blank', gmap_window_specs);
			return false;
		}

		function delete_place(placeid) {
			var answer=confirm('<?php 
        echo WT_I18N::translate('Remove this location?');
        ?>
');
			if (answer == true) {
				window.location = '<?php 
        echo $_SERVER['REQUEST_URI'];
        ?>
&action=DeleteRecord&deleteRecord=' + placeid;
			}
		}
		</script>
		<?php 
        echo '<div id="gm_breadcrumb">';
        $where_am_i = $this->placeIdToHierarchy($parent);
        foreach (array_reverse($where_am_i, true) as $id => $place) {
            if ($id == $parent) {
                if ($place != 'Unknown') {
                    echo WT_Filter::escapeHtml($place);
                } else {
                    echo WT_I18N::translate('unknown');
                }
            } else {
                echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $id, '&inactive=', $inactive, '">';
                if ($place != 'Unknown') {
                    echo WT_Filter::escapeHtml($place), '</a>';
                } else {
                    echo WT_I18N::translate('unknown'), '</a>';
                }
            }
            echo ' - ';
        }
        echo '<a href="module.php?mod=googlemap&mod_action=admin_places&parent=0&inactive=', $inactive, '">', WT_I18N::translate('Top level'), '</a></div>';
        echo '<form name="active" method="post" action="module.php?mod=googlemap&mod_action=admin_places&parent=', $parent, '&inactive=', $inactive, '"><div id="gm_active">';
        echo '<label for="inactive">', WT_I18N::translate('Show inactive places'), '</label>';
        echo '<input type="checkbox" name="inactive" id="inactive"';
        if ($inactive) {
            echo ' checked="checked"';
        }
        echo ' onclick="updateList(this.checked)"';
        echo '>', help_link('PLE_ACTIVE', 'googlemap'), '</div></form>';
        $placelist = $this->getPlaceListLocation($parent, $inactive);
        echo '<div class="gm_plac_edit">';
        echo '<table class="gm_plac_edit"><tr>';
        echo '<th>', WT_Gedcom_Tag::getLabel('PLAC'), '</th>';
        echo '<th>', WT_Gedcom_Tag::getLabel('LATI'), '</th>';
        echo '<th>', WT_Gedcom_Tag::getLabel('LONG'), '</th>';
        echo '<th>', WT_I18N::translate('Zoom level'), '</th>';
        echo '<th>', WT_I18N::translate('Icon'), '</th>';
        echo '<th>';
        echo WT_I18N::translate('Edit'), '</th><th>', WT_I18N::translate('Delete'), '</th></tr>';
        if (count($placelist) == 0) {
            echo '<tr><td colspan="7" class="accepted">', WT_I18N::translate('No places found'), '</td></tr>';
        }
        foreach ($placelist as $place) {
            echo '<tr><td><a href="module.php?mod=googlemap&mod_action=admin_places&parent=', $place['place_id'], '&inactive=', $inactive, '">';
            if ($place['place'] != 'Unknown') {
                echo WT_Filter::escapeHtml($place['place']), '</a></td>';
            } else {
                echo WT_I18N::translate('unknown'), '</a></td>';
            }
            echo '<td>', $place['lati'], '</td>';
            echo '<td>', $place['long'], '</td>';
            echo '<td>', $place['zoom'], '</td>';
            echo '<td>';
            if ($place['icon'] == NULL || $place['icon'] == '') {
                if ($place['lati'] == NULL || $place['long'] == NULL || $place['lati'] == '0' && $place['long'] == '0') {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_yellow.png">';
                } else {
                    echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/images/mm_20_red.png">';
                }
            } else {
                echo '<img src="', WT_STATIC_URL, WT_MODULES_DIR, 'googlemap/', $place['icon'], '" width="25" height="15">';
            }
            echo '</td>';
            echo '<td class="narrow"><a href="#" onclick="edit_place_location(', $place['place_id'], ');return false;" class="icon-edit" title="', WT_I18N::translate('Edit'), '"></a></td>';
            $noRows = WT_DB::prepare("SELECT COUNT(pl_id) FROM `##placelocation` WHERE pl_parent_id=?")->execute(array($place['place_id']))->fetchOne();
            if ($noRows == 0) {
                ?>
				<td><a href="#" onclick="delete_place(<?php 
                echo $place['place_id'];
                ?>
);return false;" class="icon-delete" title="<?php 
                echo WT_I18N::translate('Remove');
                ?>
"></a></td>
		<?php 
            } else {
                ?>
				<td><i class="icon-delete-grey"></i></td>
		<?php 
            }
            ?>
			</tr>
			<?php 
        }
        ?>
		</table>
		</div>

		<table id="gm_manage">
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Add  a new geographic location');
        ?>
				</td>
				<td>
					<form action="?" onsubmit="add_place_location(this.parent_id.options[this.parent_id.selectedIndex].value); return false;">
						<?php 
        echo select_edit_control('parent_id', $where_am_i, WT_I18N::translate('Top level'), $parent);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Add');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Import all places from a family tree');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ImportGedcom">
						<?php 
        echo select_edit_control('ged', WT_Tree::getNameList(), null, WT_GEDCOM);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Import');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Upload geographic data');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ImportFile">
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Upload');
        ?>
">
					</form>
				</td>
			</tr>
			<tr>
				<td>
					<?php 
        echo WT_I18N::translate('Download geographic data');
        ?>
				</td>
				<td>
					<form action="module.php" method="get">
						<input type="hidden" name="mod" value="googlemap">
						<input type="hidden" name="mod_action" value="admin_places">
						<input type="hidden" name="action" value="ExportFile">
						<?php 
        echo select_edit_control('parent', $where_am_i, WT_I18N::translate('All'), WT_GED_ID);
        ?>
						<input type="submit" value="<?php 
        echo WT_I18N::translate('Download');
        ?>
">
					</form>
				</td>
			</tr>
		</table>
		<?php 
    }
示例#19
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_merge.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isManager())->setPageTitle(WT_I18N::translate('Merge records'))->addExternalJavascript(WT_STATIC_URL . 'js/autocomplete.js')->addInlineJavascript('autocomplete();')->pageHeader();
require_once WT_ROOT . 'includes/functions/functions_edit.php';
$ged = $GEDCOM;
$gid1 = WT_Filter::post('gid1', WT_REGEX_XREF);
$gid2 = WT_Filter::post('gid2', WT_REGEX_XREF);
$action = WT_Filter::post('action', 'choose|select|merge', 'choose');
$ged1 = WT_Filter::post('ged1', null, $ged);
$ged2 = WT_Filter::post('ged2', null, $ged);
$keep1 = WT_Filter::postArray('keep1');
$keep2 = WT_Filter::postArray('keep2');
if ($action != 'choose') {
    if ($gid1 == $gid2 && $ged1 == $ged2) {
        $action = 'choose';
        echo '<span class="error">', WT_I18N::translate('You entered the same IDs.  You cannot merge the same records.'), '</span>';
    } else {
        $rec1 = WT_GedcomRecord::getInstance($gid1, WT_Tree::getIdFromName($ged1));
示例#20
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_users_bulk.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Send broadcast messages'))->pageHeader();
?>
<div id="users_bulk">
	<p>
		<a href="#" onclick="message('all', 'messaging2', ''); return false;">
			<?php 
echo WT_I18N::translate('Send message to all users');
?>
		</a>
	</p>
	<p>
		<a href="#" onclick="message('never_logged', 'messaging2', ''); return false;">
			<?php 
echo WT_I18N::translate('Send message to users who have never logged in');
?>
		</a>
示例#21
0
    if (array_key_exists($module_name, $all_blocks)) {
        $class_name = $module_name . '_WT_Module';
        $module = new $class_name();
        $module->getBlock($block_id);
    }
    if (WT_DEBUG) {
        echo execution_stats();
    }
    if (WT_DEBUG_SQL) {
        echo WT_DB::getQueryLog();
    }
    exit;
}
$controller = new WT_Controller_Page();
if ($ctype == 'user') {
    $controller->restrictAccess(Auth::isMember());
}
$controller->setPageTitle($ctype == 'user' ? WT_I18N::translate('My page') : WT_TREE_TITLE)->setMetaRobots('index,follow')->setCanonicalUrl(WT_SCRIPT_NAME . '?ctype=' . $ctype . '&amp;ged=' . WT_GEDCOM)->pageHeader()->addInlineJavascript('jQuery.ajaxSetup({cache:true});');
if ($ctype == 'user') {
    echo '<div id="my-page">';
    echo '<h1 class="center">', WT_I18N::translate('My page'), '</h1>';
} else {
    echo '<div id="home-page">';
}
if ($blocks['main']) {
    if ($blocks['side']) {
        echo '<div id="index_main_blocks">';
    } else {
        echo '<div id="index_full_blocks">';
    }
    foreach ($blocks['main'] as $block_id => $module_name) {
示例#22
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_clean.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Clean up data folder'))->pageHeader();
require WT_ROOT . 'includes/functions/functions_edit.php';
function full_rmdir($dir)
{
    if (!is_writable($dir)) {
        if (!@chmod($dir, WT_PERM_EXE)) {
            return false;
        }
    }
    $d = dir($dir);
    while (false !== ($entry = $d->read())) {
        if ($entry == '.' || $entry == '..') {
            continue;
        }
        $entry = $dir . '/' . $entry;
        if (is_dir($entry)) {
示例#23
0
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\User;
define('WT_SCRIPT_NAME', 'admin_trees_manage.php');
require './includes/session.php';
require WT_ROOT . 'includes/functions/functions_edit.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Family trees'));
// Don’t allow the user to cancel the request.  We do not want to be left
// with an incomplete transaction.
ignore_user_abort(true);
// $path is the full path to the (possibly temporary) file.
// $filename is the actual filename (no folder).
function import_gedcom_file($gedcom_id, $path, $filename)
{
    // Read the file in blocks of roughly 64K.  Ensure that each block
    // contains complete gedcom records.  This will ensure we don’t split
    // multi-byte characters, as well as simplifying the code to import
    // each block.
    $file_data = '';
    $fp = fopen($path, 'rb');
    WT_DB::exec("START TRANSACTION");
    WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id=?")->execute(array($gedcom_id));
示例#24
0
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
use WT\Log;
use WT\User;
define('WT_SCRIPT_NAME', 'admin_users.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('User administration'));
require_once WT_ROOT . 'includes/functions/functions_edit.php';
// Valid values for form variables
$ALL_THEMES_DIRS = array();
foreach (get_theme_names() as $themename => $themedir) {
    $ALL_THEME_DIRS[] = $themedir;
}
$ALL_EDIT_OPTIONS = array('none' => WT_I18N::translate('Visitor'), 'access' => WT_I18N::translate('Member'), 'edit' => WT_I18N::translate('Editor'), 'accept' => WT_I18N::translate('Moderator'), 'admin' => WT_I18N::translate('Manager'));
// Form actions
$action = WT_Filter::get('action', null, 'listusers');
$usrlang = WT_Filter::post('usrlang', implode('|', array_keys(WT_I18N::installed_languages())), WT_LOCALE);
$username = WT_Filter::post('username', WT_REGEX_USERNAME);
$filter = WT_Filter::post('filter');
$ged = WT_Filter::post('ged');
// Extract form variables
$realname = WT_Filter::post('realname');
示例#25
0
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
use WT\Auth;
define('WT_SCRIPT_NAME', 'admin_site_info.php');
require './includes/session.php';
$controller = new WT_Controller_Page();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('PHP information'))->pageHeader();
ob_start();
phpinfo();
$php_info = ob_get_contents();
ob_end_clean();
$php_info = str_replace(" width=\"600\"", " width=\"\"", $php_info);
$php_info = str_replace("</body></html>", "", $php_info);
$php_info = str_replace("<table", "<table class=\"php_info ltr\"", $php_info);
$php_info = str_replace("td class=\"e\"", "td", $php_info);
$php_info = str_replace("td class=\"v\"", "td", $php_info);
$php_info = str_replace("tr class=\"v\"", "tr", $php_info);
$php_info = str_replace("tr class=\"h\"", "tr", $php_info);
$php_info = str_replace(";", "; ", $php_info);
$php_info = str_replace(",", ", ", $php_info);
// Put logo in table header
$logo_offset = strpos($php_info, "<td>");