$lastWeek = strtotime('-7 days');
     // Enumerate through the list of hosts from config.php
     foreach ($checkHosts as $host) {
         curl_setopt($ch, CURLOPT_URL, 'https://api.pingdom.com/api/2.0/summary.performance/' . $host['id'] . '?from=' . $lastWeek . '&to=' . $now . '&resolution=day');
         // Decode the response from Pingdom to an associative array
         $response = json_decode(curl_exec($ch), true);
         // Before we look through the response, was there an error?
         if (isset($response['error'])) {
             // Crap, there was an error!
             // Send the error to Status Board
             $finalArray['graph']['error'] = ['message' => 'Error: ' . $response['error']['statusdesc'] . ' (' . $response['error']['statuscode'] . '): ' . $response['error']['errormessage'], 'detail' => $response['error']['errormessage']];
             // Abort this loop!
             break;
         }
         foreach ($response['summary']['days'] as $hour) {
             $check[] = ['title' => processDate($hour['starttime'], $dateFormat), 'value' => $hour['avgresponse']];
         }
         $responseTime[] = ['title' => $host['name'], 'datapoints' => $check];
         // Unset the $check variable so it doesn't insert values into the next hosts array
         unset($check);
     }
     // End 'last-week' case
     break;
 case 'last-day':
 default:
     $finalArray['graph']['title'] .= ' (Last 24 Hours)';
     // If you do 1 day / 24 hours it doubles up the current timestamp with the timestamp 24 hours ago.  Not good!
     $yesterday = strtotime('-23 hours');
     // Enumerate through the list of hosts from config.php
     foreach ($checkHosts as $host) {
         curl_setopt($ch, CURLOPT_URL, 'https://api.pingdom.com/api/2.0/summary.performance/' . $host['id'] . '?from=' . $yesterday . '&to=' . $now . '&resolution=hour');
Exemplo n.º 2
0
$perm = v('perm', 'add');
echo 'Perm: ' . $perm . "<br />\n";
include 'lib/commontable.inc.php';
function processDate(&$datevar)
{
    $tmp = $datevar['year'] . '-' . $datevar['month'] . '-' . $datevar['day'] . ' ' . $datevar['hour'] . ':' . $datevar['minute'] . ':' . $datevar['second'];
    $datevar = preg_replace('/([^[:digit:]]*)0+0/', '\\10', $tmp);
    return $datevar;
}
if ($tablePerm[$perm]) {
    $editData = NULL;
    // Fix dates first
    $arrkeys = array_keys($_REQUEST[$_REQUEST['table']]);
    $datekeys = array_values(preg_grep("/(Date|Duration)\$/", $arrkeys));
    foreach ($datekeys as $dk) {
        processDate($_REQUEST[$_REQUEST['table']][$dk]);
    }
    unset($datekeys, $dk, $arrkeys);
    if ($perm == 'edit') {
        $tableEdit = v('table');
        $dataEdit = v($tableEdit);
        $idEdit = $dataEdit[$tableData[$tableName]['_idkey']];
        if (dodbg()) {
            echo "Trying to sequence:<br />\n";
            print_r($tableData[$tableName]['_view_cols']);
            echo "<br />\nEnd of attempt.\n<br />";
        }
        $cols = MySQL_arrayToSequence($tableData[$tableName]['_view_cols'], FALSE, FALSE);
        if (dodbg()) {
            echo "sequence:";
            print_r($cols);