コード例 #1
0
ファイル: Migration31.php プロジェクト: tronsmit/webtrees
 /**
  * Upgrade to to the next version
  */
 public function upgrade()
 {
     $index_dir = Site::getPreference('INDEX_DIRECTORY');
     // Due to the language code changes in 1.7.0, we need to update some other settings
     foreach ($this->languages as $old => $new) {
         try {
             Database::prepare("UPDATE `##site_setting` SET setting_name = REPLACE(setting_name, :old, :new) " . "WHERE setting_name LIKE 'WELCOME_TEXT_AUTH_MODE_%'")->execute(array('old' => $old, 'new' => $new));
         } catch (PDOException $ex) {
             // Duplicate key? Already done?
         }
         Database::prepare("UPDATE `##block_setting` SET setting_value = REPLACE(setting_value, :old, :new) " . "WHERE setting_name = 'languages'")->execute(array('old' => $old, 'new' => $new));
         // Historical fact files
         if (file_exists($index_dir . 'histo.' . $old . '.php') && !file_exists($index_dir . 'histo.' . $new . '.php')) {
             rename($index_dir . 'histo.' . $old . '.php', $index_dir . 'histo.' . $new . '.php');
         }
         // Language files
         if (file_exists($index_dir . 'language/' . $old . '.php') && !file_exists($index_dir . 'language/' . $new . '.php')) {
             rename($index_dir . 'language/' . $old . '.php', $index_dir . 'language/' . $new . '.php');
         }
         if (file_exists($index_dir . 'language/' . $old . '.csv') && !file_exists($index_dir . 'language/' . $new . '.csv')) {
             rename($index_dir . 'language/' . $old . '.csv', $index_dir . 'language/' . $new . '.csv');
         }
         if (file_exists($index_dir . 'language/' . $old . '.mo') && !file_exists($index_dir . 'language/' . $new . '.mo')) {
             rename($index_dir . 'language/' . $old . '.mo', $index_dir . 'language/' . $new . '.mo');
         }
     }
 }
コード例 #2
0
ファイル: theme.php プロジェクト: bxbroze/justlight
 /** {@inheritdoc} */
 public function cookieWarning()
 {
     if (empty($_SERVER['HTTP_DNT']) && empty($_COOKIE['cookie']) && (Site::getPreference('GOOGLE_ANALYTICS_ID') || Site::getPreference('PIWIK_SITE_ID') || Site::getPreference('STATCOUNTER_PROJECT_ID'))) {
         $cookie_warning = '<div class="cookie-warning">' . I18N::translate('Cookies') . ' - ' . I18N::translate('This website uses cookies to learn about visitor behaviour.') . '</div>';
         return $this->htmlAlert($cookie_warning, 'info', true);
     } else {
         return '';
     }
 }
コード例 #3
0
ファイル: Functions.php プロジェクト: jflash/webtrees
 /**
  * Check with the webtrees.net server for the latest version of webtrees.
  * Fetching the remote file can be slow, so check infrequently, and cache the result.
  * Pass the current versions of webtrees, PHP and MySQL, as the response
  * may be different for each.  The server logs are used to generate
  * installation statistics which can be found at http://svn.webtrees.net/statistics.html
  *
  * @return null|string
  */
 public static function fetchLatestVersion()
 {
     $last_update_timestamp = Site::getPreference('LATEST_WT_VERSION_TIMESTAMP');
     if ($last_update_timestamp < WT_TIMESTAMP - 24 * 60 * 60) {
         $row = Database::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow();
         $params = '?w=' . WT_VERSION . '&p=' . PHP_VERSION . '&m=' . $row->value . '&o=' . (DIRECTORY_SEPARATOR === '/' ? 'u' : 'w');
         $latest_version_txt = File::fetchUrl('http://dev.webtrees.net/build/latest-version.txt' . $params);
         if ($latest_version_txt) {
             Site::setPreference('LATEST_WT_VERSION', $latest_version_txt);
             Site::setPreference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP);
             return $latest_version_txt;
         } else {
             // Cannot connect to server - use cached version (if we have one)
             return Site::getPreference('LATEST_WT_VERSION');
         }
     } else {
         return Site::getPreference('LATEST_WT_VERSION');
     }
 }
コード例 #4
0
ファイル: I18N.php プロジェクト: bxbroze/webtrees
 /**
  * The prefered locales for this site, or a default list if no preference.
  *
  * @return LocaleInterface[]
  */
 public static function activeLocales()
 {
     $code_list = Site::getPreference('LANGUAGES');
     if ($code_list) {
         $codes = explode(',', $code_list);
     } else {
         $codes = array('ar', 'bg', 'bs', 'ca', 'cs', 'da', 'de', 'el', 'en-GB', 'en-US', 'es', 'et', 'fi', 'fr', 'he', 'hr', 'hu', 'is', 'it', 'ka', 'lt', 'mr', 'nb', 'nl', 'nn', 'pl', 'pt', 'ru', 'sk', 'sv', 'tr', 'uk', 'vi', 'zh-Hans');
     }
     $locales = array();
     foreach ($codes as $code) {
         if (file_exists(WT_ROOT . 'language/' . $code . '.mo')) {
             try {
                 $locales[] = Locale::create($code);
             } catch (\Exception $ex) {
                 // No such locale exists?
             }
         }
     }
     usort($locales, '\\Fisharebest\\Localization\\Locale::compare');
     return $locales;
 }
コード例 #5
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $controller, $WT_TREE;
     $indi_xref = $controller->getSignificantIndividual()->getXref();
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     $title = $WT_TREE->getTitleHtml();
     $content = '<table><tr>';
     $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '</a></td>';
     $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&amp;ged=' . $WT_TREE->getNameUrl() . '"><i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '</a></td>';
     if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
         $content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '</a></td>';
     }
     $content .= "</tr>";
     $content .= "</table>";
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
コード例 #6
0
ファイル: Tree.php プロジェクト: AlexSnet/webtrees
 /**
  * Delete everything relating to a tree
  */
 public function delete()
 {
     // If this is the default tree, then unset it
     if (Site::getPreference('DEFAULT_GEDCOM') === $this->name) {
         Site::setPreference('DEFAULT_GEDCOM', '');
     }
     $this->deleteGenealogyData(false);
     Database::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##block`               WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##gedcom_setting`      WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##module_privacy`      WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##next_id`             WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##hit_counter`         WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##default_resn`        WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##gedcom_chunk`        WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##log`                 WHERE gedcom_id = ?")->execute(array($this->tree_id));
     Database::prepare("DELETE FROM `##gedcom`              WHERE gedcom_id = ?")->execute(array($this->tree_id));
     // After updating the database, we need to fetch a new (sorted) copy
     self::$trees = null;
 }
コード例 #7
0
    echo I18N::translate('members');
    ?>
</span>
			</div>
		</div>
		<div class="col-sm-8">
			<?php 
    echo FunctionsEdit::selectEditControl('REQUIRE_AUTHENTICATION', array('0' => I18N::translate('Show to visitors'), '1' => I18N::translate('Show to members')), null, $WT_TREE->getPreference('REQUIRE_AUTHENTICATION'), 'class="form-control"');
    ?>
			<p class="small text-muted">
				<?php 
    echo I18N::translate('Enabling this option will force all visitors to sign in before they can view any data on the website.');
    ?>
			</p>
			<?php 
    if (Site::getPreference('USE_REGISTRATION_MODULE')) {
        ?>
			<p class="small text-muted">
				<?php 
        echo I18N::translate('If visitors can not see the family tree, they will not be able to sign up for an account. You will need to add their account manually.');
        ?>
			</p>
			<?php 
    }
    ?>
		</div>
	</div>

	<!-- SHOW_DEAD_PEOPLE -->
	<div class="form-group">
		<div class="control-label col-sm-4">
