From 686fff945e0b4697aa74da404ce90534bb7b121d Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 26 Dec 2024 20:12:34 +0100 Subject: Add async email and topic subscribing --- src/application/cron.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/application/cron.php (limited to 'src/application/cron.php') diff --git a/src/application/cron.php b/src/application/cron.php new file mode 100644 index 0000000..094fe50 --- /dev/null +++ b/src/application/cron.php @@ -0,0 +1,42 @@ +\n"); + exit(1); +} + +$jobsDir = __DIR__ . "/jobs"; + +$availableJobs = array_map(fn($i) => pathinfo($i, PATHINFO_FILENAME), array_values(array_filter(scandir($jobsDir), + fn($i) => is_file($jobsDir . "/" . $i) && $i[0] !== "." && pathinfo($i, PATHINFO_EXTENSION) === "php"))); + +if (!in_array($job, $availableJobs)) { + print_error("Error: Invalid job specified\nAvailable jobs are:\n" . implode("", array_map(fn($i) => " $i\n", $availableJobs))); + exit(1); +} + +$jobFile = $jobsDir . "/" . $job . ".php"; + +include $jobFile; -- cgit v1.2.3