3 require_once("../config.php");
5 $data = optional_param('data', '', PARAM_CLEAN
); // Formatted as: secret/username
7 $p = optional_param('p', '', PARAM_ALPHANUM
); // Old parameter: secret
8 $s = optional_param('s', '', PARAM_CLEAN
); // Old parameter: username
10 if (empty($CFG->registerauth
)) {
11 error("Sorry, you may not use this page.");
13 $authplugin = get_auth_plugin($CFG->registerauth
);
15 if (!$authplugin->can_confirm()) {
16 error("Sorry, you may not use this page.");
19 if (!empty($data) ||
(!empty($p) && !empty($s))) {
22 $dataelements = explode('/',$data);
23 $usersecret = $dataelements[0];
24 $username = $dataelements[1];
30 $confirmed = $authplugin->user_confirm($username, $usersecret);
32 if ($confirmed == AUTH_CONFIRM_ALREADY
) {
33 $user = get_complete_user_data('username', $username);
34 print_header(get_string("alreadyconfirmed"), get_string("alreadyconfirmed"), array(), "");
35 print_box_start('generalbox centerpara boxwidthnormal boxaligncenter');
36 echo "<h3>".get_string("thanks").", ". fullname($user) . "</h3>\n";
37 echo "<p>".get_string("alreadyconfirmed")."</p>\n";
38 print_single_button("$CFG->wwwroot/course/", null, get_string('courses'));
43 } else if ($confirmed == AUTH_CONFIRM_OK
) {
45 // The user has confirmed successfully, let's log them in
47 if (!$USER = get_complete_user_data('username', $username)) {
48 error("Something serious is wrong with the database");
51 set_moodle_cookie($USER->username
);
53 if ( ! empty($SESSION->wantsurl
) ) { // Send them where they were going
54 $goto = $SESSION->wantsurl
;
55 unset($SESSION->wantsurl
);
59 print_header(get_string("confirmed"), get_string("confirmed"), array(), "");
60 print_box_start('generalbox centerpara boxwidthnormal boxaligncenter');
61 echo "<h3>".get_string("thanks").", ". fullname($USER) . "</h3>\n";
62 echo "<p>".get_string("confirmed")."</p>\n";
63 print_single_button("$CFG->wwwroot/course/", null, get_string('courses'));
68 error("Invalid confirmation data");
71 print_error("errorwhenconfirming");
74 redirect("$CFG->wwwroot/");