diff --git a/www/runtest.php b/www/runtest.php index 485ec2770b..5f520b38aa 100644 --- a/www/runtest.php +++ b/www/runtest.php @@ -146,7 +146,7 @@ } if (array_key_exists('resubmit', $_POST)) { $test = GetTestInfo(trim($_POST['resubmit'])); - if (array_key_exists('key', $test)){ + if (array_key_exists('key', $test)) { $test['key'] = null; } if ($test) { @@ -221,7 +221,7 @@ $is_private = 0; $is_private_api_call = !empty($user_api_key) && !empty($req_private) && - ((int)$req_private == 1 || $req_private == 'true'); + ((int)$req_private == 1 || $req_private == 'true'); $is_private_web_call = $isPaid && ($_POST['private'] == 'on'); if ($is_private_api_call || $is_private_web_call) { @@ -900,6 +900,14 @@ function buildSelfHost($hosts) return $selfHostScript; } +$isFree = !is_null($request_context->getUser()) && $request_context->getUser()->isFree(); + +// Allow free user to run test only if email is verified +if ($isFree && !$request_context->getUser()->isVerified()) { + $errorTitle = 'Email address is not verified'; + $error = 'Please verify your email address to use WebPageTest.'; +} + if (!strlen($error) && CheckIp($test) && CheckUrl($test['url']) && CheckRateLimit($test, $error, $errorTitle)) { $total_runs = Util::getRunCount($test['runs'], $test['fvonly'], $test['lighthouse'], $test['type']); @@ -1827,9 +1835,24 @@ function ValidateParameters(&$test, $locations, &$error, $destination_url = null // make sure on/off options are explicitly 1 or 0 $values = array( - 'private', 'web10', 'ignoreSSL', 'tcpdump', 'standards', 'lighthouse', - 'timeline', 'swrender', 'netlog', 'spdy3', 'noscript', 'fullsizevideo', - 'blockads', 'sensitive', 'pngss', 'bodies', 'htmlbody', 'pss_advanced', + 'private', + 'web10', + 'ignoreSSL', + 'tcpdump', + 'standards', + 'lighthouse', + 'timeline', + 'swrender', + 'netlog', + 'spdy3', + 'noscript', + 'fullsizevideo', + 'blockads', + 'sensitive', + 'pngss', + 'bodies', + 'htmlbody', + 'pss_advanced', 'noheaders' ); foreach ($values as $value) { @@ -3555,7 +3578,7 @@ function CheckRateLimit($test, &$error, &$errorTitle) $errorTemplate = "

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) { $errorTitle = "{$errorTitleTemplate} this month"; $error = $errorTemplate; diff --git a/www/src/User.php b/www/src/User.php index 589b73fe2a..8bf27cda3d 100644 --- a/www/src/User.php +++ b/www/src/User.php @@ -89,6 +89,11 @@ public function isPaid(): bool ($this->payment_status == 'ACTIVE' || $this->isPendingCancelation()); } + public function isFree(): bool + { + return !$this->isPaid() && !$this->isAnon(); + } + public function setPaidClient(bool $is_paid): void { $this->is_paid_cp_client = $is_paid;