当前位置: 首页>>代码示例>>PHP>>正文


PHP loadAllPageData函数代码示例

本文整理汇总了PHP中loadAllPageData函数的典型用法代码示例。如果您正苦于以下问题:PHP loadAllPageData函数的具体用法?PHP loadAllPageData怎么用?PHP loadAllPageData使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了loadAllPageData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PruneDir

/**
* Remove all video directories except for the median run
* 
* @param mixed $dir
*/
function PruneDir($dir)
{
    global $count;
    global $pruned;
    $pruned++;
    echo "\r{$count} ({$pruned}): Pruning {$dir}                      ";
    $pageData = loadAllPageData($dir);
    $fv = GetMedianRun($pageData, 0);
    if ($fv) {
        $keep = array();
        $keep[0] = "video_{$fv}";
        $rv = GetMedianRun($pageData, 1);
        if ($rv) {
            $keep[1] = "video_{$rv}_cached";
        } else {
            $keep[1] = '';
        }
        $f = scandir($dir);
        foreach ($f as $file) {
            if (!strncmp($file, 'video_', 6) && is_dir("{$dir}/{$file}")) {
                $del = true;
                if (!strcmp($file, $keep[0]) || !strcmp($file, $keep[1])) {
                    $del = false;
                }
                if ($del) {
                    RemoveDirectory("{$dir}/{$file}");
                }
            }
        }
    }
    unset($pageData);
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:37,代码来源:prunevideo.php

示例2: StatsdPostResult

function StatsdPostResult(&$test, $testPath)
{
    require_once 'page_data.inc';
    $runs = $test['runs'];
    if (array_key_exists('discard', $test) && $test['discard'] > 0 && $test['discard'] <= $runs) {
        $runs -= $test['discard'];
    }
    if ($runs) {
        $pageData = loadAllPageData($testPath);
        $medians = array(GetMedianRun($pageData, 0), GetMedianRun($pageData, 1));
        if (isset($pageData) && is_array($pageData)) {
            foreach ($pageData as $run => &$pageRun) {
                foreach ($pageRun as $cached => &$testData) {
                    if (GetSetting('statsdPattern') && !preg_match('/' . GetSetting('statsdPattern') . '/', $test['label'])) {
                        continue;
                    }
                    if (GetSetting('statsdMedianOnly') && !($medians[$cached] == $run)) {
                        continue;
                    }
                    $graphData = array();
                    foreach ($testData as $metric => $value) {
                        if (is_float($value)) {
                            $value = intval($value);
                        }
                        if (is_int($value) && $metric != 'result') {
                            $graphData[$metric] = $value;
                        }
                    }
                    StatsdPost($test['location'], $test['browser'], $test['label'], $cached, $graphData);
                }
            }
        }
    }
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:34,代码来源:statsd.inc.php

示例3: GenerateHAR

/**
* Generate a HAR file for the given test
* 
* @param mixed $testPath
*/
function GenerateHAR($id, $testPath, $options)
{
    $json = '{}';
    if (isset($testPath)) {
        $pageData = null;
        if (isset($options["run"]) && $options["run"]) {
            if (!strcasecmp($options["run"], 'median')) {
                $raw = loadAllPageData($testPath);
                $run = GetMedianRun($raw, $options['cached'], $median_metric);
                if (!$run) {
                    $run = 1;
                }
                unset($raw);
            }
            $pageData[$run] = array();
            if (isset($options['cached'])) {
                $pageData[$run][$options['cached']] = loadPageRunData($testPath, $run, $options['cached']);
                if (!isset($pageData[$run][$options['cached']])) {
                    unset($pageData);
                }
            } else {
                $pageData[$run][0] = loadPageRunData($testPath, $run, 0);
                if (!isset($pageData[$run][0])) {
                    unset($pageData);
                }
                $pageData[$run][1] = loadPageRunData($testPath, $run, 1);
            }
        }
        if (!isset($pageData)) {
            $pageData = loadAllPageData($testPath);
        }
        // build up the array
        $harData = BuildHAR($pageData, $id, $testPath, $options);
        $json_encode_good = version_compare(phpversion(), '5.4.0') >= 0 ? true : false;
        $pretty_print = false;
        if (isset($options['pretty']) && $options['pretty']) {
            $pretty_print = true;
        }
        if (isset($options['php']) && $options['php']) {
            if ($pretty_print && $json_encode_good) {
                $json = json_encode($harData, JSON_PRETTY_PRINT);
            } else {
                $json = json_encode($harData);
            }
        } elseif ($json_encode_good) {
            if ($pretty_print) {
                $json = json_encode($harData, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
            } else {
                $json = json_encode($harData, JSON_UNESCAPED_UNICODE);
            }
        } else {
            $jsonLib = new Services_JSON();
            $json = $jsonLib->encode($harData);
        }
    }
    return $json;
}
开发者ID:JHand93,项目名称:WebPerformanceTestSuite,代码行数:62,代码来源:har.inc.php

示例4: notify

/**
* Send a mail notification to the user
* 
* @param mixed $mailto
* @param mixed $id
* @param mixed $testPath
*/
function notify($mailto, $from, $id, $testPath, $host)
{
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: {$from}\r\n";
    $headers .= "Reply-To: {$from}";
    $url;
    if (is_file("{$testPath}/url.txt")) {
        $url = htmlspecialchars(file_get_contents("{$testPath}/url.txt"));
    }
    $shorturl = substr($url, 0, 40);
    if (strlen($url) > 40) {
        $shorturl .= '...';
    }
    $subject = "Test results for {$shorturl}";
    if (!isset($host)) {
        $host = $_SERVER['HTTP_HOST'];
    }
    // calculate the results
    require_once '../page_data.inc';
    $pageData = loadAllPageData($testPath);
    $fv = null;
    $rv = null;
    $pageStats = calculatePageStats($pageData, $fv, $rv);
    if (isset($fv)) {
        $load = number_format($fv['loadTime'] / 1000.0, 3);
        $render = number_format($fv['render'] / 1000.0, 3);
        $requests = number_format($fv['requests'], 0);
        $bytes = number_format($fv['bytesIn'] / 1024, 0);
        $result = "http://{$host}/result/{$id}";
        // capture the optimization report
        require_once '../optimization.inc';
        ob_start();
        dumpOptimizationReport($testPath, 1, 0);
        $optimization = ob_get_contents();
        ob_end_clean();
        // build the message body
        $body = "<html>\r\n            <head>\r\n                <title>{$subject}</title>\r\n                <style type=\"text/css\">\r\n                    .indented1 {padding-left: 40pt;}\r\n                    .indented2 {padding-left: 80pt;}\r\n                </style>\r\n            </head>\r\n            <body>\r\n            <p>The full test results for <a href=\"{$url}\">{$url}</a> are now <a href=\"{$result}/\">available</a>.</p>\r\n            <p>The page loaded in <b>{$load} seconds</b> with the user first seeing something on the page after <b>{$render} seconds</b>.  To download \r\n            the page required <b>{$requests} requests</b> and <b>{$bytes} KB</b>.</p>\r\n            <p>Here is what the page looked like when it loaded (click the image for a larger view):<br><a href=\"{$result}/1/screen_shot/\"><img src=\"{$result}/1_screen_thumb.jpg\"></a></p>\r\n            <h3>Here are the things on the page that could use improving:</h3>\r\n            {$optimization}\r\n            </body>\r\n        </html>";
        // send the actual mail
        mail($mailto, $subject, $body, $headers);
    }
}
开发者ID:kondrat-shmoylov,项目名称:Pagetest,代码行数:49,代码来源:workdone.php

示例5: IsTestValid

function IsTestValid($id)
{
    $valid = false;
    $testPath = './' . GetTestPath($id);
    $page_data = loadAllPageData($testPath);
    if (CountSuccessfulTests($page_data, 0) >= 3) {
        $valid = true;
    }
    return $valid;
}
开发者ID:sethblanchard,项目名称:webpagetest,代码行数:10,代码来源:cron.php

示例6: csvPageData

function csvPageData($id, $testPath, $runs)
{
    if ($_GET['requests']) {
        for ($i = 1; $i <= $runs; $i++) {
            for ($cached = 0; $cached <= 1; $cached++) {
                $requests = getRequests($id, $testPath, $i, $cached, $secure, $loc, false);
                if (isset($requests) && is_array($requests) && count($requests)) {
                    foreach ($requests as &$row) {
                        csvArray($row, $id, $i, $cached);
                    }
                }
            }
        }
    } else {
        $pageData = loadAllPageData($testPath);
        if ($pageData && is_array($pageData) && count($pageData)) {
            for ($i = 1; $i <= $runs; $i++) {
                if (array_key_exists($i, $pageData)) {
                    if (array_key_exists(0, $pageData[$i])) {
                        csvArray($pageData[$i][0], $id, $i, 0);
                    }
                    if (array_key_exists(1, $pageData[$i])) {
                        csvArray($pageData[$i][1], $id, $i, 1);
                    }
                }
            }
        }
    }
}
开发者ID:lucasRolff,项目名称:webpagetest,代码行数:29,代码来源:csv.php

示例7: trim

             $test['run'] = (int) $p[1];
         }
         if ($p[0] == 'l') {
             $test['label'] = $p[1];
         }
         if ($p[0] == 'c') {
             $test['cached'] = (int) $p[1];
         }
         if ($p[0] == 'e') {
             $test['end'] = trim($p[1]);
         }
     }
 }
 RestoreTest($test['id']);
 $test['path'] = GetTestPath($test['id']);
 $test['pageData'] = loadAllPageData($test['path']);
 $info = GetTestInfo($test['id']);
 if ($info) {
     if (array_key_exists('discard', $info) && $info['discard'] >= 1 && array_key_exists('priority', $info) && $info['priority'] >= 1) {
         $defaultInterval = 100;
     }
     $test['url'] = $info['url'];
 }
 $testInfo = parse_ini_file("./{$test['path']}/testinfo.ini", true);
 if ($testInfo !== FALSE) {
     if (array_key_exists('test', $testInfo) && array_key_exists('location', $testInfo['test'])) {
         $test['location'] = $testInfo['test']['location'];
     }
     if (isset($testInfo['test']) && isset($testInfo['test']['completeTime'])) {
         $test['done'] = true;
         if (!array_key_exists('run', $test) || !$test['run']) {
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:filmstrip.inc.php

示例8: KeepMedianVideo

/**
* Delete all of the video files except for the median run
* 
* @param mixed $id
*/
function KeepMedianVideo($testPath)
{
    require_once 'page_data.inc';
    $pageData = loadAllPageData($testPath);
    $run = GetMedianRun($pageData, 0);
    if ($run) {
        $dir = opendir($testPath);
        if ($dir) {
            while ($file = readdir($dir)) {
                $path = $testPath . "/{$file}/";
                if (is_dir($path) && !strncmp($file, 'video_', 6) && $file != "video_{$run}") {
                    delTree("{$path}/");
                }
            }
            closedir($dir);
        }
    }
}
开发者ID:kondrats,项目名称:Pagetest,代码行数:23,代码来源:workdone.php

示例9: notify

/**
* Send a mail notification to the user
* 
* @param mixed $mailto
* @param mixed $id
* @param mixed $testPath
*/
function notify($mailto, $from, $id, $testPath, $host)
{
    global $test;
    // calculate the results
    require_once 'page_data.inc';
    $headers = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: {$from}\r\n";
    $headers .= "Reply-To: {$from}";
    $pageData = loadAllPageData($testPath);
    $url = trim($pageData[1][0]['URL']);
    $shorturl = substr($url, 0, 40);
    if (strlen($url) > 40) {
        $shorturl .= '...';
    }
    $subject = "Test results for {$shorturl}";
    $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http';
    if (!isset($host)) {
        $host = $_SERVER['HTTP_HOST'];
    }
    $fv = GetMedianRun($pageData, 0);
    if (isset($fv) && $fv) {
        $load = number_format($pageData[$fv][0]['loadTime'] / 1000.0, 3);
        $render = number_format($pageData[$fv][0]['render'] / 1000.0, 3);
        $numRequests = number_format($pageData[$fv][0]['requests'], 0);
        $bytes = number_format($pageData[$fv][0]['bytesIn'] / 1024, 0);
        $result = "{$protocol}://{$host}/result/{$id}";
        // capture the optimization report
        require_once 'optimization.inc';
        require_once 'object_detail.inc';
        $secure = false;
        $haveLocations = false;
        $requests = getRequests($id, $testPath, 1, 0, $secure, $haveLocations, false);
        ob_start();
        dumpOptimizationReport($pageData[$fv][0], $requests, $id, 1, 0, $test);
        $optimization = ob_get_contents();
        ob_end_clean();
        // build the message body
        $body = "<html>\r\n            <head>\r\n                <title>{$subject}</title>\r\n                <style type=\"text/css\">\r\n                    .indented1 {padding-left: 40pt;}\r\n                    .indented2 {padding-left: 80pt;}\r\n                </style>\r\n            </head>\r\n            <body>\r\n            <p>The full test results for <a href=\"{$url}\">{$url}</a> are now <a href=\"{$result}/\">available</a>.</p>\r\n            <p>The page loaded in <b>{$load} seconds</b> with the user first seeing something on the page after <b>{$render} seconds</b>.  To download \r\n            the page required <b>{$numRequests} requests</b> and <b>{$bytes} KB</b>.</p>\r\n            <p>Here is what the page looked like when it loaded (click the image for a larger view):<br><a href=\"{$result}/{$fv}/screen_shot/\"><img src=\"{$result}/{$fv}_screen_thumb.jpg\"></a></p>\r\n            <h3>Here are the things on the page that could use improving:</h3>\r\n            {$optimization}\r\n            </body>\r\n        </html>";
        // send the actual mail
        mail($mailto, $subject, $body, $headers);
    }
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:50,代码来源:postprocess.php

示例10: elseif

<?php

include 'common.inc';
require_once 'page_data.inc';
if (array_key_exists('f', $_REQUEST) && $_REQUEST['f'] == 'json') {
    include 'jsonResult.php';
} elseif (array_key_exists('f', $_REQUEST) && $_REQUEST['f'] == 'xml') {
    include 'xmlResult.php';
} else {
    $options = null;
    if (array_key_exists('end', $_REQUEST)) {
        $options = array('end' => $_REQUEST['end']);
    }
    $pageData = loadAllPageData($testPath, $options);
    // if we don't have an url, try to get it from the page results
    if (!strlen($url)) {
        $url = $pageData[1][0]['URL'];
    }
    if (array_key_exists('testinfo', $test) && array_key_exists('spam', $test['testinfo']) && $test['testinfo']['spam']) {
        include 'resultSpam.inc.php';
    } else {
        if (isset($test['test']) && ($test['test']['batch'] || $test['test']['batch_locations']) || !array_key_exists('test', $test) && array_key_exists('testinfo', $test) && $test['testinfo']['batch']) {
            include 'resultBatch.inc';
        } elseif (isset($test['testinfo']['cancelled'])) {
            include 'testcancelled.inc';
        } elseif (isset($test['test']) && isset($test['test']['completeTime']) || count($pageData) > 0) {
            if (@$test['test']['type'] == 'traceroute') {
                include 'resultTraceroute.inc';
            } else {
                include 'result.inc';
            }
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:results.php

示例11: CollectTestResult

function CollectTestResult($test, &$data)
{
    global $benchmark;
    $id = $test['id'];
    $count = 0;
    echo "Reprocessing Test {$id}...";
    logMsg("Reprocessing Test {$id}", "./log/reprocess-{$benchmark}.log", true);
    RestoreTest($id);
    ReprocessVideo($id);
    $testPath = './' . GetTestPath($id);
    $page_data = loadAllPageData($testPath);
    if (count($page_data)) {
        foreach ($page_data as $run => &$page_run) {
            foreach ($page_run as $cached => &$test_data) {
                $data_row = $test_data;
                unset($data_row['URL']);
                // figure out the per-type request info (todo: measure how expensive this is and see if we have a better way)
                $breakdown = getBreakdown($test['id'], $testPath, $run, $cached, $requests);
                foreach ($breakdown as $mime => &$values) {
                    $data_row["{$mime}_requests"] = $values['requests'];
                    $data_row["{$mime}_bytes"] = $values['bytes'];
                }
                // capture the page speed score
                if ($cached) {
                    $data_row['page_speed'] = GetPageSpeedScore("{$testPath}/{$run}_Cached_pagespeed.txt");
                } else {
                    $data_row['page_speed'] = GetPageSpeedScore("{$testPath}/{$run}_pagespeed.txt");
                }
                $data_row['url'] = $test['url'];
                $data_row['label'] = $test['label'];
                $data_row['location'] = $test['location'];
                $data_row['config'] = $test['config'];
                $data_row['cached'] = $cached;
                $data_row['run'] = $run;
                $data_row['id'] = $test['id'];
                $data[] = $data_row;
                $count++;
            }
        }
    } else {
        $data_row = array();
        $data_row['url'] = $test['url'];
        $data_row['label'] = $test['label'];
        $data_row['location'] = $test['location'];
        $data_row['config'] = $test['config'];
        $data_row['id'] = $test['id'];
        $data[] = $data_row;
    }
    // If the test was already archived, re-archive it.
    $testInfo = GetTestInfo($id);
    if (array_key_exists('archived', $testInfo) && $testInfo['archived']) {
        $lock = LockTest($id);
        if (isset($lock)) {
            $testInfo = GetTestInfo($id);
            $testInfo['archived'] = false;
            SaveTestInfo($id, $testInfo);
            UnlockTest($lock);
        }
        ArchiveTest($id);
    }
    echo "{$count} results\n";
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:62,代码来源:reprocess.php

示例12: array

<?php

include 'common.inc';
require_once 'page_data.inc';
$page_keywords = array('image', 'comparison', 'Webpagetest', 'Website Speed Test');
$page_description = "Visual comparison of multiple website screen shots.";
$title = 'Web page screen shot diff';
$gaTemplate = 'Screen Shot Diff';
$refPath = GetTestPath($_REQUEST['ref']);
$refData = loadAllPageData($refPath);
$cmpPath = GetTestPath($_REQUEST['cmp']);
$cmpData = loadAllPageData($cmpPath);
$refRun = GetMedianRun($refData, 0, $median_metric);
$cmpRun = GetMedianRun($cmpData, 0, $median_metric);
if ($refRun && $cmpRun) {
    $refFile = "{$refPath}/{$refRun}_screen.png";
    $cmpFile = "{$cmpPath}/{$cmpRun}_screen.png";
    if (is_file($refFile) && is_file($cmpFile)) {
        $refImg = urlencode("{$_REQUEST['ref']}/{$refRun}_screen.png");
        $cmpImg = urlencode("{$_REQUEST['cmp']}/{$cmpRun}_screen.png");
    }
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>WebPagetest - Screen Shot diff</title>
        <?php 
include 'head.inc';
?>
    </head>
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:31,代码来源:ssdiff.php

示例13: TSViewPostResult

/**
* Upload a test result to a TSView instance
*/
function TSViewPostResult(&$test, $id, $testPath, $server, $tsview_name)
{
    require_once 'page_data.inc';
    $runs = $test['runs'];
    if (array_key_exists('discard', $test) && $test['discard'] > 0 && $test['discard'] <= $runs) {
        $runs -= $test['discard'];
    }
    if ($runs) {
        $pageData = loadAllPageData($testPath);
        $metrics = array('availability' => 1);
        $fv = array('availability' => array());
        if (!$test['fvonly']) {
            $rv = array('availability' => array());
        }
        for ($run = 1; $run <= $runs; $run++) {
            if (array_key_exists($run, $pageData)) {
                // collect the first-view data
                if (array_key_exists(0, $pageData[$run]) && array_key_exists('result', $pageData[$run][0]) && ($pageData[$run][0]['result'] == 0 || $pageData[$run][0]['result'] == 99999)) {
                    $fv['availability'][] = 1;
                    foreach ($pageData[$run][0] as $metric => $value) {
                        if (is_int($value) && $metric != 'result') {
                            if (!array_key_exists($metric, $metrics)) {
                                $metrics[$metric] = 1;
                            }
                            if (!array_key_exists($metric, $fv)) {
                                $fv[$metric] = array();
                            }
                            $fv[$metric][] = $value;
                        }
                    }
                } else {
                    $fv['availability'][] = 0;
                }
                // collect the repeat view data
                if (isset($rv)) {
                    if (array_key_exists(1, $pageData[$run]) && array_key_exists('result', $pageData[$run][1]) && ($pageData[$run][1]['result'] == 0 || $pageData[$run][1]['result'] == 99999)) {
                        $rv['availability'][] = 1;
                        foreach ($pageData[$run][1] as $metric => $value) {
                            if (is_int($value) && $metric != 'result') {
                                if (!array_key_exists($metric, $metrics)) {
                                    $metrics[$metric] = 1;
                                }
                                if (!array_key_exists($metric, $rv)) {
                                    $rv[$metric] = array();
                                }
                                $rv[$metric][] = $value;
                            }
                        }
                    } else {
                        $rv['availability'][] = 0;
                    }
                }
            } else {
                $fv['availability'][] = 0;
                if (isset($rv)) {
                    $rv['availability'][] = 0;
                }
            }
        }
        if (array_key_exists('tsview_configs', $test)) {
            $configs = explode(",", $test['tsview_configs']);
        } else {
            $configs = array();
        }
        $results_host = $test['tsview_results_host'];
        $spof = "";
        if ($test['label'] == 'SPOF') {
            $spof = "-SPOF";
        }
        $datasource = "{$tsview_name}{$spof}";
        TSViewCreate($server, $datasource, $metrics);
        TSViewPost($id, $server, $datasource, $fv, $results_host);
        if (isset($rv)) {
            TSViewCreate($server, "{$datasource}-repeat-view", $metrics);
            TSViewPost($id, $server, "{$datasource}-repeat-view", $rv, $results_host);
        }
    }
}
开发者ID:ceeaspb,项目名称:webpagetest,代码行数:81,代码来源:tsview.inc.php

示例14: scandir

 // delete any .test files
 $files = scandir($testPath);
 foreach ($files as $file) {
     if (preg_match('/.*\\.test$/', $file)) {
         unlink("{$testPath}/{$file}");
     }
 }
 if (array_key_exists('job_file', $testInfo) && is_file($testInfo['job_file'])) {
     unlink($testInfo['job_file']);
 }
 $perTestTime = 0;
 $testCount = 0;
 // do pre-complete post-processing
 MoveVideoFiles($testPath);
 if (!isset($pageData)) {
     $pageData = loadAllPageData($testPath);
 }
 $medianRun = GetMedianRun($pageData, 0);
 $testInfo['medianRun'] = $medianRun;
 $testInfo_dirty = true;
 // delete all of the videos except for the median run?
 if (array_key_exists('median_video', $ini) && $ini['median_video']) {
     KeepVideoForRun($testPath, $medianRun);
 }
 $test = file_get_contents("{$testPath}/testinfo.ini");
 $now = gmdate("m/d/y G:i:s", $time);
 // update the completion time if it isn't already set
 if (!strpos($test, 'completeTime')) {
     $complete = "[test]\r\ncompleteTime={$now}";
     if ($medianRun) {
         $complete .= "\r\nmedianRun={$medianRun}";
开发者ID:krishnakanthpps,项目名称:webpagetest,代码行数:31,代码来源:workdone.php

示例15: ParseTests

/**
* Parse the list of tests and identify the screen shots to compare
* 
*/
function ParseTests()
{
    $tests = array();
    global $median_metric;
    if (isset($_REQUEST['tests'])) {
        $groups = explode(',', $_REQUEST['tests']);
        foreach ($groups as $group) {
            $parts = explode('-', $group);
            if (count($parts) >= 1 && ValidateTestId($parts[0])) {
                $test = array();
                $test['id'] = $parts[0];
                $test['cached'] = 0;
                for ($i = 1; $i < count($parts); $i++) {
                    $p = explode(':', $parts[$i]);
                    if (count($p) >= 2) {
                        if ($p[0] == 'r') {
                            $test['run'] = (int) $p[1];
                        }
                        if ($p[0] == 'l') {
                            $test['label'] = $p[1];
                        }
                        if ($p[0] == 'c') {
                            $test['cached'] = (int) $p[1];
                        }
                    }
                }
                RestoreTest($test['id']);
                $test['path'] = GetTestPath($test['id']);
                if (!isset($test['run'])) {
                    $pageData = loadAllPageData($test['path']);
                    $test['run'] = GetMedianRun($pageData, $test['cached'], $median_metric);
                }
                if (!isset($test['label'])) {
                    $label = getLabel($test['id'], $user);
                    if (!empty($label)) {
                        $test['label'] = $new_label;
                    } else {
                        $info = GetTestInfo($test['id']);
                        if ($info && isset($info['label']) && strlen($info['label'])) {
                            $test['label'] = trim($info['label']);
                        }
                    }
                }
                if (!isset($test['label'])) {
                    $test['label'] = $test['id'];
                }
                $cachedText = '';
                if ($test['cached']) {
                    $cachedText = '_Cached';
                }
                $fileBase = "{$test['path']}/{$test['run']}{$cachedText}_screen";
                if (is_file("{$fileBase}.png")) {
                    $test['image'] = "{$fileBase}.png";
                } elseif (is_file("{$fileBase}.jpg")) {
                    $test['image'] = "{$fileBase}.jpg";
                }
                if (isset($test['image'])) {
                    $size = getimagesize($test['image']);
                    if ($size && count($size) >= 2 && $size[0] > 0 && $size[1] > 0) {
                        $test['width'] = $size[0];
                        $test['height'] = $size[1];
                        $tests[] = $test;
                    }
                }
            }
        }
    }
    if (!count($tests)) {
        unset($tests);
    }
    return $tests;
}
开发者ID:NeilBryant,项目名称:webpagetest,代码行数:76,代码来源:compare_screens.php


注:本文中的loadAllPageData函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。