function CheckLocation($url, &$locations) { $doc = new MyDOMDocument(); if ($doc) { $response = file_get_contents($url); if (strlen($response)) { $response = preg_replace('/[^(\\x20-\\x7F)]*/', '', $response); $doc->loadXML($response); $data = $doc->toArray(); $status = (int) $data['response']['statusCode']; if ($status == 200) { foreach ($locations as $location => &$testers) { foreach ($testers as $tester => &$cmd) { CheckTester($data, $location, $tester, $cmd); } } } } } }
/** * Go through and update the status of all of the tests * * @param mixed $results */ function UpdateResults(&$results, $testCount) { global $server; $count = 0; $changed = false; foreach ($results as &$result) { if (array_key_exists('id', $result) && strlen($result['id']) && (!array_key_exists('result', $result) || !strlen($result['result']))) { $count++; echo "\rUpdating the status of test {$count} of {$testCount}... "; $doc = new MyDOMDocument(); if ($doc) { $url = "{$server}xmlResult/{$result['id']}/"; $response = file_get_contents($url); if (strlen($response)) { $response = preg_replace('/[^(\\x20-\\x7F)]*/', '', $response); $doc->loadXML($response); $data = $doc->toArray(); $status = (int) $data['response']['statusCode']; if ($status == 200) { $changed = true; // test is complete, get the actual result GetTestResult($data['response']['data'], $result); } unset($doc); } } } } // clear the progress text echo "\r \r"; }