Add Turnstile protection and harden export workflow
This commit is contained in:
+19
-9
@@ -1,13 +1,23 @@
|
||||
<?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);
|
||||
declare(strict_types=1);
|
||||
|
||||
if (PHP_SAPI !== 'cli') {
|
||||
http_response_code(404);
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/app.php';
|
||||
|
||||
if (($argv[1] ?? '') !== '--confirm') {
|
||||
fwrite(STDERR, "This command deletes every pending export task. Run: php deleteFiles.php --confirm\n");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$deleted = 0;
|
||||
foreach (glob(app_task_dir() . DIRECTORY_SEPARATOR . '*.json') ?: [] as $filename) {
|
||||
if (is_file($filename) && unlink($filename)) {
|
||||
$deleted++;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
fwrite(STDOUT, $deleted . " pending task(s) deleted.\n");
|
||||
|
||||
Reference in New Issue
Block a user