Example #1
0
 function get_content()
 {
     global $USER, $CFG, $SESSION;
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (!empty($CFG->registerauth)) {
         $authplugin = get_auth_plugin($CFG->registerauth);
         if ($authplugin->can_signup()) {
             $signup = $wwwroot . '/login/signup.php';
         }
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     if (!empty($CFG->loginpasswordautocomplete)) {
         $autocomplete = 'autocomplete="off"';
     } else {
         $autocomplete = '';
     }
     $username = get_moodle_cookie();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         if (empty($CFG->authloginviaemail)) {
             $strusername = get_string('username');
         } else {
             $strusername = get_string('usernameemail');
         }
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
         $this->content->text .= '<div class="c1 fld username"><label for="login_username">' . $strusername . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" value="" ' . $autocomplete . ' /></div>';
         if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
             $checked = $username ? 'checked="checked"' : '';
             $this->content->text .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" ' . $checked . '/>';
             $this->content->text .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
         }
         $this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
     }
     return $this->content;
 }
Example #2
0
 function get_content()
 {
     global $USER, $CFG;
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (!empty($CFG->registerauth)) {
         $authplugin = get_auth_plugin($CFG->registerauth);
         if ($authplugin->can_signup()) {
             $signup = $wwwroot . '/login/signup.php';
         }
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . $wwwroot . '/login/index.php">';
         $this->content->text .= '<div class="c1 fld username"><label for="login_username">' . get_string('username') . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" value="" /></div>';
         $this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
     }
     return $this->content;
 }
