-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpassword_double_opt.php
More file actions
199 lines (166 loc) · 9.29 KB
/
password_double_opt.php
File metadata and controls
199 lines (166 loc) · 9.29 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<?php
/*------------------------------------------------------------------------------
$Id: password_double_opt.php,v 1.0
XTC-NEWSLETTER_RECIPIENTS RC1 - Contribution for XT-Commerce http://www.xt-commerce.com
by Matthias Hinsche http://www.gamesempire.de
Copyright (c) 2003 XT-Commerce
-----------------------------------------------------------------------------------------
(c) 2012 Self-Commerce www.self-commerce.de
based on:
(c) 2000-2001 The Exchange Project (earlier name of osCommerce)
(c) 2002-2003 osCommerce www.oscommerce.com
(c) 2003 nextcommerce www.nextcommerce.org
Released under the GNU General Public License
---------------------------------------------------------------------------------------*/
require ('includes/application_top.php');
// create smarty elements
$smarty = new Smarty;
// include boxes
require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
// include needed functions
require_once (DIR_FS_INC.'xtc_render_vvcode.inc.php');
require_once (DIR_FS_INC.'xtc_random_charcode.inc.php');
require_once (DIR_FS_INC.'xtc_encrypt_password.inc.php');
require_once (DIR_FS_INC.'xtc_validate_password.inc.php');
require_once (DIR_FS_INC.'xtc_rand.inc.php');
$case = double_opt;
$info_message = TEXT_PASSWORD_FORGOTTEN;
if (isset ($_GET['action']) && ($_GET['action'] == 'first_opt_in')) {
$check_customer_query = xtc_db_query("select customers_email_address, customers_id from ".TABLE_CUSTOMERS." where customers_email_address = '".xtc_db_input($_POST['email'])."'");
$check_customer = xtc_db_fetch_array($check_customer_query);
$vlcode = xtc_random_charcode(32);
$link = xtc_href_link(FILENAME_PASSWORD_DOUBLE_OPT, 'action=verified&customers_id='.$check_customer['customers_id'].'&key='.$vlcode, 'NONSSL');
// assign language to template for caching
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
$smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
// assign vars
$smarty->assign('EMAIL', $check_customer['customers_email_address']);
$smarty->assign('LINK', $link);
// dont allow cache
$smarty->caching = false;
// create mails
$html_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/password_verification_mail.html');
$txt_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/password_verification_mail.txt');
if ($_POST['vvcode'] == $_SESSION['vvcode']) {
if (!xtc_db_num_rows($check_customer_query)) {
$case = wrong_mail;
$info_message = TEXT_EMAIL_ERROR;
} else {
$case = first_opt_in;
xtc_db_query("update ".TABLE_CUSTOMERS." set password_request_key = '".$vlcode."' where customers_id = '".$check_customer['customers_id']."'");
xtc_php_mail(EMAIL_SUPPORT_ADDRESS, EMAIL_SUPPORT_NAME, $check_customer['customers_email_address'], '', '', EMAIL_SUPPORT_REPLY_ADDRESS, EMAIL_SUPPORT_REPLY_ADDRESS_NAME, '', '', TEXT_EMAIL_PASSWORD_FORGOTTEN, $html_mail, $txt_mail);
}
} else {
$case = code_error;
$info_message = TEXT_CODE_ERROR;
}
}
// Verification
if (isset ($_GET['action']) && ($_GET['action'] == 'verified')) {
$check_customer_query = xtc_db_query("select customers_id, customers_email_address, password_request_key from ".TABLE_CUSTOMERS." where customers_id = '".(int)$_GET['customers_id']."' and password_request_key = '".xtc_db_input($_GET['key'])."'");
$check_customer = xtc_db_fetch_array($check_customer_query);
if (!xtc_db_num_rows($check_customer_query) || $_GET['key']=="") {
$case = no_account;
$info_message = TEXT_NO_ACCOUNT;
} else {
$newpass = xtc_create_random_value(ENTRY_PASSWORD_MIN_LENGTH);
$crypted_password = xtc_encrypt_password($newpass);
xtc_db_query("update ".TABLE_CUSTOMERS." set customers_password = '".$crypted_password."' where customers_email_address = '".xtc_db_input($check_customer['customers_email_address'])."'");
xtc_db_query("update ".TABLE_CUSTOMERS." set password_request_key = '' where customers_id = '".$check_customer['customers_id']."'");
// assign language to template for caching
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
$smarty->assign('logo_path', HTTP_SERVER.DIR_WS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/img/');
// assign vars
$smarty->assign('EMAIL', $check_customer['customers_email_address']);
$smarty->assign('NEW_PASSWORD', $newpass);
// dont allow cache
$smarty->caching = false;
// create mails
$html_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/new_password_mail.html');
$txt_mail = $smarty->fetch(CURRENT_TEMPLATE.'/mail/'.$_SESSION['language'].'/new_password_mail.txt');
xtc_php_mail(EMAIL_SUPPORT_ADDRESS, EMAIL_SUPPORT_NAME, $check_customer['customers_email_address'], '', '', EMAIL_SUPPORT_REPLY_ADDRESS, EMAIL_SUPPORT_REPLY_ADDRESS_NAME, '', '', TEXT_EMAIL_PASSWORD_NEW_PASSWORD, $html_mail, $txt_mail);
if (!isset ($mail_error)) {
xtc_redirect(xtc_href_link(FILENAME_LOGIN, 'info_message='.urlencode(TEXT_PASSWORD_SENT), 'SSL', true, false));
}
}
}
$breadcrumb->add(NAVBAR_TITLE_PASSWORD_DOUBLE_OPT, xtc_href_link(FILENAME_PASSWORD_DOUBLE_OPT, '', 'NONSSL'));
require (DIR_WS_INCLUDES.'header.php');
switch ($case) {
case first_opt_in :
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
$smarty->assign('info_message', $info_message);
$smarty->assign('info_message', TEXT_LINK_MAIL_SENDED);
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_messages.html');
break;
case second_opt_in :
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
$smarty->assign('info_message', $info_message);
// $smarty->assign('info_message', TEXT_PASSWORD_MAIL_SENDED);
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_messages.html');
break;
case code_error :
$smarty->assign('VVIMG', '<img src="'.FILENAME_DISPLAY_VVCODES.'" alt ="" />');
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
$smarty->assign('info_message', $info_message);
$smarty->assign('message', TEXT_PASSWORD_FORGOTTEN);
$smarty->assign('SHOP_NAME', STORE_NAME);
$smarty->assign('FORM_ACTION', xtc_draw_form('sign', xtc_href_link(FILENAME_PASSWORD_DOUBLE_OPT, 'action=first_opt_in', 'NONSSL')));
$smarty->assign('INPUT_EMAIL', xtc_draw_input_field('email', xtc_db_input($_POST['email'])));
$smarty->assign('INPUT_CODE', xtc_draw_input_field('vvcode', '', 'size="6" maxlenght="6"', false, '', false));
$smarty->assign('BUTTON_SEND', xtc_image_submit('button_send.gif', IMAGE_BUTTON_LOGIN));
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_double_opt_in.html');
break;
case wrong_mail :
$smarty->assign('VVIMG', '<img src="'.FILENAME_DISPLAY_VVCODES.'" alt ="" />');
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
$smarty->assign('info_message', $info_message);
$smarty->assign('message', TEXT_PASSWORD_FORGOTTEN);
$smarty->assign('SHOP_NAME', STORE_NAME);
$smarty->assign('FORM_ACTION', xtc_draw_form('sign', xtc_href_link(FILENAME_PASSWORD_DOUBLE_OPT, 'action=first_opt_in', 'NONSSL')));
$smarty->assign('INPUT_EMAIL', xtc_draw_input_field('email', xtc_db_input($_POST['email'])));
$smarty->assign('INPUT_CODE', xtc_draw_input_field('vvcode', '', 'size="6" maxlenght="6"', false, '', false));
$smarty->assign('BUTTON_SEND', xtc_image_submit('button_send.gif', IMAGE_BUTTON_LOGIN));
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_double_opt_in.html');
break;
case no_account :
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
$smarty->assign('info_message', $info_message);
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_messages.html');
break;
case double_opt :
$smarty->assign('VVIMG', '<img src="'.FILENAME_DISPLAY_VVCODES.'" alt ="" />');
$smarty->assign('text_heading', HEADING_PASSWORD_FORGOTTEN);
// $smarty->assign('info_message', $info_message);
$smarty->assign('message', TEXT_PASSWORD_FORGOTTEN);
$smarty->assign('SHOP_NAME', STORE_NAME);
$smarty->assign('FORM_ACTION', xtc_draw_form('sign', xtc_href_link(FILENAME_PASSWORD_DOUBLE_OPT, 'action=first_opt_in', 'NONSSL')));
$smarty->assign('INPUT_EMAIL', xtc_draw_input_field('email', xtc_db_input($_POST['email'])));
$smarty->assign('INPUT_CODE', xtc_draw_input_field('vvcode', '', 'size="6" maxlenght="6"', false, '', false));
$smarty->assign('BUTTON_SEND', xtc_image_submit('button_continue.gif', IMAGE_BUTTON_LOGIN));
$smarty->assign('FORM_END', '</form>');
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/password_double_opt_in.html');
break;
}
$smarty->assign('main_content', $main_content);
$smarty->assign('language', $_SESSION['language']);
$smarty->caching = 0;
if (!defined(RM))
$smarty->loadfilter('output', 'note');
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include ('includes/application_bottom.php');
?>