initial commit
This commit is contained in:
15
setup.php
Normal file
15
setup.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once 'db.php';
|
||||
$schema = file_get_contents('schema.sql');
|
||||
$pdo->exec($schema);
|
||||
|
||||
$stmt = $pdo->prepare("SELECT id FROM users WHERE username = 'admin'");
|
||||
$stmt->execute();
|
||||
if (!$stmt->fetch()) {
|
||||
$hash = password_hash('admin', PASSWORD_DEFAULT);
|
||||
$stmt = $pdo->prepare("INSERT INTO users (username, password_hash, is_admin) VALUES ('admin', ?, 1)");
|
||||
$stmt->execute([$hash]);
|
||||
echo "Setup complete. Admin user created. <a href='index.php'>Go to Login</a>";
|
||||
} else {
|
||||
echo "Setup already completed. <a href='index.php'>Go to Login</a>";
|
||||
}
|
||||
Reference in New Issue
Block a user