Example #3
0
        }
    } else {
        if (!empty($CFG->mymoodleredirect)) {
            // Redirect logged-in users to My Moodle overview if required
            if (isloggedin() && $USER->username != 'guest') {
                redirect($CFG->wwwroot . '/my/index.php');
            }
        }
    }
} else {
    // if upgrading from 1.6 or below
    if (isadmin() && moodle_needs_upgrading()) {
        redirect($CFG->wwwroot . '/' . $CFG->admin . '/index.php');
    }
}
if (get_moodle_cookie() == '') {
    set_moodle_cookie('nobody');
    // To help search for cookies on login page
}
if (!empty($USER->id)) {
    add_to_log(SITEID, 'course', 'view', 'view.php?id=' . SITEID, SITEID);
}
if (empty($CFG->langmenu)) {
    $langmenu = '';
} else {
    $currlang = current_language();
    $langs = get_list_of_languages();
    $langlabel = get_accesshide(get_string('language'));
    $langmenu = popup_form($CFG->wwwroot . '/index.php?lang=', $langs, 'chooselang', $currlang, '', '', '', true, 'self', $langlabel);
}
$PAGE = page_create_object(PAGE_COURSE_VIEW, SITEID);
Example #4
0
    }
    redirect($loginurl);
}
// make sure we really are on the https page when https login required
$PAGE->verify_https_required();
/// Generate the login page with forms
if (!isset($frm) or !is_object($frm)) {
    $frm = new stdClass();
}
if (empty($frm->username) && $authsequence[0] != 'shibboleth') {
    // See bug 5184
    if (!empty($_GET["username"])) {
        $frm->username = clean_param($_GET["username"], PARAM_RAW);
        // we do not want data from _POST here
    } else {
        $frm->username = get_moodle_cookie();
    }
    $frm->password = "";
}
if (!empty($frm->username)) {
    $focus = "password";
} else {
    $focus = "username";
}
if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) {
    $show_instructions = true;
} else {
    $show_instructions = false;
}
$potentialidps = array();
foreach ($authsequence as $authname) {
Example #5
0
}
if (!empty($loginurl)) {
    // We don't want the standard forms, go elsewhere
    redirect($loginurl);
}
/// Generate the login page with forms
if ($session_has_timed_out) {
    $errormsg = get_string('sessionerroruser', 'error');
}
if (get_moodle_cookie() == '') {
    set_moodle_cookie('nobody');
    // To help search for cookies
}
if (empty($frm->username) && $authsequence[0] != 'shibboleth') {
    // See bug 5184
    $frm->username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
    $frm->password = "";
}
if (!empty($frm->username)) {
    $focus = "password";
} else {
    $focus = "username";
}
if (!empty($CFG->registerauth) or is_enabled_auth('none') or !empty($CFG->auth_instructions)) {
    $show_instructions = true;
} else {
    $show_instructions = false;
}
print_header("{$site->fullname}: {$loginsite}", $site->fullname, $loginsite, $focus, '', true, '<div class="langmenu">' . $langmenu . '</div>');
include "index_form.html";
print_footer();
Example #6
0
function colms_theme_login_form() {
    global $CFG;
    if (empty($CFG->loginhttps)) {
        $wwwroot = $CFG->wwwroot;
    } else {
        // This actually is not so secure ;-), 'cause we're
        // in unencrypted connection...
        $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
    }

    //  if (!empty($CFG->registerauth)) {
    //   $authplugin = get_auth_plugin($CFG->registerauth);
    //    if ($authplugin->can_signup()) {
    //$signup = $wwwroot . '/login/signup.php';
    //   }
    //}
    // TODO: now that we have multiauth it is hard to find out if there is a way to change password
    $forgot = $wwwroot . '/login/forgot_password.php';

    if (!empty($CFG->loginpasswordautocomplete)) {
        $autocomplete = 'autocomplete="off"';
    } else {
        $autocomplete = '';
    }

    $username = get_moodle_cookie();
    $content = '<div id="front-login"><form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . ' >';

    //  $content .= '<label for="login_username">'.get_string('username').'</label>';
    $content .= '<div class="c1 fld username"><input type="text" name="username" id="login_username" placeholder="Username" value="' . s($username) . '" /></div>';

    //    $content .= '<label for="login_password">'.get_string('password').'</label>';

    $content .= '<div class="c1 fld password"><input type="password" name="password" id="login_password" placeholder="Password" value="" ' . $autocomplete . ' /></div>';

    if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
        $checked = $username ? 'checked="checked"' : '';
        $content .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" />';
        $content .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
    }

    $content .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" id="loginsubmit" /></div>';

    $content .= "</form>";
    if (!empty($forgot)) {
        $content .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
    }
    $content .='</div>';
    return $content;
}
Example #7
0
 function get_content()
 {
     global $USER, $CFG, $SESSION, $OUTPUT;
     require_once $CFG->libdir . '/authlib.php';
     $wwwroot = '';
     $signup = '';
     if ($this->content !== NULL) {
         return $this->content;
     }
     if (empty($CFG->loginhttps)) {
         $wwwroot = $CFG->wwwroot;
     } else {
         // This actually is not so secure ;-), 'cause we're
         // in unencrypted connection...
         $wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
     }
     if (signup_is_enabled()) {
         $signup = $wwwroot . '/login/signup.php';
     }
     // TODO: now that we have multiauth it is hard to find out if there is a way to change password
     $forgot = $wwwroot . '/login/forgot_password.php';
     if (!empty($CFG->loginpasswordautocomplete)) {
         $autocomplete = 'autocomplete="off"';
     } else {
         $autocomplete = '';
     }
     $username = get_moodle_cookie();
     $this->content = new stdClass();
     $this->content->footer = '';
     $this->content->text = '';
     if (!isloggedin() or isguestuser()) {
         // Show the block
         if (empty($CFG->authloginviaemail)) {
             $strusername = get_string('username');
         } else {
             $strusername = get_string('usernameemail');
         }
         $this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
         $this->content->text .= '<div class="form-group"><label for="login_username">' . $strusername . '</label>';
         $this->content->text .= '<input type="text" name="username" id="login_username" class="form-control" value="' . s($username) . '" /></div>';
         $this->content->text .= '<div class="form-group"><label for="login_password">' . get_string('password') . '</label>';
         $this->content->text .= '<input type="password" name="password" id="login_password" class="form-control" value="" ' . $autocomplete . ' /></div>';
         if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
             $checked = $username ? 'checked="checked"' : '';
             $this->content->text .= '<div class="form-check">';
             $this->content->text .= '<label class="form-check-label">';
             $this->content->text .= '<input type="checkbox" name="rememberusername" id="rememberusername"
                     class="form-check-input" value="1" ' . $checked . '/> ';
             $this->content->text .= get_string('rememberusername', 'admin') . '</label>';
             $this->content->text .= '</div>';
         }
         $this->content->text .= '<div class="form-group">';
         $this->content->text .= '<input type="submit" class="btn btn-primary btn-block" value="' . get_string('login') . '" />';
         $this->content->text .= '</div>';
         $this->content->text .= "</form>\n";
         if (!empty($signup)) {
             $this->content->text .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
         }
         if (!empty($forgot)) {
             $this->content->text .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
         }
         $authsequence = get_enabled_auth_plugins(true);
         // Get all auths, in sequence.
         $potentialidps = array();
         foreach ($authsequence as $authname) {
             $authplugin = get_auth_plugin($authname);
             $potentialidps = array_merge($potentialidps, $authplugin->loginpage_idp_list($this->page->url->out(false)));
         }
         if (!empty($potentialidps)) {
             $this->content->text .= '<div class="potentialidps">';
             $this->content->text .= '<h6>' . get_string('potentialidps', 'auth') . '</h6>';
             $this->content->text .= '<div class="potentialidplist">';
             foreach ($potentialidps as $idp) {
                 $this->content->text .= '<div class="potentialidp"><a href="' . $idp['url']->out() . '" title="' . s($idp['name']) . '">';
                 $this->content->text .= $OUTPUT->render($idp['icon'], $idp['name']) . s($idp['name']) . '</a></div>';
             }
             $this->content->text .= '</div>';
             $this->content->text .= '</div>';
         }
     }
     return $this->content;
 }
 function get_content()
 {
     global $USER, $CFG;
     // We don't want to show this block if OpenID auth isn't enabled
     if (!is_enabled_auth('openid')) {
         return '';
     }
     $config = get_config('auth/openid');
     $user_is_openid = isset($USER->auth) && $USER->auth == 'openid';
     $user_loggedin = !user_not_loggedin();
     // Check to see if the box should be displayed to a logged in user
     if ($user_loggedin) {
         // We don't want to allow admin users to be changed
         if (is_siteadmin($USER->id)) {
             return '';
         }
         if (!isset($config->auth_openid_allow_account_change)) {
             $config->auth_openid_allow_account_change = 'true';
         }
         if (!isset($config->auth_openid_allow_muliple)) {
             $config->auth_openid_allow_muliple = 'true';
         }
         $allow_change = $config->auth_openid_allow_account_change == 'true';
         $allow_append = $config->auth_openid_allow_muliple == 'true';
         if ($user_is_openid && !$allow_append || !$user_is_openid && !$allow_change) {
             return '';
         }
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content->footer = '';
     $this->content->text = '';
     $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
     $user = get_complete_user_data('username', $username);
     // BJB101119: added check below "if (empty($user) ||" to fix error
     if (empty($user) || $user->auth != 'openid' || $user_loggedin) {
         $username = '';
     }
     if ($user_loggedin) {
         $endpoint = $CFG->wwwroot . '/auth/openid/actions.php';
     } else {
         $endpoint = $CFG->wwwroot . '/login/index.php';
     }
     $this->content->text .= '
         <style type="text/css">
         input.openid_login {
             background: url(' . $CFG->wwwroot . '/auth/openid/icon.gif) no-repeat;
             background-color: #fff;
             background-position: 0 50%;
             color: #000;
             padding-left: 18px;
         }
         </style>
         <form class="loginform" name="login" method="post" action="' . $endpoint . '" onsubmit="if (document.login.openid_url.value == \'\') return false;" >
             <table align="center" cellpadding="2" cellspacing="0" class="logintable">
     ';
     if ($user_loggedin) {
         $this->content->text .= '<tr><td class="c0 r0" colspan="2"><small>';
         if ($user_is_openid) {
             $this->content->text .= '<input type="hidden" name="openid_action" value="append" />';
             $this->content->text .= get_string('append_text', 'auth_openid');
         } else {
             $this->content->text .= '<input type="hidden" name="openid_action" value="change" />';
             $this->content->text .= get_string('change_text', 'auth_openid');
         }
         $this->content->text .= ':</small></td></tr>';
     }
     $this->content->text .= '
             <tr>
                 <td class="c0 r1" colspan="2">
                     <input class="openid_login" type="text" name="openid_url" size="18" value="" />
                 </td>
             </tr>
            ';
     $this->content->text .= '
             <tr>
                 <td class="c0 r2" align="left">
                     <a href="http://openid.net/" target="newWindow"><small>' . get_string('whats_this', 'auth_openid') . '</small></a>
                 </td>
                 <td class="c1 r2" align="center">
                     <input type="submit" value="' . get_string('login') . '" />
                 </td>
             </tr>
            ';
     $authplugin = get_auth_plugin('openid');
     if (!$user_loggedin || $authplugin->can_change_password()) {
         $this->content->text .= '<tr>
                 <td colspan="2" class="c1 r3" align="center">';
         if (!$user_loggedin) {
             $this->content->text .= '<a href="' . $CFG->wwwroot . '/auth/openid/fallback.php"><small>' . get_string('provider_offline', 'auth_openid') . "</small></a>\n";
         }
         if ($authplugin->can_change_password()) {
             $this->content->text .= '<a href="' . $authplugin->change_password_url() . '"><small>' . get_string('openid_manage', 'auth_openid') . "</small></a>\n";
         }
         $this->content->text .= '</td>
             </tr>
            ';
     }
     $this->content->text .= '</table>
     </form>
     ';
     return $this->content;
 }
Example #9
0
 function get_content()
 {
     global $USER, $CFG;
     // We don't want to show this block if OpenID auth isn't enabled
     if (!is_enabled_auth('openid')) {
         return '';
     }
     $config = get_config('auth/openid');
     $user_is_openid = $USER->auth == 'openid';
     // Check to see if the box should be displayed to a logged in user
     if ($USER->id > 0) {
         // We don't want to allow admin or guest users to be changed
         if ($USER->username == 'admin' || $USER->username == 'guest') {
             return '';
         }
         if (!isset($config->auth_openid_allow_account_change)) {
             $config->auth_openid_allow_account_change = 'true';
         }
         if (!isset($config->auth_openid_allow_muliple)) {
             $config->auth_openid_allow_muliple = 'true';
         }
         $allow_change = $config->auth_openid_allow_account_change == 'true';
         $allow_append = $config->auth_openid_allow_muliple == 'true';
         if ($user_is_openid && !$allow_append || !$user_is_openid && !$allow_change) {
             return '';
         }
     }
     if ($this->content !== NULL) {
         return $this->content;
     }
     $this->content->footer = '';
     $this->content->text = '';
     $username = get_moodle_cookie() === 'nobody' ? '' : get_moodle_cookie();
     $user = get_complete_user_data('username', $username);
     if ($user->auth != 'openid' || $USER->id > 0) {
         $username = '';
     }
     if ($USER->id > 0) {
         $endpoint = $CFG->wwwroot . '/auth/openid/actions.php';
     } else {
         $endpoint = $CFG->wwwroot . '/login/index.php';
     }
     $this->content->text .= '
         <style type="text/css">
         input.openid_login {
             background: url(' . $CFG->wwwroot . '/auth/openid/icon.gif) no-repeat;
             background-color: #fff;
             background-position: 0 50%;
             color: #000;
             padding-left: 18px;
         }
         </style>
         <form class="loginform" name="login" method="post" action="' . $endpoint . '">
             <table align="center" cellpadding="2" cellspacing="0" class="logintable">
     ';
     if ($USER->id > 0) {
         $this->content->text .= '<tr><td class="c0 r0" colspan="2"><small>';
         if ($user_is_openid) {
             $this->content->text .= '<input type="hidden" name="openid_action" value="append" />';
             $this->content->text .= get_string('append_text', 'auth_openid');
         } else {
             $this->content->text .= '<input type="hidden" name="openid_action" value="change" />';
             $this->content->text .= get_string('change_text', 'auth_openid');
         }
         $this->content->text .= '</small></td></tr>';
     }
     $this->content->text .= '
             <tr>
                 <td class="c0 r1" colspan="2">
                     <input class="openid_login" type="text" name="openid_url" size="18" value="" />
                 </td>
             </tr>
             <tr>
                 <td colspan="2" class="c1 r2" align="right">
                     <a href="http://openid.net/"><small>' . get_string('whats_this', 'auth_openid') . '</small></a>
                     <input type="submit" value="' . get_string('login') . '" />
                 </td>
             </tr>
             <tr>
                 <td colspan="2" class="c1 r2" align="right">
                     <a href="' . $CFG->wwwroot . '/auth/openid/fallback.php"><small>' . get_string('provider_offline', 'auth_openid') . '</small></a>
                 </td>
         </table>
     </form>
     ';
     return $this->content;
 }