Task Delete Function
This commit is contained in:
parent
33f0836479
commit
c0bfad4445
|
@ -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);
|
||||||
|
|
||||||
|
?>
|
20
index.php
20
index.php
|
@ -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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue