Пример #1
0
 public function testGetRequests()
 {
     global $SINGLESTEP_REQUESTS;
     $this->tempDir = TestUtil::extractToTemp(__DIR__ . "/data/singlestepResults.zip");
     if (!$this->tempDir) {
         $this->fail("Failed to extract results to temp dir");
     }
     $testPath = $this->tempDir . "/singlestepResults";
     $actualRequests = getRequests("testId", $testPath, 1, 0, $hasSecure, $hasLocations, false, false);
     $this->assertEquals($SINGLESTEP_REQUESTS, $actualRequests);
 }
Пример #2
0
function getWelcome()
{
    global $wgUser, $wgOut, $wgLang;
    // Add CSS
    $wgOut->addModuleStyles('ext.socialprofile.userwelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMessage('mp-userlevels-link')->inContentLanguage()->plain());
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMessage('mp-welcome-logged-in', $wgUser->getName())->parse() . '</h2>
	<div class="mp-welcome-image">
	<a href="' . htmlspecialchars($wgUser->getUserPage()->getFullURL()) . '" rel="nofollow">' . $avatar->getAvatarURL() . '</a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $uploadOrEditMsg = 'mp-welcome-upload';
    } else {
        $uploadOrEditMsg = 'mp-welcome-edit';
    }
    $output .= '<div><a href="' . htmlspecialchars($avatar_link->getFullURL()) . '" rel="nofollow">' . wfMessage($uploadOrEditMsg)->plain() . '</a></div>';
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMessage('mp-welcome-points', $wgLang->formatNum($stats_data['points']))->parse() . '</div>
				<div class="honorific-level"><a href="' . htmlspecialchars($level_link->getFullURL()) . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMessage('mp-welcome-needed-points', htmlspecialchars($level_link->getFullURL()), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance())->text() . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
function getWelcome()
{
    global $wgUser, $wgOut, $wgScriptPath, $wgUploadPath;
    // Add CSS
    $wgOut->addExtensionStyle($wgScriptPath . '/extensions/SocialProfile/UserWelcome/UserWelcome.css');
    // Get stats and user level
    $stats = new UserStats($wgUser->getID(), $wgUser->getName());
    $stats_data = $stats->getUserStats();
    $user_level = new UserLevel($stats_data['points']);
    // Safe links
    $level_link = Title::makeTitle(NS_HELP, wfMsgForContent('mp-userlevels-link'));
    $avatar_link = SpecialPage::getTitleFor('UploadAvatar');
    // Make an avatar
    $avatar = new wAvatar($wgUser->getID(), 'l');
    // Profile top images/points
    $output = '<div class="mp-welcome-logged-in">
	<h2>' . wfMsg('mp-welcome-logged-in', $wgUser->getName()) . '</h2>
	<div class="mp-welcome-image">
	<a href="' . $wgUser->getUserPage()->escapeFullURL() . '" rel="nofollow"><img src="' . $wgUploadPath . '/avatars/' . $avatar->getAvatarImage() . '" alt="" border="0"/></a>';
    if (strpos($avatar->getAvatarImage(), 'default_') !== false) {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-upload') . '</a></div>';
    } else {
        $output .= '<div><a href="' . $avatar_link->escapeFullURL() . '" rel="nofollow">' . wfMsg('mp-welcome-edit') . '</a></div>';
    }
    $output .= '</div>';
    global $wgUserLevels;
    if ($wgUserLevels) {
        $output .= '<div class="mp-welcome-points">
			<div class="points-and-level">
				<div class="total-points">' . wfMsgExt('mp-welcome-points', 'parsemag', $stats_data['points']) . '</div>
				<div class="honorific-level"><a href="' . $level_link->escapeFullURL() . '">(' . $user_level->getLevelName() . ')</a></div>
			</div>
			<div class="cleared"></div>
			<div class="needed-points">
				<br />' . wfMsgExt('mp-welcome-needed-points', 'parsemag', $level_link->escapeFullURL(), $user_level->getNextLevelName(), $user_level->getPointsNeededToAdvance()) . '</div>
		</div>';
    }
    $output .= '<div class="cleared"></div>';
    $output .= getRequests();
    $output .= '</div>';
    return $output;
}
Пример #4
0
/**
* Check the given test against our block list to see if the test bypassed our blocks.
* If it did, add the domain to the automatic blocked domains list
* 
*/
function CheckForSpam()
{
    global $testPath;
    global $id;
    global $runNumber;
    global $cacheWarmed;
    global $testInfo;
    global $testInfo_dirty;
    if (isset($testInfo) && !array_key_exists('spam', $testInfo) && strpos($id, '.') == false && !strlen($testInfo['user']) && !strlen($testInfo['key']) && is_file('./settings/blockurl.txt')) {
        $blocked = false;
        $blockUrls = file('./settings/blockurl.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
        if (count($blockUrls)) {
            if (!isset($runNumber)) {
                $runNumber = 1;
            }
            if (!isset($cacheWarmed)) {
                $cacheWarmed = 0;
            }
            $secure = false;
            $haveLocations = false;
            $requests = getRequests($id, $testPath, $runNumber, $cacheWarmed, $secure, $haveLocations, false);
            if (isset($requests) && is_array($requests) && count($requests)) {
                foreach ($requests as &$request) {
                    if (array_key_exists('full_url', $request)) {
                        $url = $request['full_url'];
                        foreach ($blockUrls as $block) {
                            $block = trim($block);
                            if (strlen($block) && preg_match("/{$block}/i", $url)) {
                                $date = gmdate("Ymd");
                                // add the top-level page domain to the block list
                                $pageUrl = $requests[0]['full_url'];
                                $host = '';
                                if (strlen($pageUrl)) {
                                    $parts = parse_url($pageUrl);
                                    $host = trim($parts['host']);
                                    if (strlen($host) && strcasecmp($host, 'www.google.com') && strcasecmp($host, 'google.com') && strcasecmp($host, 'www.youtube.com') && strcasecmp($host, 'youtube.com')) {
                                        // add it to the auto-block list if it isn't already there
                                        if (is_file('./settings/blockdomainsauto.txt')) {
                                            $autoBlock = file('./settings/blockdomainsauto.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                                        }
                                        if (!isset($autoBlock) || !is_array($autoBlock)) {
                                            $autoBlock = array();
                                        }
                                        $found = false;
                                        foreach ($autoBlock as $entry) {
                                            if (!strcasecmp($entry, $host)) {
                                                $found = true;
                                                break;
                                            }
                                        }
                                        if (!$found) {
                                            $autoBlock[] = $host;
                                            file_put_contents('./settings/blockdomainsauto.txt', implode("\r\n", $autoBlock));
                                        }
                                    }
                                }
                                logMsg("[{$id}] {$host}: {$pageUrl} referenced {$url} which matched {$block}", "./log/{$date}-auto_blocked.log", true);
                                $blocked = true;
                                break 2;
                            }
                        }
                    }
                }
            }
        }
        if ($blocked) {
            $testInfo['spam'] = $blocked;
            $testInfo_dirty = true;
        }
    }
}
Пример #5
0
/**
* Build the data set
* 
* @param mixed $pageData
*/
function BuildHAR(&$pageData, $id, $testPath, $options)
{
    $result = array();
    $entries = array();
    $result['log'] = array();
    $result['log']['version'] = '1.1';
    $result['log']['creator'] = array('name' => 'WebPagetest', 'version' => VER_WEBPAGETEST);
    $result['log']['pages'] = array();
    foreach ($pageData as $run => $pageRun) {
        foreach ($pageRun as $cached => $data) {
            $cached_text = '';
            if ($cached) {
                $cached_text = '_Cached';
            }
            if (!array_key_exists('browser', $result['log'])) {
                $result['log']['browser'] = array('name' => $data['browser_name'], 'version' => $data['browser_version']);
            }
            $pd = array();
            $pd['startedDateTime'] = msdate($data['date']);
            $pd['title'] = "Run {$run}, ";
            if ($cached) {
                $pd['title'] .= "Repeat View";
            } else {
                $pd['title'] .= "First View";
            }
            $pd['title'] .= " for " . $data['URL'];
            $pd['id'] = "page_{$run}_{$cached}";
            $pd['pageTimings'] = array('onLoad' => $data['docTime'], 'onContentLoad' => -1, '_startRender' => $data['render']);
            // dump all of our metrics into the har data as custom fields
            foreach ($data as $name => $value) {
                if (!is_array($value)) {
                    $pd["_{$name}"] = $value;
                }
            }
            // add the page-level ldata to the result
            $result['log']['pages'][] = $pd;
            // now add the object-level data to the result
            $secure = false;
            $haveLocations = false;
            $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true);
            foreach ($requests as &$r) {
                $entry = array();
                $entry['pageref'] = $pd['id'];
                $entry['startedDateTime'] = msdate((double) $data['date'] + $r['load_start'] / 1000.0);
                $entry['time'] = $r['all_ms'];
                $request = array();
                $request['method'] = $r['method'];
                $protocol = $r['is_secure'] ? 'https://' : 'http://';
                $request['url'] = $protocol . $r['host'] . $r['url'];
                $request['headersSize'] = -1;
                $request['bodySize'] = -1;
                $request['cookies'] = array();
                $request['headers'] = array();
                $ver = '';
                $headersSize = 0;
                if (isset($r['headers']) && isset($r['headers']['request'])) {
                    foreach ($r['headers']['request'] as &$header) {
                        $headersSize += strlen($header) + 2;
                        // add 2 for the \r\n that is on the raw headers
                        $pos = strpos($header, ':');
                        if ($pos > 0) {
                            $name = trim(substr($header, 0, $pos));
                            $val = trim(substr($header, $pos + 1));
                            if (strlen($name)) {
                                $request['headers'][] = array('name' => $name, 'value' => $val);
                            }
                            // parse out any cookies
                            if (!strcasecmp($name, 'cookie')) {
                                $cookies = explode(';', $val);
                                foreach ($cookies as &$cookie) {
                                    $pos = strpos($cookie, '=');
                                    if ($pos > 0) {
                                        $name = (string) trim(substr($cookie, 0, $pos));
                                        $val = (string) trim(substr($cookie, $pos + 1));
                                        if (strlen($name)) {
                                            $request['cookies'][] = array('name' => $name, 'value' => $val);
                                        }
                                    }
                                }
                            }
                        } else {
                            $pos = strpos($header, 'HTTP/');
                            if ($pos >= 0) {
                                $ver = (string) trim(substr($header, $pos + 5, 3));
                            }
                        }
                    }
                }
                if ($headersSize) {
                    $request['headersSize'] = $headersSize;
                }
                $request['httpVersion'] = $ver;
                $request['queryString'] = array();
                $parts = parse_url($request['url']);
                if (isset($parts['query'])) {
                    $qs = array();
                    parse_str($parts['query'], $qs);
                    foreach ($qs as $name => $val) {
                        $request['queryString'][] = array('name' => (string) $name, 'value' => (string) $val);
                    }
                }
                if (!strcasecmp(trim($request['method']), 'post')) {
                    $request['postData'] = array();
                    $request['postData']['mimeType'] = '';
                    $request['postData']['text'] = '';
                }
                $entry['request'] = $request;
                $response = array();
                $response['status'] = (int) $r['responseCode'];
                $response['statusText'] = '';
                $response['headersSize'] = -1;
                $response['bodySize'] = (int) $r['objectSize'];
                $response['headers'] = array();
                $ver = '';
                $loc = '';
                $headersSize = 0;
                if (isset($r['headers']) && isset($r['headers']['response'])) {
                    foreach ($r['headers']['response'] as &$header) {
                        $headersSize += strlen($header) + 2;
                        // add 2 for the \r\n that is on the raw headers
                        $pos = strpos($header, ':');
                        if ($pos > 0) {
                            $name = (string) trim(substr($header, 0, $pos));
                            $val = (string) trim(substr($header, $pos + 1));
                            if (strlen($name)) {
                                $response['headers'][] = array('name' => $name, 'value' => $val);
                            }
                            if (!strcasecmp($name, 'location')) {
                                $loc = (string) $val;
                            }
                        } else {
                            $pos = strpos($header, 'HTTP/');
                            if ($pos >= 0) {
                                $ver = (string) trim(substr($header, $pos + 5, 3));
                            }
                        }
                    }
                }
                if ($headersSize) {
                    $response['headersSize'] = $headersSize;
                }
                $response['httpVersion'] = $ver;
                $response['redirectURL'] = $loc;
                $response['content'] = array();
                $response['content']['size'] = (int) $r['objectSize'];
                if (isset($r['contentType']) && strlen($r['contentType'])) {
                    $response['content']['mimeType'] = (string) $r['contentType'];
                } else {
                    $response['content']['mimeType'] = '';
                }
                // unsupported fields that are required
                $response['cookies'] = array();
                $entry['response'] = $response;
                $entry['cache'] = (object) array();
                $timings = array();
                $timings['blocked'] = -1;
                $timings['dns'] = (int) $r['dns_ms'];
                if (!$timings['dns']) {
                    $timings['dns'] = -1;
                }
                // HAR did not have an ssl time until version 1.2 .  For
                // backward compatibility, "connect" includes "ssl" time.
                // WepbageTest's internal representation does not assume any
                // overlap, so we must add our connect and ssl time to get the
                // connect time expected by HAR.
                $timings['connect'] = durationOfInterval($r['connect_ms']) + durationOfInterval($r['ssl_ms']);
                if (!$timings['connect']) {
                    $timings['connect'] = -1;
                }
                $timings['ssl'] = (int) $r['ssl_ms'];
                if (!$timings['ssl']) {
                    $timings['ssl'] = -1;
                }
                // TODO(skerner): WebpageTest's data model has no way to
                // represent the difference between the states HAR calls
                // send (time required to send HTTP request to the server)
                // and wait (time spent waiting for a response from the server).
                // We lump both into "wait".  Issue 24* tracks this work.  When
                // it is resolved, read the real values for send and wait
                // instead of using the request's TTFB.
                // *: http://code.google.com/p/webpagetest/issues/detail?id=24
                $timings['send'] = 0;
                $timings['wait'] = (int) $r['ttfb_ms'];
                $timings['receive'] = (int) $r['download_ms'];
                $entry['timings'] = $timings;
                // The HAR spec defines time as the sum of the times in the
                // timings object, excluding any unknown (-1) values and ssl
                // time (which is included in "connect", for backward
                // compatibility with tools written before "ssl" was defined
                // in HAR version 1.2).
                $entry['time'] = 0;
                foreach ($timings as $timingKey => $duration) {
                    if ($timingKey != 'ssl' && $duration != UNKNOWN_TIME) {
                        $entry['time'] += $duration;
                    }
                }
                if (array_key_exists('custom_rules', $r)) {
                    $entry['_custom_rules'] = $r['custom_rules'];
                }
                // dump all of our metrics into the har data as custom fields
                foreach ($r as $name => $value) {
                    if (!is_array($value)) {
                        $entry["_{$name}"] = $value;
                    }
                }
                // add it to the list of entries
                $entries[] = $entry;
            }
            // add the bodies to the requests
            if (isset($options['bodies']) && $options['bodies']) {
                $bodies_file = $testPath . '/' . $run . $cached_text . '_bodies.zip';
                if (is_file($bodies_file)) {
                    $zip = new ZipArchive();
                    if ($zip->open($bodies_file) === TRUE) {
                        for ($i = 0; $i < $zip->numFiles; $i++) {
                            $index = intval($zip->getNameIndex($i), 10) - 1;
                            if (array_key_exists($index, $entries)) {
                                $entries[$index]['response']['content']['text'] = utf8_encode($zip->getFromIndex($i));
                            }
                        }
                    }
                }
            }
        }
    }
    $result['log']['entries'] = $entries;
    return $result;
}
Пример #6
0
<?php

header("Content-type: image/png");
include 'common.inc';
include 'object_detail.inc';
include 'contentColors.inc';
include 'connectionView.inc';
include 'page_data.inc';
$pageData = loadPageRunData($testPath, $run, $cached);
$mime = $_GET['mime'];
// get all of the requests
$secure = false;
$haveLocations = false;
$requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false);
$mimeColors = requestColors($requests);
$summary = array();
$connections = getConnections($requests, $summary);
$options = array('id' => $id, 'path' => $testPath, 'run' => $run, 'cached' => $cached, 'cpu' => true, 'bw' => true);
$im = drawImage($connections, $summary, $url, $mime, $mimeColors, false, $pageData, $options);
// spit the image out to the browser
imagepng($im);
imagedestroy($im);
Пример #7
0
/**
* Dump information about all of the requests
*/
function xmlRequests($id, $testPath, $run, $cached)
{
    if (array_key_exists('requests', $_REQUEST) && $_REQUEST['requests']) {
        echo "<requests>\n";
        $secure = false;
        $haveLocations = false;
        $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true);
        foreach ($requests as &$request) {
            echo "<request number=\"{$request['number']}\">\n";
            foreach ($request as $field => $value) {
                if (!is_array($value)) {
                    echo "<{$field}>" . xml_entities($value) . "</{$field}>\n";
                }
            }
            if (array_key_exists('headers', $request) && is_array($request['headers'])) {
                echo "<headers>\n";
                if (array_key_exists('request', $request['headers']) && is_array($request['headers']['request'])) {
                    echo "<request>\n";
                    foreach ($request['headers']['request'] as $value) {
                        echo "<header>" . xml_entities($value) . "</header>\n";
                    }
                    echo "</request>\n";
                }
                if (array_key_exists('response', $request['headers']) && is_array($request['headers']['response'])) {
                    echo "<response>\n";
                    foreach ($request['headers']['response'] as $value) {
                        echo "<header>" . xml_entities($value) . "</header>\n";
                    }
                    echo "</response>\n";
                }
                echo "</headers>\n";
            }
            echo "</request>\n";
        }
        echo "</requests>\n";
    }
}
Пример #8
0
header("Content-disposition: attachment; filename={$id}_headersMatch.csv");
header("Content-type: text/csv");
// list of metrics that will be produced
// for each of these, the median, average and std dev. will be calculated
echo "\"Test ID\",\"Found\"\r\n";
// and now the actual data
foreach ($testIds as &$testId) {
    $cached = 0;
    RestoreTest($testId);
    GetTestStatus($testId);
    $testPath = './' . GetTestPath($testId);
    $pageData = loadAllPageData($testPath);
    $medianRun = GetMedianRun($pageData, $cached);
    $secured = 0;
    $haveLocations = 1;
    $requests = getRequests($testId, $testPath, $medianRun, $cached, $secure, $haveLocations, false, true);
    // Flag indicating if we matched
    $matched = array();
    $nSearches = count($searches);
    $nRecords = count($requests);
    if ($nRecords > $maxReqs && $maxReqs != 0) {
        $nRecords = $maxReqs;
    }
    for ($rec = 0; $rec < $nRecords; $rec++) {
        $r = $requests[$rec];
        if (isset($r['headers']) && isset($r['headers']['response'])) {
            foreach ($r['headers']['response'] as &$header) {
                // Loop through the search conditions we received
                for ($i = 0; $i < $nSearches; $i++) {
                    // Skip already matched items
                    if ($matched[$i]) {
/**
* Determine the target TTFB for the given test
*
* @param mixed $pageData
* @param mixed $test
* @param mixed $id
* @param mixed $run
*/
function getTargetTTFB(&$pageData, &$test, $id, $run, $cached)
{
    $target = NULL;
    $rtt = null;
    if (isset($test['testinfo']['latency'])) {
        $rtt = (int) $test['testinfo']['latency'];
    }
    // load the object data (unavoidable, we need the socket connect time to the first host)
    require_once 'object_detail.inc';
    $testPath = './' . GetTestPath($id);
    $secure = false;
    $haveLocations;
    $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false);
    if (count($requests)) {
        // figure out what the RTT is to the server (take the connect time from the first request unless it is over 3 seconds)
        $connect_ms = $requests[0]['connect_ms'];
        if (isset($rtt) && (!isset($connect_ms) || $connect_ms > 3000)) {
            $rtt += 100;
        } else {
            $rtt = $connect_ms;
        }
        if (isset($rtt)) {
            $ssl_ms = 0;
            if ($requests[0]['is_secure'] && (int) $requests[0]['ssl_ms'] > 0) {
                $ssl_ms = $requests[0]['ssl_ms'];
            }
            // RTT's: DNS + Socket Connect + HTTP Request
            $target = $rtt * 3 + $ssl_ms;
        }
    }
    return $target;
}
Пример #10
0
        }
    }
    if ($navTiming) {
        echo "<td{$borderClass}>";
        if ($data['firstPaint'] > 0) {
            echo number_format($data['firstPaint'] / 1000.0, 3) . 's</td><td>';
        }
        echo number_format($data['domContentLoadedEventStart'] / 1000.0, 3) . 's - ' . number_format($data['domContentLoadedEventEnd'] / 1000.0, 3) . 's (' . number_format(($data['domContentLoadedEventEnd'] - $data['domContentLoadedEventStart']) / 1000.0, 3) . 's)' . '</td>';
        echo '<td>' . number_format($data['loadEventStart'] / 1000.0, 3) . 's - ' . number_format($data['loadEventEnd'] / 1000.0, 3) . 's (' . number_format(($data['loadEventEnd'] - $data['loadEventStart']) / 1000.0, 3) . 's)' . '</td>';
    }
    echo '</tr>';
    echo '</table><br>';
}
$secure = false;
$haveLocations = false;
$requests = getRequests($id, $testPath, $run, @$_GET['cached'], $secure, $haveLocations, true, true);
?>
                <script type="text/javascript">
                  markUserTime('aft.Detail Table');
                </script>

                <div style="text-align:center;">
                <h3 name="waterfall_view">Waterfall View</h3>
                <table border="1" bordercolor="silver" cellpadding="2px" cellspacing="0" style="width:auto; font-size:11px; margin-left:auto; margin-right:auto;">
                    <tr>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#1f7c83"></div></td><td>DNS Lookup</td></tr></table></td>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#e58226"></div></td><td>Initial Connection</td></tr></table></td>
                        <?php 
if ($secure) {
    ?>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#c141cd"></div></td><td>SSL Negotiation</td></tr></table></td>
Пример #11
0
                }
            }
        }
    }
    writeUsers($users);
}
?>

