Based on code from Janne - this allows secure logins via https
$CFG->loginhttps After logging in via https, Moodle returns to a normal http URL More info: http://moodle.org/mod/forum/discuss.php?d=8555
This commit is contained in:
@@ -161,6 +161,12 @@ $CFG->admin = 'admin';
|
||||
// most likely doesn't work yet. THIS IS FOR DEVELOPERS ONLY, IT IS
|
||||
// NOT RECOMMENDED FOR PRODUCTION SITES
|
||||
// $CFG->unicode = true;
|
||||
//
|
||||
// Turning this on will make Moodle use a https connection just for the
|
||||
// login page (providing a secure login), and then afterwards revert
|
||||
// back to the normal http URL. Requires https to be enabled on the
|
||||
// web server.
|
||||
// $CFG->loginhttps = true;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,12 @@
|
||||
}
|
||||
|
||||
if (empty($USER->id)) {
|
||||
$loginstring = "<font size=2><a href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
$loginstring = "<font size=2><a href=\"$wwwroot/login/index.php\">".get_string("login")."</a></font>";
|
||||
} else {
|
||||
$loginstring = "<font size=1>".user_login_string($site)."</font>";
|
||||
}
|
||||
|
||||
+6
-1
@@ -365,7 +365,12 @@ function require_login($courseid=0) {
|
||||
$SESSION->fromurl = $_SERVER["HTTP_REFERER"];
|
||||
}
|
||||
$USER = NULL;
|
||||
redirect("$CFG->wwwroot/login/index.php");
|
||||
if (empty($CFG->loginhttps)) {
|
||||
redirect("$CFG->wwwroot/login/index.php");
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
redirect("$wwwroot/login/index.php");
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
|
||||
+15
-5
@@ -953,10 +953,15 @@ function print_header ($title="", $heading="", $navigation="", $focus="", $meta=
|
||||
}
|
||||
|
||||
if (!$menu and $navigation) {
|
||||
if (isset($USER->id)) {
|
||||
$menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a></font>";
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a></font>";
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
if (isset($USER->id)) {
|
||||
$menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/logout.php\">".get_string("logout")."</a></font>";
|
||||
} else {
|
||||
$menu = "<font size=\"2\"><a target=\"$CFG->framename\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a></font>";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1076,18 +1081,23 @@ function user_login_string($course, $user=NULL) {
|
||||
}
|
||||
|
||||
if (isset($user->id) and $user->id) {
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
$fullname = fullname($user, true);
|
||||
$username = "<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/user/view.php?id=$user->id&course=$course->id\">$fullname</a>";
|
||||
if (isguest($user->id)) {
|
||||
$loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
|
||||
" (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a>)";
|
||||
" (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
|
||||
} else {
|
||||
$loggedinas = $realuserinfo.get_string("loggedinas", "moodle", "$username").
|
||||
" (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/logout.php\">".get_string("logout")."</a>)";
|
||||
}
|
||||
} else {
|
||||
$loggedinas = get_string("loggedinnot", "moodle").
|
||||
" (<a target=\"{$CFG->framename}\" href=\"$CFG->wwwroot/login/index.php\">".get_string("login")."</a>)";
|
||||
" (<a target=\"{$CFG->framename}\" href=\"$wwwroot/login/index.php\">".get_string("login")."</a>)";
|
||||
}
|
||||
return $loggedinas;
|
||||
}
|
||||
|
||||
+6
-1
@@ -125,7 +125,12 @@
|
||||
} else {
|
||||
$currlang = current_language();
|
||||
$langs = get_list_of_languages();
|
||||
$langmenu = popup_form ("$CFG->wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
if (empty($CFG->loginhttps)) {
|
||||
$wwwroot = $CFG->wwwroot;
|
||||
} else {
|
||||
$wwwroot = str_replace('http','https',$CFG->wwwroot);
|
||||
}
|
||||
$langmenu = popup_form ("$wwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
|
||||
}
|
||||
|
||||
$loginsite = get_string("loginsite");
|
||||
|
||||
Reference in New Issue
Block a user