TRF Certest first commit

This commit is contained in:
2025-02-26 08:57:46 +01:00
commit 3ce064a108
2524 changed files with 475404 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<?php
header('Content-Type: application/json');
require_once 'class/db-functions.php';
$response = ["success" => false, "columns" => []];
try {
if (!isset($_GET['table']) || empty($_GET['table'])) {
throw new Exception("Invalid table name.");
}
$table = preg_replace('/[^a-zA-Z0-9_]/', '', $_GET['table']); // Sanitize table name
$db = DBHandlerSelect::getInstance();
$pdo = $db->getConnection();
// Retrieve table columns
$stmt = $pdo->query("SHOW COLUMNS FROM `$table`");
$columns = $stmt->fetchAll(PDO::FETCH_COLUMN);
if (!$columns) {
throw new Exception("No columns found in table.");
}
$response["success"] = true;
$response["columns"] = $columns;
} catch (Exception $e) {
$response["message"] = $e->getMessage();
}
// Log per debugging
error_log(json_encode($response));
// Restituisce la risposta JSON
echo json_encode($response);