function fetch_latest_version() { $last_update_timestamp = WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP'); if ($last_update_timestamp < WT_TIMESTAMP - 24 * 60 * 60) { $row = WT_DB::prepare("SHOW VARIABLES LIKE 'version'")->fetchOneRow(); $params = '?w=' . WT_VERSION . '&p=' . PHP_VERSION . '&m=' . $row->value . '&o=' . (DIRECTORY_SEPARATOR == '/' ? 'u' : 'w'); $latest_version_txt = WT_File::fetchUrl('http://svn.webtrees.net/build/latest-version.txt' . $params); if ($latest_version_txt) { WT_Site::preference('LATEST_WT_VERSION', $latest_version_txt); WT_Site::preference('LATEST_WT_VERSION_TIMESTAMP', WT_TIMESTAMP); return $latest_version_txt; } else { // Cannot connect to server - use cached version (if we have one) return WT_Site::preference('LATEST_WT_VERSION'); } } else { return WT_Site::preference('LATEST_WT_VERSION'); } }
public function getBlock($block_id, $template = true, $cfg = null) { global $controller; $indi_xref = $controller->getSignificantIndividual()->getXref(); $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; $title = '<span dir="auto">' . WT_TREE_TITLE . '</span>'; $content = '<table><tr>'; $content .= '<td><a href="pedigree.php?rootid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-pedigree"></i><br>' . WT_I18N::translate('Default chart') . '</a></td>'; $content .= '<td><a href="individual.php?pid=' . $indi_xref . '&ged=' . WT_GEDURL . '"><i class="icon-indis"></i><br>' . WT_I18N::translate('Default individual') . '</a></td>'; if (WT_Site::preference('USE_REGISTRATION_MODULE') && WT_USER_ID == false) { $content .= '<td><a href="' . WT_LOGIN_URL . '?action=register"><i class="icon-user_add"></i><br>' . WT_I18N::translate('Request new user account') . '</a></td>'; } $content .= "</tr>"; $content .= "</table>"; if ($template) { require WT_THEME_DIR . 'templates/block_main_temp.php'; } else { return $content; } }
public static function transport() { switch (WT_Site::preference('SMTP_ACTIVE')) { case 'internal': return new Zend_Mail_Transport_Sendmail(); case 'external': $config = array('name' => WT_Site::preference('SMTP_HELO'), 'port' => WT_Site::preference('SMTP_PORT')); if (WT_Site::preference('SMTP_AUTH')) { $config['auth'] = 'login'; $config['username'] = WT_Site::preference('SMTP_AUTH_USER'); $config['password'] = WT_Site::preference('SMTP_AUTH_PASS'); } if (WT_Site::preference('SMTP_SSL') !== 'none') { $config['ssl'] = WT_Site::preference('SMTP_SSL'); } return new Zend_Mail_Transport_Smtp(WT_Site::preference('SMTP_HOST'), $config); default: // For testing return new Zend_Mail_Transport_File(); } }
function color_theme_dropdown() { global $COLOR_THEME_LIST, $WT_SESSION, $subColor; $menu = new WT_Menu(WT_I18N::translate('Palette'), '#', 'menu-color'); uasort($COLOR_THEME_LIST, array('WT_I18N', 'strcasecmp')); foreach ($COLOR_THEME_LIST as $colorChoice => $colorName) { $submenu = new WT_Menu($colorName, get_query_url(array('themecolor' => $colorChoice), '&'), 'menu-color-' . $colorChoice); if (isset($WT_SESSION->subColor)) { if ($WT_SESSION->subColor == $colorChoice) { $submenu->addClass('', '', 'theme-active'); } } elseif (WT_Site::preference('DEFAULT_COLOR_PALETTE') == $colorChoice) { /* here when visitor changes palette from default */ $submenu->addClass('', '', 'theme-active'); } elseif ($subColor == 'ash') { /* here when site has different theme as default and user switches to colors */ if ($subColor == $colorChoice) { $submenu->addClass('', '', 'theme-active'); } } $menu->addSubMenu($submenu); } return $menu->getMenuAsList(); }
function addMessage($message) { global $WT_TREE, $WT_REQUEST; $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) { WT_I18N::init($sender->getSetting('language')); } $copy_email = $message['body']; if (!empty($message['url'])) { $copy_email .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL; } $copy_email .= WT_Mail::auditFooter(); if ($sender) { // Message from a logged-in user $copy_email = WT_I18N::translate('You sent the following message to a webtrees user:'******' ' . $recipient->getRealName() . WT_Mail::EOL . WT_Mail::EOL . $copy_email; } else { // Message from a visitor $copy_email = WT_I18N::translate('You sent the following message to a webtrees administrator:') . WT_Mail::EOL . WT_Mail::EOL . WT_Mail::EOL . $copy_email; } $success = $success && WT_Mail::send($WT_TREE, $sender_email, $sender_real_name, WT_Site::preference('SMTP_FROM_NAME'), $WT_TREE->preference('title'), WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $copy_email); } // Switch to the recipient’s language. WT_I18N::init($recipient->getSetting('language')); if (isset($message['from_name'])) { $message['body'] = WT_I18N::translate('Your name:') . ' ' . $message['from_name'] . WT_Mail::EOL . WT_I18N::translate('Email address:') . ' ' . $message['from_email'] . WT_Mail::EOL . WT_Mail::EOL . $message['body']; } // Add another footer - unless we are an admin if (!Auth::isAdmin()) { if (!empty($message['url'])) { $message['body'] .= WT_Mail::EOL . WT_Mail::EOL . '--------------------------------------' . WT_Mail::EOL . WT_I18N::translate('This message was sent while viewing the following URL: ') . $message['url'] . WT_Mail::EOL; } $message['body'] .= WT_Mail::auditFooter(); } 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') { WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($message['from'], $WT_REQUEST->getClientIp(), $recipient->getUserId(), $message['subject'], str_replace('<br>', '', $message['body']))); } if ($message['method'] != 'messaging') { if ($sender) { $original_email = WT_I18N::translate('The following message has been sent to your webtrees user account from '); $original_email .= $sender->getRealName(); } else { $original_email = WT_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 .= WT_Mail::EOL . WT_Mail::EOL . $message['body']; $success = $success && WT_Mail::send($WT_TREE, $recipient->getEmail(), $recipient->getRealName(), $sender_email, $sender_real_name, WT_I18N::translate('webtrees message') . ' - ' . $message['subject'], $original_email); } WT_I18N::init(WT_LOCALE); // restore language settings if needed return $success; }
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $GEDCOM; // Only show this block for certain languages $languages = get_block_setting($block_id, 'languages'); if ($languages && !in_array(WT_LOCALE, explode(',', $languages))) { return; } /* * Select GEDCOM */ $gedcom = get_block_setting($block_id, 'gedcom'); switch ($gedcom) { case '__current__': break; case '': break; case '__default__': $GEDCOM = WT_Site::preference('DEFAULT_GEDCOM'); if (!$GEDCOM) { foreach (WT_Tree::getAll() as $tree) { $GEDCOM = $tree->tree_name; break; } } break; default: $GEDCOM = $gedcom; break; } /* * Retrieve text, process embedded variables */ $title_tmp = get_block_setting($block_id, 'title'); $html = get_block_setting($block_id, 'html'); if (strpos($title_tmp, '#') !== false || strpos($html, '#') !== false) { $stats = new WT_Stats($GEDCOM); $title_tmp = $stats->embedTags($title_tmp); $html = $stats->embedTags($html); } /* * Restore Current GEDCOM */ $GEDCOM = WT_GEDCOM; /* * Start Of Output */ $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $title_tmp; $content = $html; if (get_block_setting($block_id, 'show_timestamp', false)) { $content .= '<br>' . format_timestamp(get_block_setting($block_id, 'timestamp', WT_TIMESTAMP)); } if ($template) { if (get_block_setting($block_id, 'block', false)) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } }
<div> <label for="user_password">', WT_I18N::translate('Password'), '</label> <input type="password" id="user_password" name="user_password" value="" autofocus> </div> <div> <label for="user_hashcode">', WT_I18N::translate('Verification code:'), '</label> <input type="text" id="user_hashcode" name="user_hashcode" value="', $user_hashcode, '"> </div> <div> <input type="submit" value="', WT_I18N::translate('Send'), '"> </div> </form> </div>'; break; case 'verify_hash': if (!WT_Site::preference('USE_REGISTRATION_MODULE')) { header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH); exit; } // switch language to webmaster settings $webmaster = User::find(get_gedcom_setting(WT_GED_ID, 'WEBMASTER_USER_ID')); WT_I18N::init($webmaster->getSetting('language')); $user = User::findByIdentifier($user_name); $mail1_body = WT_I18N::translate('Hello administrator…') . WT_Mail::EOL . WT_Mail::EOL . WT_I18N::translate('A new user (%1$s) has requested an account (%2$s) and verified an email address (%3$s).', $user->getRealName(), $user->getUserName(), $user->getEmail()) . WT_Mail::EOL . WT_Mail::EOL; if ($REQUIRE_ADMIN_AUTH_REGISTRATION && !$user->getSetting('verified_by_admin')) { $mail1_body .= WT_I18N::translate('You now need to review the account details, and set the “approved” status to “yes”.'); } else { $mail1_body .= WT_I18N::translate('You do not have to take any action; the user can now login.'); } $mail1_body .= WT_Mail::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . "admin_users.php?filter=" . rawurlencode($user->getUserName()) . '</a>' . WT_Mail::auditFooter(); $mail1_subject = WT_I18N::translate('New user at %s', WT_SERVER_NAME . WT_SCRIPT_PATH . ' ' . $WT_TREE->tree_title);
private static function historical_facts(WT_Individual $person) { global $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(WT_Site::preference('INDEX_DIRECTORY') . 'histo.' . WT_LOCALE . '.php')) { require WT_Site::preference('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 WT_Fact($hist, $person, 'histo'); $sdate = $fact->getDate(); if ($sdate->isOK() && WT_Date::Compare($birt_date, $sdate) <= 0 && WT_Date::Compare($sdate, $deat_date) <= 0) { $facts[] = $fact; } } } } return $facts; }
} // TODO May need to set 'DATA_DIRECTORY' to $INDEX_DIRECTORY when dealing with media?? @WT_Site::preference('USE_REGISTRATION_MODULE', $USE_REGISTRATION_MODULE); @WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION', $REQUIRE_ADMIN_AUTH_REGISTRATION); @WT_Site::preference('ALLOW_USER_THEMES', $ALLOW_USER_THEMES); @WT_Site::preference('ALLOW_CHANGE_GEDCOM', $ALLOW_CHANGE_GEDCOM); @WT_Site::preference('SESSION_TIME', $PGV_SESSION_TIME); @WT_Site::preference('SMTP_ACTIVE', $PGV_SMTP_ACTIVE ? 'external' : 'internal'); @WT_Site::preference('SMTP_HOST', $PGV_SMTP_HOST); @WT_Site::preference('SMTP_HELO', $PGV_SMTP_HELO); @WT_Site::preference('SMTP_PORT', $PGV_SMTP_PORT); @WT_Site::preference('SMTP_AUTH', $PGV_SMTP_AUTH); @WT_Site::preference('SMTP_AUTH_USER', $PGV_SMTP_AUTH_USER); @WT_Site::preference('SMTP_AUTH_PASS', $PGV_SMTP_AUTH_PASS); @WT_Site::preference('SMTP_SSL', $PGV_SMTP_SSL); @WT_Site::preference('SMTP_FROM_NAME', $PGV_SMTP_FROM_NAME); //////////////////////////////////////////////////////////////////////////////// echo '<p>pgv_site_setting => wt_site_setting ...</p>'; flush(); if (ini_get('output_buffering')) { ob_flush(); } WT_DB::prepare("REPLACE INTO `##site_setting` (setting_name, setting_value)" . " SELECT site_setting_name, site_setting_value FROM `{$DBNAME}`.`{$TBLPREFIX}site_setting`" . " WHERE site_setting_name IN ('DEFAULT_GEDCOM', 'LAST_CHANGE_EMAIL')")->execute(); //////////////////////////////////////////////////////////////////////////////// if ($PGV_SCHEMA_VERSION >= 12) { echo '<p>pgv_gedcom => wt_gedcom ...</p>'; flush(); if (ini_get('output_buffering')) { ob_flush(); } WT_DB::prepare("INSERT INTO `##gedcom` (gedcom_id, gedcom_name)" . " SELECT gedcom_id, gedcom_name FROM `{$DBNAME}`.`{$TBLPREFIX}gedcom`")->execute();
public function getBlock($block_id, $template = true, $cfg = null) { 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 (WT_USER_ID) { $title = WT_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">' . WT_I18N::translate('Logged in as ') . ' ' . WT_USER_NAME . '</a><br><br>'; $content .= "<input type=\"submit\" value=\"" . WT_I18N::translate('Logout') . "\">"; $content .= "<br><br></form></div>"; } else { $title = WT_I18N::translate('Login'); $content = '<div id="login-box"> <form id="login-form" name="login-form" method="post" action="' . WT_LOGIN_URL . '" onsubmit="d=new Date(); this.timediff.value=d.getTimezoneOffset()*60;"> <input type="hidden" name="action" value="login"> <input type="hidden" name="timediff" value="">'; $content .= '<div> <label for="username">' . WT_I18N::translate('Username') . '<input type="text" id="username" name="username" class="formField"> </label> </div> <div> <label for="password">' . WT_I18N::translate('Password') . '<input type="password" id="password" name="password" class="formField"> </label> </div> <div> <input type="submit" value="' . WT_I18N::translate('Login') . '"> </div> <div> <a href="#" id="passwd_click">' . WT_I18N::translate('Request new password') . '</a> </div>'; if (WT_Site::preference('USE_REGISTRATION_MODULE')) { $content .= '<div><a href="' . WT_LOGIN_URL . '?action=register">' . WT_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>' . WT_I18N::translate('Lost password request') . '</h4> <div> <label for="new_passwd_username">' . WT_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="' . WT_I18N::translate('continue') . '"></div> </form> </div>'; //"new_passwd" $content .= '</div>'; //"login-box" } if ($template) { require WT_THEME_DIR . 'templates/block_main_temp.php'; } else { return $content; } }
public static function getThemeMenu() { global $SEARCH_SPIDER; if (WT_GED_ID && !$SEARCH_SPIDER && WT_Site::preference('ALLOW_USER_THEMES') && get_gedcom_setting(WT_GED_ID, 'ALLOW_THEME_DROPDOWN')) { $menu = new WT_Menu(WT_I18N::translate('Theme'), '#', 'menu-theme'); foreach (get_theme_names() as $themename => $themedir) { $submenu = new WT_Menu($themename, get_query_url(array('theme' => $themedir), '&'), 'menu-theme-' . $themedir); if (WT_THEME_DIR == 'themes/' . $themedir . '/') { $submenu->addClass('', '', 'theme-active'); } $menu->addSubMenu($submenu); } return $menu; } else { return null; } }
// seconds, for systems with low timeout values. // // webtrees: Web based Family History software // Copyright (C) 2014 Greg Roach // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); exit; } self::exec("CREATE TABLE IF NOT EXISTS `##gedcom_chunk` (" . " gedcom_chunk_id INTEGER AUTO_INCREMENT NOT NULL," . " gedcom_id INTEGER NOT NULL," . " chunk_data MEDIUMBLOB NOT NULL," . " imported BOOLEAN NOT NULL DEFAULT FALSE," . " PRIMARY KEY (gedcom_chunk_id)," . " KEY ix1 (gedcom_id, imported)," . " FOREIGN KEY fk1 (gedcom_id) REFERENCES `##gedcom` (gedcom_id)" . ") COLLATE utf8_unicode_ci ENGINE=InnoDB"); try { self::exec("ALTER TABLE `##gedcom` DROP import_gedcom, DROP import_offset"); } catch (PDOException $ex) { // Perhaps we have already deleted these columns? } // Update the version to indicate success WT_Site::preference($schema_name, $next_version);
case 'SMTP_SSL': case 'WELCOME_TEXT_AUTH_MODE': break; case 'SMTP_AUTH_PASS': // The password will be displayed as "click to edit" on screen. // Accept the update, but pretend to fail. This will leave the "click to edit" on screen if ($value) { WT_Site::preference($id1, $value); } fail(); default: // An unrecognized setting fail(); } // Authorised and valid - make update WT_Site::preference($id1, $value); ok(); case 'site_access_rule': ////////////////////////////////////////////////////////////////////////////// // Table name: WT_SITE_ACCESS_RULE // ID format: site_access_rule-{column_name}-{user_id} ////////////////////////////////////////////////////////////////////////////// if (!Auth::isAdmin()) { fail(); } switch ($id1) { case 'ip_address_start': case 'ip_address_end': WT_DB::prepare("UPDATE `##site_access_rule` SET {$id1}=INET_ATON(?) WHERE site_access_rule_id=?")->execute(array($value, $id2)); $value = WT_DB::prepare("SELECT INET_NTOA({$id1}) FROM `##site_access_rule` WHERE site_access_rule_id=?")->execute(array($id2))->fetchOne(); ok();
public static function updateSchema($schema_dir, $schema_name, $target_version) { try { $current_version = (int) WT_Site::preference($schema_name); } catch (PDOException $e) { // During initial installation, this table won’t exist. // It will only be a problem if we can’t subsequently create it. $current_version = 0; } // The update scripts can set these to indicate that we need to run a // "post update" script. It saves from having to store/maintain lots // of separate versions at each schema version. $need_to_delete_old_files = false; $need_to_update_config_data = false; $need_to_update_stored_procedures = false; // During installation, the current version is set to a special value of // -1 (v1.2.5 to v1.2.7) or -2 (v1.3.0 onwards). This indicates that the tables have // been created, but that we still need to install/update configuration data // and/or stored procedures. switch ($current_version) { case -1: // Due to a bug in webtrees 1.2.5 - 1.2.7, the setup value of "-1" // wasn't being updated. $current_version = 12; WT_Site::preference($schema_name, $current_version); break; case -2: // Because of the above bug, we now set the version to -2 during setup. $current_version = $target_version; WT_Site::preference($schema_name, $current_version); break; } // Update the schema, one version at a time. while ($current_version < $target_version) { $next_version = $current_version + 1; require $schema_dir . 'db_schema_' . $current_version . '_' . $next_version . '.php'; // The updatescript should update the version or throw an exception $current_version = (int) WT_Site::preference($schema_name); if ($current_version != $next_version) { die("Internal error while updating {$schema_name} to {$next_version}"); } } if ($need_to_delete_old_files) { require $schema_dir . 'delete_old_files.php'; } if ($need_to_update_config_data) { require $schema_dir . 'config_data.php'; } if ($need_to_update_stored_procedures) { require $schema_dir . 'stored_procedures.php'; } }
$convert = WT_Filter::get('convert', 'yes|no', 'no'); $zip = WT_Filter::get('zip', 'yes|no', 'no'); $conv_path = WT_Filter::get('conv_path'); $privatize_export = WT_Filter::get('privatize_export', 'none|visitor|user|gedadmin'); if ($action == 'download') { $exportOptions = array(); $exportOptions['privatize'] = $privatize_export; $exportOptions['toANSI'] = $convert; $exportOptions['path'] = $conv_path; } $fileName = WT_GEDCOM; if ($action == "download" && $zip == "yes") { require WT_ROOT . 'library/pclzip.lib.php'; $temppath = WT_Site::preference('INDEX_DIRECTORY') . "tmp/"; $zipname = "dl" . date("YmdHis") . $fileName . ".zip"; $zipfile = WT_Site::preference('INDEX_DIRECTORY') . $zipname; $gedname = $temppath . $fileName; $removeTempDir = false; if (!is_dir($temppath)) { $res = mkdir($temppath); if ($res !== true) { echo "Error : Could not create temporary path!"; exit; } $removeTempDir = true; } $gedout = fopen($gedname, "w"); export_gedcom($GEDCOM, $gedout, $exportOptions); fclose($gedout); $comment = "Created by " . WT_WEBTREES . " " . WT_VERSION . " on " . date("r") . "."; $archive = new PclZip($zipfile);
</dt> <dd><?php echo edit_field_yes_no_inline('site_setting-USE_REGISTRATION_MODULE', WT_Site::preference('USE_REGISTRATION_MODULE'), $controller); ?> </dd> <dt><?php echo WT_I18N::translate('Require an administrator to approve new user registrations'), help_link('REQUIRE_ADMIN_AUTH_REGISTRATION'); ?> </dt> <dd><?php echo edit_field_yes_no_inline('site_setting-REQUIRE_ADMIN_AUTH_REGISTRATION', WT_Site::preference('REQUIRE_ADMIN_AUTH_REGISTRATION'), $controller); ?> </dd> <dt><?php echo WT_I18N::translate('Show acceptable use agreement on “Request new user account” page'), help_link('SHOW_REGISTER_CAUTION'); ?> </dt> <dd><?php echo edit_field_yes_no_inline('site_setting-SHOW_REGISTER_CAUTION', WT_Site::preference('SHOW_REGISTER_CAUTION'), $controller); ?> </dd> </dl> </td> </tr> </table> </div> </div> </div>
echo ' checked="checked" '; } echo '>', WT_I18N::translate('Daitch-Mokotoff'); echo '</p></div>'; // Associates Section echo '<div class="label">', WT_I18N::translate('Associates'), '</div> <div class="value"><input type="checkbox" name="showasso" value="on"'; if ($controller->showasso == "on") { echo ' checked="checked" '; } echo '>', WT_I18N::translate('Show related individuals/families'), '</div>'; } // If the search is a general or soundex search then possibly display checkboxes for the gedcoms if ($controller->action == "general" || $controller->action == "soundex") { // If more than one GEDCOM, switching is allowed AND DB mode is set, let the user select if (count(WT_Tree::getAll()) > 1 && WT_Site::preference('ALLOW_CHANGE_GEDCOM')) { // More Than 3 Gedcom Filess enable elect all & select none buttons if (count(WT_Tree::getAll()) > 3) { echo '<div class="label"> </div> <div class="value"> <input type="button" value="', WT_I18N::translate('select all'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', true);});return false;"> <input type="button" value="', WT_I18N::translate('select none'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', false);});return false;">'; // More Than 10 Gedcom Files enable invert selection button if (count(WT_Tree::getAll()) > 10) { echo '<input type="button" value="', WT_I18N::translate('invert selection'), '" onclick="jQuery(\'#search_trees :checkbox\').each(function(){jQuery(this).attr(\'checked\', !jQuery(this).attr(\'checked\'));});return false;">'; } echo '</div>'; } echo '<div class="label">', WT_I18N::translate('Family trees'), '</div> <div id="search_trees" class="value">'; //-- sorting menu by gedcom filename
} else { header('HTTP/1.0 406 Not Acceptable'); } break; case 'reject-changes': // Reject all the pending changes for a record require WT_ROOT . 'includes/functions/functions_import.php'; $record = WT_GedcomRecord::getInstance(WT_Filter::post('xref', WT_REGEX_XREF)); if ($record && WT_USER_CAN_ACCEPT && $record->canShow() && $record->canEdit()) { WT_FlashMessages::addMessage(WT_I18N::translate('The changes to “%s” have been rejected.', $record->getFullName())); reject_all_changes($record->getXref(), $record->getGedcomId()); } else { header('HTTP/1.0 406 Not Acceptable'); } break; case 'theme': // Change the current theme $theme_dir = WT_Filter::post('theme'); if (WT_Site::preference('ALLOW_USER_THEMES') && in_array($theme_dir, get_theme_names())) { $WT_SESSION->theme_dir = $theme_dir; if (Auth::id()) { // Remember our selection Auth::user()->setSetting('theme', $theme_dir); } } else { // Request for a non-existant theme. header('HTTP/1.0 406 Not Acceptable'); } break; } Zend_Session::writeClose();
$THEME_DIR = $WT_SESSION->theme_dir; } } else { $THEME_DIR = ''; } if (!$THEME_DIR) { // User cannot choose (or has not chosen) a theme. // 1) gedcom setting // 2) site setting // 3) webtrees // 4) first one found if (WT_GED_ID) { $THEME_DIR = get_gedcom_setting(WT_GED_ID, 'THEME_DIR'); } if (!in_array($THEME_DIR, get_theme_names())) { $THEME_DIR = WT_Site::preference('THEME_DIR'); } if (!in_array($THEME_DIR, get_theme_names())) { $THEME_DIR = 'webtrees'; } if (!in_array($THEME_DIR, get_theme_names())) { list($THEME_DIR) = get_theme_names(); } } define('WT_THEME_DIR', WT_THEMES_DIR . $THEME_DIR . '/'); // Remember this setting if (WT_THEME_DIR != WT_THEMES_DIR . '_administration/') { $WT_SESSION->theme_dir = $THEME_DIR; } } // If we have specified a CDN, use it for static theme resources
public function getBlock($block_id, $template = true, $cfg = null) { global $ctype, $WEBTREES_EMAIL; $changes = WT_DB::prepare("SELECT 1" . " FROM `##change`" . " WHERE status='pending'" . " LIMIT 1")->fetchOne(); $days = get_block_setting($block_id, 'days', 1); $sendmail = get_block_setting($block_id, 'sendmail', true); $block = get_block_setting($block_id, 'block', true); if ($cfg) { foreach (array('days', 'sendmail', 'block') as $name) { if (array_key_exists($name, $cfg)) { ${$name} = $cfg[$name]; } } } if ($changes && $sendmail == 'yes') { // There are pending changes - tell moderators/managers/administrators about them. if (WT_TIMESTAMP - WT_Site::preference('LAST_CHANGE_EMAIL') > 60 * 60 * 24 * $days) { // Which users have pending changes? foreach (User::all() as $user) { if ($user->getSetting('contactmethod') !== 'none') { foreach (WT_Tree::getAll() as $tree) { if (exists_pending_change($user, $tree)) { WT_I18N::init($user->getSetting('language')); WT_Mail::systemMessage($tree, $user, WT_I18N::translate('Pending changes'), WT_I18N::translate('There are pending changes for you to moderate.') . WT_Mail::EOL . WT_MAIL::EOL . '<a href="' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '">' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'index.php?ged=' . WT_GEDURL . '</a>'); WT_I18N::init(WT_LOCALE); } } } } WT_Site::preference('LAST_CHANGE_EMAIL', WT_TIMESTAMP); } if (WT_USER_CAN_EDIT) { $id = $this->getName() . $block_id; $class = $this->getName() . '_block'; if ($ctype == 'gedcom' && WT_USER_GEDCOM_ADMIN || $ctype == 'user' && WT_USER_ID) { $title = '<i class="icon-admin" title="' . WT_I18N::translate('Configure') . '" onclick="modalDialog(\'block_edit.php?block_id=' . $block_id . '\', \'' . $this->getTitle() . '\');"></i>'; } else { $title = ''; } $title .= $this->getTitle() . help_link('review_changes', $this->getName()); $content = ''; if (WT_USER_CAN_ACCEPT) { $content .= "<a href=\"#\" onclick=\"window.open('edit_changes.php','_blank', chan_window_specs); return false;\">" . WT_I18N::translate('There are pending changes for you to moderate.') . "</a><br>"; } if ($sendmail == "yes") { $content .= WT_I18N::translate('Last email reminder was sent ') . format_timestamp(WT_Site::preference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::preference('LAST_CHANGE_EMAIL') + 60 * 60 * 24 * $days) . "<br><br>"; } $changes = WT_DB::prepare("SELECT xref" . " FROM `##change`" . " WHERE status='pending'" . " AND gedcom_id=?" . " GROUP BY xref")->execute(array(WT_GED_ID))->fetchAll(); foreach ($changes as $change) { $record = WT_GedcomRecord::getInstance($change->xref); if ($record->canShow()) { $content .= '<b>' . $record->getFullName() . '</b>'; $content .= $block ? '<br>' : ' '; $content .= '<a href="' . $record->getHtmlUrl() . '">' . WT_I18N::translate('View the changes') . '</a>'; $content .= '<br>'; } } if ($template) { if ($block) { require WT_THEME_DIR . 'templates/block_small_temp.php'; } else { require WT_THEME_DIR . 'templates/block_main_temp.php'; } } else { return $content; } } } }
$in_progress = WT_DB::prepare("SELECT 1 FROM `##gedcom_chunk` WHERE gedcom_id=? AND imported=1 LIMIT 1")->execute(array($tree->tree_id))->fetchOne(); if (!$in_progress) { echo '<div id="import', $tree->tree_id, '"><div id="progressbar', $tree->tree_id, '"><div style="position:absolute;">', WT_I18N::translate('Deleting old genealogy data…'), '</div></div></div>'; $controller->addInlineJavascript('jQuery("#progressbar' . $tree->tree_id . '").progressbar({value: 0});'); } else { echo '<div id="import', $tree->tree_id, '"></div>'; } $controller->addInlineJavascript('jQuery("#import' . $tree->tree_id . '").load("import.php?gedcom_id=' . $tree->tree_id . '&keep_media' . $tree->tree_id . '=' . WT_Filter::get('keep_media' . $tree->tree_id) . '");'); echo '<table border="0" width="100%" id="actions', $tree->tree_id, '" style="display:none">'; } else { echo '<table border="0" width="100%" id="actions', $tree->tree_id, '">'; } echo '<tr align="center">', '<td><a href="admin_trees_export.php?ged=', $tree->tree_name_url, '" onclick="return modalDialog(\'admin_trees_export.php?ged=', $tree->tree_name_url, '\', \'', WT_I18N::translate('Export'), '\');">', WT_I18N::translate('Export'), '</a>', help_link('export_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=importform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Import'), '</a>', help_link('import_gedcom'), '</td>', '<td><a href="admin_trees_download.php?ged=', $tree->tree_name_url, '">', WT_I18N::translate('Download'), '</a>', help_link('download_gedcom'), '</td>', '<td><a href="', WT_SCRIPT_NAME, '?action=uploadform&gedcom_id=', $tree->tree_id, '">', WT_I18N::translate('Upload'), '</a>', help_link('upload_gedcom'), '</td>', '<td>', '<a href="#" onclick="if (confirm(\'' . WT_Filter::escapeJs(WT_I18N::translate('Are you sure you want to delete “%s”?', $tree->tree_name)), '\')) document.delete_form', $tree->tree_id, '.submit(); return false;">', WT_I18N::translate('Delete'), '</a>', '<form name="delete_form', $tree->tree_id, '" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="delete">', '<input type="hidden" name="gedcom_id" value="', $tree->tree_id, '">', WT_Filter::getCsrf(), '</form>', '</td></tr></table></td></tr></table><br>'; } } // Options for creating new gedcoms and setting defaults if (Auth::isAdmin()) { echo '<table class="gedcom_table2"><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<th>', WT_I18N::translate('Default family tree'), help_link('default_gedcom'), '</th>'; } echo '<th>', WT_I18N::translate('Create a new family tree'), help_link('add_new_gedcom'), '</th></tr><tr>'; if (count(WT_Tree::GetAll()) > 1) { echo '<td><form name="defaultform" method="post" action="', WT_SCRIPT_NAME, '">', '<input type="hidden" name="action" value="setdefault">', WT_Filter::getCsrf(), select_edit_control('default_ged', WT_Tree::getNameList(), '', WT_Site::preference('DEFAULT_GEDCOM'), 'onchange="document.defaultform.submit();"'), '</form></td>'; } echo '<td class="button">', '<form name="createform" method="post" action="', WT_SCRIPT_NAME, '">', WT_Filter::getCsrf(), '<input type="hidden" name="action" value="new_tree">', '<input name="ged_name">', ' <input type="submit" value="', WT_I18N::translate('save'), '">', '</form>', '</td>', '</tr></table><br>'; // display link to PGV-WT transfer wizard on first visit to this page, before any GEDCOM is loaded if (count(WT_Tree::GetAll()) == 0 && count(User::all()) == 1) { echo '<div class="center">', '<a style="color:green; font-weight:bold;" href="admin_pgv_to_wt.php">', WT_I18N::translate('Click here for PhpGedView to <b>webtrees</b> transfer wizard'), '</a>', help_link('PGV_WIZARD'), '</div>'; } }
function __construct() { parent::__construct(); // $action comes from GET (menus) or POST (form submission) $this->action = WT_Filter::post('action', 'advanced|general|soundex|replace'); if (!$this->action) { $this->action = WT_Filter::get('action', 'advanced|general|soundex|replace', 'general'); } $topsearch = WT_Filter::postBool('topsearch'); if ($topsearch) { $this->isPostBack = true; $this->srfams = 'yes'; $this->srindi = 'yes'; $this->srsour = 'yes'; $this->srnote = 'yes'; } // Get the query $this->query = WT_Filter::post('query', '.{2,}'); $this->myquery = WT_Filter::escapeHtml($this->query); $this->replace = WT_Filter::post('replace'); $this->replaceNames = WT_Filter::postBool('replaceNames'); $this->replacePlaces = WT_Filter::postBool('replacePlaces'); $this->replacePlacesWord = WT_Filter::postBool('replacePlacesWord'); $this->replaceAll = WT_Filter::postBool('replaceAll'); // TODO: fetch each variable independently, using appropriate validation // Aquire all the variables values from the $_REQUEST $varNames = array("isPostBack", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "srcResultsPrinted", "myindilist", "mysourcelist", "mynotelist", "myfamlist"); $this->setRequestValues($varNames); if (!$this->isPostBack) { // Enable the default gedcom for search $str = str_replace(array(".", "-", " "), array("_", "_", "_"), WT_GEDCOM); $_REQUEST["{$str}"] = $str; } // Retrieve the gedcoms to search in if (count(WT_Tree::getAll()) > 1 && WT_Site::preference('ALLOW_CHANGE_GEDCOM')) { foreach (WT_Tree::getAll() as $tree) { $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $tree->tree_name); if (isset($_REQUEST["{$str}"]) || $topsearch) { $this->sgeds[$tree->tree_id] = $tree->tree_name; $_REQUEST["{$str}"] = 'yes'; } } } else { $this->sgeds[WT_GED_ID] = WT_GEDCOM; } // vars use for soundex search $this->firstname = WT_Filter::post('firstname'); $this->lastname = WT_Filter::post('lastname'); $this->place = WT_Filter::post('place'); $this->year = WT_Filter::post('year'); // Set the search result titles for soundex searches if ($this->firstname || $this->lastname || $this->place) { $this->myquery = WT_Filter::escapeHtml(implode(' ', array($this->firstname, $this->lastname, $this->place))); } if (!empty($_REQUEST["name"])) { $this->name = $_REQUEST["name"]; $this->myname = $this->name; } else { $this->name = ""; $this->myname = ""; } if (!empty($_REQUEST["birthdate"])) { $this->birthdate = $_REQUEST["birthdate"]; $this->mybirthdate = $this->birthdate; } else { $this->birthdate = ""; $this->mybirthdate = ""; } if (!empty($_REQUEST["birthplace"])) { $this->birthplace = $_REQUEST["birthplace"]; $this->mybirthplace = $this->birthplace; } else { $this->birthplace = ""; $this->mybirthplace = ""; } if (!empty($_REQUEST["deathdate"])) { $this->deathdate = $_REQUEST["deathdate"]; $this->mydeathdate = $this->deathdate; } else { $this->deathdate = ""; $this->mydeathdate = ""; } if (!empty($_REQUEST["deathplace"])) { $this->deathplace = $_REQUEST["deathplace"]; $this->mydeathplace = $this->deathplace; } else { $this->deathplace = ""; $this->mydeathplace = ""; } if (!empty($_REQUEST["gender"])) { $this->gender = $_REQUEST["gender"]; $this->mygender = $this->gender; } else { $this->gender = ""; $this->mygender = ""; } $this->inputFieldNames[] = "action"; $this->inputFieldNames[] = "isPostBack"; $this->inputFieldNames[] = "resultsPerPage"; $this->inputFieldNames[] = "query"; $this->inputFieldNames[] = "srindi"; $this->inputFieldNames[] = "srfams"; $this->inputFieldNames[] = "srsour"; $this->inputFieldNames[] = "srnote"; $this->inputFieldNames[] = "showasso"; $this->inputFieldNames[] = "firstname"; $this->inputFieldNames[] = "lastname"; $this->inputFieldNames[] = "place"; $this->inputFieldNames[] = "year"; $this->inputFieldNames[] = "soundex"; $this->inputFieldNames[] = "nameprt"; $this->inputFieldNames[] = "subaction"; $this->inputFieldNames[] = "name"; $this->inputFieldNames[] = "birthdate"; $this->inputFieldNames[] = "birthplace"; $this->inputFieldNames[] = "deathdate"; $this->inputFieldNames[] = "deathplace"; $this->inputFieldNames[] = "gender"; // Get the search results based on the action if ($topsearch) { $this->TopSearch(); } // If we want to show associated persons, build the list switch ($this->action) { case 'general': $this->setPageTitle(WT_I18N::translate('General search')); $this->GeneralSearch(); break; case 'soundex': $this->setPageTitle(WT_I18N::translate('Phonetic search')); $this->SoundexSearch(); break; case 'replace': $this->setPageTitle(WT_I18N::translate('Search and replace')); $this->SearchAndReplace(); return; } }
<td>', WT_I18N::translate('Allow this user to edit his account information'), help_link('useradmin_editaccount'), '</td> <td><input type="checkbox" name="editaccount" value="1" checked="checked"></td> <tr> <td>', WT_I18N::translate('Preferred contact method'), '</td> <td>'; echo edit_field_contact('new_contact_method', $new_contact_method); echo '</td> <td>', WT_I18N::translate('Visible to other users when online'), help_link('useradmin_visibleonline'), '</td> <td><input type="checkbox" name="visibleonline" value="1" checked="checked"></td> </tr> <tr> </tr> <tr> <td>', WT_I18N::translate('Language'), '</td> <td>', edit_field_language('user_language', $user_language), '</td>'; if (WT_Site::preference('ALLOW_USER_THEMES')) { echo '<td>', WT_I18N::translate('Theme'), help_link('THEME'), '</td> <td> <select name="new_user_theme"> <option value="" selected="selected">', WT_Filter::escapeHtml(WT_I18N::translate('<default theme>')), '</option>'; foreach (get_theme_names() as $themename => $themedir) { echo '<option value="', $themedir, '">', $themename, '</option>'; } echo '</select> </td>'; } echo '</tr>'; if (Auth::isAdmin()) { echo '<tr> <td>', WT_I18N::translate('Admin comments on user'), '</td> <td colspan="3"><textarea style="width:95%;" rows="5" name="new_comment" value="', WT_Filter::escapeHtml($new_comment), '"></textarea></td>
public static function delete($tree_id) { // If this is the default tree, then unset if (WT_Site::preference('DEFAULT_GEDCOM') == self::getNameFromId($tree_id)) { WT_Site::preference('DEFAULT_GEDCOM', ''); } // Don't delete the logs. WT_DB::prepare("UPDATE `##log` SET gedcom_id=NULL WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE `##block_setting` FROM `##block_setting` JOIN `##block` USING (block_id) WHERE gedcom_id=?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##block` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##dates` WHERE d_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##families` WHERE f_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##user_gedcom_setting` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##gedcom_setting` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##individuals` WHERE i_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##link` WHERE l_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##media` WHERE m_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##module_privacy` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##name` WHERE n_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##next_id` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##other` WHERE o_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##placelinks` WHERE pl_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##places` WHERE p_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##sources` WHERE s_file =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##hit_counter` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##change` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##default_resn` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##gedcom_chunk` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##log` WHERE gedcom_id =?")->execute(array($tree_id)); WT_DB::prepare("DELETE FROM `##gedcom` WHERE gedcom_id =?")->execute(array($tree_id)); // After updating the database, we need to fetch a new (sorted) copy self::$trees = null; }