Task Delete Function

This commit is contained in:
schrom01 2023-09-26 21:46:44 +02:00
parent 33f0836479
commit c0bfad4445
2 changed files with 35 additions and 0 deletions

15
deleteFiles.php Normal file
View File

@ -0,0 +1,15 @@
<?php
$taskDir = 'tasks';
include 'env_vars.php';
if($_POST["taskDeletePassword"] == getenv("taskDeletePassword")){
$files = scandir($taskDir);
$files = array_diff($files, array('.', '..'));
foreach ($files as $file) {
echo $file;
unlink($taskDir.'/'.$file);
}
echo "Files deleted";
} echo "wrong Password";
echo json_encode($_POST);
?>

View File

@ -317,6 +317,26 @@ include "zefixAPI.php";
</p> </p>
</div> </div>
</td> </td>
<td class="footer">
<div class="col-12">
<p>
<script>
const deleteFiles = function (){
let taskDeletePassword = prompt("Passwort eingeben:")
let formdata = new FormData()
formdata.append('taskDeletePassword', taskDeletePassword)
fetch("deleteFiles.php", {
method: "POST",
body: formdata,
});
location.reload();
}
</script>
Momentan sind <?php $taskDir = 'tasks'; echo count(scandir($taskDir)) - 2 ?> Aufträge in der Warteliste.<br>
<a href="#" onclick="deleteFiles()">alle löschen</a>
</p>
</div>
</td>
</tr> </tr>
</table> </table>