コード例 #8
0
 /**
  * Get any historical events.
  *
  * @param Individual $person
  *
  * @return Fact[]
  */
 private static function historicalFacts(Individual $person)
 {
     $SHOW_RELATIVES_EVENTS = $person->getTree()->getPreference('SHOW_RELATIVES_EVENTS');
     $facts = array();
     if ($SHOW_RELATIVES_EVENTS) {
         // Only include events between birth and death
         $birt_date = $person->getEstimatedBirthDate();
         $deat_date = $person->getEstimatedDeathDate();
         if (file_exists(Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) {
             $histo = array();
             require Site::getPreference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php';
             foreach ($histo as $hist) {
                 // Earlier versions of the WIKI encouraged people to use HTML entities,
                 // rather than UTF8 encoding.
                 $hist = html_entity_decode($hist, ENT_QUOTES, 'UTF-8');
                 $fact = new Fact($hist, $person, 'histo');
                 $sdate = $fact->getDate();
                 if ($sdate->isOK() && Date::compare($birt_date, $sdate) <= 0 && Date::compare($sdate, $deat_date) <= 0) {
                     $facts[] = $fact;
                 }
             }
         }
     }
     return $facts;
 }
コード例 #9
0
ファイル: AbstractTheme.php プロジェクト: tronsmit/webtrees
 /**
  * Themes menu.
  *
  * @return Menu|null
  */
 public function menuThemes()
 {
     if ($this->tree && Site::getPreference('ALLOW_USER_THEMES') && $this->tree->getPreference('ALLOW_THEME_DROPDOWN')) {
         $submenus = array();
         foreach (Theme::installedThemes() as $theme) {
             $class = 'menu-theme-' . $theme->themeId() . ($theme === $this ? ' active' : '');
             $submenus[] = new Menu($theme->themeName(), '#', $class, array('onclick' => 'return false;', 'data-theme' => $theme->themeId()));
         }
         usort($submenus, function (Menu $x, Menu $y) {
             return I18N::strcasecmp($x->getLabel(), $y->getLabel());
         });
         $menu = new Menu(I18N::translate('Theme'), '#', 'menu-theme', array(), $submenus);
         return $menu;
     } else {
         return null;
     }
 }
コード例 #10
0
    /**
     * {@inhericDoc}
     * @see \MyArtJaub\Webtrees\Mvc\View\AbstractView::renderContent()
     */
    protected function renderContent()
    {
        /** @var \Fisharebest\Webtrees\Individual $indi */
        $indi = $this->data->get('indi');
        /** @var \Fisharebest\Webtrees\Tree $tree */
        $tree = $this->data->get('tree');
        //Welcome section - gedcom title, date, statistics - based on gedcom_block
        $content = '<table>
                <tr>
                    <td>
                        <a href="pedigree.php?rootid=' . $indi->getXref() . '&amp;ged=' . $tree->getNameUrl() . '">
                            <i class="icon-pedigree"></i><br>' . I18N::translate('Default chart') . '
                        </a>
                    </td>
                    <td>
                        <a href="individual.php?pid=' . $indi->getXref() . '&amp;ged=' . $tree->getNameUrl() . '">
                            <i class="icon-indis"></i><br>' . I18N::translate('Default individual') . '
                        </a>
                    </td>';
        if (Site::getPreference('USE_REGISTRATION_MODULE') && !Auth::check()) {
            $content .= '
                    <td>
                        <a href="' . WT_LOGIN_URL . '?action=register">
                            <i class="icon-user_add"></i><br>' . I18N::translate('Request new user account') . '
                        </a>
                    </td>';
        }
        $content .= '
                </tr>
            </table>';
        // Piwik Statistics
        if ($this->data->get('piwik_enabled', false)) {
            $content .= '
                <div class="center">
                    <div id="piwik_stats">
                        <i class="icon-loading-small"></i>&nbsp;' . I18N::translate('Retrieving Piwik statistics...') . '
                    </div>
                </div>';
        }
        $content .= '<hr />';
        // Login section - based on login_block
        if (Auth::check()) {
            $content .= '
            <div class="center">
                <form method="post" action="logout.php" name="logoutform" onsubmit="return true;">
                    <br>
                    <a href="edituser.php" class="name2">' . I18N::translate('Logged in as ') . ' ' . Auth::user()->getRealNameHtml() . '</a>
                    <br><br>
                    <input type="submit" value="' . I18N::translate('Logout') . '">
                    <br><br>
                </form>
            </div>';
        } else {
            $content .= '
            <div id="maj-login-box">
                <form id="maj-login-form" name="maj-login-form" method="post" action="' . WT_LOGIN_URL . '">
					<input type="hidden" name="action" value="login">
				    <div>
					    <label for="maj-username">' . I18N::translate('Username') . '<input type="text" id="maj-username" name="username" class="formField">
						</label>
					</div>
					<div>
						<label for="maj-password">' . I18N::translate('Password') . '<input type="password" id="maj-password" name="password" class="formField">
						</label>
					</div>
					<div>
						<input type="submit" value="' . I18N::translate('Login') . '">
					</div>
					<div>
						<a href="#" id="maj-passwd_click">' . I18N::translate('Request new password') . '</a>
					</div>';
            if (Site::getPreference('USE_REGISTRATION_MODULE')) {
                $content .= '
                    <div>
                        <a href="' . WT_LOGIN_URL . '?action=register">' . I18N::translate('Request new user account') . '</a>
                    </div>';
            }
            $content .= '
                </form>';
            // close "login-form"
            // hidden New Password block
            $content .= '
                <div id="maj-new_passwd">
                    <form id="maj-new_passwd_form" name="new_passwd_form" action="' . WT_LOGIN_URL . '" method="post">
                        <input type="hidden" name="time" value="">
                        <input type="hidden" name="action" value="requestpw">
                        <h4>' . I18N::translate('Lost password request') . '</h4>
                        <div>
                            <label for="maj-new_passwd_username">' . I18N::translate('Username or email address') . '
                                <input type="text" id="maj-new_passwd_username" name="new_passwd_username" value="">
                            </label>
        				</div>
        				<div>
                            <input type="submit" value="' . I18N::translate('Continue') . '">
                        </div>
                    </form>
                </div>
            </div>';
            //"login-box"
        }
        return $content;
    }
コード例 #11
0
ファイル: Mail.php プロジェクト: tronsmit/webtrees
 /**
  * Create a transport mechanism for sending mail
  *
  * @return Swift_Transport
  */
 public static function transport()
 {
     switch (Site::getPreference('SMTP_ACTIVE')) {
         case 'internal':
             return Swift_MailTransport::newInstance();
         case 'external':
             $transport = Swift_SmtpTransport::newInstance()->setHost(Site::getPreference('SMTP_HOST'))->setPort(Site::getPreference('SMTP_PORT'))->setLocalDomain(Site::getPreference('SMTP_HELO'));
             if (Site::getPreference('SMTP_AUTH')) {
                 $transport->setUsername(Site::getPreference('SMTP_AUTH_USER'))->setPassword(Site::getPreference('SMTP_AUTH_PASS'));
             }
             if (Site::getPreference('SMTP_SSL') !== 'none') {
                 $transport->setEncryption(Site::getPreference('SMTP_SSL'));
             }
             return $transport;
         default:
             // For testing
             return Swift_NullTransport::newInstance();
     }
 }
コード例 #12
0
    echo Filter::escapeHtml(Site::getPreference('STATCOUNTER_PROJECT_ID'));
    ?>
" maxlength="255" pattern="[0-9]+">
			</div>
		</div>

		<!-- STATCOUNTER_SECURITY_ID -->
		<div class="form-group">
			<label for="STATCOUNTER_SECURITY_ID" class="col-sm-3 control-label">
				<?php 
    echo I18N::translate('Security code');
    ?>
			</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" id="STATCOUNTER_SECURITY_ID" name="STATCOUNTER_SECURITY_ID" value="<?php 
    echo Filter::escapeHtml(Site::getPreference('STATCOUNTER_SECURITY_ID'));
    ?>
" maxlength="255" pattern="[0-9a-zA-Z]+">
				<p class="small text-muted">
					<?php 
    echo I18N::translate('Tracking and analytics are not added to the control panel.');
    ?>
				</p>
			</div>
		</div>

	<?php 
} elseif (Filter::get('action') === 'languages') {
    ?>
		<input type="hidden" name="action" value="languages">
コード例 #13
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $title = $this->getBlockSetting($block_id, 'title');
     $html = $this->getBlockSetting($block_id, 'html');
     $gedcom = $this->getBlockSetting($block_id, 'gedcom');
     $show_timestamp = $this->getBlockSetting($block_id, 'show_timestamp', '0');
     $languages = $this->getBlockSetting($block_id, 'languages');
     // Only show this block for certain languages
     if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) {
         return '';
     }
     /*
      * Select GEDCOM
      */
     switch ($gedcom) {
         case '__current__':
             $stats = new Stats($WT_TREE);
             break;
         case '__default__':
             $tree = Tree::findByName(Site::getPreference('DEFAULT_GEDCOM'));
             if ($tree) {
                 $stats = new Stats($tree);
             } else {
                 $stats = new Stats($WT_TREE);
             }
             break;
         default:
             $tree = Tree::findByName($gedcom);
             if ($tree) {
                 $stats = new Stats($tree);
             } else {
                 $stats = new Stats($WT_TREE);
             }
             break;
     }
     /*
      * Retrieve text, process embedded variables
      */
     if (strpos($title, '#') !== false || strpos($html, '#') !== false) {
         $title = $stats->embedTags($title);
         $html = $stats->embedTags($html);
     }
     /*
      * Start Of Output
      */
     $id = $this->getName() . $block_id;
     $class = $this->getName() . '_block';
     if ($ctype === 'gedcom' && Auth::isManager($WT_TREE) || $ctype === 'user' && Auth::check()) {
         $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>' . $title;
     }
     $content = $html;
     if ($show_timestamp) {
         $content .= '<br>' . FunctionsDate::formatTimestamp($this->getBlockSetting($block_id, 'timestamp', WT_TIMESTAMP) + WT_TIMESTAMP_OFFSET);
     }
     if ($template) {
         return Theme::theme()->formatBlock($id, $title, $class, $content);
     } else {
         return $content;
     }
 }
コード例 #14
0
ファイル: Database.php プロジェクト: tronsmit/webtrees
 /**
  * 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;
 }
コード例 #15
0
ファイル: Mail.php プロジェクト: pal-saugstad/webtrees
 /**
  * Create a transport mechanism for sending mail
  *
  * @return Zend_Mail_Transport_File|Zend_Mail_Transport_Smtp
  */
 public static function transport()
 {
     switch (Site::getPreference('SMTP_ACTIVE')) {
         case 'internal':
             return new Zend_Mail_Transport_Sendmail();
         case 'external':
             $config = array('name' => Site::getPreference('SMTP_HELO'), 'port' => Site::getPreference('SMTP_PORT'));
             if (Site::getPreference('SMTP_AUTH')) {
                 $config['auth'] = 'login';
                 $config['username'] = Site::getPreference('SMTP_AUTH_USER');
                 $config['password'] = Site::getPreference('SMTP_AUTH_PASS');
             }
             if (Site::getPreference('SMTP_SSL') !== 'none') {
                 $config['ssl'] = Site::getPreference('SMTP_SSL');
             }
             return new Zend_Mail_Transport_Smtp(Site::getPreference('SMTP_HOST'), $config);
         default:
             // For testing
             return new Zend_Mail_Transport_File();
     }
 }
コード例 #16
0
ファイル: search.php プロジェクト: tronsmit/webtrees
			<div class="label">
				<?php 
    echo I18N::translate('Associates');
    ?>
			</div>
			<div class="value">
				<input type="checkbox" name="showasso" value="on" <?php 
    echo $controller->showasso === 'on' ? 'checked' : '';
    ?>
