|
@@ -20,6 +20,51 @@ function hspech($str)
|
|
|
return (htmlspecialchars($str, ENT_QUOTES | ENT_HTML5, 'UTF-8'));
|
|
|
}
|
|
|
|
|
|
+function are_valid_ids($ids)
|
|
|
+{
|
|
|
+ if (count($ids) <= 0) return false;
|
|
|
+ foreach ($ids as $id) {
|
|
|
+ if (!(preg_match('/^[0-9]+$/', $id) === 1)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_SERVER["CONTENT_TYPE"] === "application/json") {
|
|
|
+ $response = array(
|
|
|
+ "done" => true,
|
|
|
+ "error" => ""
|
|
|
+ );
|
|
|
+ $body = json_decode(file_get_contents('php://input'), true);
|
|
|
+ if (array_key_exists('act', $body) &&
|
|
|
+ array_key_exists('ids', $body) &&
|
|
|
+ are_valid_ids($body["ids"])) {
|
|
|
+ switch ($body['act']) {
|
|
|
+ case "massread":
|
|
|
+ mysqli_query($link, 'UPDATE Notifications SET Seen=1 WHERE ID in (' . implode(", ", $body["ids"]) . ')')
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ break;
|
|
|
+ case "massdelete":
|
|
|
+ mysqli_query($link, 'UPDATE Notifications SET Deleted=1 WHERE ID in (' . implode(", ", $body["ids"]) . ')')
|
|
|
+ or muoribene(mysqli_error($link), true);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ http_response_code(400);
|
|
|
+ $response["done"] = false;
|
|
|
+ $response["error"] = "Unknown act.";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ http_response_code(400);
|
|
|
+ $response["done"] = false;
|
|
|
+ $response["error"] = "Bad request.";
|
|
|
+ }
|
|
|
+ echo(json_encode($response));
|
|
|
+ mysqli_close($link);
|
|
|
+ exit(0);
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
$dbg .= $dlang . '<br>' . N;
|
|
|
$dbg .= '<pre>' . print_r($_GET, 1) . '</pre>';
|
|
|
|
|
@@ -115,20 +160,17 @@ if ($filtordon) {
|
|
|
<div id="notifs-grid">
|
|
|
<div id="notifs-list-controls">
|
|
|
<input id="global-selector" type="checkbox" onclick="toggleState(this)">
|
|
|
- <button class="control-btn" onclick="applyAllSelected(markread)"><i class="fa fa-envelope-open-o"
|
|
|
- aria-hidden="true"></i>
|
|
|
+ <button class="control-btn" onclick="readSelected()">
|
|
|
+ <i class="fa fa-envelope-open-o" aria-hidden="true"></i>
|
|
|
</button>
|
|
|
- <button class="control-btn" onclick="applyAllSelected(markdeleted)"><i class="fa fa-trash-o"
|
|
|
- aria-hidden="true"></i>
|
|
|
+ <button class="control-btn" onclick="deleteSelected()">
|
|
|
+ <i class="fa fa-trash-o" aria-hidden="true"></i>
|
|
|
</button>
|
|
|
</div>
|
|
|
<h1 class="control-btn">CIAONEE</h1>
|
|
|
<div id="notifs-list">
|
|
|
<?php
|
|
|
if ($account['Level'] != 'guest') {
|
|
|
- // Questi valori sono un po' a (n|c)aso,
|
|
|
- // dovrebbero avere senso ma non ho
|
|
|
- // indagato troppo
|
|
|
$sev_classes = array(
|
|
|
1 => "sev-normal",
|
|
|
2 => "sev-warning",
|
|
@@ -139,8 +181,7 @@ if ($filtordon) {
|
|
|
1 => "seen"
|
|
|
);
|
|
|
foreach ($notifs['notifs'] as $n) {
|
|
|
- echo("<div id=\"notif-" . $n["ID"] .
|
|
|
- "\" class=\"" . "notif " . $sev_classes[$n["Severity"]] . " " . $seen_class[$n["Seen"]] . "\">" .
|
|
|
+ echo("<div id=\"notif-" . $n["ID"] . "\" class=\"" . "notif " . $sev_classes[$n["Severity"]] . " " . $seen_class[$n["Seen"]] . "\">" .
|
|
|
"<input type=\"checkbox\" class=\"seen-checkbox\" onclick='notifSelect(this)'>" .
|
|
|
"<button type='button' onclick='markread(this.parentElement)'><i class=\"fa fa-envelope-open-o\" aria-hidden=\"true\"></i></button>" .
|
|
|
"<button type='button' onclick='markdeleted(this.parentElement)'><i class=\"fa fa-trash-o\" aria-hidden=\"true\"></i></button>" .
|