2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2020 Blue Static
6 || # This program is free software; you can redistribute it and/or modify
7 || # it under the terms of the GNU General Public License as published by
8 || # the Free Software Foundation; version 2 of the License.
10 || # This program is distributed in the hope that it will be useful, but
11 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 || # You should have received a copy of the GNU General Public License along
16 || # with this program; if not, write to the Free Software Foundation, Inc.,
17 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
18 || ###################################################################
19 \*=====================================================================*/
21 define('NO_TEMPLATES', true
);
23 require_once('./global.php');
27 'time' => 60 * 60 * 1.5,
28 'function' => 'CronAdminSession',
30 'awaiting_email_confirmation' => [
31 'time' => 60 * 60 * 24 * 3,
32 'function' => 'CronPurgeInactiveUsers',
36 // List of cron jobs to remove.
39 $update_query = bugdar
::$db->prepare("
40 INSERT INTO " . TABLE_PREFIX
. "cron
45 UPDATE lastrun = :lastrun
48 // Filter the |$jobs| array, removing jobs that do not need to run.
49 $last_runs = bugdar
::$db->query("SELECT * FROM " . TABLE_PREFIX
. "cron");
50 while ($last_run = $last_runs->fetch()) {
51 $name = $last_run['name'];
52 if (!isset($jobs[$name])) {
57 $earliest_run_time = TIMENOW
- $jobs[$name]['time'];
58 if ($earliest_run_time < $last_run['lastrun']) {
65 foreach ($jobs as $name => $job) {
66 require("./includes/cron/$name.php");
69 $update_query->execute([
79 $remove_query = bugdar
::$db->prepare("DELETE FROM " . TABLE_PREFIX
. "cron WHERE name = ?");
80 foreach ($remove as $remove) {
81 $remove_query->execute([ $remove ]);
85 header('Content-Type: application/json');
86 echo '(' . json_encode([ 'jobsRun' => $jobs_run ]) . ')';