autocron.php 1.47 KB
Newer Older
1
2
3
4
5
6
7
8
<?php
/**
 * Created by PhpStorm.
 * User: crose
 * Date: 8/17/17
 * Time: 10:29 PM
 */

9
10
11
12
namespace IMATHUZH\Qfq\External;

require_once(__DIR__ . '/../../vendor/autoload.php');

13
use IMATHUZH\Qfq\Core\Helper\Path;
14
use IMATHUZH\Qfq\External\AutoCron;
15

16
17
global $argv;

18
try {
19
20
21
22
23
24
25
    try {
        $verbose = false;

        if (isset($argv[1]) && $argv[1] == '-v') {
            $verbose = true;
        }

26
27
28
        // If this script is started via an absolute path: set CWD to the T3 installation directory
        if ($argv[0][0] == '/') {
            $baseDir='';
Marc Egger's avatar
Marc Egger committed
29
            // /var/www/html/typo3conf/ext/qfq/Classes/External/autocron.php
30
31
32
33
34
35
36
37
38
39
            $arr = explode('/', $argv[0]);
            $cnt = count($arr) - 6; // Strip the last '6' entries, these are below T3 basedir until this script.
            for ($ii = 0; $ii < $cnt; $ii++) {
                if($arr[$ii]!='') {
                    $baseDir .= '/' . $arr[$ii];
                }
            }
            chdir($baseDir);
        }

Marc Egger's avatar
Marc Egger committed
40
        $autoCron = new AutoCron($verbose);
41
        $autoCron->process();
42

Marc Egger's avatar
Marc Egger committed
43
    } catch (\UserFormException $e) {
44
        $answer[API_MESSAGE] = $e->formatMessage();
Marc Egger's avatar
Marc Egger committed
45
    } catch (\CodeException $e) {
46
        $answer[API_MESSAGE] = $e->formatMessage();
Marc Egger's avatar
Marc Egger committed
47
    } catch (\DbException $e) {
48
        $answer[API_MESSAGE] = $e->formatMessage();
49
    }
50
51
52
53
} catch (\Exception $e) {
    $answer[API_MESSAGE] = "Generic Exception: " . $e->getMessage();
}

54
55
56
57
if (!empty($answer[API_MESSAGE])) {
    echo $answer[API_MESSAGE];
}