Initial commit — Serveur Lucas SmartEye
API réception alertes chute (SmartEye/YOLO), analyse IA (Gemini 2.5 Flash), gestion alertes avec escalade (watchdog), notifications Firebase, dashboard web, documentation MkDocs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
54
admin/set_password.php
Normal file
54
admin/set_password.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* DÉFINIR UN MOT DE PASSE CLIENT PERSONNALISÉ
|
||||
*
|
||||
* Usage : php set_password.php <client_id> <password>
|
||||
* Hash un mot de passe fourni et met à jour database.json
|
||||
*/
|
||||
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
die("Ce script doit être exécuté en ligne de commande.\n");
|
||||
}
|
||||
|
||||
if ($argc < 3) {
|
||||
echo "Usage : php set_password.php <client_id> <password>\n";
|
||||
echo "Exemple : php set_password.php Demo_01 MonMotDePasse123\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$client_id = $argv[1];
|
||||
$password = $argv[2];
|
||||
$json_file = dirname(__DIR__) . '/database.json';
|
||||
|
||||
if (!file_exists($json_file)) {
|
||||
die("Erreur : database.json introuvable\n");
|
||||
}
|
||||
|
||||
$db = json_decode(file_get_contents($json_file), true);
|
||||
|
||||
// Recherche du client
|
||||
$client_index = -1;
|
||||
if (isset($db['clients'])) {
|
||||
foreach ($db['clients'] as $index => $c) {
|
||||
if (strcasecmp($c['name'], $client_id) == 0) {
|
||||
$client_index = $index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($client_index === -1) {
|
||||
die("Erreur : Client '$client_id' introuvable dans la base de données\n");
|
||||
}
|
||||
|
||||
// Hash du mot de passe
|
||||
$password_hash = password_hash($password, PASSWORD_BCRYPT);
|
||||
|
||||
// Mise à jour de la base
|
||||
$db['clients'][$client_index]['password_hash'] = $password_hash;
|
||||
file_put_contents($json_file, json_encode($db, JSON_PRETTY_PRINT));
|
||||
|
||||
// Affichage
|
||||
echo "✅ Mot de passe défini avec succès pour '$client_id'\n";
|
||||
echo " Le hash bcrypt a été enregistré dans database.json\n\n";
|
||||
?>
|
||||
Reference in New Issue
Block a user