These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /*************************************************************************** |
||
3 | * for license information see LICENSE.md |
||
4 | ***************************************************************************/ |
||
5 | |||
6 | /** |
||
7 | * Class Cronjobs |
||
8 | * |
||
9 | * Cronjobs are disabled if the website is down (for maintenance). |
||
10 | */ |
||
11 | class Cronjobs |
||
0 ignored issues
–
show
|
|||
12 | { |
||
13 | /** |
||
14 | * @return bool |
||
15 | */ |
||
16 | public static function enabled() |
||
17 | { |
||
18 | global $argv, $http_response_header, $opt; |
||
19 | |||
20 | // maintenance page is active so no cronjob should be executed |
||
21 | if (file_exists(__DIR__ . '/../maintenance.enable')) { |
||
22 | return false; |
||
23 | } elseif (!in_array('--auto', $argv)) { |
||
24 | // Cronjob is run manually (testing). We do it this way round |
||
25 | // (not defaulting to 'auto' when no '--test' param is given), |
||
26 | // because the effect of forgetting a --test parameter can be worse |
||
27 | // than forgetting the --auto option in crontab. |
||
28 | return true; |
||
29 | } elseif (@file_get_contents($opt['page']['absolute_http_url'] . 'api/ping.php') !== false) { |
||
30 | // website is up and running |
||
31 | return true; |
||
32 | } |
||
33 | // === null: website is down, or DNS configuration error |
||
34 | // !== null: website is access protected or page is redirected or whatever |
||
35 | return $http_response_header !== null; |
||
36 | } |
||
37 | } |
||
38 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.