Commit inicial

This commit is contained in:
2026-05-26 00:59:40 -06:00
commit 46594fbec8
140 changed files with 26127 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
<?php
$file = 'datos.json';
if (isset($_GET['nombre']) && $_GET['nombre'] != '') {
$nombre = basename($_GET['nombre']); // 'basename' ayuda a evitar que intenten acceder a carpetas superiores
// Si el nombre no termina en .json, se lo agregamos
if (pathinfo($nombre, PATHINFO_EXTENSION) != 'json') {
$nombre .= '.json';
}
$file = $nombre;
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$data = json_decode(file_get_contents('php://input'), true);
file_put_contents($file, json_encode($data['data'], JSON_PRETTY_PRINT));
echo json_encode(['status' => 'success', 'data' => ['message' => 'Data saved successfully']]);
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (file_exists($file)) {
$data = file_get_contents($file);
echo json_encode(['status' => 'success', 'data' => json_decode($data)]);
} else {
echo json_encode(['status' => 'error', 'data' => ['message' => 'File not found']]);
}
} else {
echo json_encode(['status' => 'error', 'data' => ['message' => 'Invalid request method']]);
}