From 83b3e7d18eb6d34fb61f6b4a00f4c89ea68179a1 Mon Sep 17 00:00:00 2001 From: Claudio Biselli Date: Thu, 20 Jul 2023 12:59:33 +0000 Subject: [PATCH 1/6] changed text for anon user with expired runs --- www/runtest.php | 23 +++++++++++------------ www/templates/errors/runtest.php | 12 +++++++++--- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/www/runtest.php b/www/runtest.php index 85b29f2d8e..d1cb271676 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -896,7 +896,6 @@ function buildSelfHost($hosts) return $selfHostScript; } - if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error)) { $total_runs = Util::getRunCount($test['runs'], $test['fvonly'], $test['lighthouse'], $test['type']); $hasRunsAvailable = !is_null($request_context->getUser()) && $request_context->getUser()->hasEnoughRemainingRuns($total_runs); @@ -1452,6 +1451,7 @@ function buildSelfHost($hosts) echo $tpl->render('runlimit'); } else { echo $tpl->render('runtest', array( + 'errorTitle' => $errorTitle, 'error' => $error )); } @@ -3498,8 +3498,8 @@ function loggedOutLoginForm() { $ret = << -
  • Login
  • Sign-up
  • +
  • Login
  • HTML; @@ -3510,15 +3510,15 @@ function loggedInPerks() { $msg = << -
  • Access to 13 months of saved tests, making it easier to compare tests and analyze trends.
  • +
  • The ability to save your tests! Access up to 13 months of tests, making it easier to compare tests and analyze results
  • Ability to contribute to the WebPageTest Forum.
  • -
  • Access to upcoming betas and new features that will enhance your WebPageTest experience.
  • +
  • Access to upcoming betas and new features to enhance your WebPageTest experience.
  • HTML; return $msg; } -function CheckRateLimit($test, &$error) +function CheckRateLimit($test, &$error, &$errorTitle) { global $USER_EMAIL; global $supportsCPAuth; @@ -3551,8 +3551,10 @@ function CheckRateLimit($test, &$error) $cmrl = new RateLimiter($test['ip'], $monthly_limit); $passesMonthly = $cmrl->check($total_runs); + $error = "

    Don't worry! You can keep testing for free once you log in, which will give you access to other excellent features like:

    "; + if (!$passesMonthly) { - $error = "

    You've reached the limit for logged-out tests this month, but don't worry! You can keep testing once you log in, which will give you access to other nice features like:

    "; + $errorLimitWindow = "this month"; $error .= << var intervalId = setInterval(function () { @@ -3570,7 +3572,7 @@ function CheckRateLimit($test, &$error) // Enforce per-IP rate limits for testing $limit = Util::getSetting('rate_limit_anon', null); - if (isset($limit) && $limit > 0) { + if (true) { $cache_key = 'rladdr_' . $test['ip']; $count = Cache::fetch($cache_key); if (!isset($count)) { @@ -3580,8 +3582,7 @@ function CheckRateLimit($test, &$error) $count += $total_runs; Cache::store($cache_key, $count, 1800); } else { - $apiUrl = Util::getSetting('api_url'); - $error = '

    You\'ve reached the limit for logged-out tests per hour, but don\'t worry! You can keep testing once you log in, which will give you access to other nice features like:

    '; + $errorLimitWindow = "the hour"; $error .= << var intervalId = setInterval(function () { @@ -3594,13 +3595,11 @@ function CheckRateLimit($test, &$error) HTML; $error .= loggedInPerks(); - if ($apiUrl) { - $error .= "

    And also, if you need to run tests programmatically you might be interested in the WebPageTest API

    "; - } $error .= loggedOutLoginForm(); $ret = false; } } + $errorTitle = "You've reached the limit for {$errorLimitWindow}"; return $ret; } diff --git a/www/templates/errors/runtest.php b/www/templates/errors/runtest.php index a2e8d7b007..8636e497df 100644 --- a/www/templates/errors/runtest.php +++ b/www/templates/errors/runtest.php @@ -1,6 +1,12 @@
    -

    Oops! There was a problem with the test.

    +

    Oops! + $title = "There was a problem with the test."; + if (strlen($errorTitle)) { + $title = $errorTitle ; + } + echo $title; + ?> +

    +
    From 1979a9fda5f0e7a95c78ddba00f7114d4a0c40ed Mon Sep 17 00:00:00 2001 From: Claudio Biselli Date: Thu, 20 Jul 2023 13:05:08 +0000 Subject: [PATCH 2/6] reverted change --- www/runtest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/runtest.php b/www/runtest.php index d1cb271676..97ef151ac8 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -896,6 +896,7 @@ function buildSelfHost($hosts) return $selfHostScript; } + if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error)) { $total_runs = Util::getRunCount($test['runs'], $test['fvonly'], $test['lighthouse'], $test['type']); $hasRunsAvailable = !is_null($request_context->getUser()) && $request_context->getUser()->hasEnoughRemainingRuns($total_runs); @@ -3572,7 +3573,7 @@ function CheckRateLimit($test, &$error, &$errorTitle) // Enforce per-IP rate limits for testing $limit = Util::getSetting('rate_limit_anon', null); - if (true) { + if (isset($limit) && $limit > 0) { $cache_key = 'rladdr_' . $test['ip']; $count = Cache::fetch($cache_key); if (!isset($count)) { From b8673929686cd9cd6490c1d6720a20ace4fea475 Mon Sep 17 00:00:00 2001 From: Claudio Biselli Date: Thu, 20 Jul 2023 13:11:59 +0000 Subject: [PATCH 3/6] added missing variable --- www/runtest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/www/runtest.php b/www/runtest.php index 97ef151ac8..4e234cb75c 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -63,6 +63,7 @@ $redirect_cache = array(); $error = null; +$errorTitle = null; $xml = false; $usingAPI = false; $usingApi2 = false; @@ -897,7 +898,7 @@ function buildSelfHost($hosts) } -if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error)) { +if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error, $errorTitle)) { $total_runs = Util::getRunCount($test['runs'], $test['fvonly'], $test['lighthouse'], $test['type']); $hasRunsAvailable = !is_null($request_context->getUser()) && $request_context->getUser()->hasEnoughRemainingRuns($total_runs); $isAnon = !is_null($request_context->getUser()) && $request_context->getUser()->isAnon(); From be8a2546964dd39717813797386594fe3d17d71c Mon Sep 17 00:00:00 2001 From: Claudio Biselli Date: Thu, 20 Jul 2023 13:26:20 +0000 Subject: [PATCH 4/6] fixed monthly use case --- www/runtest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/www/runtest.php b/www/runtest.php index 4e234cb75c..8b44e60568 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -3554,9 +3554,10 @@ function CheckRateLimit($test, &$error, &$errorTitle) $passesMonthly = $cmrl->check($total_runs); $error = "

    Don't worry! You can keep testing for free once you log in, which will give you access to other excellent features like:

    "; + $errorTitleTemplate = "You've reached the limit for"; if (!$passesMonthly) { - $errorLimitWindow = "this month"; + $errorTitle = "{$errorTitleTemplate} this month"; $error .= << var intervalId = setInterval(function () { @@ -3584,7 +3585,7 @@ function CheckRateLimit($test, &$error, &$errorTitle) $count += $total_runs; Cache::store($cache_key, $count, 1800); } else { - $errorLimitWindow = "the hour"; + $errorTitle = "{$errorTitleTemplate} this month"; $error .= << var intervalId = setInterval(function () { @@ -3602,6 +3603,5 @@ function CheckRateLimit($test, &$error, &$errorTitle) } } - $errorTitle = "You've reached the limit for {$errorLimitWindow}"; return $ret; } From 93ebb8df7fb40a8ec30cadf111a98952db1c2892 Mon Sep 17 00:00:00 2001 From: Claudio Biselli Date: Thu, 20 Jul 2023 13:49:18 +0000 Subject: [PATCH 5/6] refactored error template --- www/templates/errors/runtest.php | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/www/templates/errors/runtest.php b/www/templates/errors/runtest.php index 8636e497df..7d62dfd1df 100644 --- a/www/templates/errors/runtest.php +++ b/www/templates/errors/runtest.php @@ -1,12 +1,4 @@
    -

    Oops! - -

    - +

    Oops!

    +
    From ae5230d70d73d4451698399f502bf2ab5e485442 Mon Sep 17 00:00:00 2001 From: Mike Kozicki Date: Tue, 25 Jul 2023 09:39:32 -0400 Subject: [PATCH 6/6] Added period --- www/runtest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/runtest.php b/www/runtest.php index 8b44e60568..29d0c2cf35 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -3512,7 +3512,7 @@ function loggedInPerks() { $msg = << -
  • The ability to save your tests! Access up to 13 months of tests, making it easier to compare tests and analyze results
  • +
  • The ability to save your tests! Access up to 13 months of tests, making it easier to compare tests and analyze results.
  • Ability to contribute to the WebPageTest Forum.
  • Access to upcoming betas and new features to enhance your WebPageTest experience.