diff --git a/www/common.inc b/www/common.inc index ca891d11ce..67c3b24c6d 100644 --- a/www/common.inc +++ b/www/common.inc @@ -42,7 +42,7 @@ if (Util::getSetting('cp_auth')) { error_log($e->getMessage()); $route = "/"; $message = "There was a problem with you account. Please reach out to customer service." . - "Error number: 2000"; + "Error number: 2000"; $host = Util::getSetting('host'); if (Util::getSetting('php_sessions')) { @@ -65,7 +65,7 @@ if (Util::getSetting('cp_auth')) { $message = ""; if (is_a($e, PortalException::class)) { $message = "There was a problem with you account. Please reach out to customer service." . - "Error number: {$e->getErrorNumber()}"; + "Error number: {$e->getErrorNumber()}"; } else { $message = $e->getMessage(); } @@ -375,7 +375,7 @@ if ($supportsAuth && $supportsCPAuth) { require_once INCLUDES_PATH . '/common/AttachUser.php'; require_once INCLUDES_PATH . '/common/AttachSignupClient.php'; require_once INCLUDES_PATH . '/common/AttachBannerMessageManager.php'; -// require_once INCLUDES_PATH . '/common/CheckCSRF.php'; + // require_once INCLUDES_PATH . '/common/CheckCSRF.php'; } // Load the test-specific data @@ -531,7 +531,7 @@ if (strlen($id)) { $controlTestUrlGenerator = UrlGenerator::create(FRIENDLY_URLS, "", $metaInfo['experiment']['control_id'], 0, 0); $controlTestHref = $controlTestUrlGenerator->resultSummary(); - $experimentResultsHref = "/video/compare.php?tests=" . $id . ',' . $metaInfo['experiment']['control_id']; + $experimentResultsHref = "/video/compare.php?tests=" . $id . ',' . $metaInfo['experiment']['control_id'] . ($req_fp ? "&fp=1" : ''); $experimentTestHref = "/result/" . $id; $experimentOptsUrlGenerator = UrlGenerator::create(FRIENDLY_URLS, "", $id, 0, 0); @@ -567,5 +567,6 @@ if (is_file(SETTINGS_PATH . '/custom_common.inc.php')) { require_once INCLUDES_PATH . '/experiments/user_access.inc'; $request_context->setReadOnly( - !is_null($request_context->getUser()) && $request_context->getUser() && $request_context->getUser()->newPortalExperience() + isset($req_fp) || + !is_null($request_context->getUser()) && $request_context->getUser() && $request_context->getUser()->newPortalExperience() ); diff --git a/www/include/UrlGenerator.php b/www/include/UrlGenerator.php index 5050eed1eb..4b3eac4026 100644 --- a/www/include/UrlGenerator.php +++ b/www/include/UrlGenerator.php @@ -14,25 +14,29 @@ abstract class UrlGenerator protected $step; protected $baseUrl; protected $testId; + protected $fp; protected function __construct($baseUrl, $testId, $run, $cached, $step = 1) { + global $req_fp; + $this->baseUrl = rtrim(strval($baseUrl), "/"); $this->testId = $testId; $this->run = intval($run); $this->cached = $cached ? true : false; $this->step = $step; + $this->fp = $req_fp; } - /** - * @param bool $friendlyUrls If the URL should be friendly (via mod_rewrite) or standard - * @param string $baseUrl URL base for the server (like http://my.wpt.server) - * @param string $testId ID of the test - * @param int $run Run number - * @param bool $cached True if cached run, false otherwise - * @param int $step The step number (1 by default) - * @return FriendlyUrlGenerator|StandardUrlGenerator A UrlGenerator for friendly or standard URLs - */ + /** + * @param bool $friendlyUrls If the URL should be friendly (via mod_rewrite) or standard + * @param string $baseUrl URL base for the server (like http://my.wpt.server) + * @param string $testId ID of the test + * @param int $run Run number + * @param bool $cached True if cached run, false otherwise + * @param int $step The step number (1 by default) + * @return FriendlyUrlGenerator|StandardUrlGenerator A UrlGenerator for friendly or standard URLs + */ public static function create($friendlyUrls, $baseUrl, $testId, $run, $cached, $step = 1) { if ($friendlyUrls) { @@ -42,49 +46,49 @@ public static function create($friendlyUrls, $baseUrl, $testId, $run, $cached, $ } } - /** - * @param string $page Result page to generate the URL for - * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) - * @return string The generated URL - */ + /** + * @param string $page Result page to generate the URL for + * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) + * @return string The generated URL + */ abstract public function resultPage($page, $extraParams = null); - /** - * @param string $image Image name to generate the thumbnail URL for - * @return string The generated URL - */ + /** + * @param string $image Image name to generate the thumbnail URL for + * @return string The generated URL + */ abstract public function thumbnail($image); - /** - * @param string $image Generated image name to generate the URL for - * @return string The generated URL - */ + /** + * @param string $image Generated image name to generate the URL for + * @return string The generated URL + */ abstract public function generatedImage($image); - /** - * @param bool $connectionView True for a connection view waterfall, false for the normal one. - * @param int $width Width of the generated image - * @param bool $withMime True if MIME data should be generated, false otherwise - * @return string The generated URL - */ + /** + * @param bool $connectionView True for a connection view waterfall, false for the normal one. + * @param int $width Width of the generated image + * @param bool $withMime True if MIME data should be generated, false otherwise + * @return string The generated URL + */ abstract public function waterfallImage($connectionView, $width, $withMime); - /** - * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) - * @return string The generated URL - */ + /** + * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) + * @return string The generated URL + */ abstract public function resultSummary($extraParams = null); - /** - * @return string The generated URL - */ + /** + * @return string The generated URL + */ abstract public function optimizationChecklistImage(); - /** - * @param string $file The name of the file to get with the URL - * @param string $video If it's a video-related file, this can be set to the corresponding video directory name - * @return string The generated URL - */ + /** + * @param string $file The name of the file to get with the URL + * @param string $video If it's a video-related file, this can be set to the corresponding video directory name + * @return string The generated URL + */ public function getFile($file, $video = "") { $videoParam = $video ? "&video=" . $video : ""; @@ -92,10 +96,10 @@ public function getFile($file, $video = "") return $url; } - /** - * @param string $file The name of the file to get with the URL - * @return string The generated URL - */ + /** + * @param string $file The name of the file to get with the URL + * @return string The generated URL + */ public function getGZip($file) { $compressedParam = (substr($file, -3) == ".gz") ? "&compressed=1" : ""; @@ -103,66 +107,71 @@ public function getGZip($file) return $url; } - /** - * @param string|int $requestNumber The request number to identify the response body - * @return string The generated URL - */ + /** + * @param string|int $requestNumber The request number to identify the response body + * @return string The generated URL + */ public function responseBodyWithRequestNumber($requestNumber) { - return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&request=" . strval($requestNumber); + $fpParam = $this->fp ? "&fp=$this->fp" : ""; + return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&request=" . strval($requestNumber) . $fpParam; } - /** - * @param int $bodyId The body ID to identify the response body - * @return string The generated URL - */ + /** + * @param int $bodyId The body ID to identify the response body + * @return string The generated URL + */ public function responseBodyWithBodyId($bodyId) { - return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&bodyid=" . strval($bodyId); + $fpParam = $this->fp ? "&fp=$this->fp" : ""; + return $this->baseUrl . "/response_body.php?" . $this->urlParams() . "&bodyid=" . strval($bodyId) . $fpParam; } - /** - * @param string $end Optional. A specific "end" to use for video creation - * @return string The generated URL to create a video - */ + /** + * @param string $end Optional. A specific "end" to use for video creation + * @return string The generated URL to create a video + */ public function createVideo($end = null) { $tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0); $tests .= ($this->step > 1) ? ("-s:" . $this->step) : ""; $tests .= $end ? "-e:$end" : ""; + $tests .= $this->fp ? "&fp=$this->fp" : ""; return $this->baseUrl . "/video/view.php?tests=" . $tests; } - /** - * @param string $end Optional. A specific "end" to use for filmstrip view - * @return string The generated URL for the filmstrip view - */ + /** + * @param string $end Optional. A specific "end" to use for filmstrip view + * @return string The generated URL for the filmstrip view + */ public function filmstripView($end = null) { $tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0); $tests .= ($this->step > 1) ? ("-s:" . $this->step) : ""; $tests .= $end ? "-e:$end" : ""; + $tests .= $this->fp ? "&fp=$this->fp" : ""; return $this->baseUrl . "/video/compare.php?tests=" . $tests; } - /** - * @param string $end Optional. A specific "end" to use for filmstrip view - * @return string The generated URL for the filmstrip view - */ + /** + * @param string $end Optional. A specific "end" to use for filmstrip view + * @return string The generated URL for the filmstrip view + */ public function filmstripImage($end = null) { $tests = $this->testId . "-r:" . $this->run . "-c:" . ($this->cached ? 1 : 0); $tests .= ($this->step > 1) ? ("-s:" . $this->step) : ""; $tests .= $end ? "-e:$end" : ""; + $tests .= $this->fp ? "&fp=$this->fp" : ""; return $this->baseUrl . "/video/filmstrip.php?tests=" . $tests; } - /** - * @param string $frame The thumbnail name - * @param int $fit Maximum size of the thumbnail - * @return string The URL for a thumbnail of the video frame - */ + /** + * @param string $frame The thumbnail name + * @param int $fit Maximum size of the thumbnail + * @return string The URL for a thumbnail of the video frame + */ public function videoFrameThumbnail($frame, $fit, $options = null) { $file = "video_" . rtrim(strtolower($this->underscorePrefix()), "_") . "/" . $frame; @@ -173,19 +182,19 @@ public function videoFrameThumbnail($frame, $fit, $options = null) return $url; } - /** - * @return string The generated URL to download all video frames - */ + /** + * @return string The generated URL to download all video frames + */ public function downloadVideoFrames() { return $this->baseUrl . "/video/downloadFrames.php?" . $this->urlParams(); } - /** - * @param string $page Step-independent Result page to generate the URL for - * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) - * @return string The generated URL - */ + /** + * @param string $page Step-independent Result page to generate the URL for + * @param string $extraParams|null Extra parameters to append (without '?' or '&' at start) + * @return string The generated URL + */ public function stepDetailPage($page, $extraParams = null) { $extraParams = $extraParams ? ("&" . $extraParams) : ""; @@ -201,7 +210,8 @@ protected function underscorePrefix() protected function urlParams() { $stepParam = $this->step > 1 ? ("&step=" . $this->step) : ""; - return "test=" . $this->testId . "&run=" . $this->run . ($this->cached ? "&cached=1" : "") . $stepParam; + $fpParam = $this->fp ? "&fp=$this->fp" : ""; + return "test=" . $this->testId . "&run=" . $this->run . ($this->cached ? "&cached=1" : "") . $stepParam . $fpParam; } } @@ -213,6 +223,7 @@ public function resultPage($page, $extraParams = null) if ($this->cached) { $url .= "cached/"; } + $extraParams = $this->prepareExtraParams($extraParams); if ($extraParams != null) { $url .= "?" . $extraParams; } @@ -241,7 +252,7 @@ public function generatedImage($image) { $parts = explode("_", $this->testId); $testPath = substr($parts[0], 0, 2) . "/" . substr($parts[0], 2, 2) . "/" . substr($parts[0], 4, 2) . - "/" . $parts[1]; + "/" . $parts[1]; if (sizeof($parts) > 2) { $testPath .= "/" . $parts[2]; } @@ -251,6 +262,7 @@ public function generatedImage($image) public function resultSummary($extraParams = null) { $url = $this->baseUrl . "/result/" . $this->testId . "/"; + $extraParams = $this->prepareExtraParams($extraParams); if ($extraParams != null) { $url .= "?" . $extraParams; } @@ -269,6 +281,17 @@ public function optimizationChecklistImage() { return $this->generatedImage("optimization"); } + + private function prepareExtraParams($extraParams = null) + { + if (!$this->fp) { + return $extraParams; + } + + return $extraParams + ? ("fp=$this->fp&" . $extraParams) + : "fp=$this->fp"; + } } class StandardUrlGenerator extends UrlGenerator @@ -298,6 +321,7 @@ public function generatedImage($image) public function resultSummary($extraParams = null) { $extraParams = $extraParams ? ("&" . $extraParams) : ""; + $extraParams .= $this->fp ? "&fp=$this->fp" : ""; return $this->baseUrl . "/results.php?test=" . $this->testId . $extraParams; } diff --git a/www/result.inc b/www/result.inc index 388843f1e8..32cb818061 100644 --- a/www/result.inc +++ b/www/result.inc @@ -40,398 +40,387 @@ foreach ($requests as $request) { } } - - - -$page_keywords = array('Results','WebPageTest','Website Speed Test','Page Speed'); +$page_keywords = array('Results', 'WebPageTest', 'Website Speed Test', 'Page Speed'); $page_description = "Website performance test result$testLabel."; ?> -
-
\n";
- } else {
- echo "URL: $url
\n";
- }
- echo "From: {$test['test']['location']}
\n";
- echo GetTestInfoHtml();
+ if (!$testComplete) {
?>
+
+ \n";
+ } else {
+ echo "URL: $url
\n";
+ }
+ echo "From: {$test['test']['location']}
\n";
+ echo GetTestInfoHtml();
+ ?>
You have Free Experiments Available! - Try them now!'; - } - ?>
- +You have Free Experiments Available! + Try them now!'; + } + ?>
+ +Please note: Availability of metrics will vary based on the browser being tested. Also, the way a site performs in some conditions may not predict how well it will perform in others, so we encourage testing in a variety of browsers, devices, & locations.