Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

move constants together #2431

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/Handlers/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function error_log($str)
define('VER_JS_ACCOUNT', "account.js");
define('VER_JS_ESTIMATE_TAXES', "estimate-taxes.js");
define('FRIENDLY_URLS', true);
define('EMBED', false);

final class AccountTest extends TestCase
{
Expand Down
2 changes: 0 additions & 2 deletions www/breakdown.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
require_once('object_detail.inc');
require_once('contentColors.inc');

define('BREAKDOWN_CACHE_VERSION', 4);

/**
* Aggregate the individual requests by mime type
*
Expand Down
21 changes: 10 additions & 11 deletions www/common.inc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ require_once(__DIR__ . '/common_lib.inc');
require_once(__DIR__ . '/plugins.php.inc');
require_once(__DIR__ . '/util.inc');

// constants that require common_lib nand cannot be in constants.inc
if (GetSetting('friendly_urls') || (array_key_exists('HTTP_MOD_REWRITE', $_SERVER) && $_SERVER['HTTP_MOD_REWRITE'] == 'On')) {
define('FRIENDLY_URLS', true);
define('VER_TIMELINE', '28/'); // version of the timeline javascript
} else {
define('FRIENDLY_URLS', false);
define('VER_TIMELINE', ''); // Leave the timeline version empty
}

// Create global request context for future use
$request_context = new RequestContext($_REQUEST, $_SERVER);

Expand Down Expand Up @@ -167,14 +176,6 @@ if (isset($_SERVER["HTTP_FASTLY_CLIENT_IP"])) {
$_SERVER["REMOTE_ADDR"] = $_SERVER["HTTP_FASTLY_CLIENT_IP"];
}

if (GetSetting('friendly_urls') || (array_key_exists('HTTP_MOD_REWRITE', $_SERVER) && $_SERVER['HTTP_MOD_REWRITE'] == 'On')) {
define('FRIENDLY_URLS', true);
define('VER_TIMELINE', '28/'); // version of the timeline javascript
} else {
define('FRIENDLY_URLS', false);
define('VER_TIMELINE', ''); // Leave the timeline version empty
}

$privateInstall = true;
if (
array_key_exists('HTTP_HOST', $_SERVER) &&
Expand Down Expand Up @@ -212,9 +213,7 @@ if (!is_dir($tempDir)) {
}
$tempDir = realpath($tempDir) . '/';

if (isset($_REQUEST['embed'])) {
define('EMBED', true);
} elseif (isset($_REQUEST['bare'])) {
if (!EMBED && isset($_REQUEST['bare'])) {
$noanalytics = true;
}
$is_ssl = isSslConnection();
Expand Down
2 changes: 0 additions & 2 deletions www/common_lib.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/archive.inc');
require_once(__DIR__ . '/util.inc');

define('VIDEO_CODE_VERSION', 20);

require_once(__DIR__ . '/logging.inc');
use WebPageTest\Util;
use WebPageTest\Util\Cache;
Expand Down
5 changes: 5 additions & 0 deletions www/constants.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,8 @@ define('VER_JS_ACCOUNT', @md5_file(ASSETS_PATH . '/js/account.js')); //
define('VER_JS_ESTIMATE_TAXES', @md5_file(ASSETS_PATH . '/js/estimate-taxes.js'));
define('VER_JS_COUNTRY_LIST', @md5_file(ASSETS_PATH . '/js/country-list/country-list.js'));
define('UNKNOWN_TIME', -1); // Value used as a flag for an unknown time.

define('BREAKDOWN_CACHE_VERSION', 4);
define('VIDEO_CODE_VERSION', 20);

define('EMBED', isset($_REQUEST['embed']));
15 changes: 2 additions & 13 deletions www/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,6 @@ if (isset($testPath)) {
$testInfo = TestInfo::fromFiles($testPath);
$testResults = TestResults::fromFiles($testInfo);
}
if (isset($testResults)) {
$adultKeywords = array();
if (is_file('./settings/adult.txt')) {
$adultKeywords = file('./settings/adult.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
$isAdult = $testResults->isAdultSite($adultKeywords);
if ($isAdult) {
define('ADULT_SITE', true);
$adult_site = true;
}
}

// For users that aren't logged in, include details about the test so it can be stored in indexdb for local history support
if (
Expand All @@ -55,7 +44,7 @@ if (!isset($experiment)) {
$experiment = false;
}

if (!defined('EMBED')) {
if (!EMBED) {
?>
<?php
$alert = Util::getSetting('alert');
Expand All @@ -80,7 +69,7 @@ if (!defined('EMBED')) {

<?php
//If we're looking at a test result, include the extra header section and sub-menu
if (!strcasecmp('Test Result', $tab) && (!isset($nosubheader) || !@$nosubheader) && !defined('EMBED')) {
if (!strcasecmp('Test Result', $tab) && (!isset($nosubheader) || !@$nosubheader) && !EMBED) {
// make sure the test is actually complete and the second check can be applied to non-compare pages
if (isset($test['test']['completeTime']) || (!isset($tests) && file_exists("$testPath/test.complete") )) {
if (!isset($testResults) || !isset($testInfo)) {
Expand Down
1 change: 0 additions & 1 deletion www/resultBatch.inc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ $csv = false;
$json = false;
if (array_key_exists('f', $_REQUEST)) {
if ($_REQUEST['f'] == 'csv') {
//define('RESTORE_DATA_ONLY', true);
$csv = true;
$json_response = array();
} elseif ($_REQUEST['f'] == 'json') {
Expand Down
13 changes: 1 addition & 12 deletions www/templates/layouts/header.inc
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ if (isset($testPath)) {
$testInfo = TestInfo::fromFiles($testPath);
$testResults = TestResults::fromFiles($testInfo);
}
if (isset($testResults)) {
$adultKeywords = array();
if (is_file('../../settings/adult.txt')) {
$adultKeywords = file('../../settings/adult.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
}
$isAdult = $testResults->isAdultSite($adultKeywords);
if ($isAdult) {
define('ADULT_SITE', true);
$adult_site = true;
}
}

// For users that aren't logged in, include details about the test so it can be stored in indexdb for local history support
if (
Expand All @@ -55,7 +44,7 @@ if (
// If $tab is null, make it an empty string for strcasecmp
$tab ??= "";

if (defined('EMBED')) {
if (EMBED) {
// You don't need a header
return;
}
Expand Down
4 changes: 2 additions & 2 deletions www/templates/layouts/includes/wpt-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function addTab($tabName, $tabUrl, $addClass = '')
</details>
</li>

<?php if ($supportsAuth && !defined('EMBED')) : ?>
<?php if ($supportsAuth && !EMBED) : ?>
<?= addTab('Pricing', '/signup'); ?>
<?php endif; ?>

Expand Down Expand Up @@ -138,7 +138,7 @@ function addTab($tabName, $tabUrl, $addClass = '')

<?php

if ($supportsAuth && !defined('EMBED')) {
if ($supportsAuth && !EMBED) {
if ($supportsCPAuth) {
$is_logged_in = isset($request_context) && !is_null($request_context->getUser()) && !is_null($request_context->getUser()->getAccessToken());
?>
Expand Down
2 changes: 1 addition & 1 deletion www/templates/layouts/main_hed.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require_once __DIR__ . '/../../include/TestResults.php';
require_once __DIR__ . '/../../include/TestRunResults.php';

//If we're looking at a test result, include the extra header section and sub-menu
if (!strcasecmp('Test Result', $tab) && (!isset($nosubheader) || !@$nosubheader) && !defined('EMBED')) {
if (!strcasecmp('Test Result', $tab) && (!isset($nosubheader) || !@$nosubheader) && !EMBED) {
// make sure the test is actually complete
if (isset($test['test']['completeTime'])) {
if (!isset($testResults) || !isset($testInfo)) {
Expand Down
13 changes: 4 additions & 9 deletions www/video/compare.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@
background: #296ee1;
}
<?php
if (defined('EMBED')) {
if (EMBED) {
?>
#location {display: none;}
#bottom {display: none;}
Expand Down Expand Up @@ -679,11 +679,6 @@ function ScreenShotTable()
$end = $test['video']['end'];
}
}

// if (!defined('EMBED')) {
// echo '<br>';
// }

echo '<table id="videoContainer"><tr>';


Expand All @@ -709,7 +704,7 @@ function ScreenShotTable()
// Print the index outside of the link tag
echo $test['index'] . ': ';

if (!defined('EMBED')) {
if (!EMBED) {
echo " <span id=\"label_{$test['id']}\">" . WrapableString(htmlspecialchars($test['name'])) . "</span>";
} else {
echo WrapableString(htmlspecialchars($test['name']));
Expand All @@ -722,7 +717,7 @@ function ScreenShotTable()
}
echo '</a>';

if (!defined('EMBED')) {
if (EMBED) {
$urlGenerator = UrlGenerator::create(FRIENDLY_URLS, "", $test['id'], $test['run'], $test['cached'], $test['step']);
$href = $urlGenerator->resultPage("details") . "#waterfall_view_step" . $test['step'];
echo "<a class=\"video_runlabel_backlink\" href=\"$href\">Test Run Details</a>";
Expand Down Expand Up @@ -1018,7 +1013,7 @@ function ScreenShotTable()

<div class="compare_contain_wrap">

<?php if (!defined('EMBED')) {
<?php if (!EMBED) {
// display the waterfall if there is only one test
$end_seconds = $filmstrip_end_time / 1000;
if (count($tests) == 1) {
Expand Down
11 changes: 5 additions & 6 deletions www/video/filmstrip_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@

echo ' <details class="box details_panel">
<summary class="details_panel_hed"><span><i class="icon_plus"></i> <span>Adjust Filmstrip Settings</span></span></summary>

<div class="details_panel_content">';


// START TIMELINE OPTIONS
if (!defined('EMBED')) {
if (!EMBED) {
?>

<form name="layout" method="get" action="/video/compare.php">
<?php
echo "<input type=\"hidden\" name=\"tests\" value=\"" . htmlspecialchars($_REQUEST['tests']) . "\">\n";
Expand Down Expand Up @@ -193,7 +193,7 @@
echo '<div class="compare_video_form"><label for="slow"><input type="checkbox" id="slow" name="slow" value="1"> Slow Motion</label>';
echo "<input id=\"SubmitBtn\" type=\"submit\" value=\"View Video\"></div>";
echo "</form>"; ?>


<div id="advanced" style="display:none;">
<h3>Advanced Visual Comparison Configuration</h3>
Expand All @@ -211,7 +211,7 @@
</tbody>
</table>
</div>

<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>
Expand All @@ -232,4 +232,3 @@


echo '</div></details>'; ?>