1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Copyright (c) 2018 Justin Kuenzel (jukusoft.com) |
||
5 | * |
||
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
||
7 | * you may not use this file except in compliance with the License. |
||
8 | * You may obtain a copy of the License at |
||
9 | * |
||
10 | * http://www.apache.org/licenses/LICENSE-2.0 |
||
11 | * |
||
12 | * Unless required by applicable law or agreed to in writing, software |
||
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
||
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||
15 | * See the License for the specific language governing permissions and |
||
16 | * limitations under the License. |
||
17 | */ |
||
18 | |||
19 | $start_time = microtime(true); |
||
20 | |||
21 | //define root path |
||
22 | define('ROOT_PATH', dirname(__FILE__) . "/"); |
||
23 | |||
24 | error_reporting(E_ALL); |
||
25 | |||
26 | require("system/core/init.php"); |
||
27 | |||
28 | if (!Settings::get("cronjob_enabled", true)) { |
||
29 | //dont execute cronjob |
||
30 | exit; |
||
31 | } |
||
32 | |||
33 | $auth_key = Settings::get("cronjob_auth_key", ""); |
||
34 | |||
35 | if (!empty($auth_key)) { |
||
36 | //auth key is required |
||
37 | if (!isset($_REQUEST['auth_key']) || $_REQUEST['auth_key'] !== $auth_key) { |
||
38 | echo "No auth key set or auth key is wrong."; |
||
39 | ob_end_flush(); |
||
40 | |||
41 | Logger::log(LogLevel::WARNING, "No auth key set or auth key is wrong."); |
||
42 | |||
43 | exit; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | Logger::log(LogLevel::INFO, "execute cronjon.php"); |
||
48 | |||
49 | Events::throwEvent("init_cronjob"); |
||
50 | |||
51 | //execute tasks (task schedular) |
||
52 | Tasks::schedule(Settings::get("max_tasks_on_cronjob", 10)); |
||
53 | |||
54 | $end_time = microtime(true); |
||
55 | $exec_time = $end_time - $start_time; |
||
56 | |||
57 | echo "<!-- cronjob executed in " . $exec_time . " seconds -->"; |
||
58 | |||
59 | ob_end_flush(); |
||
60 | flush(); |
||
61 | |||
62 | //send logs to server |
||
63 | if (LOGGING_ENABLED) { |
||
64 | Logger::send(); |
||
65 | } |
||
66 | |||
67 | ?> |
||
0 ignored issues
–
show
|
|||
68 |
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.