Exemple #1
0
} else {
    $proxy_host = NULL;
    $proxy_port = NULL;
}
displayDatabaseForm($originPage, $db_mantis_host, $db_mantis_database, $db_mantis_user, $db_mantis_pass);
$action = (string) getHttpVariable(INPUT_POST, 'action', 'none');
if ("setDatabaseInfo" == $action) {
    try {
        $database_version = checkDBConnection($db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database);
        echo "<script type=\"text/javascript\">console.log(\"DEBUG: Mantis database_version = {$database_version}\");</script>";
        checkDBprivileges($db_mantis_database);
        echo "<script type=\"text/javascript\">console.log(\"Step 1/4 create config.ini file\");</script>";
        createConfigFile($db_mantis_host, $db_mantis_user, $db_mantis_pass, $db_mantis_database, $proxy_host, $proxy_port);
        echo "<script type=\"text/javascript\">console.log(\"Step 2/4 execSQLscript2 - create Tables\");</script>";
        //$retCode = Tools::execSQLscript2(Install::FILENAME_TABLES);
        $retCode = SqlParser::execSqlScript(Install::FILENAME_TABLES);
        if (0 != $retCode) {
            throw new Exception('ERROR: Could not execute SQL script: ' . Install::FILENAME_TABLES);
        }
        $request = "SELECT value from `codev_config_table` WHERE `config_id` = 'database_version' ";
        if (!SqlWrapper::getInstance()->sql_query($request)) {
            throw new Exception('ERROR: CodevTT database tables not created.');
        }
        echo "<script type=\"text/javascript\">console.log(\"Step 3/4 execSQLscript2 - create Procedures\");</script>";
        // procedures are defined in install/codevtt_procedures.php
        foreach ($codevtt_sqlProcedures as $query) {
            $result = SqlWrapper::getInstance()->sql_query(trim($query));
            if (!$result) {
                throw new Exception('ERROR: SQL procedure creation failed FAILED');
            }
        }