log clear add

This commit is contained in:
Bruno Rybársky 2023-06-10 14:12:10 +02:00
parent d44a4b8d7e
commit 1bdd87a4ee
No known key found for this signature in database
GPG Key ID: DFE2C061EF985CD4
2 changed files with 30 additions and 11 deletions

@ -98,9 +98,9 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
$stmt7 = $mysqli->prepare($query);
}
else{
$query = "SELECT `ID`, `Action`, `LinkID`, `ContentID`, `Datetime`, `Timestamp`, `Nickname`, `IP` FROM Logs WHERE `LinkID` = ?";
$query = "SELECT `ID`, `Action`, `LinkID`, `ContentID`, `Datetime`, `Timestamp`, `Nickname`, `IP` FROM Logs WHERE `LinkID` = ? OR ContentID = ? OR Nickname = ?";
$stmt7 = $mysqli->prepare($query);
$stmt7->bind_param("s", $idcko);
$stmt7->bind_param("sss", $idcko, $idcko, $idcko);
}
$stmt7->bind_result ($rowidx, $actionx, $linkidx, $contentidx, $datetimex, $timestampx, $nicknamex, $ipx);
$stmt7->execute();
@ -119,11 +119,20 @@ if (!empty($action) && $_SESSION["password"] == $config["admin_pwd"]){
$out = $out . "</tbody></table>";
echo $out;
}
if ($action == "deletelog" && !empty($_POST["id"])){
$stmt5 = $mysqli->prepare("DELETE FROM Logs WHERE `ID` = ?");
$stmt5->bind_param('i', $_POST["id"]);
$stmt5->execute();
$stmt5->store_result();
if ($action == "clrlog" && !empty($_POST["id"])){
$idcko = $_POST["id"];
if (empty($idcko)||$idcko == "*"){
$query = "DELETE FROM Logs";
$stmt10 = $mysqli->prepare($query);
}
else{
$query = "DELETE FROM Logs WHERE `ID` = ?";
$stmt10 = $mysqli->prepare($query);
$stmt10->bind_param("i", $idcko);
}
$stmt10->execute();
$stmt10->store_result();
}
}

@ -186,10 +186,22 @@
});
}
function clearlog(){
let id = $("#logid").val();
$.post("api.php",
{
action: "clrlog",
id: id
}, function( data ) {
$("#loglist").html(data);
});
}
$(function() {
$("#submitpwd").click(verifyPassword);
$("#logget").click(getlog);
$("#logclr").click(clearlog);
$.post("api.php",
{
@ -201,9 +213,7 @@
});
$("#logid").keyup(function(event) {
if (event.keyCode === 13) {
$("#logget").click();
}
});
});
@ -227,7 +237,7 @@
</div>
<h1>Log manager:</h1>
<input type="text" id="logid" value="*" placeholder="Link ID"><button id="logget">Get log</button><br>
<input type="text" id="logid" value="*" placeholder="Link ID"><button id="logget">Get log</button><button id="logclr">Clear matching</button><br>
<div id="loglist">
</div>