来源:自学PHP网 时间:2015-04-17 11:59 作者: 阅读:次
[导读] public function save_profile() {3 $user_info =@ ParamHolder::get(#39;user#39;, array());//获取数组4 if (sizeof($user_info) = 0) {5 $this-assign(#39;json#39;, To......
public function save_profile() {
3
$user_info =@ ParamHolder::get('user', array());//获取数组
4
if (sizeof($user_info) <= 0) {
5
$this->assign('json', Toolkit::jsonERR(__('Missing user information!')));
6
return '_result';
7
}
8
$passwd_changed = false;
9
try {
10
$o_user = new User(SessionHolder::get('user/id'));
11
if ($user_info['email'] != $o_user->email) {
12
/* Check duplicates */
13
if ($o_user->count("email=?", array($user_info['email'])) > 0) {
14
$this->assign('json', Toolkit::jsonERR(__('User E-mail address exists!')));
15
return '_result';
16
}
17
}
18
19
$o_user->set($user_info);
20
/* Check password */
21
$passwd_info =@ ParamHolder::get('passwd', array());
22
if (sizeof($passwd_info) != 2) {
23
$this->assign('json', Toolkit::jsonERR(__('Invalid Password!')));
24
return '_result';
25
}
26
27
if (strlen(trim($passwd_info['passwd'])) > 0 ||
28
www.2cto.com
29
strlen(trim($passwd_info['re_passwd'])) > 0) {
30
31
if ($passwd_info['passwd'] == $passwd_info['re_passwd']) {
32
33
$o_user->passwd = sha1($passwd_info['passwd']);
34
35
$passwd_changed = true;
36
}
37
}
38
39
$o_user->save(); //可以xo了 这里我不跟踪了 这个源码看的我蛋疼
40
41
} catch (Exception $ex) {
42
$this->assign('json', Toolkit::jsonERR($ex->getMessage()));
43
return '_result';
44
}
45
if ($passwd_changed) {
46
47
SessionHolder::destroy();
48
49
$this->assign('json', Toolkit::jsonOK(array('forward' => 'index.php')));
50
51
} else {
52
53
$forward_url = Html::uriquery('mod_user', 'edit_profile');
54
55
$this->assign('json', Toolkit::jsonOK(array('forward' => $forward_url)));
56
57
}
58
59
return '_result';
60
61
}
数据库user表结构
直接改一下包可以秒了
|
自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习
京ICP备14009008号-1@版权所有www.zixuephp.com
网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com