'any', 'requestData' => [] ]; } public function handler() { if(defined('MYSQL_HOST')) { throw new RequestException(ERRORS::INIT_SETTINGS_DONE); } $dbHost = Controller::request('dbHost'); $dbPort = Controller::request('dbPort'); $dbName = Controller::request('dbName'); $dbUser = Controller::request('dbUser'); $dbPass = Controller::request('dbPassword'); RedBean::setup("mysql:host=$dbHost;port=$dbPort", $dbUser, $dbPass); if($dbName) { RedBean::addDatabase($dbName, "mysql:host=$dbHost;port=$dbPort;dbname=$dbName", $dbUser, $dbPass); RedBean::selectDatabase($dbName); if(!RedBean::testConnection()) { throw new RequestException(ERRORS::DATABASE_CONNECTION); } } else { $dbName = 'opensupports_' . Hashing::generateRandomNumber(100, 999); RedBean::exec('CREATE DATABASE ' . $dbName); RedBean::addDatabase($dbName, "mysql:host=$dbHost;port=$dbPort;dbname=$dbName", $dbUser, $dbPass); RedBean::selectDatabase($dbName); if(!RedBean::testConnection()) { throw new RequestException(ERRORS::DATABASE_CREATION); } } $configFile = fopen('config.php', 'w+') or die(ERRORS::INVALID_FILE); $content = '