first commit
This commit is contained in:
55
controllers/InitController.php
Normal file
55
controllers/InitController.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
class InitController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
try {
|
||||
$db = Database::getInstance();
|
||||
$db->initDatabase();
|
||||
|
||||
echo "<!DOCTYPE html>
|
||||
<html lang='pl'>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>Inicjalizacja bazy danych</title>
|
||||
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
|
||||
</head>
|
||||
<body class='bg-light'>
|
||||
<div class='container mt-5'>
|
||||
<div class='alert alert-success' role='alert'>
|
||||
<h4 class='alert-heading'>Sukces!</h4>
|
||||
<p>Baza danych została pomyślnie zainicjalizowana.</p>
|
||||
<hr>
|
||||
<p class='mb-0'>Testowy użytkownik:<br>
|
||||
Login: <strong>projectpro</strong><br>
|
||||
Hasło: <strong>testowehaslo</strong></p>
|
||||
</div>
|
||||
<a href='/logowanie' class='btn btn-primary'>Przejdź do logowania</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
} catch (Exception $e) {
|
||||
echo "<!DOCTYPE html>
|
||||
<html lang='pl'>
|
||||
<head>
|
||||
<meta charset='UTF-8'>
|
||||
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
|
||||
<title>Błąd inicjalizacji</title>
|
||||
<link href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css' rel='stylesheet'>
|
||||
</head>
|
||||
<body class='bg-light'>
|
||||
<div class='container mt-5'>
|
||||
<div class='alert alert-danger' role='alert'>
|
||||
<h4 class='alert-heading'>Błąd!</h4>
|
||||
<p>Nie udało się zainicjalizować bazy danych.</p>
|
||||
<hr>
|
||||
<p class='mb-0'>Szczegóły: " . htmlspecialchars($e->getMessage()) . "</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user