4 require_once("../../config.php");
5 require_once($CFG->dirroot
."/auth/shibboleth/auth.php");
10 /// Check for timed out sessions
11 if (!empty($SESSION->has_timed_out
)) {
12 $session_has_timed_out = true;
13 $SESSION->has_timed_out
= false;
15 $session_has_timed_out = false;
19 //HTTPS is potentially required in this page
22 /// Define variables used in page
23 if (!$site = get_site()) {
24 error("No site found!");
27 if (empty($CFG->langmenu
)) {
30 $currlang = current_language();
31 $langs = get_list_of_languages();
32 $langlabel = get_accesshide(get_string('language'));
33 $langmenu = popup_form ("$CFG->httpswwwroot/login/index.php?lang=", $langs, "chooselang", $currlang, "", "", "", true, 'self', $langlabel);
36 $loginsite = get_string("loginsite");
38 $loginurl = (!empty($CFG->alternateloginurl
)) ?
$CFG->alternateloginurl
: '';
41 if (get_moodle_cookie() == '') {
42 set_moodle_cookie('nobody'); // To help search for cookies
45 if (!empty($CFG->registerauth
) or is_enabled_auth('none') or !empty($CFG->auth_instructions
)) {
46 $show_instructions = true;
48 $show_instructions = false;
51 // Set SAML domain cookie
52 $config = get_config('auth/shibboleth');
55 $IdPs = get_idp_list($config->organization_selection
);
56 if (isset($_POST['idp']) && isset($IdPs[$_POST['idp']])){
57 $selectedIdP = $_POST['idp'];
58 set_saml_cookie($selectedIdP);
60 // Redirect to SessionInitiator with providerId as argument
61 if (isset($IdPs[$selectedIdP][1]) && !empty($IdPs[$selectedIdP][1])){
62 header('Location: '.$IdPs[$selectedIdP][1].'?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot
.'/auth/shibboleth/index.php'));
64 header('Location: /Shibboleth.sso?providerId='. urlencode($selectedIdP) .'&target='. urlencode($CFG->wwwroot
.'/auth/shibboleth/index.php'));
66 } elseif (isset($_POST['idp']) && !isset($IdPs[$_POST['idp']])) {
67 $errormsg = get_string('auth_shibboleth_errormsg', 'auth');
70 $loginsite = get_string("loginsite");
71 $navlinks = array(array('name' => $loginsite, 'link' => null, 'type' => 'misc'));
72 $navigation = build_navigation($navlinks);
74 print_header("$site->fullname: $loginsite", $site->fullname
, $navigation, $focus,
75 '', true, '<div class="langmenu">'.$langmenu.'</div>');
77 include("index_form.html");