2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2002-2007 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=last_login 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=last_login WHERE member_id=$id";
64 $sql = "UPDATE ".TABLE_PREFIX."members SET status=".AT_STATUS_STUDENT.", creation_date=creation_date, last_login=last_login WHERE member_id=$id";
66 $result = mysql_query($sql, $db);
68 $msg->addFeedback('CONFIRM_GOOD');
70 header('Location: '.$_base_href.'login.php');
73 $msg->addError('CONFIRM_BAD');
76 $msg->addError('CONFIRM_BAD');
78 } else if (isset($_POST['submit'])) {
79 $_POST['email'] = $addslashes($_POST['email']);
81 $sql = "SELECT member_id, email, creation_date, status FROM ".TABLE_PREFIX."members WHERE email='$_POST[email]'";
82 $result = mysql_query($sql, $db);
84 if ($row = mysql_fetch_assoc($result)) {
86 if ($row['status'] == AT_STATUS_UNCONFIRMED) {
87 $code = substr(md5($row['email'] . $row['creation_date']. $row['member_id']), 0, 10);
88 $confirmation_link = $_base_href . 'confirm.php?id='.$row['member_id'].SEP.'m='.$code;
90 /* send the email confirmation message: */
91 require(AT_INCLUDE_PATH . 'classes/phpmailer/atutormailer.class.php');
92 $mail = new ATutorMailer();
94 $mail->From = $_config['contact_email'];
95 $mail->AddAddress($row['email']);
96 $mail->Subject = SITE_NAME . ': ' . _AT('email_confirmation_subject');
97 $mail->Body = _AT('email_confirmation_message', $_base_href, $confirmation_link)."\n\n";
100 $msg->addFeedback('CONFIRMATION_SENT');
102 $msg->addFeedback('ACCOUNT_CONFIRMED');
105 header('Location: '.$_base_href.'login.php');
108 $msg->addError('EMAIL_NOT_FOUND');
112 require(AT_INCLUDE_PATH.'header.inc.php'); ?>
114 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
116 <div class="input-form" style="max-width: 400px">
118 <p><?php echo _AT('send_confirmation'); ?></p>
122 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="email"><?php echo _AT('email'); ?></label><br />
123 <input type="text" name="email" id="email" size="50" />
126 <div class="row buttons">
127 <input type="submit" name="submit" value="<?php echo _AT('send'); ?>" />
128 <input type="submit" name="cancel" value="<?php echo _AT('cancel'); ?>" />
133 <?php require(AT_INCLUDE_PATH.'footer.inc.php'); ?>