forked from inclusive-design/AChecker
/
confirm.php
147 lines (122 loc) · 3.88 KB
/
confirm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/************************************************************************/
/* AChecker */
/************************************************************************/
/* Copyright (c) 2008 - 2011 */
/* Inclusive Design Institute */
/* */
/* This program is free software. You can redistribute it and/or */
/* modify it under the terms of the GNU General Public License */
/* as published by the Free Software Foundation. */
/************************************************************************/
// $Id$
$_user_location = 'public';
define('AC_INCLUDE_PATH', 'include/');
require(AC_INCLUDE_PATH.'vitals.inc.php');
require_once(AC_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');
if (isset($_POST['cancel'])) {
$msg->addFeedback('CANCELLED');
header('Location: '.$_base_href.'login.php');
exit;
}
if (isset($_GET['e'], $_GET['id'], $_GET['m']))
{
$id = intval($_GET['id']);
$m = $_GET['m'];
$e = $addslashes($_GET['e']);
$usersDAO = new UsersDAO();
if ($row = $usersDAO->getUserByID($id))
{
$code = substr(md5($_GET['e'] . $row['creation_date'] . $id), 0, 10);
if ($code == $m)
{
$usersDAO->setEmail($id, $e);
$msg->addFeedback('CONFIRM_GOOD');
header('Location: '.$_base_href.'index.php');
exit;
}
else
{
$msg->addError('CONFIRM_BAD');
}
}
else
{
$msg->addError('CONFIRM_BAD');
}
}
else if (isset($_GET['id'], $_GET['m']))
{
$id = intval($_GET['id']);
$m = $_GET['m'];
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByID($id);
if ($row['status'] == AC_STATUS_UNCONFIRMED)
{
$code = substr(md5($row['email'] . $row['creation_date'] . $id), 0, 10);
if ($code == $m)
{
$usersDAO->setStatus($id, AC_STATUS_ENABLED);
$msg->addFeedback('CONFIRM_GOOD');
header('Location: '.$_base_href.'login.php');
exit;
}
else
{
$msg->addError('CONFIRM_BAD');
}
}
else
{
$msg->addError('CONFIRM_BAD');
}
}
else if (isset($_POST['submit'])) {
$_POST['email'] = $addslashes($_POST['email']);
$usersDAO = new UsersDAO();
$row = $usersDAO->getUserByEmail($_POST['email']);
if ($row)
{
if ($row['status'] == AC_STATUS_UNCONFIRMED)
{
$code = substr(md5($row['email'] . $row['creation_date']. $row['user_id']), 0, 10);
$confirmation_link = $_base_href . 'confirm.php?id='.$row['user_id'].SEP.'m='.$code;
/* send the email confirmation message: */
require(AC_INCLUDE_PATH . 'classes/phpmailer/acheckermailer.class.php');
$mail = new ACheckerMailer();
$mail->From = $_config['contact_email'];
$mail->AddAddress($row['email']);
$mail->Subject = SITE_NAME . ': ' . _AC('email_confirmation_subject');
$mail->Body = _AC('email_confirmation_message', $_base_href, $confirmation_link)."\n\n";
$mail->Send();
$msg->addFeedback('CONFIRMATION_SENT');
}
else
{
$msg->addFeedback('ACCOUNT_CONFIRMED');
}
header('Location: '.$_base_href.'login.php');
exit;
}
else
{
$msg->addError('EMAIL_NOT_FOUND');
}
}
require(AC_INCLUDE_PATH.'header.inc.php'); ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="form">
<div class="input-form" style="max-width: 400px">
<div class="row">
<p><?php echo _AC('send_confirmation'); ?></p>
</div>
<div class="row">
<div class="required" title="<?php echo _AC('required_field'); ?>">*</div><label for="email"><?php echo _AC('email_address'); ?></label><br />
<input type="text" name="email" id="email" size="50" />
</div>
<div class="row buttons">
<input type="submit" name="submit" value="<?php echo _AC('send'); ?>" />
<input type="submit" name="cancel" value="<?php echo _AC('cancel'); ?>" />
</div>
</div>
</form>
<?php require(AC_INCLUDE_PATH.'footer.inc.php'); ?>