Add initial implementation of Fantacalcio application

This commit is contained in:
Simone
2026-03-07 17:15:34 +01:00
parent 6e74a538ea
commit dc6fc7b7e0
41 changed files with 2086 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
<?php
header('Content-Type: application/json');
require_once 'logic.php'; // Include the logic file
$response = [
'success' => false,
'message' => 'Errore sconosciuto.'
];
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
$response['message'] = 'Metodo non valido.';
echo json_encode($response);
exit;
}
// Legge il corpo della richiesta JSON inviato da JavaScript
$jsonPayload = file_get_contents('php://input');
$data = json_decode($jsonPayload, true);
if ($data === null) {
$response['message'] = 'Dati JSON non validi.';
echo json_encode($response);
exit;
}
// Applica la conversione dinamica delle stringhe numeriche
recursively_convert_numeric_strings($data);
// Formatta il JSON in modo leggibile prima di salvarlo
$prettyJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);
// Salva i dati nel file squadre.json
$destinationFile = 'squadre.json';
if (file_put_contents($destinationFile, $prettyJson) !== false) {
$response['success'] = true;
$response['message'] = 'Squadre salvate con successo!';
} else {
$response['message'] = 'Errore durante il salvataggio del file squadre.json.';
}
echo json_encode($response);