updates
This commit is contained in:
@@ -218,52 +218,6 @@ if ($type == "update_config_sqlite") {
|
||||
}
|
||||
}
|
||||
|
||||
//UPDATING the config_scripts table from SQLite DB
|
||||
if ($type == "update_config_scripts_sqlite") {
|
||||
$script_path = $_GET['param'] ?? null;
|
||||
$enabled = $_GET['value'] ?? null;
|
||||
|
||||
if ($script_path === null || $enabled === null) {
|
||||
echo json_encode(["error" => "Missing parameter or value"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
try {
|
||||
$db = new PDO("sqlite:$database_path");
|
||||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
// First, check if parameter exists and get its type
|
||||
$checkStmt = $db->prepare("SELECT enabled FROM config_scripts_table WHERE script_path = :script_path");
|
||||
$checkStmt->bindParam(':script_path', $script_path);
|
||||
$checkStmt->execute();
|
||||
$result = $checkStmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result) {
|
||||
// Convert enabled value to 0 or 1
|
||||
$enabledValue = (filter_var($enabled, FILTER_VALIDATE_BOOLEAN)) ? 1 : 0;
|
||||
|
||||
// Update the enabled status
|
||||
$updateStmt = $db->prepare("UPDATE config_scripts_table SET enabled = :enabled WHERE script_path = :script_path");
|
||||
$updateStmt->bindParam(':enabled', $enabledValue, PDO::PARAM_INT);
|
||||
$updateStmt->bindParam(':script_path', $script_path);
|
||||
$updateStmt->execute();
|
||||
|
||||
echo json_encode([
|
||||
"success" => true,
|
||||
"message" => "Script configuration updated successfully",
|
||||
"script_path" => $script_path,
|
||||
"enabled" => (bool)$enabledValue
|
||||
], JSON_UNESCAPED_SLASHES); // Prevent escaping forward slashes
|
||||
} else {
|
||||
echo json_encode([
|
||||
"error" => "Script path not found in configuration",
|
||||
"script_path" => $script_path
|
||||
], JSON_UNESCAPED_SLASHES); // Prevent escaping forward slashes
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
echo json_encode(["error" => $e->getMessage()]);
|
||||
}
|
||||
}
|
||||
|
||||
//UPDATING the envea_sondes_table table from SQLite DB
|
||||
if ($type == "update_sonde") {
|
||||
|
||||
Reference in New Issue
Block a user