-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
40 lines (35 loc) · 1.28 KB
/
Copy pathinstall.php
File metadata and controls
40 lines (35 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
require_once __DIR__ . '/core/bootstrap.php';
// Schon installiert? → zur App
if (pult_installed()) {
header('Location: index.php');
exit;
}
$fehler = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!csrf_valid($_POST['csrf'] ?? null)) {
$fehler = 'Sitzung abgelaufen, bitte Seite neu laden.';
} else {
$pw = (string) ($_POST['passwort'] ?? '');
$pw2 = (string) ($_POST['passwort2'] ?? '');
if (strlen($pw) < 8) {
$fehler = 'Das Passwort muss mindestens 8 Zeichen haben.';
} elseif ($pw !== $pw2) {
$fehler = 'Die Passwörter stimmen nicht überein.';
} else {
// Instanz-Konfiguration (Passwort) schreiben. Dashboards legt man danach in der Übersicht an.
$cfg = [
'auth' => ['hash' => password_hash($pw, PASSWORD_DEFAULT)],
'erstellt' => date('c'),
];
if (!store_write(PULT_INSTALL_CONFIG, $cfg)) {
$fehler = 'Konnte die Konfiguration nicht schreiben — sind die Schreibrechte für data/ gesetzt?';
} else {
attempt_login($pw);
header('Location: index.php');
exit;
}
}
}
}
include __DIR__ . '/views/install.php';