/** * 帐号登录 */ function login() { if (IS_POST) { $post = I('post.'); if ($post['email'] == '') { $this->error('邮件地址不能为空!'); } if ($post['verification_code'] != $_SESSION['verification_code']) { $this->error('你输入的验证码不正确!'); } if ($post['password'] == '') { $this->error('密码不能为空!'); } $map['email'] = $post['email']; $data = $this->user->where($map)->field('id,email,password,login_ip,login_time,email_auth,auth_code,timeout')->find(); if ($data == null || $data['email_auth'] == 0 || $post['password'] != pdm_decode($data['password'])) { $this->error('帐号或密码错误!'); } // 更新登录信息 $data_user['login_count'] = array('exp', 'login_count+1'); $data_user['login_ip'] = get_client_ip(1); $data_user['login_time'] = NOW_TIME; $this->user->where($map)->save($data_user); unset($data['password']); session('user', $data); session('pdm_timeout', NOW_TIME); redirect(pdm_ux('Console/Index/index')); } else { $this->display(); } }
function index() { $map['id'] = $this->uid; $data = $this->user->where($map)->field('id,email,password,login_count,register_time,register_ip,login_count,timeout')->find(); if (IS_POST) { $post = I('post.'); if ($post['opassword'] != '' || $post['password'] != '') { if ($post['opassword'] != pdm_decode($data['password'])) { $this->error('你的旧密码填写错误!'); } $data_user['password'] = pdm_encode($post['password']); } $data_user['timeout'] = $post['timeout']; if ($data_user['timeout'] < 1 || $data_user['timeout'] > 15) { $this->error('你填写的超时时间不在1~15分钟之内!'); } if ($this->user->where($map)->save($data_user) !== false) { $this->success('修改成功!'); } else { $this->error('修改失败!'); } } else { $map_secret['user_id'] = $this->uid; $data['password_sum'] = $this->password->where($map_secret)->count(); $this->assign('data', $data); $this->display(); } }
function view() { $id = I('id'); $map['user_id'] = $this->uid; $map['id'] = pdm_code($id, 'DECODE'); $data = $this->password->where($map)->field(true)->find(); if ($data == null) { $this->error('参数错误!'); } $data['uname'] = pdm_decode($data['uname'], $this->auth_code); $data['pwd'] = pdm_decode($data['pwd'], $this->auth_code); // 获取类别 $map_categories['id'] = $data['category_id']; $data['category_name'] = $this->categories->where($map_categories)->getField('title'); // 计算热点 $data_password['hits'] = array('exp', 'hits+1'); $this->password->where($map)->save($data_password); $this->assign('data', $data); $this->display(); }