コード例 #1
0
ファイル: status.php プロジェクト: lucasRolff/webpagetest
/**
* Go through and update the status of all of the tests
* 
* @param mixed $results
*/
function UpdateResults(&$results, $testCount)
{
    global $server;
    global $statsVer;
    global $video;
    $count = 0;
    $changed = false;
    foreach ($results as &$result) {
        if (array_key_exists('id', $result) && strlen($result['id']) && (!array_key_exists('statsVer', $result) || $result['statsVer'] != $statsVer || !array_key_exists('result', $result) || !strlen($result['result']))) {
            $count++;
            echo "\rUpdating the status of test {$count} of {$testCount}...                  ";
            //$url = "{$server}jsonResult.php?test={$result['id']}&medianRun=fastest";
            $url = "{$server}jsonResult.php?test={$result['id']}";
            if ($video) {
                $url .= "&medianMetric=SpeedIndex";
            }
            $response = http_fetch($url);
            if (strlen($response)) {
                $data = json_decode($response, true);
                unset($response);
                if (isset($data) && is_array($data) && array_key_exists('statusCode', $data)) {
                    if (array_key_exists('data', $data) && is_array($data['data']) && $data['statusCode'] == 200) {
                        $changed = true;
                        GetTestResult($data['data'], $result);
                        $result['statsVer'] = $statsVer;
                    } elseif ($data['statusCode'] >= 400) {
                        $changed = true;
                        $result['statsVer'] = $statsVer;
                        $result['result'] = -1;
                    }
                    IncrementStatus($data['statusCode']);
                } else {
                    IncrementStatus(-2);
                }
                unset($data);
            } else {
                IncrementStatus(-1);
            }
        } else {
            IncrementStatus(0);
        }
    }
    // clear the progress text
    echo "\r                                                     \r";
}
コード例 #2
0
require_once 'common.inc';
require_once 'page_data.inc';
require_once 'testStatus.inc';
require_once 'video/visualProgress.inc.php';
require_once 'domains.inc';
require_once 'breakdown.inc';
require_once 'devtools.inc.php';
require_once 'archive.inc';
if (array_key_exists('batch', $test['test']) && $test['test']['batch']) {
    include 'resultBatch.inc';
} else {
    $ret = array('data' => GetTestStatus($id));
    $ret['statusCode'] = $ret['data']['statusCode'];
    $ret['statusText'] = $ret['data']['statusText'];
    if ($ret['statusCode'] == 200) {
        $ret['data'] = GetTestResult($id);
    }
    json_response($ret);
}
/**
* Gather all of the data for a given test and return it as an array
* 
* @param mixed $id
*/
function GetTestResult($id)
{
    global $url;
    global $median_metric;
    $testPath = './' . GetTestPath($id);
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
    $host = $_SERVER['HTTP_HOST'];
コード例 #3
0
ファイル: status.php プロジェクト: risyasin/webpagetest
/**
* 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";
}