forked from pal/prestashop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
identity.php
85 lines (71 loc) · 2.76 KB
/
identity.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
<?php
/* SSL Management */
$useSSL = true;
include(dirname(__FILE__).'/config/config.inc.php');
include(dirname(__FILE__).'/init.php');
if (!$cookie->isLogged())
Tools::redirect('authentication.php?back=identity.php');
$customer = new Customer(intval($cookie->id_customer));
if (sizeof($_POST))
{
$exclusion = array('secure_key', 'old_passwd', 'passwd', 'active', 'date_add', 'date_upd', 'last_passwd_gen', 'newsletter_date_add');
$fields = $customer->getFields();
foreach ($fields AS $key => $value)
if (!in_array($key, $exclusion))
$customer->{$key} = key_exists($key, $_POST) ? trim($_POST[$key]) : 0;
}
if (isset($_POST['years']) AND isset($_POST['months']) AND isset($_POST['days']))
$customer->birthday = intval($_POST['years']).'-'.intval($_POST['months']).'-'.intval($_POST['days']);
$errors = array();
if (Tools::isSubmit('submitIdentity'))
{
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) AND
!(Tools::getValue('months') == '' AND Tools::getValue('days') == '' AND Tools::getValue('years') == ''))
$errors[] = Tools::displayError('invalid birthday');
else
{
$customer->birthday = (empty($_POST['years']) ? '' : intval($_POST['years']).'-'.intval($_POST['months']).'-'.intval($_POST['days']));
$_POST['old_passwd'] = trim($_POST['old_passwd']);
if (empty($_POST['old_passwd']) OR (Tools::encrypt($_POST['old_passwd']) != $cookie->passwd))
$errors[] = Tools::displayError('your current password is not that one');
elseif ($_POST['passwd'] != $_POST['confirmation'])
$errors[] = Tools::displayError('password and confirmation do not match');
else
$errors = $customer->validateControler();
if (!sizeof($errors))
{
$customer->lastname = Tools::strtoupper($customer->lastname);
$customer->firstname = Tools::ucfirst(Tools::strtolower($customer->firstname));
if (Tools::getValue('passwd'))
$cookie->passwd = $customer->passwd;
if ($customer->update())
{
$cookie->customer_lastname = $customer->lastname;
$cookie->customer_firstname = $customer->firstname;
$smarty->assign('confirmation', 1);
}
else
$errors[] = Tools::displayError('impossible to update information');
}
}
}
else
$_POST = array_map('stripslashes', $customer->getFields());
if ($customer->birthday)
$birthday = explode('-', $customer->birthday);
else
$birthday = array('-', '-', '-');
/* Generate years, months and days */
$smarty->assign(array(
'years' => Tools::dateYears(),
'sl_year' => $birthday[0],
'months' => Tools::dateMonths(),
'sl_month' => $birthday[1],
'days' => Tools::dateDays(),
'sl_day' => $birthday[2],
'errors' => $errors));
Tools::safePostVars();
include(dirname(__FILE__).'/header.php');
$smarty->display(_PS_THEME_DIR_.'identity.tpl');
include(dirname(__FILE__).'/footer.php');
?>