$val) { if (!is_array($val)) { $in[$k][$key] = stripslashes($val); continue; } $in[] =& $in[$k][$key]; } } unset($in); } } if (!empty($_POST['action']) && $_POST['action']=='download') { header('Content-Type: text/plain'); header('Content-Disposition: attachment; filename="'.WT_CONFIG_FILE.'"'); echo '; DO NOT DELETE THIS LINE'."\r\n"; echo 'dbhost="', addcslashes($_POST['dbhost'], '"').'"'."\r\n"; echo 'dbport="', addcslashes($_POST['dbport'], '"').'"'."\r\n"; echo 'dbuser="', addcslashes($_POST['dbuser'], '"').'"'."\r\n"; echo 'dbpass="', addcslashes($_POST['dbpass'], '"').'"'."\r\n"; echo 'dbname="', addcslashes($_POST['dbname'], '"').'"'."\r\n"; echo 'tblpfx="', addcslashes($_POST['tblpfx'], '"').'"'."\r\n"; exit; } header('Content-Type: text/html; charset=UTF-8'); if (version_compare(PHP_VERSION, '5.2')<0) { // Our translation system requires PHP 5.2, so we cannot translate this message :-( echo '', '', '
', '', 'This server is running PHP version ', PHP_VERSION, '
', 'webtrees requires PHP 5.2 or later. PHP 5.3 is recommended.
'; if (version_compare(PHP_VERSION, '5.0')<0) { echo 'Many servers offer both PHP4 and PHP5. You may be able to change your default to PHP5 using a control panel or a configuration setting.
'; } exit; } // This script (uniquely) does not load session.php. // session.php won't run until a configuration file exists... // This next block of code is a minimal version of session.php define('WT_WEBTREES', true); define('WT_ROOT', ''); define('WT_GED_ID', 0); define('WT_USER_ID', 0); // Invoke the Zend Framework Autoloader, so we can use Zend_XXXXX and WT_XXXXX classes set_include_path(WT_ROOT.'library'.PATH_SEPARATOR.get_include_path()); require_once 'Zend/Loader/Autoloader.php'; Zend_Loader_Autoloader::getInstance()->registerNamespace('WT_'); require 'includes/functions/functions.php'; require 'includes/functions/functions_edit.php'; $WT_SESSION=new Zend_Session_Namespace('WEBTREES'); define('WT_LOCALE', WT_I18N::init(safe_POST('lang', '[@a-zA-Z_]+'))); echo '', '', '', '', WT_I18N::translate('The configuration file has been successfully uploaded to the server.'), '
'; echo '', WT_I18N::translate('Checking the access permissions...'), '
'; if (!is_readable(WT_DATA_DIR)) { echo '', WT_I18N::translate('The directory %s does not have read permission. You must change this.', WT_DATA_DIR), '
'; $error=true; } elseif (!is_writable(WT_DATA_DIR)) { echo '', WT_I18N::translate('The directory %s does not have write permission. You must change this.', WT_DATA_DIR), '
'; $error=true; } else { echo '', WT_I18N::translate('The directory %s has read-write permission. Good.', WT_DATA_DIR), '
'; } if (!is_writable(WT_MEDIA_DIR)) { echo '', WT_I18N::translate('The directory %s does not have write permission. You must change this.', WT_MEDIA_DIR), '
'; $error=true; } elseif (!is_readable(WT_MEDIA_DIR)) { echo '', WT_I18N::translate('The directory %s does not have read permission. You must change this.', WT_MEDIA_DIR), '
'; $error=true; } else { echo '', WT_I18N::translate('The directory %s has read-write permission. Good.', WT_MEDIA_DIR), '
'; } if (!is_readable(WT_DATA_DIR.WT_CONFIG_FILE)) { echo '', WT_I18N::translate('The file %s does not have read permission. You must change this.', WT_DATA_DIR.WT_CONFIG_FILE), '
'; $error=true; } elseif (is_writable(WT_DATA_DIR.WT_CONFIG_FILE) && DIRECTORY_SEPARATOR=='/') { echo '', WT_I18N::translate('The file %s has write permission. This will work, but for better security, you should make it read only.', WT_DATA_DIR.WT_CONFIG_FILE), '
'; $warning=true; } else { echo '', WT_I18N::translate('The file %s has read-only permission. Good.', WT_DATA_DIR.WT_CONFIG_FILE), '
'; } if ($error || $warning) { echo ''; } if (!$error) { echo ''; } // The config file exists - do not go any further. // This is an important security feature, to protect existing installations. exit; } echo ''; exit; } else { // Copy these values through to the next step echo ''; echo ''; } //////////////////////////////////////////////////////////////////////////////// // Step two - Database connection. //////////////////////////////////////////////////////////////////////////////// if (empty($_POST['dbhost'])) $_POST['dbhost']='localhost'; if (empty($_POST['dbport'])) $_POST['dbport']='3306'; if (empty($_POST['dbuser'])) $_POST['dbuser']=''; if (empty($_POST['dbpass'])) $_POST['dbpass']=''; try { $db_version_ok=false; if (substr($_POST['dbhost'], 0, 1)=='/') { $dbh=new PDO('mysql:unix_socket='.$_POST['dbhost'], $_POST['dbuser'], $_POST['dbpass'], array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_OBJ, PDO::ATTR_CASE=>PDO::CASE_LOWER, PDO::ATTR_AUTOCOMMIT=>true)); } else { $dbh=new PDO('mysql:host='.$_POST['dbhost'].';port='.$_POST['dbport'], $_POST['dbuser'], $_POST['dbpass'], array(PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION, PDO::ATTR_DEFAULT_FETCH_MODE=>PDO::FETCH_OBJ, PDO::ATTR_CASE=>PDO::CASE_LOWER, PDO::ATTR_AUTOCOMMIT=>true)); } $dbh->exec("SET NAMES 'utf8'"); foreach ($dbh->query("SHOW VARIABLES LIKE 'VERSION'") as $row) { if (version_compare($row->value, WT_REQUIRED_MYSQL_VERSION, '<')) { echo '', WT_I18N::translate('This database is only running MySQL version %s. You cannot install webtrees here.', $row->value), '
'; } else { $db_version_ok=true; } } } catch (PDOException $ex) { $dbh=null; if ($_POST['dbuser']) { // If we've supplied a login, then show the error echo '', WT_I18N::translate('Unable to connect using these settings. Your server gave the following error.'), '
', '', $ex->getMessage(), '', '
', WT_I18N::translate('Check the settings and try again.'), '
'; } } if (empty($_POST['dbuser']) || !$dbh || !$db_version_ok) { echo '', WT_I18N::translate('webtrees needs a MySQL database, version %s or later.', WT_REQUIRED_MYSQL_VERSION), '
', '', WT_I18N::translate('Your server\'s administrator will provide you with the connection details.'), '
', '', '', WT_I18N::translate('Unable to connect using these settings. Your server gave the following error.'), '
', '', $ex->getMessage(), '', '
', WT_I18N::translate('Check the settings and try again.'), '
'; } } // If the database exists, check whether it is already used by another application. if ($dbname_ok) { try { // PhpGedView (4.2.3 and earlier) and many other applications have a USERS table. // webtrees has a USER table $dummy=$dbh->query("SELECT COUNT(*) FROM `{$TBLPREFIX}users`"); echo '', WT_I18N::translate('This database and table-prefix appear to be used by another application. If you have an existing PhpGedView system, you should create a new webtrees system. You can import your PhpGedView data and settings later.'), '
'; $dbname_ok=false; } catch (PDOException $ex) { // Table not found? Good! } } if ($dbname_ok) { try { // PhpGedView (4.2.4 and later) has a site_setting.site_setting_name column. // [We changed the column name in webtrees, so we can tell the difference!] $dummy=$dbh->query("SELECT site_setting_value FROM `{$TBLPREFIX}site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'"); echo '', WT_I18N::translate('This database and table-prefix appear to be used by another application. If you have an existing PhpGedView system, you should create a new webtrees system. You can import your PhpGedView data and settings later.'), '
'; $dbname_ok=false; } catch (PDOException $ex) { // Table/column not found? Good! } } if (!$dbname_ok) { echo '', WT_I18N::translate('A database server can store many separate databases. You need to select an existing database (created by your server\'s administrator) or create a new one (if your database user account has sufficient privileges).'), '
', '', '