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 builder() { $request = I('post.'); $alen = $request['alen']; $plen = $request['plen']; $char = $request['char']; $type = $request['type']; $chars = ''; if ($char == 1) { $chars = '_+=@$()[]0Oo1Ll'; } $data['user'] = pdm_rand_code($alen, $type, $chars); $data['pwd'] = pdm_rand_code($plen, $type, $chars); if ($data['user'] != '' && $data['pwd'] != '') { $data_history['user_id'] = $this->uid; $data_history['uname'] = pdm_encode($data['user'], $this->auth_code); $data_history['pwd'] = pdm_encode($data['pwd'], $this->auth_code); $data_history['create_time'] = NOW_TIME; $data_history['create_ip'] = get_client_ip(1); if ($this->history->add($data_history) !== false) { $lastId = $this->history->getLastInsID(); $data['signature'] = pdm_code($lastId); $this->jsonRender($data); } } $this->jsonRender(null, -1, 'error!'); }
function add() { if (IS_POST) { $post = I('post.'); $this->_check_form($post); $data['uname'] = pdm_encode($post['uname'], $this->auth_code); $data['pwd'] = pdm_encode($post['pwd'], $this->auth_code); $data['category_id'] = $post['category_id']; $data['user_id'] = $this->uid; $data['add_time'] = NOW_TIME; $data['add_ip'] = get_client_ip(1); $data['note'] = $post['note']; $data['title'] = $post['title']; if ($this->password->add($data) !== false) { $map_categories['id'] = $post['category_id']; $map_categories['user_id'] = $this->uid; $data_categories['sum'] = array('exp', 'sum+1'); $this->categories->where($map_categories)->save($data_categories); $this->success('密码添加成功!', pdm_ux('index')); } else { $this->error('密码添加失败!'); } } else { $get = I('get.'); if ($get['sign'] != '') { $map_history['id'] = pdm_code($get['sign'], 'DECODE'); $map_history['user_id'] = $this->uid; $data_history = $this->history->where($map_history)->field('uname,pwd')->find(); if ($data_history == null) { $this->error('参数不正确!'); } $data['uname'] = pdm_decode($data_history['uname'], $this->auth_code); $data['pwd'] = pdm_decode($data_history['pwd'], $this->auth_code); } $map['user_id'] = $this->uid; $list = $this->categories->where($map)->order('listorder')->select(); import('@.Rover.Tree'); $tree = new Tree(); $tree->init($list); $str = "<option \$css value=\$id \$selected>\$spacer\$title</option>"; $selected = $tree->get_tree(0, $str, $get['typeid']); $this->assign('selected', $selected); $this->assign('data', $data); $this->display('mod'); } }
/** * 重置密码 */ function resetpassword() { if (IS_POST) { $post = I('post.'); if ($post['password'] == '') { $this->error('密码不能为空!'); } $id = pdm_code($post['id'], 'DECODE'); if ($id == null) { $this->error(PDM_ERROR); } $map['id'] = $id; $data['password'] = pdm_encode($post['password']); if ($this->user->where($map)->save($data) !== false) { $this->success('密码重置成功!', pdm_ux('login')); } else { $this->error('密码重置失败!'); } } else { $sign = I('sign'); $map['email'] = pdm_code($sign, 'DECODE'); $map['email_auth'] = 1; $data = $this->user->where($map)->field('id,email')->find(); if ($data == null) { $this->error('链接失效了!', pdm_ux('login')); } $this->assign('data', $data); $this->display(); } }