Exemple #1
0
if ($dbname_ok) {
    try {
        // PhpGedView (4.2.3 and earlier) and many other applications have a USERS table.
        // webtrees has a USER table
        $dummy = WT_DB::query("SELECT COUNT(*) FROM `##users`")->fetchOne();
        echo '<p class="bad">', 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.'), '</p>';
        $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 = WT_DB::query("SELECT site_setting_value FROM `##site_setting` WHERE site_setting_name='PGV_SCHEMA_VERSION'")->fetchOne();
        echo '<p class="bad">', 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.'), '</p>';
        $dbname_ok = false;
    } catch (PDOException $ex) {
        // Table/column not found?  Good!
    }
}
if (!$dbname_ok) {
    echo '<h2>', WT_I18N::translate('Database and table names'), '</h2>', '<p>', 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).'), '</p>', '<fieldset><legend>', WT_I18N::translate('Database name'), '</legend>', '<table border="0"><tr><td>', WT_I18N::translate('Database name'), '</td><td>', '<input type="text" name="dbname" value="', WT_Filter::escapeHtml($_POST['dbname']), '" autofocus></td><td>', WT_I18N::translate('This is case sensitive. If a database with this name does not already exist webtrees will attempt to create one for you. Success will depend on permissions set for your web server, but you will be notified if this fails.'), '</td></tr><tr><td>', WT_I18N::translate('Table prefix'), '</td><td>', '<input type="text" name="tblpfx" value="', WT_Filter::escapeHtml($_POST['tblpfx']), '"></td><td>', WT_I18N::translate('The prefix is optional, but recommended.  By giving the table names a unique prefix you can let several different applications share the same database. “wt_” is suggested, but can be anything you want.'), '</td></tr></table>', '</fieldset>', '<br><hr><input type="submit" id="btncontinue" value="', WT_I18N::translate('continue'), '">', '</form>', '</body></html>';
    exit;
} else {
    // Copy these values through to the next step
    echo '<input type="hidden" name="dbname" value="', WT_Filter::escapeHtml($_POST['dbname']), '">';
    echo '<input type="hidden" name="tblpfx" value="', WT_Filter::escapeHtml($_POST['tblpfx']), '">';
}
////////////////////////////////////////////////////////////////////////////////