[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 <?php 2 3 // This file is part of Moodle - http://moodle.org/ 4 // 5 // Moodle is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // Moodle is distributed in the hope that it will be useful, 11 // but WITHOUT ANY WARRANTY; without even the implied warranty of 12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 // GNU General Public License for more details. 14 // 15 // You should have received a copy of the GNU General Public License 16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 17 18 /** 19 * Confirm self registered user. 20 * 21 * @package core 22 * @subpackage auth 23 * @copyright 1999 Martin Dougiamas http://dougiamas.com 24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 25 */ 26 27 require('../config.php'); 28 29 $data = optional_param('data', '', PARAM_RAW); // Formatted as: secret/username 30 31 $p = optional_param('p', '', PARAM_ALPHANUM); // Old parameter: secret 32 $s = optional_param('s', '', PARAM_RAW); // Old parameter: username 33 34 $PAGE->set_url('/login/confirm.php'); 35 $PAGE->set_context(context_system::instance()); 36 37 if (empty($CFG->registerauth)) { 38 print_error('cannotusepage2'); 39 } 40 $authplugin = get_auth_plugin($CFG->registerauth); 41 42 if (!$authplugin->can_confirm()) { 43 print_error('cannotusepage2'); 44 } 45 46 if (!empty($data) || (!empty($p) && !empty($s))) { 47 48 if (!empty($data)) { 49 $dataelements = explode('/', $data, 2); // Stop after 1st slash. Rest is username. MDL-7647 50 $usersecret = $dataelements[0]; 51 $username = $dataelements[1]; 52 } else { 53 $usersecret = $p; 54 $username = $s; 55 } 56 57 $confirmed = $authplugin->user_confirm($username, $usersecret); 58 59 if ($confirmed == AUTH_CONFIRM_ALREADY) { 60 $user = get_complete_user_data('username', $username); 61 $PAGE->navbar->add(get_string("alreadyconfirmed")); 62 $PAGE->set_title(get_string("alreadyconfirmed")); 63 $PAGE->set_heading($COURSE->fullname); 64 echo $OUTPUT->header(); 65 echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter'); 66 echo "<p>".get_string("alreadyconfirmed")."</p>\n"; 67 echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses')); 68 echo $OUTPUT->box_end(); 69 echo $OUTPUT->footer(); 70 exit; 71 72 } else if ($confirmed == AUTH_CONFIRM_OK) { 73 74 // The user has confirmed successfully, let's log them in 75 76 if (!$user = get_complete_user_data('username', $username)) { 77 print_error('cannotfinduser', '', '', s($username)); 78 } 79 80 if (!$user->suspended) { 81 complete_user_login($user); 82 83 \core\session\manager::apply_concurrent_login_limit($user->id, session_id()); 84 85 if ( ! empty($SESSION->wantsurl) ) { // Send them where they were going. 86 $goto = $SESSION->wantsurl; 87 unset($SESSION->wantsurl); 88 redirect($goto); 89 } 90 } 91 92 $PAGE->navbar->add(get_string("confirmed")); 93 $PAGE->set_title(get_string("confirmed")); 94 $PAGE->set_heading($COURSE->fullname); 95 echo $OUTPUT->header(); 96 echo $OUTPUT->box_start('generalbox centerpara boxwidthnormal boxaligncenter'); 97 echo "<h3>".get_string("thanks").", ". fullname($USER) . "</h3>\n"; 98 echo "<p>".get_string("confirmed")."</p>\n"; 99 echo $OUTPUT->single_button("$CFG->wwwroot/course/", get_string('courses')); 100 echo $OUTPUT->box_end(); 101 echo $OUTPUT->footer(); 102 exit; 103 } else { 104 print_error('invalidconfirmdata'); 105 } 106 } else { 107 print_error("errorwhenconfirming"); 108 } 109 110 redirect("$CFG->wwwroot/");
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |