Ejemplo n.º 1
0
 /**
  * 生成密码
  */
 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!');
 }
Ejemplo n.º 2
0
 /**
  * 删除密码
  */
 function delete()
 {
     $id = I('id');
     $map['user_id'] = $this->uid;
     $map['id'] = pdm_code($id, 'DECODE');
     $map['status'] = 1;
     // 获取密码信息
     $data = $this->password->field('category_id,delete_time')->where($map)->find();
     $expire_time = $data['delete_time'] + PDM_ALLOW_DELETE_DAY * 86400;
     if (NOW_TIME <= $expire_time) {
         $this->error('这个密码放入回收站没有超过' . PDM_ALLOW_DELETE_DAY . '天,你不能删除它!');
     }
     if ($this->password->where($map)->delete() > 0) {
         $this->_update_password($data['category_id']);
         $this->success('密码删除成功!');
     } else {
         $this->error('密码删除失败!');
     }
 }
Ejemplo n.º 3
0
 /**
  * 重置密码
  */
 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();
     }
 }
Ejemplo n.º 4
0
 function search()
 {
     $wd = trim(I('query'));
     if ($wd == null) {
         return null;
     }
     $map['userid'] = $this->uid;
     $map['title'] = array('LIKE', '%' . $wd . '%');
     $_list = $this->password->field('id,title')->where($map)->select();
     foreach ($_list as $k => $v) {
         $tmp[$k]['id'] = pdm_code($v['id']);
         $tmp[$k]['name'] = $v['title'];
     }
     unset($_list);
     $this->ajaxReturn($tmp);
 }