define('WT_GED_ID', null); define('WT_GEDURL', ''); define('WT_TREE_TITLE', WT_WEBTREES); define('WT_IMPORTED', false); define('WT_USER_GEDCOM_ADMIN', false); define('WT_USER_CAN_ACCEPT', false); define('WT_USER_CAN_EDIT', false); define('WT_USER_CAN_ACCESS', false); define('WT_USER_GEDCOM_ID', ''); define('WT_USER_ROOT_ID', ''); define('WT_USER_PATH_LENGTH', 0); define('WT_USER_ACCESS_LEVEL', WT_PRIV_PUBLIC); } $GEDCOM = WT_GEDCOM; // With no parameters, init() looks to the environment to choose a language define('WT_LOCALE', WT_I18N::init()); $WT_SESSION->locale = WT_I18N::$locale; // Set our gedcom selection as a default for the next page $WT_SESSION->GEDCOM = WT_GEDCOM; if (empty($WEBTREES_EMAIL)) { $WEBTREES_EMAIL = 'webtrees-noreply@' . preg_replace('/^www\\./i', '', $_SERVER['SERVER_NAME']); } // Note that the database/webservers may not be synchronised, so use DB time throughout. define('WT_TIMESTAMP', (int) WT_DB::prepare("SELECT UNIX_TIMESTAMP()")->fetchOne()); // Server timezone is defined in php.ini define('WT_SERVER_TIMESTAMP', WT_TIMESTAMP + (int) date('Z')); if (WT_USER_ID) { define('WT_CLIENT_TIMESTAMP', WT_TIMESTAMP - $WT_SESSION->timediff); } else { define('WT_CLIENT_TIMESTAMP', WT_SERVER_TIMESTAMP); }
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::getPreference('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::setPreference('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::getPreference('LAST_CHANGE_EMAIL')) . "<br>"; $content .= WT_I18N::translate('Next email reminder will be sent after ') . format_timestamp(WT_Site::getPreference('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; } } } }
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; }
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); // Change to the new user’s language WT_I18N::init($user->getSetting('language')); $controller->setPageTitle(WT_I18N::translate('User verification')); $controller->pageHeader(); echo '<div id="login-register-page">'; echo '<h2>' . WT_I18N::translate('User verification') . '</h2>'; echo '<div id="user-verify">'; echo WT_I18N::translate('The data for the user <b>%s</b> was checked.', $user_name); if ($user) { if ($user->checkPassword($user_password) && $user->getSetting('reg_hashcode') == $user_hashcode) { WT_Mail::send($WT_TREE, $webmaster->getEmail(), $webmaster->getRealName(), $WEBTREES_EMAIL, $WEBTREES_EMAIL, $mail1_subject, $mail1_body); $mail1_method = $webmaster->getSetting('CONTACT_METHOD'); if ($mail1_method != 'messaging3' && $mail1_method != 'mailto' && $mail1_method != 'none') { WT_DB::prepare("INSERT INTO `##message` (sender, ip_address, user_id, subject, body) VALUES (? ,? ,? ,? ,?)")->execute(array($user_name, $WT_REQUEST->getClientIp(), $webmaster->getUserId(), $mail1_subject, WT_Filter::unescapeHtml($mail1_body))); } $user->setSetting('verified', 1)->setSetting('reg_timestamp', date("U"))->setSetting('reg_hashcode', null); if (!$REQUIRE_ADMIN_AUTH_REGISTRATION) {
exit; } if (version_compare(PHP_VERSION, WT_REQUIRED_PHP_VERSION) < 0) { // We cannot translate these messages without a modern PHP echo '<h1>Sorry, the setup wizard cannot start.</h1>', '<p>This server is running PHP version ', PHP_VERSION, '</p>', '<p>PHP ', WT_REQUIRED_PHP_VERSION, ' (or any later version) is required</p>'; exit; } require 'includes/functions/functions.php'; require 'includes/functions/functions_edit.php'; $WT_REQUEST = new Zend_Controller_Request_Http(); $WT_SESSION = new stdClass(); $WT_SESSION->locale = null; // Needed for WT_I18N $WT_SESSION->wt_user = null; // Needed for WT_Auth define('WT_LOCALE', WT_I18N::init(WT_Filter::post('lang', '[@a-zA-Z_]+'))); header('Content-Type: text/html; charset=UTF-8'); ?> <!DOCTYPE html> <html <?php echo WT_I18N::html_markup(); ?> > <head> <meta charset="UTF-8"> <title> webtrees setup wizard </title> <style type="text/css"> body {color: black; background-color: white; font: 14px tahoma, arial, helvetica, sans-serif; padding:10px; } a {color: black; font-weight: normal; text-decoration: none;}
function commonCountriesList() { $countries = $this->_statsPlaces(); if (!is_array($countries)) { return ''; } $top10 = array(); $i = 1; // Get the country names for each language $country_names = array(); foreach (WT_I18N::installed_languages() as $code => $lang) { WT_I18N::init($code); $all_countries = self::get_all_countries(); foreach ($all_countries as $country_code => $country_name) { $country_names[$country_name] = $country_code; } } WT_I18N::init(WT_LOCALE); $all_db_countries = array(); foreach ($countries as $place) { $country = trim($place['country']); if (array_key_exists($country, $country_names)) { if (!isset($all_db_countries[$country_names[$country]][$country])) { $all_db_countries[$country_names[$country]][$country] = $place['tot']; } else { $all_db_countries[$country_names[$country]][$country] += $place['tot']; } } } // get all the user’s countries names $all_countries = self::get_all_countries(); foreach ($all_db_countries as $country_code => $country) { $top10[] = '<li>'; foreach ($country as $country_name => $tot) { $tmp = new WT_Place($country_name, $this->_ged_id); $place = '<a href="' . $tmp->getURL() . '" class="list_item">' . $all_countries[$country_code] . '</a>'; $top10[] .= $place . ' - ' . WT_I18N::number($tot); } $top10[] .= '</li>'; if ($i++ == 10) { break; } } $top10 = join('', $top10); return '<ul>' . $top10 . '</ul>'; }