FSCash/html/save_symbol.php
fds2610-bot 6f377ea251 V.2.2: Unit-Tests für wichtige Funktionen, automatisch geprüft bei Update
Extrahiert die wichtigste DB-/netzwerkfreie Geschäftslogik (Monatsnavigation,
Admin-/Aktien-Rollenprüfung, Aktien-GuV-Berechnung, OpenFIGI-/Alpha-Vantage-
Antwortauswertung, Eingabevalidierung, CSV-Export, Migrations-Logik) nach
html/lib/fscash.php und deckt sie mit 31 PHPUnit-Tests ab. update.sh
installiert Composer-Abhängigkeiten bei Bedarf und führt die Tests jetzt vor
jedem Deploy aus - bei Fehlschlag wird nichts kopiert oder migriert.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-23 17:54:30 +02:00

46 lines
1.1 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
require 'config.php';
require_once 'lib/fscash.php';
header('Content-Type: application/json');
// JSON-Input einlesen
$data = json_decode(file_get_contents('php://input'), true);
$id = $data['id'] ?? null;
$symbol = $data['symbol'] ?? null;
// Input validieren
if (!fscash_is_valid_symbol_payload($id, $symbol)) {
echo json_encode([
'success' => false,
'message' => 'Ungültige Eingabedaten.'
]);
exit;
}
try {
$stmt = $pdo->prepare("UPDATE aktien SET Symbol = :symbol WHERE id = :id AND user_id = :userid");
$stmt->execute([
'symbol' => $symbol,
'id' => $id,
'userid' => $_SESSION['user_id']
]);
// Prüfen, ob ein Datensatz tatsächlich aktualisiert wurde
if ($stmt->rowCount() > 0) {
echo json_encode([
'success' => true,
'symbol' => $symbol,
'message' => "Symbol erfolgreich gespeichert: $symbol"
]);
} else {
echo json_encode([
'success' => false,
'message' => 'Keine Änderung – evtl. ID existiert nicht oder gehört nicht zum Benutzer.'
]);
}
} catch (PDOException $e) {
echo json_encode([
'success' => false,
'message' => 'Datenbankfehler: ' . $e->getMessage()
]);
}