Initial commit
This commit is contained in:
commit
05c65aad4d
155 changed files with 93617 additions and 0 deletions
24
viewer/admin/create_admin.php
Normal file
24
viewer/admin/create_admin.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
// CLI script: php create_admin.php username password
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
echo "This script must be run from CLI\n";
|
||||
exit(1);
|
||||
}
|
||||
if ($argc < 3) {
|
||||
echo "Usage: php create_admin.php username password\n";
|
||||
exit(1);
|
||||
}
|
||||
$username = $argv[1];
|
||||
$password = $argv[2];
|
||||
|
||||
$pdo = require __DIR__ . '/db.php';
|
||||
|
||||
$hash = password_hash($password, PASSWORD_DEFAULT);
|
||||
$stmt = $pdo->prepare('INSERT INTO admins (username, password, created_at) VALUES (?, ?, ?)');
|
||||
try {
|
||||
$stmt->execute([$username, $hash, date('c')]);
|
||||
echo "Admin user created: $username\n";
|
||||
} catch (Exception $e) {
|
||||
echo "Error creating admin: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue