Ejemplo n.º 1
0
 /**
  * Manage updates sent from the AdminConfig@index form.
  */
 protected function update()
 {
     if (Auth::isAdmin()) {
         $this->module->setSetting('MAJ_SHOW_CERT', Filter::post('MAJ_SHOW_CERT'));
         $this->module->setSetting('MAJ_SHOW_NO_WATERMARK', Filter::post('MAJ_SHOW_NO_WATERMARK'));
         if ($MAJ_WM_DEFAULT = Filter::post('MAJ_WM_DEFAULT')) {
             $this->module->setSetting('MAJ_WM_DEFAULT', $MAJ_WM_DEFAULT);
         }
         if ($MAJ_WM_FONT_MAXSIZE = Filter::postInteger('MAJ_WM_FONT_MAXSIZE')) {
             $this->module->setSetting('MAJ_WM_FONT_MAXSIZE', $MAJ_WM_FONT_MAXSIZE);
         }
         // Only accept valid color for MAJ_WM_FONT_COLOR
         $MAJ_WM_FONT_COLOR = Filter::post('MAJ_WM_FONT_COLOR', '#([a-fA-F0-9]{3}){1,2}');
         if ($MAJ_WM_FONT_COLOR) {
             $this->module->setSetting('MAJ_WM_FONT_COLOR', $MAJ_WM_FONT_COLOR);
         }
         // Only accept valid folders for MAJ_CERT_ROOTDIR
         $MAJ_CERT_ROOTDIR = preg_replace('/[\\/\\\\]+/', '/', Filter::post('MAJ_CERT_ROOTDIR') . '/');
         if (substr($MAJ_CERT_ROOTDIR, 0, 1) === '/') {
             $MAJ_CERT_ROOTDIR = substr($MAJ_CERT_ROOTDIR, 1);
         }
         if ($MAJ_CERT_ROOTDIR) {
             if (is_dir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
             } elseif (File::mkdir(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)) {
                 $this->module->setSetting('MAJ_CERT_ROOTDIR', $MAJ_CERT_ROOTDIR);
                 FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'info');
             } else {
                 FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MAJ_CERT_ROOTDIR)), 'danger');
             }
         }
         FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
         return;
     }
 }
Ejemplo n.º 2
0
 /** {@inheritdoc} */
 public function bodyHeaderPopupWindow()
 {
     if (Filter::get('action') === 'addnewnote_assisted') {
         $class = 'class="census-assistant"';
     } else {
         $class = '';
     }
     return '<body class="container container-popup">' . '<main id="content"' . $class . '">' . $this->flashMessagesContainer(FlashMessages::getMessages());
 }
Ejemplo n.º 3
0
 /**
  * This is a general purpose hook, allowing modules to respond to routes
  * of the form module.php?mod=FOO&mod_action=BAR
  *
  * @param string $mod_action
  */
 public function modAction($mod_action)
 {
     global $WT_TREE;
     switch ($mod_action) {
         case 'menu-add-favorite':
             // Process the "add to user favorites" menu item on indi/fam/etc. pages
             $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
             if (Auth::check() && $record->canShowName()) {
                 self::addFavorite(array('user_id' => Auth::id(), 'gedcom_id' => $record->getTree()->getTreeId(), 'gid' => $record->getXref(), 'type' => $record::RECORD_TYPE, 'url' => null, 'note' => null, 'title' => null));
                 FlashMessages::addMessage(I18N::translate('“%s” has been added to your favorites.', $record->getFullName()));
             }
             break;
     }
 }
Ejemplo n.º 4
0
 /**
  * Manage updates sent from the AdminConfig@index form.
  */
 protected function update()
 {
     global $WT_TREE;
     if (Auth::isAdmin()) {
         $this->module->setSetting('MAJ_TITLE_PREFIX', Filter::post('MAJ_TITLE_PREFIX'));
         $this->module->setSetting('MAJ_ADD_HTML_HEADER', Filter::postInteger('MAJ_ADD_HTML_HEADER', 0, 1));
         $this->module->setSetting('MAJ_SHOW_HTML_HEADER', Filter::postInteger('MAJ_SHOW_HTML_HEADER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE));
         $this->module->setSetting('MAJ_HTML_HEADER', Filter::post('MAJ_HTML_HEADER'));
         $this->module->setSetting('MAJ_ADD_HTML_FOOTER', Filter::postInteger('MAJ_ADD_HTML_FOOTER', 0, 1));
         $this->module->setSetting('MAJ_SHOW_HTML_FOOTER', Filter::postInteger('MAJ_SHOW_HTML_FOOTER', Auth::PRIV_HIDE, Auth::PRIV_PRIVATE, Auth::PRIV_HIDE));
         $this->module->setSetting('MAJ_HTML_FOOTER', Filter::post('MAJ_HTML_FOOTER'));
         $this->module->setSetting('MAJ_DISPLAY_CNIL', Filter::postInteger('MAJ_DISPLAY_CNIL', 0, 1));
         $this->module->setSetting('MAJ_CNIL_REFERENCE', Filter::post('MAJ_CNIL_REFERENCE'));
         FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->module->getTitle()), 'success');
         return;
     }
 }
Ejemplo n.º 5
0
 /**
  * Startup activity
  *
  * @param GedcomRecord|null $record
  */
 public function __construct(GedcomRecord $record = null)
 {
     $this->record = $record;
     // Automatically fix broken links
     if ($this->record && $this->record->canEdit()) {
         $broken_links = 0;
         foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
             if (!$fact->isPendingDeletion() && $fact->getTarget() === null) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
             // These can be links or inline. Only delete links.
             if (!$fact->isPendingDeletion() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 FlashMessages::addMessage(I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         if ($broken_links) {
             // Reload the updated family
             $this->record = GedcomRecord::getInstance($this->record->getXref(), $this->record->getTree());
         }
     }
     parent::__construct();
     // We want robots to index this page
     $this->setMetaRobots('index,follow');
     // Set a page title
     if ($this->record) {
         if ($this->record->canShowName()) {
             // e.g. "John Doe" or "1881 Census of Wales"
             $this->setPageTitle($this->record->getFullName());
         } else {
             // e.g. "Individual" or "Source"
             $record = $this->record;
             $this->setPageTitle(GedcomTag::getLabel($record::RECORD_TYPE));
         }
     } else {
         // No such record
         $this->setPageTitle(I18N::translate('Private'));
     }
 }
Ejemplo n.º 6
0
 /**
  * Saves Sosa's user preferences (root individual for the user).
  * 
  * @param BaseController $controller
  * @return bool True is saving successfull
  */
 protected function update(BaseController $controller)
 {
     global $WT_TREE;
     if ($this->canUpdate() && Filter::checkCsrf()) {
         $indi = Individual::getInstance(Filter::post('rootid'), $WT_TREE);
         $user = User::find(Filter::postInteger('userid', -1));
         if ($user && $indi) {
             $WT_TREE->setUserPreference($user, 'MAJ_SOSA_ROOT_ID', $indi->getXref());
             $controller->addInlineJavascript('
                 $( document ).ready(function() {
                     majComputeSosa(' . $user->getUserId() . ');
                 });');
             FlashMessages::addMessage(I18N::translate('The preferences have been updated.'));
             return true;
         }
     }
     FlashMessages::addMessage(I18N::translate('An error occurred while saving data...'), 'danger');
     return false;
 }
Ejemplo n.º 7
0
 $timezone = Filter::post('timezone');
 $contact_method = Filter::post('contact_method');
 $comment = Filter::post('comment');
 $auto_accept = Filter::postBool('auto_accept');
 $canadmin = Filter::postBool('canadmin');
 $visible_online = Filter::postBool('visible_online');
 $verified = Filter::postBool('verified');
 $approved = Filter::postBool('approved');
 if ($user_id === 0) {
     // Create a new user
     if (User::findByUserName($username)) {
         FlashMessages::addMessage(I18N::translate('Duplicate username. A user with that username already exists. Please choose another username.'));
     } elseif (User::findByEmail($email)) {
         FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
     } elseif ($pass1 !== $pass2) {
         FlashMessages::addMessage(I18N::translate('The passwords do not match.'));
     } else {
         $user = User::create($username, $real_name, $email, $pass1);
         $user->setPreference('reg_timestamp', date('U'))->setPreference('sessiontime', '0');
         Log::addAuthenticationLog('User ->' . $username . '<- created');
     }
 } else {
     $user = User::find($user_id);
     if ($user && $username && $real_name) {
         $user->setEmail($email);
         $user->setUserName($username);
         $user->setRealName($real_name);
         if ($pass1 !== null && $pass1 === $pass2) {
             $user->setPassword($pass1);
         }
     }
Ejemplo n.º 8
0
    /**
     * A form to edit the module configuration.
     */
    private function config()
    {
        $controller = new PageController();
        $controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Google Maps™'));
        if (Filter::post('action') === 'update') {
            $this->setSetting('GM_MAP_TYPE', Filter::post('GM_MAP_TYPE'));
            $this->setSetting('GM_USE_STREETVIEW', Filter::post('GM_USE_STREETVIEW'));
            $this->setSetting('GM_MIN_ZOOM', Filter::post('GM_MIN_ZOOM'));
            $this->setSetting('GM_MAX_ZOOM', Filter::post('GM_MAX_ZOOM'));
            $this->setSetting('GM_XSIZE', Filter::post('GM_XSIZE'));
            $this->setSetting('GM_YSIZE', Filter::post('GM_YSIZE'));
            $this->setSetting('GM_PRECISION_0', Filter::post('GM_PRECISION_0'));
            $this->setSetting('GM_PRECISION_1', Filter::post('GM_PRECISION_1'));
            $this->setSetting('GM_PRECISION_2', Filter::post('GM_PRECISION_2'));
            $this->setSetting('GM_PRECISION_3', Filter::post('GM_PRECISION_3'));
            $this->setSetting('GM_PRECISION_4', Filter::post('GM_PRECISION_4'));
            $this->setSetting('GM_PRECISION_5', Filter::post('GM_PRECISION_5'));
            $this->setSetting('GM_COORD', Filter::post('GM_COORD'));
            $this->setSetting('GM_PLACE_HIERARCHY', Filter::post('GM_PLACE_HIERARCHY'));
            $this->setSetting('GM_PH_XSIZE', Filter::post('GM_PH_XSIZE'));
            $this->setSetting('GM_PH_YSIZE', Filter::post('GM_PH_YSIZE'));
            $this->setSetting('GM_PH_MARKER', Filter::post('GM_PH_MARKER'));
            $this->setSetting('GM_PREFIX_1', Filter::post('GM_PREFIX_1'));
            $this->setSetting('GM_PREFIX_2', Filter::post('GM_PREFIX_2'));
            $this->setSetting('GM_PREFIX_3', Filter::post('GM_PREFIX_3'));
            $this->setSetting('GM_PREFIX_4', Filter::post('GM_PREFIX_4'));
            $this->setSetting('GM_PREFIX_5', Filter::post('GM_PREFIX_5'));
            $this->setSetting('GM_PREFIX_6', Filter::post('GM_PREFIX_6'));
            $this->setSetting('GM_PREFIX_7', Filter::post('GM_PREFIX_7'));
            $this->setSetting('GM_PREFIX_8', Filter::post('GM_PREFIX_8'));
            $this->setSetting('GM_PREFIX_9', Filter::post('GM_PREFIX_9'));
            $this->setSetting('GM_POSTFIX_1', Filter::post('GM_POSTFIX_1'));
            $this->setSetting('GM_POSTFIX_2', Filter::post('GM_POSTFIX_2'));
            $this->setSetting('GM_POSTFIX_3', Filter::post('GM_POSTFIX_3'));
            $this->setSetting('GM_POSTFIX_4', Filter::post('GM_POSTFIX_4'));
            $this->setSetting('GM_POSTFIX_5', Filter::post('GM_POSTFIX_5'));
            $this->setSetting('GM_POSTFIX_6', Filter::post('GM_POSTFIX_6'));
            $this->setSetting('GM_POSTFIX_7', Filter::post('GM_POSTFIX_7'));
            $this->setSetting('GM_POSTFIX_8', Filter::post('GM_POSTFIX_8'));
            $this->setSetting('GM_POSTFIX_9', Filter::post('GM_POSTFIX_9'));
            FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been updated.', $this->getName()), 'success');
            header('Location: ' . WT_BASE_URL . 'module.php?mod=googlemap&mod_action=admin_config');
            return;
        }
        $controller->pageHeader();
        ?>
		<ol class="breadcrumb small">
			<li><a href="admin.php"><?php 
        echo I18N::translate('Control panel');
        ?>
</a></li>
			<li><a href="admin_modules.php"><?php 
        echo I18N::translate('Module administration');
        ?>
</a></li>
			<li class="active"><?php 
        echo $controller->getPageTitle();
        ?>
</li>
		</ol>

		<ul class="nav nav-tabs nav-justified" role="tablist">
			<li role="presentation" class="active">
				<a href="#" role="tab">
					<?php 
        echo I18N::translate('Google Maps™ preferences');
        ?>
				</a>
			</li>
			<li role="presentation">
				<a href="?mod=googlemap&amp;mod_action=admin_places">
					<?php 
        echo I18N::translate('Geographic data');
        ?>
				</a>
			</li>
			<li role="presentation">
				<a href="?mod=googlemap&amp;mod_action=admin_placecheck">
					<?php 
        echo I18N::translate('Place check');
        ?>
				</a>
			</li>
		</ul>

		<h2><?php 
        echo I18N::translate('Google Maps™ preferences');
        ?>
</h2>

		<form class="form-horizontal" method="post" name="configform" action="module.php?mod=googlemap&mod_action=admin_config">
			<input type="hidden" name="action" value="update">
			<h3><?php 
        echo I18N::translate('Basic');
        ?>
</h3>

			<!-- GM_MAP_TYPE -->
			<div class="form-group">
				<label class="control-label col-sm-3" for="GM_MAP_TYPE">
					<?php 
        echo I18N::translate('Default map type');
        ?>
				</label>
				<div class="col-sm-9">
					<?php 
        $options = array('ROADMAP' => I18N::translate('Map'), 'SATELLITE' => I18N::translate('Satellite'), 'HYBRID' => I18N::translate('Hybrid'), 'TERRAIN' => I18N::translate('Terrain'));
        echo FunctionsEdit::selectEditControl('GM_MAP_TYPE', $options, null, $this->getSetting('GM_MAP_TYPE'), 'class="form-control"');
        ?>
				</div>
			</div>

			<!-- GM_USE_STREETVIEW -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Google Street View™');
        ?>
				</legend>
				<div class="col-sm-9">
					<?php 
        echo FunctionsEdit::radioButtons('GM_USE_STREETVIEW', array(false => I18N::translate('hide'), true => I18N::translate('show')), $this->getSetting('GM_USE_STREETVIEW'), 'class="radio-inline"');
        ?>
				</div>
			</fieldset>

			<!-- GM_XSIZE / GM_YSIZE -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Size of map (in pixels)');
        ?>
				</legend>
				<div class="col-sm-9">
					<div class="row">
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_XSIZE"><?php 
        echo I18N::translate('Width');
        ?>
</label>
								<input id="GM_XSIZE" class="form-control" type="text" name="GM_XSIZE" value="<?php 
        echo $this->getSetting('GM_XSIZE');
        ?>
">
							</div>
						</div>
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_YSIZE"><?php 
        echo I18N::translate('Height');
        ?>
</label>
								<input id="GM_YSIZE" class="form-control" type="text" name="GM_YSIZE" value="<?php 
        echo $this->getSetting('GM_YSIZE');
        ?>
">
							</div>
						</div>
					</div>
				</div>
			</fieldset>

			<!-- GM_MIN_ZOOM / GM_MAX_ZOOM -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Zoom level of map');
        ?>
				</legend>
				<div class="col-sm-9">
					<div class="row">
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_MIN_ZOOM"><?php 
        echo I18N::translate('minimum');
        ?>
</label>
								<?php 
        echo FunctionsEdit::selectEditControl('GM_MIN_ZOOM', array_combine(range(1, 14), range(1, 14)), null, $this->getSetting('GM_MIN_ZOOM'), 'class="form-control"');
        ?>
							</div>
						</div>
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_MAX_ZOOM"><?php 
        echo I18N::translate('maximum');
        ?>
</label>
								<?php 
        echo FunctionsEdit::selectEditControl('GM_MAX_ZOOM', array_combine(range(1, 20), range(1, 20)), null, $this->getSetting('GM_MAX_ZOOM'), 'class="form-control"');
        ?>
							</div>
						</div>
					</div>
					<p class="small text-muted"><?php 
        echo I18N::translate('Minimum and maximum zoom level for the Google map.  1 is the full map, 15 is single house.  Note that 15 is only available in certain areas.');
        ?>
</p>
				</div>
			</fieldset>

			<h3><?php 
        echo I18N::translate('Advanced');
        ?>
</h3>

			<!-- GM_PRECISION -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Precision of the latitude and longitude');
        ?>
				</legend>
				<div class="col-sm-9">
					<div class="row">
						<?php 
        foreach (array(I18N::translate('Country'), I18N::translate('State'), I18N::translate('City'), I18N::translate('Neighborhood'), I18N::translate('House'), I18N::translate('Max')) as $level => $label) {
            ?>
						<div class="col-sm-4">
							<div class="input-group">
								<label class="input-group-addon" for="GM_PRECISION_<?php 
            echo $level;
            ?>
"><?php 
            echo $label;
            ?>
</label>
								<?php 
            echo FunctionsEdit::selectEditControl('GM_PRECISION_' . $level, range(0, 9), null, $this->getSetting('GM_PRECISION_' . $level), 'class="form-control"');
            ?>
							</div>
						</div>
						<?php 
        }
        ?>
					</div>
					<p class="small text-muted"><?php 
        echo I18N::translate('This specifies the precision of the different levels when entering new geographic locations.  For example a country will be specified with precision 0 (=0 digits after the decimal point), while a town needs 3 or 4 digits.');
        ?>
</p>
				</div>
			</fieldset>

			<!-- GM_PREFIX / GM_POSTFIX -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Optional prefixes and suffixes');
        ?>
				</legend>
				<div class="col-sm-9">
					<div class="row">
						<div class ="col-sm-6">
							<p class="form-control-static"><strong><?php 
        echo I18N::translate('Prefixes');
        ?>
</strong></p>
							<?php 
        for ($level = 1; $level < 10; $level++) {
            ?>
							<?php 
            if ($level == 1) {
                $label = I18N::translate('Country');
            } else {
                $label = I18N::translate('Level') . ' ' . $level;
            }
            ?>
							<div class="input-group">
								<label class="input-group-addon" for="GM_PREFIX_<?php 
            echo $level;
            ?>
"><?php 
            echo $label;
            ?>
</label>
								<input class="form-control" type="text" name="GM_PREFIX_<?php 
            echo $level;
            ?>
" value="<?php 
            echo $this->getSetting('GM_PREFIX_' . $level);
            ?>
">
							</div>
							<?php 
        }
        ?>
						</div>
						<div class="col-sm-6">
							<p class="form-control-static"><strong><?php 
        echo I18N::translate('Suffixes');
        ?>
</strong></p>
							<?php 
        for ($level = 1; $level < 10; $level++) {
            ?>
							<?php 
            if ($level == 1) {
                $label = I18N::translate('Country');
            } else {
                $label = I18N::translate('Level') . ' ' . $level;
            }
            ?>
							<div class="input-group">
								<label class="input-group-addon" for="GM_POSTFIX_<?php 
            echo $level;
            ?>
"><?php 
            echo $label;
            ?>
</label>
								<input class="form-control" type="text" name="GM_POSTFIX_<?php 
            echo $level;
            ?>
" value="<?php 
            echo $this->getSetting('GM_POSTFIX_' . $level);
            ?>
">
							</div>
							<?php 
        }
        ?>
						</div>
					</div>
					<p class="small text-muted"><?php 
        echo I18N::translate('Some place names may be written with optional prefixes and suffixes.  For example “Orange” versus “Orange County”.  If the family tree contains the full place names, but the geographic database contains the short place names, then you should specify a list of the prefixes and suffixes to be disregarded.  Multiple options should be separated with semicolons.  For example “County;County of” or “Township;Twp;Twp.”.');
        ?>
</p>
				</div>
			</fieldset>

			<h3><?php 
        echo I18N::translate('Place hierarchy');
        ?>
</h3>

			<!-- GM_PLACE_HIERARCHY -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Use Google Maps™ for the place hierarchy');
        ?>
				</legend>
				<div class="col-sm-9">
					<?php 
        echo FunctionsEdit::editFieldYesNo('GM_PLACE_HIERARCHY', $this->getSetting('GM_PLACE_HIERARCHY'), 'class="radio-inline"');
        ?>
				</div>
			</fieldset>

			<!-- GM_PH_XSIZE / GM_PH_YSIZE -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Size of map (in pixels)');
        ?>
				</legend>
				<div class="col-sm-9">
					<div class="row">
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_PH_XSIZE"><?php 
        echo I18N::translate('Width');
        ?>
</label>
								<input id="GM_XSIZE" class="form-control" type="text" name="GM_PH_XSIZE" value="<?php 
        echo $this->getSetting('GM_PH_XSIZE');
        ?>
">
							</div>
						</div>
						<div class="col-sm-6">
							<div class="input-group">
								<label class="input-group-addon" for="GM_PH_YSIZE"><?php 
        echo I18N::translate('Height');
        ?>
</label>
								<input id="GM_YSIZE" class="form-control" type="text" name="GM_PH_YSIZE" value="<?php 
        echo $this->getSetting('GM_PH_YSIZE');
        ?>
">
							</div>
						</div>
					</div>
				</div>
			</fieldset>

			<!-- GM_PH_MARKER -->
			<div class="form-group">
				<label class="control-label col-sm-3" for="GM_PH_MARKER">
					<?php 
        echo I18N::translate('Type of place markers in Place Hierarchy');
        ?>
				</label>
				<div class="col-sm-9">
					<?php 
        $ph_options = array('G_DEFAULT_ICON' => I18N::translate('Standard'), 'G_FLAG' => I18N::translate('Flag'));
        echo FunctionsEdit::selectEditControl('GM_PH_MARKER', $ph_options, null, $this->getSetting('GM_PH_MARKER'), 'class="form-control"');
        ?>
				</div>
			</div>

			<!-- GM_COORD -->
			<fieldset class="form-group">
				<legend class="control-label col-sm-3">
					<?php 
        echo I18N::translate('Display map coordinates');
        ?>
				</legend>
				<div class="col-sm-9">
					<?php 
        echo FunctionsEdit::editFieldYesNo('GM_COORD', $this->getSetting('GM_COORD'), 'class="radio-inline"');
        ?>
					<p class="small text-muted">
						<?php 
        echo I18N::translate('This options sets whether latitude and longitude are displayed on the pop-up window attached to map markers.');
        ?>
					</p>
				</div>
			</fieldset>

			<!-- SAVE BUTTON -->
			<div class="form-group">
				<div class="col-sm-offset-3 col-sm-9">
					<button type="submit" class="btn btn-primary">
						<i class="fa fa-check"></i>
						<?php 
        echo I18N::translate('save');
        ?>
					</button>
				</div>
			</div>
		</form>
		<?php 
    }
Ejemplo n.º 9
0
        if (Filter::checkCsrf()) {
            Site::setPreference('BING_WEBMASTER_ID', Filter::post('BING_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_WEBMASTER_ID', Filter::post('GOOGLE_WEBMASTER_ID'));
            Site::setPreference('GOOGLE_ANALYTICS_ID', Filter::post('GOOGLE_ANALYTICS_ID'));
            Site::setPreference('PIWIK_URL', Filter::post('PIWIK_URL'));
            Site::setPreference('PIWIK_SITE_ID', Filter::post('PIWIK_SITE_ID'));
            Site::setPreference('STATCOUNTER_PROJECT_ID', Filter::post('STATCOUNTER_PROJECT_ID'));
            Site::setPreference('STATCOUNTER_SECURITY_ID', Filter::post('STATCOUNTER_SECURITY_ID'));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
    case 'languages':
        if (Filter::checkCsrf()) {
            Site::setPreference('LANGUAGES', implode(',', Filter::postArray('LANGUAGES')));
            FlashMessages::addMessage(I18N::translate('The website preferences have been updated.'), 'success');
        }
        header('Location: ' . WT_BASE_URL . 'admin.php');
        return;
}
// Lists of options for <select> controls.
$SMTP_SSL_OPTIONS = array('none' => I18N::translate('none'), 'ssl' => I18N::translate('ssl'), 'tls' => I18N::translate('tls'));
$SMTP_ACTIVE_OPTIONS = array('internal' => I18N::translate('Use PHP mail to send messages'), 'external' => I18N::translate('Use SMTP to send messages'));
$WELCOME_TEXT_AUTH_MODE_OPTIONS = array(0 => I18N::translate('No predefined text'), 1 => I18N::translate('Predefined text that states all users can request a user account'), 2 => I18N::translate('Predefined text that states admin will decide on each request for a user account'), 3 => I18N::translate('Predefined text that states only family members can request a user account'), 4 => I18N::translate('Choose user defined welcome text typed below'));
$language_tags = array();
foreach (I18N::activeLocales() as $active_locale) {
    $language_tags[] = $active_locale->languageTag();
}
switch (Filter::get('action')) {
    case 'site':
        $controller->setPageTitle(I18N::translate('Website preferences'));
Ejemplo n.º 10
0
		<div class="form-group">
			<div class="col-sm-offset-3 col-sm-9">
				<button type="submit" class="btn btn-primary">
					<?php 
        echo I18N::translate('continue');
        ?>
				</button>
			</div>
		</div>
	</form>
	<?php 
        return;
}
if (!Tree::getAll()) {
    FlashMessages::addMessage(I18N::translate('You need to create a family tree.'), 'info');
}
$controller->pageHeader();
$all_trees = Tree::getAll();
// On sites with hundreds or thousands of trees, this page becomes very large.
// Just show the current tree, the default tree, and unimported trees
if (count($all_trees) >= $multiple_tree_threshold) {
    $all_trees = array_filter($all_trees, function (Tree $x) use($WT_TREE) {
        return $x->getPreference('imported') === '0' || $WT_TREE->getTreeId() === $x->getTreeId() || $x->getName() === Site::getPreference('DEFAULT_GEDCOM');
    });
}
// List the gedcoms available to this user
?>
<ol class="breadcrumb small">
	<li><a href="admin.php"><?php 
echo I18N::translate('Control panel');
Ejemplo n.º 11
0
                $WT_TREE->setPreference('MEDIA_DIRECTORY', $MEDIA_DIRECTORY);
                FlashMessages::addMessage(I18N::translate('The folder %s has been created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'info');
            } else {
                FlashMessages::addMessage(I18N::translate('The folder %s does not exist, and it could not be created.', Html::filename(WT_DATA_DIR . $MEDIA_DIRECTORY)), 'danger');
            }
        }
        $gedcom = Filter::post('gedcom');
        if ($gedcom && $gedcom !== $WT_TREE->getName()) {
            try {
                Database::prepare("UPDATE `##gedcom` SET gedcom_name = ? WHERE gedcom_id = ?")->execute(array($gedcom, $WT_TREE->getTreeId()));
                Database::prepare("UPDATE `##site_setting` SET setting_value = ? WHERE setting_name='DEFAULT_GEDCOM' AND setting_value = ?")->execute(array($gedcom, $WT_TREE->getName()));
            } catch (\Exception $ex) {
                // Probably a duplicate name.
            }
        }
        FlashMessages::addMessage(I18N::translate('The preferences for the family tree “%s” have been updated.', $WT_TREE->getTitleHtml()), 'success');
        header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
        return;
}
switch (Filter::get('action')) {
    case 'privacy':
        $controller->setPageTitle($WT_TREE->getTitleHtml() . ' — ' . I18N::translate('Privacy'))->addInlineJavascript('
			jQuery("#default-resn input[type=checkbox]").on("click", function() {
				if ($(this).prop("checked")) {
					jQuery($(this).closest("tr").addClass("text-muted"));
				} else {
					jQuery($(this).closest("tr").removeClass("text-muted"));
				}
			});
			jQuery("#add-resn").on("click", function() {
				jQuery("#default-resn tbody").prepend(jQuery("#new-resn-template").html()); autocomplete();
Ejemplo n.º 12
0
 /**
  * Create the <header> tag for a popup window.
  *
  * @return string
  */
 protected function headerSimple()
 {
     return $this->flashMessagesContainer(FlashMessages::getMessages()) . '<div id="content">';
 }
Ejemplo n.º 13
0
 /**
  * Check that the POST request contains the CSRF token generated above.
  *
  * @return bool
  */
 public static function checkCsrf()
 {
     if (self::post('csrf') !== self::getCsrfToken()) {
         // Oops.  Something is not quite right
         Log::addAuthenticationLog('CSRF mismatch - session expired or malicious attack');
         FlashMessages::addMessage(I18N::translate('This form has expired.  Try again.'), 'error');
         return false;
     }
     return true;
 }
Ejemplo n.º 14
0
// The login URL must be an absolute URL, and can be user-defined
if (Site::getPreference('LOGIN_URL')) {
    define('WT_LOGIN_URL', Site::getPreference('LOGIN_URL'));
} else {
    define('WT_LOGIN_URL', WT_BASE_URL . 'login.php');
}
// If there is no current tree and we need one, then redirect somewhere
if (WT_SCRIPT_NAME != 'admin_trees_manage.php' && WT_SCRIPT_NAME != 'admin_pgv_to_wt.php' && WT_SCRIPT_NAME != 'login.php' && WT_SCRIPT_NAME != 'logout.php' && WT_SCRIPT_NAME != 'import.php' && WT_SCRIPT_NAME != 'help_text.php' && WT_SCRIPT_NAME != 'message.php' && WT_SCRIPT_NAME != 'action.php') {
    if (!$WT_TREE || !$WT_TREE->getPreference('imported')) {
        if (Auth::isAdmin()) {
            header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
        } else {
            // We're not an administrator, so we can only log in if there is a tree.
            if (Auth::id()) {
                Auth::logout();
                FlashMessages::addMessage(I18N::translate('This user account does not have access to any tree.'));
            }
            header('Location: ' . WT_LOGIN_URL . '?url=' . rawurlencode(WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '')), true, 301);
        }
        exit;
    }
}
// Update the last-login time no more than once a minute
if (WT_TIMESTAMP - Session::get('activity_time') >= 60) {
    Auth::user()->setPreference('sessiontime', WT_TIMESTAMP);
    Session::put('activity_time', WT_TIMESTAMP);
}
// Set the theme
if (substr(WT_SCRIPT_NAME, 0, 5) === 'admin' || WT_SCRIPT_NAME === 'module.php' && substr(Filter::get('mod_action'), 0, 5) === 'admin') {
    // Administration scripts begin with “admin” and use a special administration theme
    Theme::theme(new AdministrationTheme())->init($WT_TREE);
Ejemplo n.º 15
0
            if (!empty($from_name)) {
                $message['from_name'] = $from_name;
                $message['from_email'] = $from_email;
            }
            $message['subject'] = $subject;
            $message['body'] = nl2br($body, false);
            $message['created'] = WT_TIMESTAMP;
            $message['method'] = $method;
            $message['url'] = $url;
            if ($i > 0) {
                $message['no_from'] = true;
            }
            if (addMessage($message)) {
                FlashMessages::addMessage(I18N::translate('The message was successfully sent to %s.', Filter::escapeHtml($to)));
            } else {
                FlashMessages::addMessage(I18N::translate('The message was not sent.'));
                Log::addErrorLog('Unable to send a message. FROM:' . $from . ' TO:' . $to . ' (failed to send)');
            }
            $i++;
        }
        $controller->pageHeader()->addInlineJavascript('window.opener.location.reload(); window.close();');
        break;
}
/**
 * Add a message to a user's inbox
 *
 * @param string[] $message
 *
 * @return bool
 */
function addMessage($message)
Ejemplo n.º 16
0
require './includes/session.php';
$to_delete = Filter::postArray('to_delete');
if ($to_delete && Filter::checkCsrf()) {
    foreach ($to_delete as $path) {
        $is_dir = is_dir(WT_DATA_DIR . $path);
        if (File::delete(WT_DATA_DIR . $path)) {
            if ($is_dir) {
                FlashMessages::addMessage(I18N::translate('The folder %s has been deleted.', Filter::escapeHtml($path)), 'success');
            } else {
                FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', Filter::escapeHtml($path)), 'success');
            }
        } else {
            if ($is_dir) {
                FlashMessages::addMessage(I18N::translate('The folder %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
            } else {
                FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', Filter::escapeHtml($path)), 'danger');
            }
        }
    }
    header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME);
    return;
}
$controller = new PageController();
$controller->restrictAccess(Auth::isAdmin())->setPageTitle(I18N::translate('Clean up data folder'))->pageHeader();
$do_not_delete = array('index.php', 'config.ini.php');
// If we are storing the media in the data folder (this is the default), then don’t delete it.
foreach (Tree::getAll() as $tree) {
    $MEDIA_DIRECTORY = $tree->getPreference('MEDIA_DIRECTORY');
    if (substr($MEDIA_DIRECTORY, 0, 3) != '../') {
        // Just need to add the first part of the path
        $tmp = explode('/', $MEDIA_DIRECTORY);
Ejemplo n.º 17
0
        $gedcom .= "\n" . $fact->getGedcom();
    }
    foreach ($facts1 as $fact_id => $fact) {
        if (in_array($fact_id, $keep1)) {
            $gedcom .= "\n" . $fact->getGedcom();
        }
    }
    foreach ($facts2 as $fact_id => $fact) {
        if (in_array($fact_id, $keep2)) {
            $gedcom .= "\n" . $fact->getGedcom();
        }
    }
    $rec1->updateRecord($gedcom, true);
    $rec2->deleteRecord();
    FunctionsDb::updateFavorites($gid2, $gid1, $WT_TREE);
    FlashMessages::addMessage(I18N::translate('The records “%1$s” and “%2$s” have been merged.', '<a class="alert-link" href="' . $rec1->getHtmlUrl() . '">' . $rec1->getFullName() . '</a>', $record2_name), 'success');
    header('Location: ' . WT_BASE_URL . Filter::post('url', 'admin_trees_duplicates\\.php', WT_SCRIPT_NAME));
    return;
}
$controller->pageHeader();
?>
<ol class="breadcrumb small">
	<li><a href="admin.php"><?php 
echo I18N::translate('Control panel');
?>
</a></li>
	<li><a href="admin_trees_manage.php"><?php 
echo I18N::translate('Manage family trees');
?>
</a></li>
	<li class="active"><?php 
Ejemplo n.º 18
0
} elseif (Filter::server('HTTP_X_FORWARDED_FOR') !== null) {
    define('WT_CLIENT_IP', Filter::server('HTTP_X_FORWARDED_FOR'));
} else {
    define('WT_CLIENT_IP', Filter::server('REMOTE_ADDR', WT_REGEX_IPV4, '127.0.0.1'));
}
// Connect to the database
try {
    Database::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
    define('WT_TBLPREFIX', $dbconfig['tblpfx']);
    unset($dbconfig);
    // Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
    Database::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
    // Update the database schema
    Database::updateSchema('\\Fisharebest\\Webtrees\\Schema', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
} catch (PDOException $ex) {
    FlashMessages::addMessage($ex->getMessage(), 'danger');
    header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
    throw $ex;
}
// The config.ini.php file must always be in a fixed location.
// Other user files can be stored elsewhere...
define('WT_DATA_DIR', realpath(Site::getPreference('INDEX_DIRECTORY') ? Site::getPreference('INDEX_DIRECTORY') : 'data') . DIRECTORY_SEPARATOR);
// If we have a preferred URL (e.g. www.example.com instead of www.isp.com/~example), then redirect to it.
$SERVER_URL = Site::getPreference('SERVER_URL');
if ($SERVER_URL && $SERVER_URL != WT_BASE_URL) {
    header('Location: ' . $SERVER_URL . WT_SCRIPT_NAME . (isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : ''), true, 301);
    exit;
}
// Request more resources - if we can/want to
if (!ini_get('safe_mode')) {
    $memory_limit = Site::getPreference('MEMORY_LIMIT');
Ejemplo n.º 19
0
     break;
 case 'register':
     if (!Site::getPreference('USE_REGISTRATION_MODULE')) {
         header('Location: ' . WT_BASE_URL);
         return;
     }
     $controller->setPageTitle(I18N::translate('Request new user account'));
     // The form parameters are mandatory, and the validation errors are shown in the client.
     if (Session::get('good_to_send') && $user_name && $user_password01 && $user_password01 == $user_password02 && $user_realname && $user_email && $user_comments) {
         // These validation errors cannot be shown in the client.
         if (User::findByUserName($user_name)) {
             FlashMessages::addMessage(I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.'));
         } elseif (User::findByEmail($user_email)) {
             FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
         } elseif (preg_match('/(?!' . preg_quote(WT_BASE_URL, '/') . ')(((?:ftp|http|https):\\/\\/)[a-zA-Z0-9.-]+)/', $user_comments, $match)) {
             FlashMessages::addMessage(I18N::translate('You are not allowed to send messages that contain external links.') . ' ' . I18N::translate('You should delete the “%1$s” from “%2$s” and try again.', $match[2], $match[1]));
             Log::addAuthenticationLog('Possible spam registration from "' . $user_name . '"/"' . $user_email . '" comments="' . $user_comments . '"');
         } else {
             // Everything looks good - create the user
             $controller->pageHeader();
             Log::addAuthenticationLog('User registration requested for: ' . $user_name);
             $user = User::create($user_name, $user_realname, $user_email, $user_password01);
             $user->setPreference('language', WT_LOCALE)->setPreference('verified', '0')->setPreference('verified_by_admin', 0)->setPreference('reg_timestamp', date('U'))->setPreference('reg_hashcode', md5(Uuid::uuid4()))->setPreference('contactmethod', 'messaging2')->setPreference('comment', $user_comments)->setPreference('visibleonline', '1')->setPreference('auto_accept', '0')->setPreference('canadmin', '0')->setPreference('sessiontime', '0');
             // Generate an email in the admin’s language
             $webmaster = User::find($WT_TREE->getPreference('WEBMASTER_USER_ID'));
             I18N::init($webmaster->getPreference('language'));
             $mail1_body = I18N::translate('Hello administrator…') . Mail::EOL . Mail::EOL . I18N::translate('A prospective user has registered with webtrees at %s.', WT_BASE_URL . ' ' . $WT_TREE->getTitleHtml()) . Mail::EOL . Mail::EOL . I18N::translate('Username') . ' ' . Filter::escapeHtml($user->getUserName()) . Mail::EOL . I18N::translate('Real name') . ' ' . $user->getRealNameHtml() . Mail::EOL . I18N::translate('Email address') . ' ' . Filter::escapeHtml($user->getEmail()) . Mail::EOL . I18N::translate('Comments') . ' ' . Filter::escapeHtml($user_comments) . Mail::EOL . Mail::EOL . I18N::translate('The user has been sent an e-mail with the information necessary to confirm the access request.') . Mail::EOL . Mail::EOL . I18N::translate('You will be informed by e-mail when this prospective user has confirmed the request. You can then complete the process by activating the user name. The new user will not be able to login until you activate the account.');
             $mail1_subject = I18N::translate('New registration at %s', WT_BASE_URL . ' ' . $WT_TREE->getTitle());
             I18N::init(WT_LOCALE);
             echo '<div id="login-register-page">';
             // Generate an email in the user’s language
Ejemplo n.º 20
0
    $module_name = Filter::post('module_name');
    Database::prepare("DELETE `##block_setting`" . " FROM `##block_setting`" . " JOIN `##block` USING (block_id)" . " JOIN `##module` USING (module_name)" . " WHERE module_name=?")->execute(array($module_name));
    Database::prepare("DELETE `##block`" . " FROM `##block`" . " JOIN `##module` USING (module_name)" . " WHERE module_name=?")->execute(array($module_name));
    Database::prepare("DELETE FROM `##module_setting` WHERE module_name=?")->execute(array($module_name));
    Database::prepare("DELETE FROM `##module_privacy` WHERE module_name=?")->execute(array($module_name));
    Database::prepare("DELETE FROM `##module` WHERE module_name=?")->execute(array($module_name));
    FlashMessages::addMessage(I18N::translate('The preferences for the module “%s” have been deleted.', $module_name), 'success');
    header('Location: ' . WT_BASE_URL . 'admin_modules.php');
    return;
}
// The module can’t be found on disk?
// Don't delete it automatically. It may be temporarily missing, after a re-installation, etc.
foreach ($module_status as $module_name => $status) {
    if (!array_key_exists($module_name, $modules)) {
        $html = I18N::translate('Preferences exist for the module “%s”, but this module no longer exists.', '<span dir="ltr">' . $module_name . '</span>') . '<form method="post" class="form-inline">' . Filter::getCsrf() . '<input type="hidden" name="action" value="delete">' . '<input type="hidden" name="module_name" value="' . $module_name . '">' . '<button type="submit" class="btn btn-link">' . I18N::translate('Delete the preferences for this module.') . '</button>' . '</form>';
        FlashMessages::addMessage($html, 'warning');
    }
}
$controller->pageHeader()->addExternalJavascript(WT_JQUERY_DATATABLES_JS_URL)->addExternalJavascript(WT_DATATABLES_BOOTSTRAP_JS_URL)->addInlineJavascript('
		function reindexMods(id) {
			jQuery("#" + id + " input").each(
				function (index, value) {
					value.value = index+1;
				});
		}
		jQuery("#installed_table").dataTable( {
			paging: false,
			' . I18N::datatablesI18N() . ',
			sorting: [[ 1, "asc" ]],
			columns : [
				{ sortable: false, class: "center" },
Ejemplo n.º 21
0
             $messages = true;
         }
     }
     if ($oldServerThumb != $newServerThumb) {
         $move_file = true;
         if (!file_exists($newServerThumb) || md5_file($oldServerFile) == md5_file($newServerThumb)) {
             try {
                 rename($oldServerThumb, $newServerThumb);
                 FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s has been renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
             } catch (\ErrorException $ex) {
                 FlashMessages::addMessage(I18N::translate('The thumbnail file %1$s could not be renamed to %2$s.', Html::filename($oldFilename), Html::filename($newFilename)));
             }
             $messages = true;
         }
         if (!file_exists($newServerThumb)) {
             FlashMessages::addMessage(I18N::translate('The thumbnail file %s does not exist.', Html::filename($newFilename)));
             $messages = true;
         }
     }
 }
 // Insert the 1 FILE xxx record into the arrays used by function FunctionsEdit::handle_updatesges()
 $glevels = array_merge(array('1'), $glevels);
 $tag = array_merge(array('FILE'), $tag);
 $islink = array_merge(array(0), $islink);
 $text = array_merge(array($newFilename), $text);
 $record = GedcomRecord::getInstance($pid, $WT_TREE);
 $newrec = "0 @{$pid}@ OBJE\n";
 $newrec = FunctionsEdit::handleUpdates($newrec);
 $record->updateRecord($newrec, $update_CHAN);
 if ($move_file) {
     // We've moved a file. Therefore we must approve the change, as rejecting
Ejemplo n.º 22
0
    if (in_array($delete_file, $disk_files)) {
        $tmp = WT_DATA_DIR . $media_folder . $delete_file;
        try {
            unlink($tmp);
            FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', Html::filename($tmp)), 'success');
        } catch (\ErrorException $ex) {
            FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', Html::filename($tmp)) . '<hr><samp dir="ltr">' . $ex->getMessage() . '</samp>', 'danger');
        }
        // Delete any corresponding thumbnail
        $tmp = WT_DATA_DIR . $media_folder . 'thumbs/' . $delete_file;
        if (file_exists($tmp)) {
            try {
                unlink($tmp);
                FlashMessages::addMessage(I18N::translate('The file %s has been deleted.', Html::filename($tmp)), 'success');
            } catch (\ErrorException $ex) {
                FlashMessages::addMessage(I18N::translate('The file %s could not be deleted.', Html::filename($tmp)) . '<hr><samp dir="ltr">' . $ex->getMessage() . '</samp>', 'danger');
            }
        }
    } else {
        // File no longer exists? Maybe it was already deleted or renamed.
    }
    $controller->pageHeader();
    return;
}
////////////////////////////////////////////////////////////////////////////////
// GET callback for server-side pagination
////////////////////////////////////////////////////////////////////////////////
switch ($action) {
    case 'load_json':
        $search = Filter::get('search');
        $search = $search['value'];
Ejemplo n.º 23
0
                     } elseif (strpos($fact->getGedcom(), ' @' . $target . '@')) {
                         // Level 2-3 links
                         $source->updateFact($fact->getFactId(), preg_replace(array('/\\n2 OBJE @' . $target . '@(\\n[3-9].*)*/', '/\\n3 OBJE @' . $target . '@(\\n[4-9].*)*/'), '', $fact->getGedcom()), true);
                     }
                 }
             }
         }
     } else {
         http_response_code(406);
     }
     break;
 case 'reject-changes':
     // Reject all the pending changes for a record
     $record = GedcomRecord::getInstance(Filter::post('xref', WT_REGEX_XREF), $WT_TREE);
     if ($record && $record->canEdit() && Auth::isModerator($record->getTree())) {
         FlashMessages::addMessage(I18N::translate('The changes to “%s” have been rejected.', $record->getFullName()));
         FunctionsImport::rejectAllChanges($record);
     } else {
         http_response_code(406);
     }
     break;
 case 'theme':
     // Change the current theme
     $theme = Filter::post('theme');
     if (Site::getPreference('ALLOW_USER_THEMES') && array_key_exists($theme, Theme::themeNames())) {
         Session::put('theme_id', $theme);
         // Remember our selection
         Auth::user()->setPreference('theme', $theme);
     } else {
         // Request for a non-existant theme.
         http_response_code(406);
Ejemplo n.º 24
0
            FlashMessages::addMessage(I18N::translate('This family has been deleted. The deletion will need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
        }
    } elseif ($controller->record->isPendingAddtion()) {
        if (Auth::isModerator($controller->record->getTree())) {
            FlashMessages::addMessage(I18N::translate('This family has been edited. You should review the changes and then %1$s or %2$s them.', '<a href="#" onclick="accept_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'accept') . '</a>', '<a href="#" onclick="reject_changes(\'' . $controller->record->getXref() . '\');">' . I18N::translateContext('You should review the changes and then accept or reject them.', 'reject') . '</a>') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
        } elseif (Auth::isEditor($controller->record->getTree())) {
            FlashMessages::addMessage(I18N::translate('This family has been edited. The changes need to be reviewed by a moderator.') . ' ' . FunctionsPrint::helpLink('pending_changes'), 'warning');
        }
    }
    $controller->pageHeader();
} elseif ($controller->record && $controller->record->getTree()->getPreference('SHOW_PRIVATE_RELATIONSHIPS')) {
    $controller->pageHeader();
    // Continue - to display the children/parents/grandparents.
    // We'll check for showing the details again later
} else {
    FlashMessages::addMessage(I18N::translate('This family does not exist or you do not have permission to view it.'), 'danger');
    http_response_code(404);
    $controller->pageHeader();
    return;
}
?>
<div id="family-page">
	<h2><?php 
echo $controller->record->getFullName();
?>
</h2>

	<table id="family-table">
		<tr style="vertical-align:top;">
			<td style="width: <?php 
echo Theme::theme()->parameter('chart-box-x') + 30;
Ejemplo n.º 25
0
// This script does not load session.php.
// session.php won’t run until a configuration file and database connection exist...
// This next block of code is a minimal version of session.php
define('WT_WEBTREES', 'webtrees');
define('WT_BASE_URL', '');
define('WT_ROOT', '');
define('WT_DATA_DIR', realpath('data') . DIRECTORY_SEPARATOR);
define('WT_MODULES_DIR', 'modules_v3/');
require 'vendor/autoload.php';
Session::start();
define('WT_LOCALE', I18N::init());
http_response_code(503);
header('Content-Type: text/html; charset=UTF-8');
// The page which redirected here may have provided an error message.
$messages = '';
foreach (FlashMessages::getMessages() as $message) {
    $messages .= '<blockquote>' . Filter::escapeHtml($message->text) . '</blockquote>';
}
// If we can't connect to the database at all, give the reason why
$config_ini_php = file_exists('data/config.ini.php') && parse_ini_file('data/config.ini.php');
if (is_array($config_ini_php) && array_key_exists('dbhost', $config_ini_php) && array_key_exists('dbport', $config_ini_php) && array_key_exists('dbuser', $config_ini_php) && array_key_exists('dbpass', $config_ini_php) && array_key_exists('dbname', $config_ini_php)) {
    try {
        new PDO('mysql:host=' . $config_ini_php['dbhost'] . ';port=' . $config_ini_php['dbport'] . ';dbname=' . $config_ini_php['dbname'], $config_ini_php['dbuser'], $config_ini_php['dbpass'], array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_OBJ, PDO::ATTR_CASE => PDO::CASE_LOWER, PDO::ATTR_AUTOCOMMIT => true));
    } catch (PDOException $ex) {
        $messages .= '<p>' . I18N::translate('The database reported the following error message:') . '</p>';
        $messages .= '<blockquote>' . $ex->getMessage() . '</blockquote>';
    }
}
?>
<!DOCTYPE html>
<html <?php 
Ejemplo n.º 26
0
            FlashMessages::addMessage(I18N::translate('PhpGedView must use the same database as webtrees.', 'danger'));
            $PGV_PATH = null;
            unset($wt_config);
        } else {
            unset($wt_config);
            try {
                $PGV_SCHEMA_VERSION = Database::prepare("SELECT site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'")->fetchOne();
                if ($PGV_SCHEMA_VERSION < 10) {
                    FlashMessages::addMessage(I18N::translate('The version of %s is too old.', 'PhpGedView'), 'danger');
                    $PGV_PATH = null;
                } elseif ($PGV_SCHEMA_VERSION > 14) {
                    FlashMessages::addMessage(I18N::translate('The version of %s is too new.', 'PhpGedView'), 'danger');
                    $PGV_PATH = null;
                }
            } catch (PDOException $ex) {
                FlashMessages::addMessage(I18N::translate('webtrees cannot connect to the PhpGedView database: %s.', $DBNAME . '@' . $DBHOST) . '<br>' . I18N::translate('MySQL gave the error: %s', $ex->getMessage()), 'danger');
                $PGV_PATH = null;
            }
        }
    }
}
if ($PGV_PATH) {
    // The account we are using is about to be deleted.
    Session::forget('wt_user');
}
$controller->pageHeader();
?>
<ol class="breadcrumb small">
	<li><a href="admin.php"><?php 
echo I18N::translate('Control panel');
?>
Ejemplo n.º 27
0
$form_pass2 = Filter::post('form_pass2', WT_REGEX_PASSWORD);
$form_email = Filter::postEmail('form_email');
$form_rootid = Filter::post('form_rootid', WT_REGEX_XREF);
$form_theme = Filter::post('form_theme');
$form_language = Filter::post('form_language');
$form_timezone = Filter::post('form_timezone');
$form_contact_method = Filter::post('form_contact_method');
$form_visible_online = Filter::postBool('form_visible_online');
// Respond to form action
if ($form_action && Filter::checkCsrf()) {
    switch ($form_action) {
        case 'update':
            if ($form_username !== Auth::user()->getUserName() && User::findByUserName($form_username)) {
                FlashMessages::addMessage(I18N::translate('Duplicate user name. A user with that user name already exists. Please choose another user name.'));
            } elseif ($form_email !== Auth::user()->getEmail() && User::findByEmail($form_email)) {
                FlashMessages::addMessage(I18N::translate('Duplicate email address. A user with that email already exists.'));
            } else {
                // Change username
                if ($form_username !== Auth::user()->getUserName()) {
                    Log::addAuthenticationLog('User ' . Auth::user()->getUserName() . ' renamed to ' . $form_username);
                    Auth::user()->setUserName($form_username);
                }
                // Change password
                if ($form_pass1 && $form_pass1 === $form_pass2) {
                    Auth::user()->setPassword($form_pass1);
                }
                // Change other settings
                Auth::user()->setRealName($form_realname)->setEmail($form_email)->setPreference('language', $form_language)->setPreference('TIMEZONE', $form_timezone)->setPreference('contactmethod', $form_contact_method)->setPreference('visibleonline', $form_visible_online ? '1' : '0');
                if ($form_theme === null) {
                    Auth::user()->deletePreference('theme');
                } else {
Ejemplo n.º 28
0
 /**
  * Run a series of scripts to bring the database schema up to date.
  *
  * @param string $namespace      Where to find our MigrationXXX classes
  * @param string $schema_name    Where to find our MigrationXXX classes
  * @param int    $target_version updade/downgrade to this version
  *
  * @throws PDOException
  *
  * @return bool  Were any updates applied
  */
 public static function updateSchema($namespace, $schema_name, $target_version)
 {
     try {
         $current_version = (int) Site::getPreference($schema_name);
     } catch (PDOException $e) {
         // During initial installation, the site_preference table won’t exist.
         $current_version = 0;
     }
     $updates_applied = false;
     try {
         // Update the schema, one version at a time.
         while ($current_version < $target_version) {
             $class = $namespace . '\\Migration' . $current_version;
             /** @var MigrationInterface $migration */
             $migration = new $class();
             $migration->upgrade();
             Site::setPreference($schema_name, ++$current_version);
             $updates_applied = true;
         }
     } catch (PDOException $ex) {
         // The schema update scripts should never fail. If they do, there is no clean recovery.
         FlashMessages::addMessage($ex->getMessage(), 'danger');
         header('Location: ' . WT_BASE_URL . 'site-unavailable.php');
         throw $ex;
     }
     return $updates_applied;
 }
Ejemplo n.º 29
0
 /**
  * Performs a search and replace
  *
  * @param Tree $tree
  */
 private function searchAndReplace(Tree $tree)
 {
     $this->generalSearch();
     //-- don't try to make any changes if nothing was found
     if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) {
         return;
     }
     Log::addEditLog("Search And Replace old:" . $this->query . " new:" . $this->replace);
     $adv_name_tags = preg_split("/[\\s,;: ]+/", $tree->getPreference('ADVANCED_NAME_FACTS'));
     $name_tags = array_unique(array_merge(Config::standardNameFacts(), $adv_name_tags));
     $name_tags[] = '_MARNM';
     $records_updated = 0;
     foreach ($this->myindilist as $id => $record) {
         $old_record = $record->getGedcom();
         $new_record = $old_record;
         if ($this->replaceAll) {
             $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
         } else {
             if ($this->replaceNames) {
                 foreach ($name_tags as $tag) {
                     $new_record = preg_replace("~(\\d) " . $tag . " (.*)" . $this->query . "(.*)~i", "\$1 " . $tag . " \$2" . $this->replace . "\$3", $new_record);
                 }
             }
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
                 } else {
                     $new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($new_record !== $old_record) {
             $record->updateRecord($new_record, true);
             $records_updated++;
         } else {
             unset($this->myindilist[$id]);
         }
     }
     if ($records_updated) {
         FlashMessages::addMessage(I18N::plural('%s individual has been updated.', '%s individuals have been updated.', $records_updated, I18N::number($records_updated)));
     }
     $records_updated = 0;
     foreach ($this->myfamlist as $id => $record) {
         $old_record = $record->getGedcom();
         $new_record = $old_record;
         if ($this->replaceAll) {
             $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
         } else {
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
                 } else {
                     $new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($new_record !== $old_record) {
             $record->updateRecord($new_record, true);
             $records_updated++;
         } else {
             unset($this->myfamlist[$id]);
         }
     }
     if ($records_updated) {
         FlashMessages::addMessage(I18N::plural('%s family has been updated.', '%s families have been updated.', $records_updated, I18N::number($records_updated)));
     }
     $records_updated = 0;
     foreach ($this->mysourcelist as $id => $record) {
         $old_record = $record->getGedcom();
         $new_record = $old_record;
         if ($this->replaceAll) {
             $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
         } else {
             if ($this->replaceNames) {
                 $new_record = preg_replace("~(\\d) TITL (.*)" . $this->query . "(.*)~i", "\$1 TITL \$2" . $this->replace . "\$3", $new_record);
                 $new_record = preg_replace("~(\\d) ABBR (.*)" . $this->query . "(.*)~i", "\$1 ABBR \$2" . $this->replace . "\$3", $new_record);
             }
             if ($this->replacePlaces) {
                 if ($this->replacePlacesWord) {
                     $new_record = preg_replace('~(\\d) PLAC (.*)([,\\W\\s])' . $this->query . '([,\\W\\s])~i', "\$1 PLAC \$2\$3" . $this->replace . "\$4", $new_record);
                 } else {
                     $new_record = preg_replace("~(\\d) PLAC (.*)" . $this->query . "(.*)~i", "\$1 PLAC \$2" . $this->replace . "\$3", $new_record);
                 }
             }
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($new_record !== $old_record) {
             $record->updateRecord($new_record, true);
             $records_updated++;
         } else {
             unset($this->mysourcelist[$id]);
         }
     }
     if ($records_updated) {
         FlashMessages::addMessage(I18N::plural('%s source has been updated.', '%s sources have been updated.', $records_updated, I18N::number($records_updated)));
     }
     $records_updated = 0;
     foreach ($this->mynotelist as $id => $record) {
         $old_record = $record->getGedcom();
         $new_record = $old_record;
         if ($this->replaceAll) {
             $new_record = preg_replace("~" . $this->query . "~i", $this->replace, $new_record);
         }
         //-- if the record changed replace the record otherwise remove it from the search results
         if ($new_record != $old_record) {
             $record->updateRecord($new_record, true);
             $records_updated++;
         } else {
             unset($this->mynotelist[$id]);
         }
     }
     if ($records_updated) {
         FlashMessages::addMessage(I18N::plural('%s note has been updated.', '%s notes have been updated.', $records_updated, I18N::number($records_updated)));
     }
 }
Ejemplo n.º 30
0
            if (!empty($from_name)) {
                $message['from_name'] = $from_name;
                $message['from_email'] = $from_email;
            }
            $message['subject'] = $subject;
            $message['body'] = nl2br($body, false);
            $message['created'] = WT_TIMESTAMP;
            $message['method'] = $method;
            $message['url'] = $url;
            if ($i > 0) {
                $message['no_from'] = true;
            }
            if (addMessage($message)) {
                FlashMessages::addMessage(I18N::translate('Message successfully sent to %s', Filter::escapeHtml($to)));
            } else {
                FlashMessages::addMessage(I18N::translate('Message was not sent'));
                Log::addErrorLog('Unable to send a message. FROM:' . $from . ' TO:' . $to . ' (failed to send)');
            }
            $i++;
        }
        $controller->pageHeader()->addInlineJavascript('window.opener.location.reload(); window.close();');
        break;
}
/**
 * Add a message to a user's inbox
 *
 * @param string[] $message
 *
 * @return bool
 */
function addMessage($message)