/** * 生成密码 */ 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 authentication() { if (IS_POST) { $post = I('post.'); if ($post['password'] == '') { $this->error('密码不能为空!'); } $post['auth_code'] = mt_rand('0, 100000') . pdm_rand_code(16); // if ($post ['auth_code'] == '') { // $this->error ( '加密KEY不能为空!' ); // } $id = pdm_code($post['id'], 'DECODE'); if ($id == null) { $this->error(PDM_ERROR); } $map['id'] = $id; $data['password'] = pdm_encode($post['password']); $data['email_auth'] = 1; $data['auth_code'] = pdm_encode(md5($post['auth_code'])); if ($this->user->where($map)->save($data) !== false) { // 清理多余帐号 $_email = $this->user->where($map)->getField('email'); $map_tmp['email'] = $_email; $map_tmp['email_auth'] = 0; $this->user->where($map_tmp)->delete(); $this->success('帐号激活成功!', pdm_ux('login')); } else { $this->error('帐号激活失败!'); } } else { $sign = I('sign'); $map['email'] = pdm_code($sign, 'DECODE'); $map['email_auth'] = 0; $data = $this->user->where($map)->field('id,email')->find(); if ($data == null) { $this->error('链接失效了!', pdm_ux('login')); } $this->assign('data', $data); $this->display(); } }