Files
website/html/api/logic.php
2026-01-11 20:44:01 -05:00

27 lines
919 B
PHP
Executable File

<?php
require_once "api.php";
require_once "../include/logic.php";
if (array_key_exists("solved", $_GET)) {
try {
dbCommand("START TRANSACTION");
$solved = GetLogicSolved();
$complexity = GetLogicTotalComplexity();
$complexity += $_GET["solved"];
$solved++;
dbCommand("DELETE FROM information WHERE pointer='logicSolved'");
dbCommand("DELETE FROM information WHERE pointer='logicComplexity'");
dbCommand("INSERT INTO information VALUES ('logicComplexity', ?)", [$complexity]);
dbCommand("INSERT INTO information VALUES ('logicSolved', ?)", [$solved]);
dbCommand("COMMIT");
echo json_encode([
"solved" => $solved,
"average" => GetLogicAverageComplexity()
]);
} catch (Exception $e) {
dbCommand("ROLLBACK");
http_response_code(500);
writeLog(9, "Error updating logic count with error: " . $e->getMessage());
echo "Error saving solve";
}
}