コード例 #1
0
ファイル: session.php プロジェクト: brambravo/webtrees
    }
    // Down for maintenance?
    if (file_exists(WT_ROOT . 'data/offline.txt')) {
        header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-offline.php');
        exit;
    }
} else {
    // No config file. Set one up.
    header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'setup.php');
    exit;
}
$WT_REQUEST = new Zend_Controller_Request_Http();
require WT_ROOT . 'includes/authentication.php';
// Connect to the database
try {
    WT_DB::createInstance($dbconfig['dbhost'], $dbconfig['dbport'], $dbconfig['dbname'], $dbconfig['dbuser'], $dbconfig['dbpass']);
    define('WT_TBLPREFIX', $dbconfig['tblpfx']);
    unset($dbconfig);
    // Some of the FAMILY JOIN HUSBAND JOIN WIFE queries can excede the MAX_JOIN_SIZE setting
    WT_DB::exec("SET NAMES 'utf8' COLLATE 'utf8_unicode_ci', SQL_BIG_SELECTS=1");
    try {
        WT_DB::updateSchema(WT_ROOT . 'includes/db_schema/', 'WT_SCHEMA_VERSION', WT_SCHEMA_VERSION);
    } catch (PDOException $ex) {
        // The schema update scripts should never fail.  If they do, there is no clean recovery.
        die($ex);
    }
} catch (PDOException $ex) {
    header('Location: ' . WT_SERVER_NAME . WT_SCRIPT_PATH . 'site-unavailable.php');
    exit;
}
// The config.ini.php file must always be in a fixed location.
コード例 #2
0
ファイル: setup.php プロジェクト: jacoline/webtrees
if (!isset($_POST['dbuser'])) {
    $_POST['dbuser'] = '';
}
if (!isset($_POST['dbpass'])) {
    $_POST['dbpass'] = '';
}
if (!isset($_POST['dbname'])) {
    $_POST['dbname'] = '';
}
if (!isset($_POST['tblpfx'])) {
    $_POST['tblpfx'] = 'wt_';
}
define('WT_TBLPREFIX', $_POST['tblpfx']);
try {
    $db_version_ok = false;
    WT_DB::createInstance($_POST['dbhost'], $_POST['dbport'], '', $_POST['dbuser'], $_POST['dbpass']);
    WT_DB::exec("SET NAMES 'utf8'");
    $row = WT_DB::prepare("SHOW VARIABLES LIKE 'VERSION'")->fetchOneRow();
    if (version_compare($row->value, WT_REQUIRED_MYSQL_VERSION, '<')) {
        echo '<p class="bad">', WT_I18N::translate('This database is only running MySQL version %s.  You cannot install webtrees here.', $row->value), '</p>';
    } else {
        $db_version_ok = true;
    }
} catch (PDOException $ex) {
    WT_DB::disconnect();
    if ($_POST['dbuser']) {
        // If we’ve supplied a login, then show the error
        echo '<p class="bad">', WT_I18N::translate('Unable to connect using these settings.  Your server gave the following error.'), '</p>', '<pre>', $ex->getMessage(), '</pre>', '<p class="bad">', WT_I18N::translate('Check the settings and try again.'), '</p>';
    }
}
if (empty($_POST['dbuser']) || !WT_DB::isConnected() || !$db_version_ok) {