/** * Dump the console log if we have one * * @param mixed $id * @param mixed $testPath * @param mixed $run * @param mixed $cached */ function ConsoleLog($id, $testPath, $run, $cached) { $consoleLog = DevToolsGetConsoleLog($testPath, $run, $cached); if (isset($consoleLog) && is_array($consoleLog) && count($consoleLog)) { echo "<consoleLog>\n"; foreach ($consoleLog as &$entry) { echo "<entry>\n"; echo "<source>" . xml_entities($entry['source']) . "</source>\n"; echo "<level>" . xml_entities($entry['level']) . "</level>\n"; echo "<message>" . xml_entities($entry['text']) . "</message>\n"; echo "<url>" . xml_entities($entry['url']) . "</url>\n"; echo "<line>" . xml_entities($entry['line']) . "</line>\n"; echo "</entry>\n"; } echo "</consoleLog>\n"; } }
/** * Gather all of the data that we collect for a single run * * @param mixed $id * @param mixed $testPath * @param mixed $run * @param mixed $cached */ function GetSingleRunData($id, $testPath, $run, $cached, &$pageData, $testInfo) { $ret = null; if (array_key_exists($run, $pageData) && is_array($pageData[$run]) && array_key_exists($cached, $pageData[$run]) && is_array($pageData[$run][$cached])) { $protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On' ? 'https' : 'http'; $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $path = substr($testPath, 1); $ret = $pageData[$run][$cached]; $ret['run'] = $run; $cachedText = ''; if ($cached) { $cachedText = '_Cached'; } if (isset($testInfo)) { if (array_key_exists('tester', $testInfo)) { $ret['tester'] = $testInfo['tester']; } if (array_key_exists('test_runs', $testInfo) && array_key_exists($run, $testInfo['test_runs']) && array_key_exists('tester', $testInfo['test_runs'][$run])) { $ret['tester'] = $testInfo['test_runs'][$run]['tester']; } } $basic_results = false; if (array_key_exists('basic', $_REQUEST) && $_REQUEST['basic']) { $basic_results = true; } if (!$basic_results && gz_is_file("{$testPath}/{$run}{$cachedText}_pagespeed.txt")) { $ret['PageSpeedScore'] = GetPageSpeedScore("{$testPath}/{$run}{$cachedText}_pagespeed.txt"); $ret['PageSpeedData'] = "{$protocol}://{$host}{$uri}//getgzip.php?test={$id}&file={$run}{$cachedText}_pagespeed.txt"; } $ret['pages'] = array(); $ret['pages']['details'] = "{$protocol}://{$host}{$uri}/details.php?test={$id}&run={$run}&cached={$cached}"; $ret['pages']['checklist'] = "{$protocol}://{$host}{$uri}/performance_optimization.php?test={$id}&run={$run}&cached={$cached}"; $ret['pages']['breakdown'] = "{$protocol}://{$host}{$uri}/breakdown.php?test={$id}&run={$run}&cached={$cached}"; $ret['pages']['domains'] = "{$protocol}://{$host}{$uri}/domains.php?test={$id}&run={$run}&cached={$cached}"; $ret['pages']['screenShot'] = "{$protocol}://{$host}{$uri}/screen_shot.php?test={$id}&run={$run}&cached={$cached}"; $ret['thumbnails'] = array(); $ret['thumbnails']['waterfall'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_waterfall_thumb.png"; $ret['thumbnails']['checklist'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_optimization_thumb.png"; $ret['thumbnails']['screenShot'] = "{$protocol}://{$host}{$uri}/result/{$id}/{$run}{$cachedText}_screen_thumb.png"; $ret['images'] = array(); $ret['images']['waterfall'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_waterfall.png"; $ret['images']['connectionView'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_connection.png"; $ret['images']['checklist'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_optimization.png"; $ret['images']['screenShot'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_screen.jpg"; if (is_file("{$testPath}/{$run}{$cachedText}_screen.png")) { $ret['images']['screenShotPng'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_screen.png"; } $ret['rawData'] = array(); $ret['rawData']['headers'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_report.txt"; $ret['rawData']['pageData'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_IEWPG.txt"; $ret['rawData']['requestsData'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_IEWTR.txt"; $ret['rawData']['utilization'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_progress.csv"; if (is_file("{$testPath}/{$run}{$cachedText}_bodies.zip")) { $ret['rawData']['bodies'] = "{$protocol}://{$host}{$uri}{$path}/{$run}{$cachedText}_bodies.zip"; } if (!$basic_results) { $startOffset = array_key_exists('testStartOffset', $ret) ? intval(round($ret['testStartOffset'])) : 0; $progress = GetVisualProgress($testPath, $run, $cached, null, null, $startOffset); if (array_key_exists('frames', $progress) && is_array($progress['frames']) && count($progress['frames'])) { $cachedTextLower = strtolower($cachedText); $ret['videoFrames'] = array(); foreach ($progress['frames'] as $ms => $frame) { $videoFrame = array('time' => $ms); $videoFrame['image'] = "http://{$host}{$uri}{$path}/video_{$run}{$cachedTextLower}/{$frame['file']}"; $videoFrame['VisuallyComplete'] = $frame['progress']; $ret['videoFrames'][] = $videoFrame; } } $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true); $ret['domains'] = getDomainBreakdown($id, $testPath, $run, $cached, $requests); $ret['breakdown'] = getBreakdown($id, $testPath, $run, $cached, $requests); // check if removing requests $addRequests = 1; if (isset($_GET['requests'])) { if ($_GET['requests'] == 0) { $addRequests = 0; } } // add requests if ($addRequests == 1) { $ret['requests'] = $requests; } $console_log = DevToolsGetConsoleLog($testPath, $run, $cached); if (isset($console_log)) { $ret['consoleLog'] = $console_log; } if (gz_is_file("{$testPath}/{$run}{$cachedText}_status.txt")) { $ret['status'] = array(); $lines = gz_file("{$testPath}/{$run}{$cachedText}_status.txt"); foreach ($lines as $line) { $line = trim($line); if (strlen($line)) { list($time, $message) = explode("\t", $line); if (strlen($time) && strlen($message)) { $ret['status'][] = array('time' => $time, 'message' => $message); } } } } } } return $ret; }
<?php include 'common.inc'; require_once 'video.inc'; require_once 'page_data.inc'; require_once 'devtools.inc.php'; $pageRunData = loadPageRunData($testPath, $run, $cached, null, $test['testinfo']); $videoPath = "{$testPath}/video_{$run}"; if ($cached) { $videoPath .= '_cached'; } // get the status messages $messages = LoadStatusMessages($testPath . '/' . $run . $cachedText . '_status.txt'); $console_log = DevToolsGetConsoleLog($testPath, $run, $cached); $page_keywords = array('Screen Shot', 'Webpagetest', 'Website Speed Test'); $page_description = "Website performance test screen shots{$testLabel}."; $userImages = true; ?> <!DOCTYPE html> <html> <head> <title>WebPagetest Screen Shots<?php echo $testLabel; ?> </title> <?php $gaTemplate = 'Screen Shot'; include 'head.inc'; ?> <style type="text/css"> img.center {