Skip to content

Commit 633126c

Browse files
committed
Merge branch 'master' of github.com:WPO-Foundation/webpagetest
2 parents b61a034 + 8d94b71 commit 633126c

24 files changed

+61
-42
lines changed

www/benchmarks/cron.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ function PreProcessBenchmark($benchmark) {
119119
echo "Benchmark '$benchmark' needs processing, spawning task\n";
120120
logMsg("Benchmark '$benchmark' needs processing, spawning task", "./log/$logFile", true);
121121

122-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
122+
$protocol = getUrlProtocol();
123123
$url = "$protocol://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?benchmark=' . urlencode($benchmark);
124124
if (function_exists('curl_init')) {
125125
$c = curl_init();
@@ -497,7 +497,7 @@ function SubmitBenchmarkTest($url, $location, &$settings, $benchmark) {
497497
));
498498

499499
$ctx = stream_context_create($params);
500-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
500+
$protocol = getUrlProtocol();
501501
$fp = fopen("$protocol://{$_SERVER['HTTP_HOST']}/runtest.php", 'rb', false, $ctx);
502502
if ($fp) {
503503
$response = @stream_get_contents($fp);

www/chrome/timeline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
$run = 'lighthouse';
1010
$timelineUrlParam = "/getTimeline.php?timeline=t:$id,r:$run,c:$cached,s:$step";
1111
if ($newTimeline) {
12-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
12+
$protocol = getUrlProtocol();
1313
$host = $_SERVER['HTTP_HOST'];
1414
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
1515
$cdn = GetSetting('cdn');

www/common.inc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,11 @@ if (array_key_exists('HTTP_HOST', $_SERVER) &&
139139
if (isset($_REQUEST['bulk'])) {
140140
$settings['noBulk'] = 0;
141141
}
142-
$is_ssl = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? true : false;
142+
$is_ssl = isSslConnection();
143143
$GLOBALS['cdnPath'] = '';
144144
if (isset($settings['cdn']) && !$is_ssl) {
145145
$GLOBALS['cdnPath'] = $settings['cdn'];
146146
}
147-
$GLOBALS['ptotocol'] = 'http';
148-
if ($is_ssl) {
149-
$GLOBALS['ptotocol'] = 'https';
150-
}
151147

152148
$tz_offset = null;
153149
if (isset($_COOKIE['tzo'])) {

www/common_lib.inc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
require_once(__DIR__ . '/archive.inc');
3+
require_once(__DIR__ . '/util.inc');
34

45
if(extension_loaded('newrelic')) {
56
newrelic_add_custom_tracer('RestoreTest');
@@ -2502,7 +2503,7 @@ function ShardKey($test_num, $locationID = null) {
25022503
* @param mixed $relative_url
25032504
*/
25042505
function SendAsyncRequest($relative_url) {
2505-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
2506+
$protocol = getUrlProtocol();
25062507
$url = "$protocol://{$_SERVER['HTTP_HOST']}$relative_url";
25072508
$local = GetSetting('local_server');
25082509
if ($local)

www/create_pss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
if (FRIENDLY_URLS)
3333
$url = "/result/{$test['id']}/";
3434

35-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
35+
$protocol = getUrlProtocol();
3636
header("Location: $protocol://{$_SERVER['HTTP_HOST']}$url");
3737
} else {
3838
echo "Invalid Test. Should be /create_pss.php?original=&LT;original test ID&GT;&optimized=&LT;optimized test ID&GT;";

www/getkey.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function EmailKeyInfo($info, $display) {
291291
}
292292
}
293293
}
294-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
294+
$protocol = getUrlProtocol();
295295
$url = "$protocol://{$_SERVER['HTTP_HOST']}/getLocations.php?f=html&k=$prefix";
296296
$content .= "\nThe list of current locations available for API testing here: $url.\n";
297297
if (count($locations)) {
@@ -314,7 +314,7 @@ function EmailKeyInfo($info, $display) {
314314
function EmailValidation($info) {
315315
$email = $info['email'];
316316
$id = $info['id'];
317-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
317+
$protocol = getUrlProtocol();
318318
$url = "$protocol://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?validate=$id";
319319
$content = "Thank you for requesting a WebPageTest API key. In order to assign a key we need to validate your email address.\n\nTo complete the validation and retrieve your API key please go to $url";
320320
SendMessage($email, 'WebPagetest API Key Request', $content);

www/google/get_pss_cached_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111

1212
if (isset($id) && strlen($id)) {
13-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
13+
$protocol = getUrlProtocol();
1414
$host = $_SERVER['HTTP_HOST'];
1515
$ret['statusCode'] = 200;
1616
$ret['statusText'] = 'Ok';

www/import.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ function CreateTestID() {
333333
}
334334

335335
function TestResult(&$test, $error) {
336-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
336+
$protocol = getUrlProtocol();
337337
$host = $_SERVER['HTTP_HOST'];
338338
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
339339
if (array_key_exists('f', $_REQUEST)) {

www/import_benchmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function ImportBenchmarkRun($benchmark, $epoch, &$test_data) {
161161
file_put_contents("./results/benchmarks/$benchmark/state.json", json_encode($state));
162162
Unlock($lock);
163163
// kick off the collection and aggregation of the results
164-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
164+
$protocol = getUrlProtocol();
165165
$host = $_SERVER['HTTP_HOST'];
166166
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
167167
$cron = "$protocol://$host$uri/benchmarks/cron.php?benchmark=" . urlencode($benchmark);

www/jpeginfo/jpeginfo.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
require_once(__DIR__ . '/../util.inc');
23
chdir('..');
34
include 'jpeginfo/jpeginfo.inc.php';
45
if (array_key_exists('url', $_REQUEST) &&
@@ -34,7 +35,7 @@
3435
mkdir($dir, 0777, true);
3536
move_uploaded_file($_FILES['imgfile']['tmp_name'], $path);
3637
}
37-
$protocol = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_SSL']) && $_SERVER['HTTP_SSL'] == 'On')) ? 'https' : 'http';
38+
$protocol = getUrlProtocol();
3839
header("Location: $protocol://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?id=$id");
3940
} else {
4041
echo "<!DOCTYPE html>\n<html>\n<head>\n</head>\n<body>\n";
@@ -229,4 +230,4 @@ function PrintArray($data, $indent) {
229230
}
230231
}
231232

232-
?>
233+
?>

0 commit comments

Comments
 (0)