Commit b8ff08c6 authored by Melissa Draper's avatar Melissa Draper

Change the https checks to use is_https() (bug #829674)

As per Francois' comment in the bug
https://bugs.launchpad.net/mahara/+bug/829674/comments/1

Change-Id: I03d99dbc93ea57d16240d0904c6bd670534f82b5
Signed-off-by: default avatarMelissa Draper <melissa@catalyst.net.nz>
parent 2262a1a7
......@@ -742,7 +742,7 @@ class PluginBlocktypeGallery extends PluginBlocktype {
private static function get_supported_external_galleries() {
$smarty = smarty_core();
$smarty->assign('wwwroot', get_config('wwwroot'));
if (stripos(get_config('wwwroot'), 'https') === 0) {
if (is_https() === true) {
$smarty->assign('protocol', 'https');
}
else {
......
......@@ -231,7 +231,7 @@ class PluginBlocktypeGoogleApps extends SystemBlocktype {
private static function get_html_of_supported_googleapps() {
$smarty = smarty_core();
$smarty->assign('lang', substr(get_config('lang'), 0, 2));
if (stripos(get_config('wwwroot'), 'https') === 0) {
if (is_https() === true) {
$smarty->assign('protocol', 'https');
}
else {
......
......@@ -160,7 +160,7 @@ catch (SQLException $e) {
// Make sure wwwroot is set and available, either in the database or in the
// config file. Cron requires it when sending out forums emails.
if (!isset($CFG->wwwroot) && isset($_SERVER['HTTP_HOST'])) {
$proto = (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https://' : 'http://';
$proto = is_https() === true ? 'https://' : 'http://';
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST'];
if (false !== strpos($host, ',')) {
list($host) = explode(',', $host);
......@@ -212,13 +212,12 @@ if (isset($CFG->wwwroot)) {
}
// If we're forcing an ssl proxy, make sure the wwwroot is correct
if ($CFG->sslproxy == true && parse_url($CFG->wwwroot, PHP_URL_SCHEME) !== 'https') {
if ($CFG->sslproxy === true && is_https() === false) {
throw new ConfigSanityException(get_string('wwwrootnothttps', 'error', get_config('wwwroot')));
}
// Make sure that we are using ssl if wwwroot expects us to do so
if ($CFG->sslproxy === false && isset($_SERVER['REMOTE_ADDR']) && (!isset($_SERVER['HTTPS']) || strtolower($_SERVER['HTTPS']) == 'off') &&
parse_url($CFG->wwwroot, PHP_URL_SCHEME) === 'https'){
if ($CFG->sslproxy === false && isset($_SERVER['REMOTE_ADDR']) && is_https() === true){
redirect(get_relative_script_path());
}
if (!isset($CFG->noreplyaddress) && isset($_SERVER['HTTP_HOST'])) {
......
......@@ -149,7 +149,7 @@ function serve_file($path, $filename, $mimetype, $options=array()) {
}
}
else { // Do not cache files in proxies and browsers
if (strpos(get_config('wwwroot'), 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431
if (is_https() === true) { //https sites - watch out for IE! KB812935 and KB316431
header('Cache-Control: max-age=10');
header('Expires: '. gmdate('D, d M Y H:i:s', 0) .' GMT');
header('Pragma: ');
......
......@@ -2232,7 +2232,7 @@ function remote_avatar($email, $size, $notfound) {
}
$baseurl = 'http://www.gravatar.com/avatar/';
if (stripos(get_config('wwwroot'), 'https://') === 0) {
if (is_https() === true) {
$baseurl = 'https://secure.gravatar.com/avatar/';
}
if (get_config('remoteavatarbaseurl')) {
......
......@@ -2545,10 +2545,8 @@ function get_full_script_path() {
}
}
if (isset($_SERVER['HTTPS'])) {
$protocol = ($_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
} else if (isset($_SERVER['SERVER_PORT'])) { # Apache2 does not export $_SERVER['HTTPS']
$protocol = ($_SERVER['SERVER_PORT'] == '443') ? 'https://' : 'http://';
if (is_https() === true || (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443' )) {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment