From d7697d0ec07df977483c34279b13b33461b8c0be Mon Sep 17 00:00:00 2001 From: stronk7 Date: Thu, 14 Jul 2005 19:44:42 +0000 Subject: [PATCH] Add the httpsrequired() function to be 100% SSL in some pages. Merged from MOODLE_15_STABLE --- lib/moodlelib.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 5e6f399243f..1b50b825e5b 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5958,6 +5958,26 @@ function address_in_subnet($addr, $subnetstr) { return $found; } +/** + * This function sets the $HTTPSPAGEREQUIRED global + * (used in some parts of moodle to change some links) + * and calculate the proper wwwroot to be used + * + * By using this function properly, we can ensure 100% https-ized pages + * at our entire discretion (login, forgot_password, change_password) + */ +function httpsrequired() { + + global $CFG, $HTTPSPAGEREQUIRED; + + if (!empty($CFG->loginhttps)) { + $HTTPSPAGEREQUIRED = true; + $CFG->httpswwwroot = str_replace('http', 'https', $CFG->wwwroot); + } else { + $CFG->httpswwwroot = $CFG->wwwroot; + } +} + /** * For outputting debugging info *