>
				<?php 
    echo I18N::translate('Show related individuals/families');
    ?>
			</div>
			<?php 
    if (count(Tree::getAll()) > 1 && Site::getPreference('ALLOW_CHANGE_GEDCOM')) {
        ?>
				<?php 
        if (count(Tree::getAll()) > 3) {
            ?>
					<div class="label"></div>
					<div class="value">
						<input type="button" value="<?php 
            echo I18N::translate('select all');
            ?>
" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', true);});return false;">
						<input type="button" value="<?php 
            echo I18N::translate('select none');
            ?>
" onclick="jQuery('#search_trees :checkbox').each(function(){jQuery(this).attr('checked', false);});return false;">
						<?php 
コード例 #17
0
ファイル: session.php プロジェクト: jflash/webtrees
    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);
} else {
    // Last theme used?
    $theme_id = Session::get('theme_id');
    // Default for tree
    if (!array_key_exists($theme_id, Theme::themeNames()) && $WT_TREE) {
        $theme_id = $WT_TREE->getPreference('THEME_DIR');
    }
    // Default for site
    if (!array_key_exists($theme_id, Theme::themeNames())) {
        $theme_id = Site::getPreference('THEME_DIR');
    }
    // Default
    if (!array_key_exists($theme_id, Theme::themeNames())) {
        $theme_id = 'webtrees';
    }
    foreach (Theme::installedThemes() as $theme) {
        if ($theme->themeId() === $theme_id) {
            Theme::theme($theme)->init($WT_TREE);
            // Remember this setting
            Session::put('theme_id', $theme_id);
        }
    }
}
// Search engines are only allowed to see certain pages.
if (Auth::isSearchEngine() && !in_array(WT_SCRIPT_NAME, array('index.php', 'indilist.php', 'module.php', 'mediafirewall.php', 'individual.php', 'family.php', 'mediaviewer.php', 'note.php', 'repo.php', 'source.php'))) {
コード例 #18
0
        ?>
')" type="submit">
										<?php 
        echo I18N::translate('Delete');
        ?>
									</button>
								</form>
							</li>
							<!-- SET AS DEFAULT -->
							<?php 
        if (count(Tree::getAll()) > 1) {
            ?>
								<li>
									<i class="fa fa-li fa-star"></i>
									<?php 
            if ($tree->getName() == Site::getPreference('DEFAULT_GEDCOM')) {
                ?>
										<?php 
                echo I18N::translate('Default family tree');
                ?>
									<?php 
            } else {
                ?>
										<a href="#" onclick="document.defaultform<?php 
                echo $tree->getTreeId();
                ?>
.submit();">
											<?php 
                echo I18N::translate('Set as default');
                ?>
											<span class="sr-only">
コード例 #19
0
ファイル: action.php プロジェクト: josefpavlik/webtrees
                        }
                    }
                }
            }
        } 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);
        }
        break;
}
コード例 #20
0
    /**
     * Generate the HTML content of this block.
     *
     * @param int      $block_id
     * @param bool     $template
     * @param string[] $cfg
     *
     * @return string
     */
    public function getBlock($block_id, $template = true, $cfg = array())
    {
        global $controller;
        $id = $this->getName() . $block_id;
        $class = $this->getName() . '_block';
        $controller->addInlineJavascript('
			jQuery("#new_passwd").hide();
			jQuery("#passwd_click").click(function() {
				jQuery("#new_passwd").slideToggle(100, function() {
					jQuery("#new_passwd_username").focus();
				});
				return false;
			});
		');
        if (Auth::check()) {
            $title = I18N::translate('Logout');
            $content = '<div class="center"><form method="post" action="logout.php" name="logoutform" onsubmit="return true;">';
            $content .= '<br><a href="../../edituser.php" class="name2">' . I18N::translate('Logged in as ') . ' ' . Auth::user()->getRealNameHtml() . '</a><br><br>';
            $content .= '<input type="submit" value="' . I18N::translate('Logout') . '">';
            $content .= '<br><br></form></div>';
        } else {
            $title = I18N::translate('Login');
            $content = '<div id="login-box">
				<form id="login-form" name="login-form" method="post" action="' . WT_LOGIN_URL . '">
				<input type="hidden" name="action" value="login">';
            $content .= '<div>
				<label for="username">' . I18N::translate('Username') . '<input type="text" id="username" name="username" class="formField">
				</label>
				</div>
				<div>
					<label for="password">' . I18N::translate('Password') . '<input type="password" id="password" name="password" class="formField">
					</label>
				</div>
				<div>
					<input type="submit" value="' . I18N::translate('Login') . '">
				</div>
				<div>
					<a href="#" id="passwd_click">' . I18N::translate('Request new password') . '</a>
				</div>';
            if (Site::getPreference('USE_REGISTRATION_MODULE')) {
                $content .= '<div><a href="' . WT_LOGIN_URL . '?action=register">' . I18N::translate('Request new user account') . '</a></div>';
            }
            $content .= '</form>';
            // close "login-form"
            // hidden New Password block
            $content .= '<div id="new_passwd">
			<form id="new_passwd_form" name="new_passwd_form" action="' . WT_LOGIN_URL . '" method="post">
			<input type="hidden" name="time" value="">
			<input type="hidden" name="action" value="requestpw">
			<h4>' . I18N::translate('Lost password request') . '</h4>
			<div>
				<label for="new_passwd_username">' . I18N::translate('Username or email address') . '<input type="text" id="new_passwd_username" name="new_passwd_username" value="">
				</label>
			</div>
			<div><input type="submit" value="' . I18N::translate('continue') . '"></div>
			</form>
		</div>';
            //"new_passwd"
            $content .= '</div>';
            //"login-box"
        }
        if ($template) {
            return Theme::theme()->formatBlock($id, $title, $class, $content);
        } else {
            return $content;
        }
    }
コード例 #21
0
 /**
  * Generate the HTML content of this block.
  *
  * @param int      $block_id
  * @param bool     $template
  * @param string[] $cfg
  *
  * @return string
  */
 public function getBlock($block_id, $template = true, $cfg = array())
 {
     global $ctype, $WT_TREE;
     $sendmail = $this->getBlockSetting($block_id, 'sendmail', '1');
     $days = $this->getBlockSetting($block_id, 'days', '1');
     $block = $this->getBlockSetting($block_id, 'block', '1');
     foreach (array('days', 'sendmail', 'block') as $name) {
         if (array_key_exists($name, $cfg)) {
             ${$name} = $cfg[$name];
         }
     }
     $changes = Database::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne();
     if ($changes === '1' && $sendmail === '1') {
         // There are pending changes - tell moderators/managers/administrators about them.
         if (WT_TIMESTAMP - Site::getPreference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) {
             // Which users have pending changes?
             foreach (User::all() as $user) {
                 if ($user->getPreference('contactmethod') !== 'none') {
                     foreach (Tree::getAll() as $tree) {
                         if ($tree->hasPendingEdit() && Auth::isManager($tree, $user)) {
                             I18N::init($user->getPreference('language'));
                             Mail::systemMessage($tree, $user, I18N::translate('Pending changes'), I18N::translate('There are pending changes for you to moderate.') . Mail::EOL . Mail::EOL . '<a href="' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '">' . WT_BASE_URL . 'index.php?ged=' . $WT_TREE->getNameUrl() . '</a>');
                             I18N::init(WT_LOCALE);
                         }
                     }
                 }
             }
             Site::setPreference('LAST_CHANGE_EMAIL', WT_TIMESTAMP);
         }
     }
     if (Auth::isEditor($WT_TREE) && $WT_TREE->hasPendingEdit()) {
         $id = $this->getName() . $block_id;
         $class = $this->getName() . '_block';
         if ($ctype === 'user' || Auth::isManager($WT_TREE)) {
             $title = '<a class="icon-admin" title="' . I18N::translate('Configure') . '" href="block_edit.php?block_id=' . $block_id . '&amp;ged=' . $WT_TREE->getNameHtml() . '&amp;ctype=' . $ctype . '"></a>';
         } else {
             $title = '';
         }
         $title .= $this->getTitle();
         $content = '';
         if (Auth::isModerator($WT_TREE)) {
             $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . I18N::translate('There are pending changes for you to moderate.') . "</a><br>";
         }
         if ($sendmail === '1') {
             $content .= I18N::translate('Last email reminder was sent ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL')) . "<br>";
             $content .= I18N::translate('Next email reminder will be sent after ') . FunctionsDate::formatTimestamp(Site::getPreference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>";
         }
         $content .= '<ul>';
         $changes = Database::prepare("SELECT xref" . " FROM  `##change`" . " WHERE status='pending'" . " AND   gedcom_id=?" . " GROUP BY xref")->execute(array($WT_TREE->getTreeId()))->fetchAll();
         foreach ($changes as $change) {
             $record = GedcomRecord::getInstance($change->xref, $WT_TREE);
             if ($record->canShow()) {
                 $content .= '<li><a href="' . $record->getHtmlUrl() . '">' . $record->getFullName() . '</a></li>';
             }
         }
         $content .= '</ul>';
         if ($template) {
             if ($block) {
                 $class .= ' small_inner_block';
             }
             return Theme::theme()->formatBlock($id, $title, $class, $content);
         } else {
             return $content;
         }
     }
 }
コード例 #22
0
ファイル: ColorsTheme.php プロジェクト: tronsmit/webtrees
 /**
  * Create a menu of palette options
  *
  * @return Menu
  */
 protected function menuPalette()
 {
     if ($this->tree && Site::getPreference('ALLOW_USER_THEMES') && $this->tree->getPreference('ALLOW_THEME_DROPDOWN')) {
         $menu = new Menu(I18N::translate('Palette'), '#', 'menu-color');
         foreach ($this->palettes as $palette_id => $palette_name) {
             $menu->addSubmenu(new Menu($palette_name, Functions::getQueryUrl(array('themecolor' => $palette_id), '&amp;'), 'menu-color-' . $palette_id . ($this->palette === $palette_id ? ' active' : '')));
         }
         return $menu;
     } else {
         return null;
     }
 }
コード例 #23
0
ファイル: edituser.php プロジェクト: pal-saugstad/webtrees
?>
				</label>
			</div>
			<div class="value">
				<input type="email" id="form_email" name="form_email" value="<?php 
echo Filter::escapeHtml(Auth::user()->getEmail());
?>
" size="50">
				<p class="small text-muted">
					<?php 
echo I18N::translate('This email address will be used to send password reminders, website notifications, and messages from other family members who are registered on the website.');
?>
				</p>
			</div>
			<?php 
if (Site::getPreference('ALLOW_USER_THEMES')) {
    ?>

			<div class="label">
				<label for="form_theme">
					<?php 
    echo I18N::translate('Theme');
    ?>
				</label>
			</div>
			<div class="value">
				<select id="form_theme" name="form_theme">
					<option value="">
						<?php 
    echo Filter::escapeHtml(I18N::translate('<default theme>'));
    ?>
コード例 #24
0
ファイル: message.php プロジェクト: josefpavlik/webtrees
/**
 * Add a message to a user's inbox
 *
 * @param string[] $message
 *
 * @return bool
 */
function addMessage($message)
{
    global $WT_TREE;
    $success = true;
    $sender = User::findByIdentifier($message['from']);
    $recipient = User::findByIdentifier($message['to']);
    // Sender may not be a webtrees user
    if ($sender) {
        $sender_email = $sender->getEmail();
        $sender_real_name = $sender->getRealName();
    } else {
        $sender_email = $message['from'];
        $sender_real_name = $message['from_name'];
    }
    // Send a copy of the copy message back to the sender.
    if ($message['method'] !== 'messaging') {
        // Switch to the sender’s language.
        if ($sender) {
            I18N::init($sender->getPreference('language'));
        }
        $copy_email = $message['body'];
        if (!empty($message['url'])) {
            $copy_email .= Mail::EOL . Mail::EOL . '--------------------------------------' . Mail::EOL . I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL;
        }
        if ($sender) {
            // Message from a logged-in user
            $copy_email = I18N::translate('You sent the following message to a webtrees user:'******' ' . $recipient->getRealNameHtml() . Mail::EOL . Mail::EOL . $copy_email;
        } else {
            // Message from a visitor
            $copy_email = I18N::translate('You sent the following message to a webtrees administrator:') . Mail::EOL . Mail::EOL . Mail::EOL . $copy_email;
        }
        $success = $success && Mail::send($WT_TREE, $sender_email, $sender_real_name, Site::getPreference('SMTP_FROM_NAME'), $WT_TREE->getPreference('title'), I18N::translate('webtrees message') . ' - ' . $message['subject'], $copy_email);
    }
    // Switch to the recipient’s language.
    I18N::init($recipient->getPreference('language'));
    if (isset($message['from_name'])) {
        $message['body'] = I18N::translate('Your name') . ' ' . $message['from_name'] . Mail::EOL . I18N::translate('Email address') . ' ' . $message['from_email'] . Mail::EOL . Mail::EOL . $message['body'];
    }
    // Add another footer - unless we are an admin
    if (!Auth::isAdmin()) {
        if (!empty($message['url'])) {
            $message['body'] .= Mail::EOL . Mail::EOL . '--------------------------------------' . Mail::EOL . I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . Mail::EOL;
        }
    }
    if (empty($message['created'])) {
        $message['created'] = gmdate("D, d M Y H:i:s T");
    }
    if ($message['method'] !== 'messaging3' && $message['method'] !== 'mailto' && $message['method'] !== 'none') {
        Database::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($message['from'], WT_CLIENT_IP, $recipient->getUserId(), $message['subject'], str_replace('<br>', '', $message['body'])));
    }
    if ($message['method'] !== 'messaging') {
        if ($sender) {
            $original_email = I18N::translate('The following message has been sent to your webtrees user account from ');
            $original_email .= $sender->getRealNameHtml();
        } else {
            $original_email = I18N::translate('The following message has been sent to your webtrees user account from ');
            if (!empty($message['from_name'])) {
                $original_email .= $message['from_name'];
            } else {
                $original_email .= $message['from'];
            }
        }
        $original_email .= Mail::EOL . Mail::EOL . $message['body'];
        $success = $success && Mail::send($WT_TREE, $recipient->getEmail(), $recipient->getRealName(), $sender_email, $sender_real_name, I18N::translate('webtrees message') . ' - ' . $message['subject'], $original_email);
    }
    I18N::init(WT_LOCALE);
    // restore language settings if needed
    return $success;
}
コード例 #25
0
ファイル: SearchController.php プロジェクト: bmhm/webtrees
 /**
  * Startup activity
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     // $action comes from GET (search) or POST (replace)
     if (Filter::post('action')) {
         $this->action = Filter::post('action', 'replace', 'general');
         $this->query = Filter::post('query');
         $this->replace = Filter::post('replace');
         $this->replaceNames = Filter::post('replaceNames', 'checked', '');
         $this->replacePlaces = Filter::post('replacePlaces', 'checked', '');
         $this->replacePlacesWord = Filter::post('replacePlacesWord', 'checked', '');
         $this->replaceAll = Filter::post('replaceAll', 'checked', '');
     } else {
         $this->action = Filter::get('action', 'advanced|general|soundex|replace|header', 'general');
         $this->query = Filter::get('query');
         $this->replace = Filter::get('replace');
         $this->replaceNames = Filter::get('replaceNames', 'checked', '');
         $this->replacePlaces = Filter::get('replacePlaces', 'checked', '');
         $this->replacePlacesWord = Filter::get('replacePlacesWord', 'checked', '');
         $this->replaceAll = Filter::get('replaceAll', 'checked', '');
     }
     // Only editors can use search/replace
     if ($this->action === 'replace' && !Auth::isEditor($WT_TREE)) {
         $this->action = 'general';
     }
     $this->srindi = Filter::get('srindi', 'checked', '');
     $this->srfams = Filter::get('srfams', 'checked', '');
     $this->srsour = Filter::get('srsour', 'checked', '');
     $this->srnote = Filter::get('srnote', 'checked', '');
     $this->soundex = Filter::get('soundex', 'DaitchM|Russell', 'DaitchM');
     $this->showasso = Filter::get('showasso');
     $this->firstname = Filter::get('firstname');
     $this->lastname = Filter::get('lastname');
     $this->place = Filter::get('place');
     $this->year = Filter::get('year');
     // If no record types specified, search individuals
     if (!$this->srfams && !$this->srsour && !$this->srnote) {
         $this->srindi = 'checked';
     }
     // If no replace types specifiied, replace full records
     if (!$this->replaceNames && !$this->replacePlaces && !$this->replacePlacesWord) {
         $this->replaceAll = 'checked';
     }
     // Trees to search
     if (Site::getPreference('ALLOW_CHANGE_GEDCOM')) {
         foreach (Tree::getAll() as $search_tree) {
             if (Filter::get('tree_' . $search_tree->getTreeId())) {
                 $this->search_trees[] = $search_tree;
             }
         }
         if (!$this->search_trees) {
             $this->search_trees[] = $WT_TREE;
         }
     } else {
         $this->search_trees[] = $WT_TREE;
     }
     // If we want to show associated persons, build the list
     switch ($this->action) {
         case 'header':
             // We can type in an XREF into the header search, and jump straight to it.
             // Otherwise, the header search is the same as the general search
             if (preg_match('/' . WT_REGEX_XREF . '/', $this->query)) {
                 $record = GedcomRecord::getInstance($this->query, $WT_TREE);
                 if ($record && $record->canShowName()) {
                     header('Location: ' . WT_BASE_URL . $record->getRawUrl());
                     exit;
                 }
             }
             $this->action = 'general';
             $this->srindi = 'checked';
             $this->srfams = 'checked';
             $this->srsour = 'checked';
             $this->srnote = 'checked';
             $this->setPageTitle(I18N::translate('General search'));
             $this->generalSearch();
             break;
         case 'general':
             $this->setPageTitle(I18N::translate('General search'));
             $this->generalSearch();
             break;
         case 'soundex':
             // Create a dummy search query to use as a title to the results list
             $this->query = trim($this->firstname . ' ' . $this->lastname . ' ' . $this->place);
             $this->setPageTitle(I18N::translate('Phonetic search'));
             $this->soundexSearch();
             break;
         case 'replace':
             $this->setPageTitle(I18N::translate('Search and replace'));
             $this->search_trees = array($WT_TREE);
             $this->srindi = 'checked';
             $this->srfams = 'checked';
             $this->srsour = 'checked';
             $this->srnote = 'checked';
             if (Filter::post('query')) {
                 $this->searchAndReplace($WT_TREE);
                 header('Location: ' . WT_BASE_URL . WT_SCRIPT_NAME . '?action=replace&query=' . Filter::escapeUrl($this->query) . '&replace=' . Filter::escapeUrl($this->replace) . '&replaceAll=' . $this->replaceAll . '&replaceNames=' . $this->replaceNames . '&replacePlaces=' . $this->replacePlaces . '&replacePlacesWord=' . $this->replacePlacesWord);
                 exit;
             }
     }
 }
コード例 #26
0
ファイル: ColorsTheme.php プロジェクト: tunandras/webtrees
 /**
  * Create resources for the colors theme.
  */
 public function hookAfterInit()
 {
     $this->palettes = array('aquamarine' => I18N::translate('Aqua Marine'), 'ash' => I18N::translate('Ash'), 'belgianchocolate' => I18N::translate('Belgian Chocolate'), 'bluelagoon' => I18N::translate('Blue Lagoon'), 'bluemarine' => I18N::translate('Blue Marine'), 'coffeeandcream' => I18N::translate('Coffee and Cream'), 'coldday' => I18N::translate('Cold Day'), 'greenbeam' => I18N::translate('Green Beam'), 'mediterranio' => I18N::translate('Mediterranio'), 'mercury' => I18N::translate('Mercury'), 'nocturnal' => I18N::translate('Nocturnal'), 'olivia' => I18N::translate('Olivia'), 'pinkplastic' => I18N::translate('Pink Plastic'), 'sage' => I18N::translate('Sage'), 'shinytomato' => I18N::translate('Shiny Tomato'), 'tealtop' => I18N::translate('Teal Top'));
     uasort($this->palettes, '\\Fisharebest\\Webtrees\\I18N::strcasecmp');
     // If we've selected a new palette, and we are logged in, set this value as a default.
     if (isset($_GET['themecolor']) && array_key_exists($_GET['themecolor'], $this->palettes)) {
         // Request to change color
         $this->palette = $_GET['themecolor'];
         Auth::user()->setPreference('themecolor', $this->palette);
         if (Auth::isAdmin()) {
             Site::setPreference('DEFAULT_COLOR_PALETTE', $this->palette);
         }
         unset($_GET['themecolor']);
         // Rember that we have selected a value
         Session::put('subColor', $this->palette);
     }
     // If we are logged in, use our preference
     $this->palette = Auth::user()->getPreference('themecolor');
     // If not logged in or no preference, use one we selected earlier in the session?
     if (!$this->palette) {
         $this->palette = Session::get('subColor');
     }
     // We haven't selected one this session?  Use the site default
     if (!$this->palette) {
         $this->palette = Site::getPreference('DEFAULT_COLOR_PALETTE');
     }
     // Make sure our selected palette actually exists
     if (!array_key_exists($this->palette, $this->palettes)) {
         $this->palette = 'ash';
     }
 }