2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2008 by Greg Gay, Joel Kronenberg & Heidi Hazelton*/
6 /* Adaptive Technology Resource Centre / University of Toronto */
9 /* This program is free software. You can redistribute it and/or */
10 /* modify it under the terms of the GNU General Public License */
11 /* as published by the Free Software Foundation. */
12 /************************************************************************/
15 $_user_location = 'public';
17 define('AT_INCLUDE_PATH', 'include/');
18 require(AT_INCLUDE_PATH.'vitals.inc.php');
20 if (isset($_POST['cancel'])) {
21 $msg->addFeedback('CANCELLED');
22 header('Location: '.$_base_href.'login.php');
26 if (isset($_GET['e'], $_GET['id'], $_GET['m'])) {
27 $id = intval($_GET['id']);
29 $e = $addslashes($_GET['e']);
31 $sql = "SELECT creation_date FROM ".TABLE_PREFIX."members WHERE member_id=$id";
32 $result = mysql_query($sql, $db);
33 if ($row = mysql_fetch_assoc($result)) {
34 $code = substr(md5($_GET['e'] . $row['creation_date'] . $id), 0, 10);
37 $sql = "UPDATE ".TABLE_PREFIX."members SET email='$_GET[e]', last_login=NOW(), creation_date=creation_date WHERE member_id=$id";
38 $result = mysql_query($sql, $db);
40 $msg->addFeedback('CONFIRM_GOOD');
42 header('Location: '.$_base_href.'users/index.php');
45 $msg->addError('CONFIRM_BAD');
48 $msg->addError('CONFIRM_BAD');
51 } else if (isset($_GET['id'], $_GET['m'])) {
52 $id = intval($_GET['id']);
55 $sql = "SELECT email, creation_date FROM ".TABLE_PREFIX."members WHERE member_id=$id AND status=".AT_STATUS_UNCONFIRMED;
56 $result = mysql_query($sql, $db);
57 if ($row = mysql_fetch_assoc($result)) {
58 $code = substr(md5($row['email'] . $row['creation_date'] . $id), 0, 10);
61 if (defined('AUTO_APPROVE_INSTRUCTORS') && AUTO_APPROVE_INSTRUCTORS) {
62 $sql = "UPDATE ".TABLE_PREFIX."members SET status=".AT_STATUS_INSTRUCTOR.", creation_date=creation_date, last_login=NOW() WHERE member_id=$id";
64 $sql = "UPDATE ".TABLE_PREFIX."members SET status=".AT_STATUS_STUDENT.", creation_date=creation_date, last_login=NOW() WHERE member_id=$id";
66 $result = mysql_query($sql, $db);
68 if (isset($_REQUEST["en_id"]) && $_REQUEST["en_id"] <> "")
70 $msg->addFeedback('CONFIRM_GOOD');
73 require (AT_INCLUDE_PATH.'html/auto_enroll_courses.inc.php');
74 unset($_SESSION['valid_user']);
75 unset($_SESSION['member_id']);
79 <h3>" . _AT('auto_enrolled_msg'). "<br /></h3>
82 require(AT_INCLUDE_PATH.'header.inc.php');
83 echo "<div class=\"input-form\">";
84 require(AT_INCLUDE_PATH.'html/auto_enroll_list_courses.inc.php');
85 echo '<p style="text-align:center"><a href="'. $_SERVER['PHP_SELF'] . '?auto_login=1&member_id='. $id .'">' . _AT("go_to_my_start_page") . '</a></p>';
87 require(AT_INCLUDE_PATH.'footer.inc.php');
92 $msg->addFeedback('CONFIRM_GOOD');
94 // enable auto login student into "my start page"
95 $_REQUEST["auto_login"] = 1;
96 $_REQUEST["member_id"] = $id;
99 $msg->addError('CONFIRM_BAD');
102 $msg->addError('CONFIRM_BAD');
104 } else if (isset($_POST['submit'])) {
105 $_POST['email'] = $addslashes($_POST['email']);
107 $sql = "SELECT member_id, email, creation_date, status FROM ".TABLE_PREFIX."members WHERE email='$_POST[email]'";
108 $result = mysql_query($sql, $db);
110 if ($row = mysql_fetch_assoc($result)) {
112 if ($row['status'] == AT_STATUS_UNCONFIRMED) {
113 $code = substr(md5($row['email'] . $row['creation_date']. $row['member_id']), 0, 10);
115 if ($_POST["en_id"] <> "")
116 $confirmation_link = $_base_href . 'confirm.php?id='.$row['member_id'].SEP.'m='.$code.'&en_id='.$_POST["en_id"];
118 $confirmation_link = $_base_href . 'confirm.php?id='.$row['member_id'].SEP.'m='.$code;
120 /* send the email confirmation message: */
121 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
122 $mail = new ATutorMailer();
124 $mail->From = $_config['contact_email'];
125 $mail->AddAddress($row['email']);
126 $mail->Subject = SITE_NAME . ': ' . _AT('email_confirmation_subject');
127 $mail->Body = _AT('email_confirmation_message', $_base_href, $confirmation_link)."\n\n";
130 $msg->addFeedback('CONFIRMATION_SENT');
132 $msg->addFeedback('ACCOUNT_CONFIRMED');
135 header('Location: '.$_base_href.'login.php');
138 $msg->addError('EMAIL_NOT_FOUND');
142 if (isset($_REQUEST['auto_login']))
145 $sql = "SELECT M.member_id, M.login, M.preferences, M.language FROM ".TABLE_PREFIX."members M WHERE M.member_id=".$_REQUEST["member_id"];
146 $result = mysql_query($sql, $db);
147 if ($row = mysql_fetch_assoc($result))
149 $_SESSION['valid_user'] = true;
150 $_SESSION['member_id'] = $_REQUEST["member_id"];
151 $_SESSION['course_id'] = 0;
152 $_SESSION['login'] = $row[login];
153 if ($row['preferences'] == "")
154 assign_session_prefs(unserialize(stripslashes($_config["pref_defaults"])));
156 assign_session_prefs(unserialize(stripslashes($row['preferences'])));
157 $_SESSION['is_guest'] = 0;
158 $_SESSION['lang'] = $row[lang];
159 session_write_close();
161 header('Location: '.AT_BASE_HREF.'bounce.php?course='.$_POST['course']);
166 require(AT_INCLUDE_PATH.'header.inc.php'); ?>
168 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
170 <div class="input-form" style="max-width: 400px">
172 <p><?php echo _AT('send_confirmation'); ?></p>
176 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="email"><?php echo _AT('email'); ?></label><br />
177 <input type="text" name="email" id="email" size="50" />
178 <input type="hidden" name="en_id" id="en_id" value="<?php echo $_REQUEST['en_id']; ?>" size="50" />
181 <div class="row buttons">
182 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" />
183 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
188 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>