// " collation VARCHAR(16) NOT NULL,". // " language_name VARCHAR(64) NOT NULL,". // " language_name_base VARCHAR(64) NOT NULL,". // " enabled ENUM ('yes', 'no') DEFAULT 'yes' NOT NULL,". // " PRIMARY KEY (language_tag),". // " INDEX (language_name_base, language_name)". // ") COLLATE utf8_unicode_ci ENGINE=InnoDB" //); WT_DB::exec("CREATE TABLE IF NOT EXISTS `##site_access_rule` (" . " site_access_rule_id INTEGER NOT NULL AUTO_INCREMENT," . " ip_address_start INTEGER UNSIGNED NOT NULL DEFAULT 0," . " ip_address_end INTEGER UNSIGNED NOT NULL DEFAULT 4294967295," . " user_agent_pattern VARCHAR(255) NOT NULL," . " rule ENUM('allow', 'deny', 'robot', 'unknown') NOT NULL DEFAULT 'unknown'," . " comment VARCHAR(255) NOT NULL," . " updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," . " PRIMARY KEY (site_access_rule_id)," . " UNIQUE KEY `##site_access_rule_ix1` (ip_address_end, ip_address_start, user_agent_pattern, rule)," . " KEY `##site_access_rule_ix2` (rule)" . ") ENGINE=InnoDB COLLATE=utf8_unicode_ci"); WT_DB::exec("INSERT IGNORE INTO `##site_access_rule` (user_agent_pattern, rule, comment) VALUES" . " ('Mozilla/5.0 (%) Gecko/% %/%', 'allow', 'Gecko-based browsers')," . " ('Mozilla/5.0 (%) AppleWebKit/% (KHTML, like Gecko)%', 'allow', 'WebKit-based browsers')," . " ('Opera/% (%) Presto/% Version/%', 'allow', 'Presto-based browsers')," . " ('Mozilla/% (compatible; MSIE %', 'allow', 'Trident-based browsers')," . " ('Mozilla/% (Windows%; Trident%; rv:%) like Gecko', 'allow', 'Modern Internet Explorer')," . " ('Mozilla/5.0 (compatible; Konqueror/%', 'allow', 'Konqueror browser')"); WT_DB::prepare("INSERT IGNORE INTO `##gedcom` (gedcom_id, gedcom_name) VALUES " . " (-1, 'DEFAULT_TREE')")->execute(); WT_DB::prepare("INSERT IGNORE INTO `##user` (user_id, user_name, real_name, email, password) VALUES " . " (-1, 'DEFAULT_USER', 'DEFAULT_USER', 'DEFAULT_USER', 'DEFAULT_USER'), (1, ?, ?, ?, ?)")->execute(array($_POST['wtuser'], $_POST['wtname'], $_POST['wtemail'], password_hash($_POST['wtpass'], PASSWORD_DEFAULT))); WT_DB::prepare("INSERT IGNORE INTO `##user_setting` (user_id, setting_name, setting_value) VALUES " . " (1, 'canadmin', ?)," . " (1, 'language', ?)," . " (1, 'verified', ?)," . " (1, 'verified_by_admin', ?)," . " (1, 'editaccount', ?)," . " (1, 'auto_accept', ?)," . " (1, 'visibleonline', ?)")->execute(array(1, WT_LOCALE, 1, 1, 1, 0, 1)); WT_DB::prepare("INSERT IGNORE INTO `##site_setting` (setting_name, setting_value) VALUES " . "('WT_SCHEMA_VERSION', '-2')," . "('INDEX_DIRECTORY', 'data/')," . "('USE_REGISTRATION_MODULE', '1')," . "('REQUIRE_ADMIN_AUTH_REGISTRATION', '1')," . "('ALLOW_USER_THEMES', '1')," . "('ALLOW_CHANGE_GEDCOM', '1')," . "('SESSION_TIME', '7200')," . "('SMTP_ACTIVE', 'internal')," . "('SMTP_HOST', 'localhost')," . "('SMTP_PORT', '25')," . "('SMTP_AUTH', '1')," . "('SMTP_AUTH_USER', '')," . "('SMTP_AUTH_PASS', '')," . "('SMTP_SSL', 'none')," . "('SMTP_HELO', ?)," . "('SMTP_FROM_NAME', ?)")->execute(array($_SERVER['SERVER_NAME'], $_SERVER['SERVER_NAME'])); // Search for all installed modules, and enable them. WT_Module::getInstalledModules('enabled'); // Create the default settings for new users/family trees WT_DB::prepare("INSERT INTO `##block` (user_id, location, block_order, module_name) VALUES (-1, 'main', 1, 'todays_events'), (-1, 'main', 2, 'user_messages'), (-1, 'main', 3, 'user_favorites'), (-1, 'side', 1, 'user_welcome'), (-1, 'side', 2, 'random_media'), (-1, 'side', 3, 'upcoming_events'), (-1, 'side', 4, 'logged_in')")->execute(); WT_DB::prepare("INSERT INTO `##block` (gedcom_id, location, block_order, module_name) VALUES (-1, 'main', 1, 'gedcom_stats'), (-1, 'main', 2, 'gedcom_news'), (-1, 'main', 3, 'gedcom_favorites'), (-1, 'main', 4, 'review_changes'), (-1, 'side', 1, 'gedcom_block'), (-1, 'side', 2, 'random_media'), (-1, 'side', 3, 'todays_events'), (-1, 'side', 4, 'logged_in')")->execute(); // Create the blocks for the admin user WT_DB::prepare("INSERT INTO `##block` (user_id, location, block_order, module_name)" . " SELECT 1, location, block_order, module_name" . " FROM `##block`" . " WHERE user_id=-1")->execute(); // Write the config file. We already checked that this would work. $config_ini_php = '; <' . '?php exit; ?' . '> DO NOT DELETE THIS LINE' . PHP_EOL . 'dbhost="' . addcslashes($_POST['dbhost'], '"') . '"' . PHP_EOL . 'dbport="' . addcslashes($_POST['dbport'], '"') . '"' . PHP_EOL . 'dbuser="******"') . '"' . PHP_EOL . 'dbpass="******"') . '"' . PHP_EOL . 'dbname="' . addcslashes($_POST['dbname'], '"') . '"' . PHP_EOL . 'tblpfx="' . addcslashes($_POST['tblpfx'], '"') . '"' . PHP_EOL; file_put_contents(WT_DATA_DIR . 'config.ini.php', $config_ini_php); // Done - start using webtrees echo '<script>document.location=document.location;</script>', '</form></body></html>'; exit; } catch (PDOException $ex) { echo '<p class="bad">', WT_I18N::translate('An unexpected database error occurred.'), '</p>', '<pre>', $ex->getMessage(), '</pre>', '<p class="info">', WT_I18N::translate('The webtrees developers would be very interested to learn about this error. If you contact them, they will help you resolve the problem.'), '</p>'; } echo '</form>';
// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA use WT\Auth; define('WT_SCRIPT_NAME', 'admin_modules.php'); require 'includes/session.php'; require WT_ROOT . 'includes/functions/functions_edit.php'; $controller = new WT_Controller_Page(); $controller->restrictAccess(Auth::isAdmin())->setPageTitle(WT_I18N::translate('Module administration')); $modules = WT_Module::getInstalledModules('disabled'); $module_status = WT_DB::prepare("SELECT module_name, status FROM `##module`")->fetchAssoc(); switch (WT_Filter::post('action')) { case 'update_mods': if (WT_Filter::checkCsrf()) { foreach ($modules as $module_name => $status) { $new_status = WT_Filter::post("status-{$module_name}", '[01]'); if ($new_status !== null) { $new_status = $new_status ? 'enabled' : 'disabled'; if ($new_status != $status) { WT_DB::prepare("UPDATE `##module` SET status=? WHERE module_name=?")->execute(array($new_status, $module_name)); $module_status[$module_name] = $new_status; } } } }