php include_once _cfg init php _loader- addPost purse chgData _loader-

 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
<?php
include_once('_cfg/init.php');
$_loader->addPost('purse', 'chgData');
$_loader->addPost('password,confirmation', 'chgPassword');
$_loader->setDefault('show');
$_loader->process();
function show()
{
global $data,$user,$messenger;
$User = $user->getCurrent();
$aPurse = reformPurseData($user->getPurses());
showFile(TPL_PATH.'global.tpl', array(
'szTemplate' => TPL_PATH.FILE_NAME.'.tpl',
'aMeta' => array(
'title' => __PROFILE_TITLE,
),
'User' => $User,
'aData' => array(
'User' => $User,
'aPurse' => $aPurse,
'szMsg' => $messenger->getMessage(),
),
));
$messenger->clearMessageBuffer();
global $Application;
$Application->output();
}
function chgData()
{
global $user,$data,$messenger,$Application;
$aPost = $_POST;
$User = $user->getCurrent();
$aPurse = getPurseNames($user->getPurses());
// Создаю кошельки
foreach ($aPost['purse'] as $szName=>$szNumber) {
if (!empty($szNumber) &&
(strtoupper(substr($szName, 2, 1)) == strtoupper(substr($szNumber, 0, 1)) &&
!in_array(strtoupper($szName), $aPurse))
) {
$data->exec('once', 'insert', TYPE_WM_PURSE, array(
'name' => strtoupper($szName),
'number' => $User['email'],
'user_id' => $User['id'],
'datetime_add' => date('Y-m-d H:i:s'),
));
}
}
if (!empty($aPost['icq'])) {
$user->update(array('icq' => $aPost['icq']));
}
$messenger->setMessage(__USER_UPDATED);
$Application->jump(HTTP_ROOT.'back.php?return=1');
}
function chgPassword()
{
global $user,$messenger;
$User = $user->getCurrent();
$nError = $user->chgPassword($_POST['password'], $_POST['confirmation']);
switch ($nError)
{
//case 1: $messenger->setMessage('Ошибка! Введен не правильный пароль (старый).'); break;
//case 2: $messenger->setMessage('Ошибка! Старый и новый пароль совпадают. Пароль не был обновлен.'); break;
case 3: $messenger->setMessage(__USER_ERROR); break;
default: $messenger->setMessage(__USER_UPDATED);
}
global $Application;
$Application->jump(HTTP_ROOT.'back.php?return=1');
}
?>