Example #1
0
<?php

require_once dirname(dirname(__FILE__)) . '/lib.php';
#require_once(dirname(__FILE__).'/config.php');
// Verbose
$v = false;
function debug($message)
{
    global $v;
    if (!empty($v)) {
        echo "{$message}\n";
    }
}
// Last dataset hash
$lasthash = '';
$lastcodes = array();
$laststates = array();
while (1) {
    print "API call\n";
    $data = rand(0, 9);
    dashboard_push_data('demo', array('lastchange' => time(), 'data' => $data));
    print "Update sent\n";
    print "Press enter to continue\n";
    $input = fread(STDIN, 10000);
}
Example #2
0
<?php

require_once dirname(__FILE__) . '/../lib.php';
if (empty($argv[1])) {
    die("Usage: {$argv['0']} URL\n\n");
}
$url = $argv[1];
// Data to send
dashboard_push_data('iframe', $url, false);
Example #3
0
<?php

require_once dirname(dirname(__FILE__)) . '/lib.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['message'])) {
    dashboard_push_data('messages', $_POST['message']);
}
?>
<html>
    <head>
        <title>Dashboard message</title>
    </head>

    <body>

        <form method="post">
            <textarea name="message" cols="50" rows="5"></textarea><br />
            <input type="submit" value="Send" />
        </form>

    </body>
</html>
Example #4
0
                if (count($row->allocated_to_ids) == 1) {
                    if (in_array($row->allocated_to_ids[0], $config->ignore_allocateds)) {
                        continue;
                    }
                }
            }
            // Add URL
            $row->request_url = "{$config->url}/wr.php?request_id={$row->request_id}";
            // Check if it doesn't match what is in $lastwrs
            if (!isset($lastwrs[$seen]) || $row != $lastwrs[$seen]) {
                // Update $lastwrs and trigger sending of new version
                $send = true;
                foreach ($row as $key => $val) {
                    if (is_string($val)) {
                        // escape any nasties
                        $row->{$key} = htmlspecialchars($val, ENT_QUOTES | ENT_SUBSTITUTE);
                    }
                }
                $lastwrs[$seen] = $row;
            }
            ++$seen;
        }
    }
    if ($send) {
        print "Update sent\n";
        // Reverse order of WRs (as they will be prepended one at a time) and
        // pad the array to flush out the cache
        dashboard_push_data('wrms', array_pad(array_reverse($lastwrs), -20, 1), $multiple = true);
    }
    sleep(60);
}
Example #5
0
            sleep(300);
            break;
        }
        // Only shame the fools on Mon, Tue and Wed
        $user->shamedlastweek = in_array($dayofweek, array(1, 2, 3)) && $user->hourslastweek < $expectedhourslw;
        // Hours this week
        $user->hoursthisweek = timesheets_get_total_hours($user, 'w%3Aw');
        if ($user->hoursthisweek === false) {
            sleep(300);
            break;
        }
        $user->shamedthisweek = $user->hoursthisweek < $expectedhourstw;
        $send[] = $user;
    }
    print count($send) . " users sent\n";
    dashboard_push_data('availability', $send, $multiple = true);
    sleep(300);
}
function timesheets_get_total_hours($user, $daterange)
{
    include dirname(__FILE__) . '/config.php';
    // Get data from WRMS
    $url = '/api2/report?report_type=timesheet&page_size=200&display_fields=hours_sum&order_by=request_id&order_direction=desc&worker=' . $user->id . '&created_date=' . $daterange;
    // Last week
    $ch = curl_init($config->url . $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True);
    curl_setopt($ch, CURLOPT_COOKIE, 'wrms3_auth=' . $config->secret);
    $result = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($result);
    if (empty($response->success) || $response->response->results_count != 1) {
Example #6
0
            $site = strtr($file, array('_moodle' => '', '.rrd' => ''));
            echo "+ {$file}\n";
            $options = array("AVERAGE", "--start", RRD3_DOMAIN, "--end", "now");
            if ($data = rrd_fetch(RRD3_PATH . $file, $options)) {
                foreach ($data['data'] as $name => $values) {
                    if (!isset($labels[$name])) {
                        continue;
                    }
                    array_walk($values, function (&$n) {
                        if (is_nan($n)) {
                            $n = 0.0;
                        }
                    });
                    $data['data'][$name] = array();
                    echo "  -{$name}\n";
                    foreach ($values as $key => $value) {
                        $data['data'][$name][$key * 1000] = $value;
                    }
                    $send = new stdClass();
                    $send->name = $labels[$name]['name'];
                    $send->data = $data['data'][$name];
                    $send->url = $site;
                    $send->ylabel = $labels[$name]['ylabel'];
                    // Data to send
                    dashboard_push_data('rrd3', $send, false);
                    sleep(RRD3_UPDATE_INTERVAL);
                }
            }
        }
    }
}