Completed
Pull Request — master (#320)
by
unknown
07:52
created

Cronjobs::enabled()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
nc 3
nop 0
dl 0
loc 19
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/***************************************************************************
3
 *  For license information see doc/license.txt
4
 *
5
 *  Unicode Reminder メモ
6
 ***************************************************************************/
7
8
class Cronjobs
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    // Cronjobs are disabled if the website is down (for maintenance).
11
12
    public static function enabled()
13
    {
14
        global $argv, $http_response_header, $opt;
15
16
        if (!in_array('--auto', $argv)) {
17
            // Cronjob is run manually (testing). We do it this way round
18
            // (not defaulting to 'auto' when no '--test' param is given),
19
            // because the effect of forgetting a --test parameter can be worse
20
            // than forgetting the --auto option in crontab.
21
            return true;
22
        } elseif (@file_get_contents($opt['page']['absolute_http_url'] . 'api/ping.php') !== false) {
23
            // website is up and running
24
            return true;
25
        } else {
26
            // === null: website is down, or DNS configuration error
27
            // !== null: website is access protected or page is redirected or whatever
28
            return $http_response_header !== null;
29
        }
30
    }
31
}
32