<div class="wrapper">
	<div class="left"> 
		<h3>Pending Requests</h3>
		<?php 
if (!empty($message)) {
    echo "<p>{$message}</p>";
}
$requests = getRequests($_SESSION['username']);
if (empty($requests)) {
    echo "<p>You have no new friend requests at this time.</p>";
} else {
    echo "<table>";
    foreach ($requests as $request) {
        // loop through pending requests
        $requestImg = getUser($request)->pic;
        echo "<tr><td><img class=\"smallpic\" src=\"{$requestImg}\" alt=\"Photo of {$request}\"/></td>";
        echo "<td><label>{$request}</label></td>";
        ?>
				<td>
				<form method="post" action="requests.php">
					<input type="hidden" name="decision" value="accept" />
					<input type="hidden" name="uname" value=<?php 
        echo '"' . $request . '"';
Пример #12
0
/**
* Draw the checklist image
* 
* @param resource $img
*/
function tbnDrawChecklist(&$img)
{
    global $id;
    global $testPath;
    global $run;
    global $cached;
    global $url;
    include 'optimizationChecklist.inc';
    $is_secure = false;
    $has_locations = false;
    $requests = getRequests($id, $testPath, $run, $cached, $is_secure, $has_locations, false);
    $page_data = loadPageRunData($testPath, $run, $cached);
    $img = drawChecklist($url, $requests, $page_data);
    if (!$requests || !$page_data) {
        $failed = true;
    }
}
Пример #13
0
/**
* Build a side-by-side table with the captured frames from each test
* 
*/
function ScreenShotTable()
{
    global $tests;
    global $thumbSize;
    global $interval;
    global $maxCompare;
    if (count($tests)) {
        // figure out how many columns there are
        $end = 0;
        foreach ($tests as &$test) {
            if ($test['video']['end'] > $end) {
                $end = $test['video']['end'];
            }
        }
        echo '<br/><form id="createForm" name="create" method="get" action="/video/create.php" onsubmit="return ValidateInput(this)"><table id="videoContainer"><tr>';
        // build a table with the labels
        echo '<td id="labelContainer"><table id="videoLabels"><tr><th>&nbsp;</th></tr>';
        foreach ($tests as &$test) {
            // figure out the height of this video
            $height = 100;
            if ($test['video']['width'] && $test['video']['height']) {
                $height = 10 + (int) ((double) $thumbSize / (double) $test['video']['width'] * (double) $test['video']['height']);
            }
            $break = '';
            if (!strpos($test['name'], ' ')) {
                $break = ' style="word-break: break-all;"';
            }
            echo "<tr width=10% height={$height}px ><td{$break}>";
            $name = urlencode($test['name']);
            $cached = 0;
            if ($test['cached']) {
                $cached = 1;
            }
            echo "<input type=\"checkbox\" name=\"t[]\" value=\"{$test['id']},{$test['run']}," . $name . ",{$cached}\" checked=checked> ";
            $cached = '';
            if ($test['cached']) {
                $cached = 'cached/';
            }
            echo "<a class=\"pagelink\" href=\"/result/{$test['id']}/{$test['run']}/details/{$cached}\" target=\"_blank\">";
            echo WrapableString($test['name']);
            echo "</a></td></tr>\n";
        }
        echo '</table></td>';
        // the actual video frames
        echo '<td><div id="videoDiv"><table id="video"><thead><tr>';
        $skipped = $interval;
        $last = $end + $interval - 1;
        for ($frame = 0; $frame <= $last; $frame++) {
            $skipped++;
            if ($skipped >= $interval) {
                $skipped = 0;
                echo '<th>' . number_format((double) $frame / 10.0, 1) . 's</th>';
            }
        }
        echo "</tr></thead><tbody>\n";
        $firstFrame = 0;
        foreach ($tests as &$test) {
            // figure out the height of the image
            $height = 0;
            if ($test['video']['width'] && $test['video']['height']) {
                $height = (int) ((double) $thumbSize / (double) $test['video']['width'] * (double) $test['video']['height']);
            }
            echo "<tr>";
            $lastThumb = null;
            $frameCount = 0;
            $skipped = $interval;
            $last = $end + $interval - 1;
            for ($frame = 0; $frame <= $last; $frame++) {
                $path = $test['video']['frames'][$frame];
                if (isset($path)) {
                    $test['currentframe'] = $frame;
                } else {
                    if (isset($test['currentframe'])) {
                        $path = $test['video']['frames'][$test['currentframe']];
                    } else {
                        $path = $test['video']['frames'][0];
                    }
                }
                if (!$lastThumb) {
                    $lastThumb = $path;
                }
                $skipped++;
                if ($skipped >= $interval) {
                    $skipped = 0;
                    echo '<td>';
                    if ($frame - $interval + 1 <= $test['video']['end']) {
                        echo '';
                        $cached = '';
                        if ($test['cached']) {
                            $cached = '_cached';
                        }
                        $imgPath = GetTestPath($test['id']) . "/video_{$test['run']}{$cached}/{$path}";
                        echo "<a href=\"/{$imgPath}\">";
                        echo "<img title=\"{$test['name']}\"";
                        $class = 'thumb';
                        if ($lastThumb != $path) {
                            if (!$firstFrame || $frameCount < $firstFrame) {
                                $firstFrame = $frameCount;
                            }
                            $class = 'thumbChanged';
                        }
                        echo " class=\"{$class}\"";
                        echo " width=\"{$thumbSize}\"";
                        if ($height) {
                            echo " height=\"{$height}\"";
                        }
                        echo " src=\"/thumbnail.php?test={$test['id']}&width={$thumbSize}&file=video_{$test['run']}{$cached}/{$path}\"></a>";
                        $lastThumb = $path;
                    }
                    $frameCount++;
                    echo '</td>';
                }
            }
            echo "</tr>\n";
        }
        echo "</tr>\n";
        // end of the table
        echo "</tbody></table></div>\n";
        // end of the container table
        echo "</td></tr></table>\n";
        echo "<div id=\"image\">";
        $ival = $interval * 100;
        echo "<a class=\"pagelink\" href=\"filmstrip.php?tests={$_REQUEST['tests']}&thumbSize={$thumbSize}&ival={$ival}\">Export filmstrip as an image...</a>";
        echo "</div>";
        echo '<div id="bottom"><input type="checkbox" name="slow" value="1"> Slow Motion<br/><br/>';
        echo "Select up to {$maxCompare} tests and <input id=\"SubmitBtn\" type=\"submit\" value=\"Create Video\"></div>";
        echo "</form>";
        ?>
        <div id="layout">
            <form id="layoutForm" name="layout" method="get" action="/video/compare.php">
            <?php 
        echo "<input type=\"hidden\" name=\"tests\" value=\"{$_REQUEST['tests']}\" />\n";
        ?>
                <table id="layoutTable">
                    <tr><th>Thumbnail Size</th><th>Thumbnail Interval</th></tr>
                    <?php 
        // fill in the thumbnail size selection
        echo "<tr><td>";
        $checked = '';
        if ($thumbSize <= 100) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"thumbSize\" value=\"100\"{$checked} onclick=\"this.form.submit();\"> Small<br>";
        $checked = '';
        if ($thumbSize <= 150 && $thumbSize > 100) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"thumbSize\" value=\"150\"{$checked} onclick=\"this.form.submit();\"> Medium<br>";
        $checked = '';
        if ($thumbSize > 150) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"thumbSize\" value=\"200\"{$checked} onclick=\"this.form.submit();\"> Large";
        echo "</td>";
        // fill in the interval selection
        echo "<td>";
        $checked = '';
        if ($interval <= 1) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"ival\" value=\"100\"{$checked} onclick=\"this.form.submit();\"> 0.1 sec<br>";
        $checked = '';
        if ($interval == 5) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"ival\" value=\"500\"{$checked} onclick=\"this.form.submit();\"> 0.5 sec<br>";
        $checked = '';
        if ($interval == 10) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"ival\" value=\"1000\"{$checked} onclick=\"this.form.submit();\"> 1 sec<br>";
        $checked = '';
        if ($interval == 50) {
            $checked = ' checked=checked';
        }
        echo "<input type=\"radio\" name=\"ival\" value=\"5000\"{$checked} onclick=\"this.form.submit();\"> 5 sec<br>";
        echo "</td></tr>";
        ?>
                </table>
            </form>
        </div>
        <?php 
        // scroll the table to show the first thumbnail change
        $scrollPos = $firstFrame * ($thumbSize + 8);
        ?>
        <script language="javascript">
            var scrollPos = <?php 
        echo "{$scrollPos};";
        ?>
            document.getElementById("videoDiv").scrollLeft = scrollPos;
        </script>
        <?php 
        // display the waterfall if there is only one test
        if (count($tests) == 1) {
            ?>
        <div id="waterfall">
            <map name="waterfall_map">
            <?php 
            $data = loadPageRunData($tests[0]['path'], $tests[0]['run'], $tests[0]['cached']);
            $secure = false;
            $haveLocations = false;
            $requests = getRequests($tests[0]['id'], $tests[0]['path'], $tests[0]['run'], $tests[0]['cached'], $secure, $haveLocations, false);
            $options = array('id' => $tests[0]['id'], 'path' => $tests[0]['path'], 'run' => $tests[0]['run'], 'cached' => $tests[0]['cached'], 'cpu' => false);
            $map = drawWaterfall($tests[0]['url'], $requests, $data, true, $options);
            foreach ($map as $entry) {
                if ($entry['request'] !== NULL) {
                    $index = $entry['request'] + 1;
                    $title = $index . ': ' . $entry['url'];
                    echo '<area alt="' . $title . '" title="' . $title . '" shape=RECT coords="' . $entry['left'] . ',' . $entry['top'] . ',' . $entry['right'] . ',' . $entry['bottom'] . '">' . "\n";
                } else {
                    echo '<area alt="' . $entry['url'] . '" title="' . $entry['url'] . '" shape=RECT coords="' . $entry['left'] . ',' . $entry['top'] . ',' . $entry['right'] . ',' . $entry['bottom'] . '">' . "\n";
                }
            }
            ?>
            </map>
            
            <?php 
            echo "<img id=\"waterfallImage\" usemap=\"#waterfall_map\" border=\"0\" alt=\"Waterfall\" src=\"/waterfall.php?test={$tests[0]['id']}&run={$tests[0]['run']}&cached={$tests[0]['cached']}&cpu=0&bw=0\">";
            ?>
        </div>
        <?php 
        }
        echo '<br/><br/>';
    }
}
Пример #14
0
\t\t\t\t<th>Departure
\t\t\t\t<th>Arrival
\t\t\t\t<th>Departure date
\t\t\t\t<th>Requests<br><small>pending/accepted</small>
\t\t\t\t<td>
\t\t\t</tr>
\t\t</thead>
\t\t<tbody>
EOF;
$i = 0;
foreach ($travel_plans->find(array("user" => $_SESSION['user']))->sort(array("date" => 1)) as $k => $v) {
    $i++;
    $v['date'] = convertDate($v['date'], false);
    $accepted = 0;
    $pending = 0;
    $list = getRequests(array("travel" => "" . $v['_id']));
    foreach ($list as $_k => $_v) {
        if ($_v['status'] == 0) {
            $pending++;
        } else {
            if ($_v['status'] == 1) {
                $accepted++;
            }
        }
    }
    $HTML[] = <<<EOF
\t\t<tr>
\t\t\t<td>{$i}
\t\t\t\t<a href="?travel_plan/edit/{$v['_id']}"><span class="glyphicon glyphicon-edit"></span></a>
\t\t\t<td><a href="?travel_plan/view/{$v['_id']}">{$v['from']}</a> 
\t\t\t\t&nbsp;&nbsp;
Пример #15
0
/**
* Build the data set
* 
* @param mixed $pageData
*/
function BuildResult(&$pageData)
{
    global $id;
    global $testPath;
    $result = array();
    $entries = array();
    $result['log'] = array();
    $result['log']['version'] = '1.1';
    $result['log']['creator'] = array('name' => 'WebPagetest', 'version' => '1.8');
    $result['log']['browser'] = array('name' => 'Internet Explorer', 'version' => '');
    $result['log']['pages'] = array();
    foreach ($pageData as $run => &$pageRun) {
        foreach ($pageRun as $cached => &$data) {
            $pd = array();
            $pd['startedDateTime'] = msdate($data['date']);
            $pd['title'] = "Run {$run}, ";
            if ($cached) {
                $pd['title'] .= "Repeat View";
            } else {
                $pd['title'] .= "First View";
            }
            $pd['title'] .= " for " . $data['URL'];
            $pd['id'] = "page_{$run}_{$cached}";
            $pd['pageTimings'] = array('onLoad' => $data['docTime'], 'onContentLoad' => -1);
            // add the page-level ldata to the result
            $result['log']['pages'][] = $pd;
            // now add the object-level data to the result
            $secure = false;
            $haveLocations = false;
            $requests = getRequests($id, $testPath, $run, $cached, $secure, $haveLocations, false, true);
            foreach ($requests as &$r) {
                $entry = array();
                $entry['pageref'] = $pd['id'];
                $entry['startedDateTime'] = msdate((double) $data['date'] + $r['offset'] / 1000.0);
                $entry['time'] = $r['totalTime'];
                $request = array();
                $request['method'] = $r['method'];
                $protocol = 'http://';
                if ($r['secure']) {
                    $protocol = 'https://';
                }
                $request['url'] = $protocol . $r['host'] . $r['url'];
                $request['headersSize'] = -1;
                $request['bodySize'] = -1;
                $request['cookies'] = array();
                $request['headers'] = array();
                $ver = '';
                if (isset($r['headers']) && isset($r['headers']['request'])) {
                    foreach ($r['headers']['request'] as &$header) {
                        $pos = strpos($header, ':');
                        if ($pos > 0) {
                            $name = trim(substr($header, 0, $pos));
                            $val = trim(substr($header, $pos + 1));
                            if (strlen($name)) {
                                $request['headers'][] = array('name' => $name, 'value' => $val);
                            }
                            // parse out any cookies
                            if (!strcasecmp($name, 'cookie')) {
                                $cookies = explode(';', $val);
                                foreach ($cookies as &$cookie) {
                                    $pos = strpos($cookie, '=');
                                    if ($pos > 0) {
                                        $name = (string) trim(substr($cookie, 0, $pos));
                                        $val = (string) trim(substr($cookie, $pos + 1));
                                        if (strlen($name)) {
                                            $request['cookies'][] = array('name' => $name, 'value' => $val);
                                        }
                                    }
                                }
                            }
                        } else {
                            $pos = strpos($header, 'HTTP/');
                            if ($pos >= 0) {
                                $ver = (string) trim(substr($header, $pos + 5, 3));
                            }
                        }
                    }
                }
                $request['httpVersion'] = $ver;
                $request['queryString'] = array();
                $parts = parse_url($request['url']);
                if (isset($parts['query'])) {
                    $qs = array();
                    parse_str($parts['query'], $qs);
                    foreach ($qs as $name => $val) {
                        $request['queryString'][] = array('name' => (string) $name, 'value' => (string) $val);
                    }
                }
                if (!strcasecmp(trim($request['method']), 'post')) {
                    $request['postData'] = array();
                    $request['postData']['mimeType'] = '';
                    $request['postData']['text'] = '';
                }
                $entry['request'] = $request;
                $response = array();
                $response['status'] = (int) $r['responseCode'];
                $response['statusText'] = '';
                $response['headersSize'] = -1;
                $response['bodySize'] = (int) $r['objectSize'];
                $response['headers'] = array();
                $ver = '';
                $loc = '';
                if (isset($r['headers']) && isset($r['headers']['response'])) {
                    foreach ($r['headers']['response'] as &$header) {
                        $pos = strpos($header, ':');
                        if ($pos > 0) {
                            $name = (string) trim(substr($header, 0, $pos));
                            $val = (string) trim(substr($header, $pos + 1));
                            if (strlen($name)) {
                                $response['headers'][] = array('name' => $name, 'value' => $val);
                            }
                            if (!strcasecmp($name, 'location')) {
                                $loc = (string) $val;
                            }
                        } else {
                            $pos = strpos($header, 'HTTP/');
                            if ($pos >= 0) {
                                $ver = (string) trim(substr($header, $pos + 5, 3));
                            }
                        }
                    }
                }
                $response['httpVersion'] = $ver;
                $response['redirectURL'] = $loc;
                $response['content'] = array();
                $response['content']['size'] = (int) $r['objectSize'];
                if (isset($r['contentType']) && strlen($r['contentType'])) {
                    $response['content']['mimeType'] = (string) $r['contentType'];
                } else {
                    $response['content']['mimeType'] = '';
                }
                // unsupported fields that are required
                $response['cookies'] = array();
                $entry['response'] = $response;
                $entry['cache'] = (object) array();
                $timings = array();
                $timings['blocked'] = -1;
                $timings['dns'] = (int) $r['dnsTime'];
                if (!$timings['dns']) {
                    $timings['dns'] = -1;
                }
                $timings['connect'] = (int) ($r['socketTime'] + $r['sslTime']);
                if (!$timings['connect']) {
                    $timings['connect'] = -1;
                }
                $timings['send'] = 0;
                $timings['wait'] = (int) $r['ttfb'];
                if ($r['loadTime'] && $r['ttfb']) {
                    $timings['receive'] = $r['loadTime'] - $r['ttfb'];
                } else {
                    $timings['receive'] = 0;
                }
                $entry['timings'] = $timings;
                $entry['time'] = (int) ($r['dnsTime'] + $r['socketTime'] + $r['sslTime'] + $r['ttfb'] + $timings['receive']);
                // add it to the list of entries
                $entries[] = $entry;
            }
        }
    }
    $result['log']['entries'] = $entries;
    return $result;
}
Пример #16
0
/**
 * Resets the recent requests counter (for example, after the required time
 * has ellapsed, or after the user has successfully logged in).
 *
 * @param $decrement If true, the count will be decremented instead of cleared
 * @return A copy of the requests array
 */
function &resetRequests($decrement = false)
{
    $requests = getRequests();
    if ($decrement) {
        $requests['count'] = max($requests['count'] - 1, 0);
    } else {
        $requests['count'] = 0;
    }
    return $requests;
}
Пример #17
0
?>
	<?php 
if ($_SESSION["username"] != "guest") {
    $logged_in = true;
    $admin = getUser($_SESSION["username"])->admin;
}
?>
	<?php 
if ($logged_in) {
    ?>
	<a href="profile.php?uname=<?php 
    echo $_SESSION["username"];
    ?>
"><span class="navitem">Profile</span></a>
	<a href="requests.php"><span class="navitem">Requests<?php 
    echo "(" . count(getRequests($_SESSION['username'])) . ")";
    ?>
</span></a>
	<!-- TODO only show admin tab if logged in user has admin rights -->
	<?php 
    if ($admin == "1") {
        ?>
	<a href="admin.php"><span class="navitem">Admin<?php 
        echo "(" . countUsersToBeApproved() . ")";
        ?>
</span></a> 
	<?php 
    }
}
?>
	<?php 
Пример #18
0
    $out = "";
    $out = $out . '<?xml version="1.0" encoding="UTF-8"?>';
    $out = $out . '<messages version="1.0"';
    if (isset($sessionid)) {
        $out = $out . ' sessionid="' . $sessionid;
    }
    $out = $out . '>';
    foreach ($responses as $r) {
        $out = $out . '<message requestid="1"' . ' direction="OUTGOING" datatype="JSON" type="' . $r['type'] . '" scope="' . $r['scope'] . '"><![CDATA[' . $json->encode($r['data']) . ']]></message>';
    }
    $out = $out . '</messages>';
    return $out;
}
$responses = array();
$requests = array();
$requests = getRequests($content_type, $post);
foreach ($requests as $request) {
    // no handlers registered for this request type
    if (array_key_exists($request['type'], $services) === FALSE) {
        continue;
    }
    foreach ($services[$request['type']] as $handler) {
        // handler doesn't apply to this version
        if ($handler->getVersion() != $request['version']) {
            continue;
        }
        if (is_null($handler->getResponseType())) {
            $response = array();
            // empty response type means
        } else {
            $response = array();
<?php

include "util.php";
include "../db/smssndbconn.php";
include "menu.php";
add_menu("../");
$con = dbopen();
$array = getRequests();
$groupid = "";
for ($i = 0; $i < count($array); $i++) {
    if (false == strpos($array[$i], "=")) {
        continue;
    }
    list($name, $value) = explode("=", $array[$i]);
    if ($name == "id") {
        $groupid = urldecode($value);
    }
}
$sql = "SELECT id, name FROM bpgroups";
if ($groupid != 0) {
    $sql .= " where id=" . $groupid;
}
if (!($result = mysqli_query($con, $sql))) {
    echo "Error description: " . mysqli_error($con);
}
$num = mysqli_num_rows($result);
if ($num == 0) {
    ?>
		
		<center>
			Group <?php 
Пример #20
0
\t\t\t\t<th>Name
\t\t\t\t<th>Travels
\t\t\t\t<th>Requests
\t\t\t\t<th>Grade
\t\t\t\t<th>Referrals
\t\t\t\t<th>Joined
\t\t\t\t<th>Last online
\t\t\t</tr>
\t\t</thead>
\t\t<tbody>
EOF;
$i = 0;
foreach ($users->find()->sort(array("last" => -1)) as $k => $v) {
    $i++;
    $v['travels'] = getCount(getTravels(array("user" => $v['facebookid'])));
    $v['requests'] = getCount(getRequests(array("user" => $v['facebookid'])));
    $v['grade'] = 4.6;
    $v['referrals'] = 26;
    $v['joined'] = @convertDateTime($v['date'], false);
    $v['online'] = relativeTime($v['last']);
    $HTML[] = @<<<EOF
\t\t<tr>
\t\t\t<td>{$i}
\t\t\t<td><a href="?users/view/{$v['facebookid']}">{$v['first']}</a> 
\t\t\t<td>{$v['travels']}
\t\t\t<td>{$v['requests']}
\t\t\t<td>{$v['grade']}
\t\t\t<td>{$v['referrals']}
\t\t\t<td>{$v['joined']}
\t\t\t<td>{$v['online']}
\t\t</tr>
Пример #21
0
include 'common.inc';
require_once 'object_detail.inc';
require_once 'page_data.inc';
require_once 'waterfall.inc';
$page_data = loadPageRunData($testPath, $run, $cached, $requests);
$is_mime = (bool) @$_REQUEST['mime'];
$is_state = (bool) @$_REQUEST['state'];
$use_dots = !isset($_REQUEST['dots']) || $_REQUEST['dots'] != 0;
$show_labels = !isset($_REQUEST['labels']) || $_REQUEST['labels'] != 0;
$rowcount = array_key_exists('rowcount', $_REQUEST) ? $_REQUEST['rowcount'] : 0;
// Get all of the requests;
$is_secure = false;
$has_locations = false;
$use_location_check = false;
if (!isset($requests)) {
    $requests = getRequests($id, $testPath, $run, $cached, $is_secure, $has_locations, $use_location_check);
} else {
    // not multisteps enabled
    $requests = $requests[$run][$cached];
    fixRequests($requests, $id, $testPath, $run, $cached, $is_secure, $has_locations, $use_location_check);
}
if (@$_REQUEST['type'] == 'connection') {
    $is_state = true;
    $rows = GetConnectionRows($requests, $show_labels);
} else {
    $rows = GetRequestRows($requests, $use_dots, $show_labels);
}
$page_events = GetPageEvents($page_data);
$bwIn = 0;
if (isset($test) && array_key_exists('testinfo', $test) && array_key_exists('bwIn', $test['testinfo'])) {
    $bwIn = $test['testinfo']['bwIn'];
Пример #22
0
function isPending($requestor, $requestee)
{
    $pend = getRequests($requestee);
    return in_array($requestor, $pend);
}
Пример #23
0
if ((double) $data['domTime'] > 0.0) {
    echo "<td id=\"domTime\" valign=\"middle\">" . number_format($data['domTime'] / 1000.0, 3) . "s</td>\n";
}
echo "<td id=\"docComplete\" valign=\"middle\">" . number_format($data['docTime'] / 1000.0, 3) . "s</td>\n";
echo "<td id=\"fullyLoaded\" valign=\"middle\">" . number_format($data['fullyLoaded'] / 1000.0, 3) . "s</td>\n";
echo "<td id=\"requests\" valign=\"middle\">{$data['requests']}</td>\n";
echo "<td id=\"bytesIn\" valign=\"middle\">" . number_format($data['bytesIn'] / 1024, 0) . " KB</td>\n";
echo "<td id=\"result\" valign=\"middle\">{$data['result']}</td>\n";
?>
                    </tr>
                </table>
                <br>
                <?php 
$secure = false;
$haveLocations = false;
$requests = getRequests($id, $testPath, $run, $_GET["cached"], $secure, $haveLocations, true);
?>
                <div style="text-align:center;">
                <h3 name="waterfall_view">Waterfall View</h3>
                <table border="1" cellpadding="2px" cellspacing="0" style="width:auto; font-size:70%; margin-left:auto; margin-right:auto;">
                    <tr>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#007B84"></div></td><td>DNS Lookup</td></tr></table></td>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#FF7B00"></div></td><td>Initial Connection</td></tr></table></td>
                        <?php 
if ($secure) {
    ?>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#CF25DF"></div></td><td>SSL Negotiation</td></tr></table></td>
                        <?php 
}
?>
                        <td><table><tr><td><div class="bar" style="width:15px; background-color:#00FF00"></div></td><td>Time to First Byte</td></tr></table></td>
Пример #24
0
    case 'Rejected':
        $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Rejected'";
        getRequests("Rejected", $query);
        break;
    case 'nonConflicts':
        $nonConflicts = "(" . arrayToCSV(checkNonConflicts()) . ")";
        $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where reqNo in " . $nonConflicts . "";
        getRequests("nonConflicts", $query);
        break;
    case 'Cancelled':
        $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Cancelled'";
        getRequests("Cancelled", $query);
        break;
    case 'Accepted':
        $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Accepted'";
        getRequests("Accepted", $query);
        break;
    case 'Conflicts':
        clashMux(checkConflicts());
        if (isset($_GET['st'])) {
            $mstart = $_GET['st'];
        } else {
            $mstart = 0;
        }
}
?>
</table>

<form method='POST' action='cancelReq.php' id='cancelForm'>
	<table>
		<tr>
Пример #25
0
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);
                    }
                }
            }
        }
    }
}
Пример #26
0
/**
* 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);
    }
}
Пример #27
0
/**
* Build a side-by-side table with the captured frames from each test
*
*/
function ScreenShotTable()
{
    global $tests;
    global $thumbSize;
    global $interval;
    global $maxCompare;
    global $color;
    global $bgcolor;
    global $supports60fps;
    $endTime = 'visual';
    if (array_key_exists('end', $_REQUEST) && strlen($_REQUEST['end'])) {
        $endTime = trim($_REQUEST['end']);
    }
    $filmstrip_end_time = 0;
    if (count($tests)) {
        // figure out how many columns there are
        $end = 0;
        foreach ($tests as &$test) {
            if ($test['video']['end'] > $end) {
                $end = $test['video']['end'];
            }
        }
        if (!defined('EMBED')) {
            echo '<br>';
        }
        echo '<form id="createForm" name="create" method="get" action="/video/create.php">';
        echo "<input type=\"hidden\" name=\"end\" value=\"{$endTime}\">";
        echo '<input type="hidden" name="tests" value="' . htmlspecialchars($_REQUEST['tests']) . '">';
        echo "<input type=\"hidden\" name=\"bg\" value=\"{$bgcolor}\">";
        echo "<input type=\"hidden\" name=\"text\" value=\"{$color}\">";
        if (isset($_REQUEST['labelHeight']) && is_numeric($_REQUEST['labelHeight'])) {
            echo '<input type="hidden" name="labelHeight" value="' . htmlspecialchars($_REQUEST['labelHeight']) . '">"';
        }
        if (isset($_REQUEST['timeHeight']) && is_numeric($_REQUEST['timeHeight'])) {
            echo '<input type="hidden" name="timeHeight" value="' . htmlspecialchars($_REQUEST['timeHeight']) . '">"';
        }
        echo '<table id="videoContainer"><tr>';
        // build a table with the labels
        echo '<td id="labelContainer"><table id="videoLabels"><tr><th>&nbsp;</th></tr>';
        foreach ($tests as &$test) {
            // figure out the height of this video
            $height = 100;
            if ($test['video']['width'] && $test['video']['height']) {
                if ($test['video']['width'] > $test['video']['height']) {
                    $height = 22 + (int) ((double) $thumbSize / (double) $test['video']['width'] * (double) $test['video']['height']);
                } else {
                    $height = 22 + $thumbSize;
                }
            }
            $break = '';
            if (!strpos($test['name'], ' ')) {
                $break = ' style="word-break: break-all;"';
            }
            echo "<tr width=10% height={$height}px ><td{$break} class=\"pagelinks\">";
            $name = urlencode($test['name']);
            $cached = 0;
            if ($test['cached']) {
                $cached = 1;
            }
            // Print the index outside of the link tag
            echo $test['index'] . ': ';
            if (!defined('EMBED')) {
                $cached = '';
                if ($test['cached']) {
                    $cached = 'cached/';
                }
                if (FRIENDLY_URLS) {
                    $href = "/result/{$test['id']}/{$test['run']}/details/{$cached}";
                } else {
                    $href = "/details.php?test={$test['id']}&run={$test['run']}&cached={$test['cached']}";
                }
                echo "<a class=\"pagelink\" id=\"label_{$test['id']}\" href=\"{$href}\">" . WrapableString(htmlspecialchars($test['name'])) . '</a>';
            } else {
                echo WrapableString(htmlspecialchars($test['name']));
            }
            // Print out a link to edit the test
            echo '<br/>';
            echo '<a href="#" class="editLabel" data-test-guid="' . $test['id'] . '" data-current-label="' . htmlentities($test['name']) . '">';
            if (class_exists("SQLite3")) {
                echo '(Edit)';
            }
            echo '</a>';
            echo "</td></tr>\n";
        }
        echo '</table></td>';
        // the actual video frames
        echo '<td><div id="videoDiv"><table id="video"><thead><tr>';
        $filmstrip_end_time = ceil($end / $interval) * $interval;
        $decimals = $interval >= 100 ? 1 : 3;
        $frameCount = 0;
        $ms = 0;
        while ($ms < $filmstrip_end_time) {
            $ms = $frameCount * $interval;
            echo '<th>' . number_format((double) $ms / 1000.0, $decimals) . 's</th>';
            $frameCount++;
        }
        echo "</tr></thead><tbody>\n";
        $firstFrame = 0;
        $maxThumbWidth = 0;
        foreach ($tests as &$test) {
            $aft = (int) $test['aft'] / 100;
            // figure out the height of the image
            $height = 0;
            $width = $thumbSize;
            if ($test['video']['width'] && $test['video']['height']) {
                if ($test['video']['width'] > $test['video']['height']) {
                    $width = $thumbSize;
                    $height = (int) ((double) $thumbSize / (double) $test['video']['width'] * (double) $test['video']['height']);
                } else {
                    $height = $thumbSize;
                    $width = (int) ((double) $thumbSize / (double) $test['video']['height'] * (double) $test['video']['width']);
                }
            }
            $maxThumbWidth = max($maxThumbWidth, $width);
            echo "<tr>";
            $testEnd = ceil($test['video']['end'] / $interval) * $interval;
            $lastThumb = null;
            $frameCount = 0;
            $progress = null;
            $ms = 0;
            while ($ms < $filmstrip_end_time) {
                $ms = $frameCount * $interval;
                // find the closest video frame <= the target time
                $frame_ms = null;
                foreach ($test['video']['frames'] as $frameTime => $file) {
                    if ($frameTime <= $ms && (!isset($frame_ms) || $frameTime > $frame_ms)) {
                        $frame_ms = $frameTime;
                    }
                }
                $path = null;
                if (isset($frame_ms)) {
                    $path = $test['video']['frames'][$frame_ms];
                }
                if (array_key_exists('frame_progress', $test['video']) && array_key_exists($frame_ms, $test['video']['frame_progress'])) {
                    $progress = $test['video']['frame_progress'][$frame_ms];
                }
                if (!isset($lastThumb)) {
                    $lastThumb = $path;
                }
                echo '<td>';
                if ($ms <= $testEnd) {
                    $cached = '';
                    if ($test['cached']) {
                        $cached = '_cached';
                    }
                    $imgPath = GetTestPath($test['id']) . "/video_{$test['run']}{$cached}/{$path}";
                    echo "<a href=\"/{$imgPath}\">";
                    echo "<img title=\"" . htmlspecialchars($test['name']) . "\"";
                    $class = 'thumb';
                    if ($lastThumb != $path) {
                        if (!$firstFrame || $frameCount < $firstFrame) {
                            $firstFrame = $frameCount;
                        }
                        $class = 'thumbChanged';
                    }
                    echo " class=\"{$class}\"";
                    echo " width=\"{$width}\"";
                    if ($height) {
                        echo " height=\"{$height}\"";
                    }
                    echo " src=\"/thumbnail.php?test={$test['id']}&fit={$thumbSize}&file=video_{$test['run']}{$cached}/{$path}\"></a>";
                    if (isset($progress)) {
                        echo "<br>{$progress}%";
                    }
                    $lastThumb = $path;
                }
                $frameCount++;
                echo '</td>';
            }
            echo "</tr>\n";
        }
        echo "</tr>\n";
        // end of the table
        echo "</tbody></table></div>\n";
        // end of the container table
        echo "</td></tr></table>\n";
        echo "<div id=\"image\">";
        echo "<a id=\"export\" class=\"pagelink\" href=\"filmstrip.php?tests={$_REQUEST['tests']}&thumbSize={$thumbSize}&ival={$interval}&end={$endTime}&text={$color}&bg={$bgcolor}\">Export filmstrip as an image...</a>";
        echo "</div>";
        echo '<div id="bottom"><input type="checkbox" name="slow" value="1"> Slow Motion<br><br>';
        echo "<input id=\"SubmitBtn\" type=\"submit\" value=\"Create Video\">";
        echo '<br><br><a class="pagelink" href="javascript:ShowAdvanced()">Advanced customization options...</a>';
        echo "</div></form>";
        if (!defined('EMBED')) {
            ?>
        <div id="layout">
            <form id="layoutForm" name="layout" method="get" action="/video/compare.php">
            <?php 
            echo "<input type=\"hidden\" name=\"tests\" value=\"{$_REQUEST['tests']}\">\n";
            ?>
                <table id="layoutTable">
                    <tr><th>Thumbnail Size</th><th>Thumbnail Interval</th><th>Comparison End Point</th></th></tr>
                    <?php 
            // fill in the thumbnail size selection
            echo "<tr><td>";
            $checked = '';
            if ($thumbSize <= 100) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"thumbSize\" value=\"100\"{$checked} onclick=\"this.form.submit();\"> Small<br>";
            $checked = '';
            if ($thumbSize <= 150 && $thumbSize > 100) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"thumbSize\" value=\"150\"{$checked} onclick=\"this.form.submit();\"> Medium<br>";
            $checked = '';
            if ($thumbSize > 150) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"thumbSize\" value=\"200\"{$checked} onclick=\"this.form.submit();\"> Large";
            echo "</td>";
            // fill in the interval selection
            echo "<td>";
            if ($supports60fps) {
                $checked = '';
                if ($interval < 100) {
                    $checked = ' checked=checked';
                }
                echo "<input type=\"radio\" name=\"ival\" value=\"16.67\"{$checked} onclick=\"this.form.submit();\"> 60 FPS<br>";
            }
            $checked = '';
            if ($supports60fps && $interval == 100 || !$supports60fps && $interval < 500) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"ival\" value=\"100\"{$checked} onclick=\"this.form.submit();\"> 0.1 sec<br>";
            $checked = '';
            if ($interval == 500) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"ival\" value=\"500\"{$checked} onclick=\"this.form.submit();\"> 0.5 sec<br>";
            $checked = '';
            if ($interval == 1000) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"ival\" value=\"1000\"{$checked} onclick=\"this.form.submit();\"> 1 sec<br>";
            $checked = '';
            if ($interval > 1000) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"ival\" value=\"5000\"{$checked} onclick=\"this.form.submit();\"> 5 sec<br>";
            echo "</td>";
            // fill in the end-point selection
            echo "<td>";
            if (!strcasecmp($endTime, 'aft')) {
                $endTime = 'visual';
            }
            $checked = '';
            if (!strcasecmp($endTime, 'visual')) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"end\" value=\"visual\"{$checked} onclick=\"this.form.submit();\"> Visually Complete<br>";
            $checked = '';
            if (!strcasecmp($endTime, 'all')) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"end\" value=\"all\"{$checked} onclick=\"this.form.submit();\"> Last Change<br>";
            $checked = '';
            if (!strcasecmp($endTime, 'doc')) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"end\" value=\"doc\"{$checked} onclick=\"this.form.submit();\"> Document Complete<br>";
            $checked = '';
            if (!strcasecmp($endTime, 'full')) {
                $checked = ' checked=checked';
            }
            echo "<input type=\"radio\" name=\"end\" value=\"full\"{$checked} onclick=\"this.form.submit();\"> Fully Loaded<br>";
            echo "</td></tr>";
            ?>
                </table>
            </form>
        </div>
        <?php 
            // display the waterfall if there is only one test
            $end_seconds = $filmstrip_end_time / 1000;
            if (count($tests) == 1) {
                $data = loadPageRunData($tests[0]['path'], $tests[0]['run'], $tests[0]['cached']);
                $secure = false;
                $haveLocations = false;
                $requests = getRequests($tests[0]['id'], $tests[0]['path'], $tests[0]['run'], $tests[0]['cached'], $secure, $haveLocations, true, true);
                InsertWaterfall('', $requests, $tests[0]['id'], $tests[0]['run'], $tests[0]['cached'], $data, "&max={$end_seconds}&mime=1&state=1&cpu=1&bw=1");
                echo '<br><br>';
            } else {
                $waterfalls = array();
                foreach ($tests as &$test) {
                    $waterfalls[] = array('id' => $test['id'], 'label' => $test['name'], 'run' => $test['run'], 'cached' => $test['cached']);
                }
                $labels = '';
                if (array_key_exists('hideurls', $_REQUEST) && $_REQUEST['hideurls']) {
                    $labels = '&labels=0';
                }
                InsertMultiWaterfall($waterfalls, "&max={$end_seconds}&mime=1&state=1&cpu=1&bw=1{$labels}");
            }
            ?>

        <div id="advanced" style="display:none;">
            <h3>Advanced Visual Comparison Configuration</h3>
            <p>There are additional customizations that can be done by modifying the <b>tests</b> parameter in the comparison URL directly.</p>
            <p>URL structure: ...compare.php?tests=&lt;Test 1 ID&gt;,&lt;Test 2 ID&gt;...</p>
            <p>The tests are displayed in the order listed and can be customized with options:</p>
            <table>
            <tr><td>Custom label</td><td>-l:&lt;label&gt;</td><td>110606_MJ_RZEY-l:Original</td></tr>
            <tr><td>Specific run</td><td>-r:&lt;run&gt;</td><td>110606_MJ_RZEY-r:3</td></tr>
            <tr><td>Repeat view</td><td>-c:1</td><td>110606_MJ_RZEY-c:1</td></tr>
            <tr><td>Specific End Time</td><td>-e:&lt;seconds&gt;</td><td>110606_MJ_RZEY-e:1.1</td></tr>
            </table>
            <br>
            <p>You can also customize the background and text color by passing HTML color values to <b>bg</b> and <b>text</b> query parameters.</p>
            <p>Examples:</p>
            <ul>
            <li><b>Customizing labels:</b>
            http://www.webpagetest.org/video/compare.php?tests=110606_MJ_RZEY-l:Original,110606_AE_RZN5-l:No+JS</li>
            <li><b>Compare First vs. Repeat view:</b>
            http://www.webpagetest.org/video/compare.php?tests=110606_MJ_RZEY, 110606_MJ_RZEY-c:1</li>
            <li><b>White background with black text:</b>
            http://www.webpagetest.org/video/compare.php?tests=110606_MJ_RZEY, 110606_MJ_RZEY-c:1&bg=ffffff&text=000000</li>
            </ul>
            <input id="advanced-ok" type=button class="simplemodal-close" value="OK">
        </div>
        <?php 
        }
        // EMBED
        // scroll the table to show the first thumbnail change
        $scrollPos = $firstFrame * ($maxThumbWidth + 6);
        ?>
        <script language="javascript">
            var thumbWidth = <?php 
        echo "{$maxThumbWidth};";
        ?>
            var scrollPos = <?php 
        echo "{$scrollPos};";
        ?>
            document.getElementById("videoDiv").scrollLeft = scrollPos;
        </script>
        <?php 
    }
}
Пример #28
0
            if ($update_ticket !== null) {
                header('Content-Type: application/json');
                http_response_code(201);
                echo json_encode($update_ticket);
                exit;
            } else {
                header('Content-Type: application/json');
                echo json_encode(['error' => 'Error: Unable to update specified ticket!']);
                exit;
            }
        }
    }
} else {
    if (isset($_GET['gm_id'])) {
        $gm_id = trim($_GET['gm_id']);
        $requests = getRequests($gm_id);
        if ($requests !== null) {
            header('Content-Type: application/json');
            echo json_encode($requests);
            exit;
        } else {
            header('Content-Type: application/json');
            echo json_encode(['error' => 'Error: GM ID not found in system!']);
            exit;
        }
    } else {
        if (isset($_GET['admin_gm_id'])) {
            $admin_gm_id = trim($_GET['admin_gm_id']);
            $requests = getPersonal($admin_gm_id);
            if ($requests !== null) {
                header('Content-Type: application/json');
Пример #29
0
/**
* 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}&amp;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;
}
Пример #30
0
 function getRequests()
 {
     return getRequests();
 }