Fixes for setup
This commit is contained in:
parent
46fc2c978f
commit
2080de7a10
|
@ -2,11 +2,11 @@
|
|||
|
||||
declare(strict_types=1);
|
||||
|
||||
class Autoloader
|
||||
final class Autoloader
|
||||
{
|
||||
private const PATH_CLASSES = 'backend/classes';
|
||||
private const PATH_CONTROLLERS = self::PATH_CLASSES . '/controller';
|
||||
private const PATH_CACHE = 'backend/cache/';
|
||||
public const PATH_CLASSES = 'backend/classes';
|
||||
public const PATH_CONTROLLERS = self::PATH_CLASSES . '/controller';
|
||||
public const PATH_CACHE = 'backend/cache/';
|
||||
|
||||
public function __construct(string $cachePath = self::PATH_CACHE)
|
||||
{
|
||||
|
|
|
@ -28,7 +28,9 @@ final class Setting
|
|||
}
|
||||
';
|
||||
|
||||
$hostname = getUserInput('MySQL host address (default "localhost"): ');
|
||||
echo 'Let\'s setup the database. Please enter the informations for your database...' . PHP_EOL;
|
||||
|
||||
$hostname = getUserInput('MySQL host address: ');
|
||||
$username = getUserInput('MySQL user: ');
|
||||
$password = getUserInput('MySQL password (shown!): ');
|
||||
$database = getUserInput('MySQL database: ');
|
||||
|
@ -39,12 +41,16 @@ $settings = str_replace(
|
|||
TEMPLATE_SETTINGS
|
||||
);
|
||||
|
||||
require 'backend/classes/core/Autoloader.php';
|
||||
|
||||
if (!is_dir(Autoloader::PATH_CACHE)) {
|
||||
mkdir(Autoloader::PATH_CACHE);
|
||||
}
|
||||
|
||||
$file = fopen(getcwd() . '/backend/classes/Setting.php', 'w');
|
||||
fwrite($file, $settings);
|
||||
fclose($file);
|
||||
|
||||
require 'backend/classes/core/Autoloader.php';
|
||||
|
||||
Autoloader::BuildCache();
|
||||
|
||||
$autoloader = new Autoloader();
|
||||
|
@ -54,6 +60,22 @@ $setupSql = fread($file, filesize('backend/scripts/setup.sql'));
|
|||
fclose($file);
|
||||
|
||||
$db = new MySqlDatabase($hostname, $username, $password, $database);
|
||||
$db->Query($setupSql);
|
||||
|
||||
echo 'Ringfinger setup has successfully finished.' . PHP_EOL;
|
||||
$db->startTransaction();
|
||||
|
||||
$db->Query(str_replace('$DB_NAME', $database, $setupSql));
|
||||
|
||||
echo 'Let\'s create an admin account...' . PHP_EOL;
|
||||
|
||||
$user = new User(null, $db);
|
||||
|
||||
$user->setUsername(getUserInput('Username: '));
|
||||
$user->setPassword(getUserInput('Password: '));
|
||||
$user->setEmail(getUserInput('Email: '));
|
||||
$user->setJabberAddress(getUserInput('Jabber address: '));
|
||||
$user->setAdmin(true);
|
||||
$user->Save();
|
||||
|
||||
$db->commit();
|
||||
|
||||
echo 'Ringfinger setup has successfully finished.' . PHP_EOL;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
START TRANSACTION;
|
||||
|
||||
USE ringfinger;
|
||||
USE $DB_NAME;
|
||||
|
||||
CREATE TABLE User (
|
||||
UserId int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||
|
|
Loading…
Reference in New Issue