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 (!method_exists($authplugin, 'user_create')) {
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 $authplugin = get_auth_plugin($CFG->registerauth
);
31 $confirmed = $authplugin->user_confirm($username, $usersecret);
33 if ($confirmed == AUTH_CONFIRM_ALREADY
) {
34 $user = get_complete_user_data('username', $username);
35 print_header(get_string("alreadyconfirmed"), get_string("alreadyconfirmed"), "", "");
36 echo "<center><h3>".get_string("thanks").", ". fullname($user) . "</h3>\n";
37 echo "<h4>".get_string("alreadyconfirmed")."</h4>\n";
38 echo "<h3> -> <a href=\"$CFG->wwwroot/course/\">".get_string("courses")."</a></h3></center>\n";
42 if ($confirmed == AUTH_CONFIRM_OK
) {
43 // Activate new user if necessary
44 $authplugin = get_auth_plugin($CFG->registerauth
);
45 if (method_exists($authplugin, 'user_activate')) {
46 if (!$authplugin->user_activate($username)) {
47 error('Could not activate this user!');
51 // The user has confirmed successfully, let's log them in
53 if (!$USER = get_complete_user_data('username', $username)) {
54 error("Something serious is wrong with the database");
57 set_moodle_cookie($USER->username
);
59 if ( ! empty($SESSION->wantsurl
) ) { // Send them where they were going
60 $goto = $SESSION->wantsurl
;
61 unset($SESSION->wantsurl
);
65 print_header(get_string("confirmed"), get_string("confirmed"), "", "");
66 echo "<center><h3>".get_string("thanks").", ". fullname($USER) . "</h3>\n";
67 echo "<h4>".get_string("confirmed")."</h4>\n";
68 echo "<h3> -> <a href=\"$CFG->wwwroot/course/\">".get_string("courses")."</a></h3></center>\n";
72 error("Invalid confirmation data");
75 error(get_string("errorwhenconfirming"));
78 redirect("$CFG->wwwroot/");