First commit

This commit is contained in:
julien
2026-03-27 14:43:08 +01:00
commit ced7dbfbf7
54 changed files with 3680 additions and 0 deletions

7
scripts/bootstrap.php Normal file
View File

@@ -0,0 +1,7 @@
<?php
declare(strict_types=1);
require dirname(__DIR__) . '/vendor/autoload.php';
return require dirname(__DIR__) . '/app/bootstrap.php';

37
scripts/create-admin.php Normal file
View File

@@ -0,0 +1,37 @@
<?php
declare(strict_types=1);
$f3 = require __DIR__ . '/bootstrap.php';
$db = $f3->get('DB');
$username = trim((string) ($argv[1] ?? ''));
if ($username === '') {
fwrite(STDERR, "Usage: php scripts/create-admin.php <username>\n");
exit(1);
}
fwrite(STDOUT, 'Mot de passe (10 caractères minimum): ');
if (stripos(PHP_OS, 'WIN') !== 0) {
system('stty -echo');
}
$password = trim((string) fgets(STDIN));
if (stripos(PHP_OS, 'WIN') !== 0) {
system('stty echo');
}
fwrite(STDOUT, PHP_EOL);
if ($password === '') {
fwrite(STDERR, "Mot de passe vide.\n");
exit(1);
}
User::bootstrap($db);
try {
$id = (new User($db))->create($username, $password);
fwrite(STDOUT, "Admin créé (ID {$id}).\n");
} catch (RuntimeException $e) {
fwrite(STDERR, $e->getMessage() . "\n");
exit(1);
}

12
scripts/install.php Normal file
View File

@@ -0,0 +1,12 @@
<?php
declare(strict_types=1);
$f3 = require __DIR__ . '/bootstrap.php';
$db = $f3->get('DB');
User::bootstrap($db);
Post::bootstrap($db);
Media::bootstrap($db);
fwrite(STDOUT, 'Base initialisée : ' . app_db_path() . "\n");