Completed
Push — development ( 43bb99...2fa2b9 )
by Thomas
03:02 queued 02:41
created

util2/cron/modules/push_waypoint_reports.class.php (1 issue)

Upgrade to new PHP Analysis Engine

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
checkJob(new PushWayPointReports());
7
8
class PushWayPointReports
9
{
10
    public $name = 'push_waypoint_reports';
11
    public $interval = 120;
12
13
    public function run()
14
    {
15
        global $opt;
16
17
        if ($opt['cron']['gcwp']['report']) {
18
            $rs = sql(
19
                'SELECT * FROM `waypoint_reports`
20
                 WHERE `gcwp_processed`=0
21
                 ORDER BY `date_reported`'
22
            );
23
            while ($r = sql_fetch_assoc($rs)) {
24
                if (substr($r['wp_external'], 0, 2) != 'GC') {
25
                    $result = 'ok';
26
                } else {
27
                    $result = @file_get_contents(
28
                        $opt['cron']['gcwp']['report'] .
29
                        '?ocwp=' . urlencode($r['wp_oc']) .
30
                        '&gcwp=' . urlencode($r['wp_external']) .
31
                        '&source=' . urlencode($r['source'])
32
                    );
33
                    $result = trim($result);
34
                }
35
                if ($result != 'ok') {
36
                    echo "could not push GC waypoint report (id " . $r['report_id'] . "): " . $result . "\n";
37
                    break;
38
                } else {
39
                    sql(
0 ignored issues
show
Deprecated Code introduced by
The function sql() has been deprecated with message: use DBAL Conenction instead. See adminreports.php for an example implementation

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
40
                        "
41
                        UPDATE `waypoint_reports`
42
                        SET `gcwp_processed`=1
43
                        WHERE `report_id`='&1'",
44
                        $r['report_id']
45
                    );
46
                }
47
            }
48
            sql_free_result($rs);
49
        }
50
    }
51
}
52