3 require_once("../config.php");
4 require_once("../auth/$CFG->auth/lib.php");
6 if (isset($_GET['p']) and isset($_GET['s']) ) { # p = user.secret s = user.username
8 $user = get_complete_user_data('username', $_GET['s']);
12 if ($user->confirmed
) {
13 print_header(get_string("alreadyconfirmed"), get_string("alreadyconfirmed"), "", "");
14 echo "<center><h3>".get_string("thanks").", ". fullname($user) . "</h3>\n";
15 echo "<h4>".get_string("alreadyconfirmed")."</h4>\n";
16 echo "<h3> -> <a href=\"$CFG->wwwroot/course/\">".get_string("courses")."</a></h3></center>\n";
21 if ($user->secret
== $_GET['p']) { // They have provided the secret key to get in
23 if (!set_field("user", "confirmed", 1, "id", $user->id
)) {
24 error("Could not confirm this user!");
26 if (!set_field("user", "firstaccess", time(), "id", $user->id
)) {
27 error("Could not set this user's first access date!");
29 if (isset($CFG->auth_user_create
) and $CFG->auth_user_create
==1 and function_exists('auth_user_activate') ) {
30 if (!auth_user_activate($user->username
)) {
31 error("Could not activate this user!");
35 // The user has confirmed successfully, let's log them in
37 if (!$USER = get_complete_user_data('username', $user->username
)) {
38 error("Something serious is wrong with the database");
41 set_moodle_cookie($USER->username
);
43 if ( ! empty($SESSION->wantsurl
) ) { // Send them where they were going
44 $goto = $SESSION->wantsurl
;
45 unset($SESSION->wantsurl
);
49 print_header(get_string("confirmed"), get_string("confirmed"), "", "");
50 echo "<center><h3>".get_string("thanks").", ". fullname($USER) . "</h3>\n";
51 echo "<h4>".get_string("confirmed")."</h4>\n";
52 echo "<h3> -> <a href=\"$CFG->wwwroot/course/\">".get_string("courses")."</a></h3></center>\n";
57 error("Invalid confirmation data");
61 error(get_string("errorwhenconfirming"));
64 redirect("$CFG->wwwroot/");