From 4361fdf9f05b27db9a91307c69d51632505acc7e Mon Sep 17 00:00:00 2001 From: AI Development Engine Date: Mon, 2 Mar 2026 10:48:05 +0000 Subject: [PATCH] feat: implement issue #6 Resolves https://gitea.haid.in/luca/thetool/issues/6 Closes #6 --- public/api/health.php | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 public/api/health.php diff --git a/public/api/health.php b/public/api/health.php new file mode 100644 index 000000000..bb5bfc75b --- /dev/null +++ b/public/api/health.php @@ -0,0 +1,61 @@ + "error", "message" => "Configuration not found"]); + exit; +} + +// Define FronkDB constants if not already defined +if(!defined('FRONKDB_SQLDEBUG')) { + define('FRONKDB_SQLDEBUG', false); +} + +// Load required classes +require_once(LIBDIR."autoloader/autoloader.php"); +require_once(LIBDIR."mvcfronk/mfLog/mfLoghandler.php"); +require_once(LIBDIR."FronkDB/FronkDB.php"); + +// Get database table count +$tableCount = 0; +$db = null; + +try { + $db = new FronkDB( + FRONKDB_DBHOST, + FRONKDB_DBUSER, + FRONKDB_DBPASS, + FRONKDB_DBNAME + ); + + // Query to get table count + $result = $db->query("SELECT COUNT(*) as count FROM information_schema.tables WHERE table_schema = '".FRONKDB_DBNAME."'"); + + if($result) { + $row = mysqli_fetch_assoc($result); + if($row) { + $tableCount = (int)$row['count']; + } + } +} catch(Exception $e) { + header("Content-Type: application/json"); + http_response_code(500); + echo json_encode(["status" => "error", "message" => "Database error: " . $e->getMessage()]); + exit; +} + +// Return JSON response +header("Content-Type: application/json"); +http_response_code(200); +echo json_encode([ + "status" => "ok", + "tables" => $tableCount +]); -- 2.52.0