public function update($id) { /* 获取下载数据 */ //TODO: 根据不同用户获取允许更改或添加的字段 $data = $this->field('download', true)->create(); if (!$data) { return false; } $file = json_decode(think_decrypt(I('post.file')), true); if (!empty($file)) { $data['file_id'] = $file['id']; $data['size'] = $file['size']; } else { $this->error = '获取上传文件信息失败!'; return false; } /* 添加或更新数据 */ if (empty($data['id'])) { //新增数据 $data['id'] = $id; $id = $this->add($data); if (!$id) { $this->error = '新增详细内容失败!'; return false; } } else { //更新数据 $status = $this->save($data); if (false === $status) { $this->error = '更新详细内容失败!'; return false; } } return true; }
/** * 用户邮箱验证 * @return void */ public function repwd() { $repwd = I('post.repwd'); $code = I('get.code'); $email = think_decrypt($code); //解密(此处未考虑加密时随机性,发送邮件链接会一致) $Model = M('root_admin'); if (!empty($email)) { $emailTime = $Model->field('this_time')->where("admin_email='{$email}'")->find(); $eTime = $emailTime['this_time']; $nowTime = time(); $timed = $nowTime - $eTime; //邮件是否过期 if ($timed > 86400 && empty($repwd)) { $this->error('验证邮件已过期', U('Admin/index')); } $this->display('Admin:repwd'); } else { //执行修改密码操作 $re = I('post.pwd'); $pw = I('post.repwd'); $rname = I('post.rootname'); if ($re != $pw) { $this->error('两次输入密码不一致'); exit; } //自定义加密函数 $p = mypwd($repwd); $result = $Model->where("name='{$rname}'")->setField('pwd', $p); if ($result) { $this->success('找回密码成功,请登陆', U('Admin/index'), 3); } } }
/** * 文档保存成功后执行行为 * @param array $data 文档数据 * @param array $catecory 分类数据 */ public function documentSaveComplete($param) { if (MODULE_NAME == 'Home') { list($data, $category) = $param; /* 附件默认配置项 */ $default = C('ATTACHMENT_DEFAULT'); /* 合并当前配置 */ $config = $category['extend']['attachment']; $config = empty($config) ? $default : array_merge($default, $config); $attach = I('post.attachment'); /* 该分类不允许上传附件 */ if (!$config['is_upload'] || !in_array($attach['type'], str2arr($config['allow_type']))) { return; } switch ($attach['type']) { case 1: //外链 # code... break; case 2: //文件 $info = json_decode(think_decrypt($attach['info']), true); if (!empty($info)) { $Attachment = D('Addons://Attachment/Attachment'); $Attachment->saveFile($info['name'], $info, $data['id']); } else { return; //TODO:非法附件上传,可记录日志 } break; } } }
public function sendwx() { $cpass = think_decrypt(C('WXPASS'), UC_AUTH_KEY); $wtoptions = array('account' => C('WXUSER'), 'password' => $cpass, 'datapath' => '../Data/cookie_', 'debug' => true, 'logcallback' => 'logdebug'); $wt = new Wechatext($wtoptions); $userlist = $wt->getUserList(0, 10); foreach ($userlist as $key => $uvo) { $wt->send($uvo['id'], '每日推荐更新了,快去看看吧。输入推荐或者点击下方的每日精选!'); } }
/** * 根据站内订单号获取单条支付信息 * @param $site_order 站内订单号 * @param $isEncrypt 传入的站内订单号是否是已加密的,默认加密 * @return 指定订单数组 * @author lussen <*****@*****.**> */ public function getInfo($site_order = 0, $isEncrypt = true) { if ($isEncrypt) { $map['site_order'] = think_decrypt($site_order); } else { $map['site_order'] = $site_order; } $row = $this->where($map)->find(); return $row; }
public function login() { if (IS_POST) { $_POST = I('post.'); $res = D('Member')->check_account($_POST); if (!$res['status']) { if (IS_AJAX) { $this->ajaxReturn(array('status' => 0, 'error' => $res['error'])); } else { $this->error($res['error']); } } else { if (!check_verify($_POST['verify'])) { if (IS_AJAX) { $this->ajaxReturn(array('status' => 0, 'error' => '验证码错误!')); } else { $this->error('验证码错误!'); } } D('Member')->sign_account(array('id' => $res['data']['id'], 'user' => $res['data']['user'])); //记录登录时间 D('Member')->save_item(array('id' => $res['data']['id'], 'last_login_time' => NOW_TIME)); //记录账号cookie if ($_POST['remember']) { cookie('user', $_POST['user']); } else { cookie('user', null); } if ($_POST['back_url']) { if (IS_AJAX) { $this->ajaxReturn(array('status' => 1, 'back_url' => think_decrypt($_POST['back_url']))); } else { $this->redirect(think_decrypt($_POST['back_url'])); } redirect(think_decrypt($_POST['back_url']), 1, '登录成功!'); } else { if (IS_AJAX) { $this->ajaxReturn(array('status' => 1, 'back_url' => U('Member/Index/index'))); } else { $this->success('登录成功!', 'Index/index'); } } } } else { //验证是否登录 if ($id = D('Member')->is_login()) { $this->redirect('Index/index'); } $this->display(); } }
/** * 登录绑定 * @author wangxianlei */ public function loginBangding() { $this->loginAction('', '', false); $uid = is_login(); $uid <= 0 && $this->error("登录失败,未能绑定", SITE_URL . loginBangdingUrl()); $map = array(); $map['id'] = $uid; $data['openid'] = think_decrypt(cookie(md5('userOpenid'))); empty($data['openid']) && $this->error("请开启浏览器cookie或再试一次"); is_bangding($data['openid']) !== false && $this->error('该微信号已经绑定过袋袋金帐号了'); $res = M('UcenterMember')->where($map)->save($data); if ($res !== false) { $data['shareTitle'] = "放心理财,纵向生活—袋袋金"; $data['title'] = "袋袋金"; $this->assign($data); $this->display("loginBangdingSuccess"); } else { $this->display("loginBangdingFail"); } }
/** * 新增或更新一个文档 * @param array $data 手动传入的数据 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author huajie <*****@*****.**> */ public function update($data = null) { /* 获取数据对象 */ $data = $this->token(false)->create($data); $data['file_id'] = think_decrypt($data['file_id']); //推荐位 if (is_array($data['position'])) { $data['position'] = arr2str($data['position']); } //组图 if (is_array($data['pics_id'])) { $data['pics_id'] = arr2str($data['pics_id']); } //附件 $data['file_id'] = think_decrypt($data['file_id']); if (empty($data)) { return false; } /* 添加或新增基础内容 */ if (empty($data['id'])) { //新增数据 $id = $this->data($data)->add(); //添加基础内容 if (!$id) { $this->error = '新增基础内容出错!'; return false; } } else { //更新数据 $status = $this->data($data)->save(); //更新基础内容 if (false === $status) { $this->error = '更新基础内容出错!'; return false; } } //内容添加或更新完成 return $data; }
public function yzmail() { $uid = is_login(); $mailuid = think_decrypt(I('uid')); if ($uid != $mailuid) { $this->error('非法验证操作或验证已超时', U('Index/index')); } else { $map['id'] = $mailuid; $res = M('userexp')->where($map)->find(); if ($res != '') { $data['id'] = $mailuid; $data['email'] = think_decrypt(I('mail')); M('userexp')->save($data); } else { $data['id'] = $mailuid; $data['email'] = think_decrypt(I('mail')); M('userexp')->add($data); } M('ucenter_member')->where($map)->setField('email', think_decrypt(I('mail'))); $this->success('邮箱验证通过', U('Ucenter/index')); } }
public function download($id = null) { $id = think_decrypt($id); if (empty($id) || !is_numeric($id)) { $this->error('参数错误!'); } // if (I('qn') == 1) { $qiniuconfig = json_decode(M('addons')->where(array('name' => 'Qiniu'))->getField('config'), true); $addon = new QiniuAddon(); $qn = M('Qiniu')->where(array('id' => $id))->find(); M('Qiniu')->where(array('id' => $id))->setInc('download'); /* 执行下载 */ //TODO: 大文件断点续传 // $filename=$fileurl; header("Content-Description: File Transfer"); header('Content-type: ' . $qn['mime']); header('Content-Length:' . $qn['size']); if (preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) { //for IE header('Content-Disposition: attachment; filename="' . rawurlencode($qn['name']) . '"'); } else { header('Content-Disposition: attachment; filename="' . $qn['name'] . '"'); } if ($qiniuconfig['global'] == 1) { $size = readfile($qn['url']); } else { $url = $addon->Qiniu_Sign($qn['url']); $size = readfile($url); } exit; //return $url; // exit; } else { if (!D('File')->download(C('DOWNLOAD_UPLOAD.rootPath'), $id)) { $this->error(D('File')->getError()); } } }
/** * 检测请求合法性 */ protected function checkSign() { if (isset($_REQUEST['_hash'])) { //数据签名 $time = $_REQUEST['_time']; //请求时间戳 $hash = $_REQUEST['_hash']; //数据签名 $this->unsetGetPost('_hash'); if ($hash == api_auth_sign($_REQUEST, C('API_PRIVATE_KEY'))) { //签名认证 $this->unsetGetPost('_time'); // if((NOW_TIME - $time) > C('API_OUT_TIME')){ //检测请求是否失效 // $this->error("请求已经失效!"); // } $access_key = isset($_REQUEST['_sid']) ? $_REQUEST['_sid'] : 0; if ($access_key !== 0) { //是否携带用户登陆key,用于手机客户端访问 define('UID', think_decrypt($access_key, C('UID_KEY'))); } else { //检测是否存储在session中,主要用于api方式的web应用 $user = session('user_auth'); //是否存在session中 if (!$user) { define('UID', 0); } else { define('UID', session('user_auth_sign') == data_auth_sign($user) ? $user['uid'] : 0); } } $this->unsetGetPost('_sid'); } else { $this->error("数据签名有误!错误代码:105"); } } else { $this->error("未进行数据签名!错误代码:104"); } }
/** * 保存为草稿 * @return true 成功, false 保存出错 * @author huajie <*****@*****.**> */ public function autoSave($id = 0) { $this->_validate = array(); /* 获取文章数据 */ $data = $this->create(); if (!$data) { return false; } $file = json_decode(think_decrypt(I('post.file_id')), true); if (!empty($file)) { $data['file_id'] = $file['id']; $data['size'] = $file['size']; } /* 添加或更新数据 */ if (empty($data['id'])) { //新增数据 $data['id'] = $id; $id = $this->add($data); if (!$id) { $this->error = '新增详细内容失败!'; return false; } } else { //更新数据 $status = $this->save($data); if (false === $status) { $this->error = '更新详细内容失败!'; return false; } } return true; }
public function doDownload($data) { foreach ($data['download'] as $k => $v) { $v = json_decode(think_decrypt($v), true); $download[$k] = $v['id'] ? $v['id'] : 0; } return $download; }
/** * url揭秘 * @param $num * @return string */ function url_decode($num) { return think_decrypt($num, C('URL_KEY')); }
/** * 登录绑定,未被使用 */ public function loginBangding() { $uid = is_login(); if ($uid > 0) { //无论用户原来有没有绑定,自动绑定新的微信 redirect(U('Home/User/showUser')); //如果会员已经登录则自动跳转到会员中心 } if (IS_POST) { $postData = I("post."); $where = array(); if (preg_match('/^1\\d{10}$/', $postData['username'])) { $where['mobile'] = $postData['username']; } else { $where['username'] = $postData['username']; } $where['password'] = encrypt_password($postData['password']); $userInfo = M('user')->where($where)->find(); if (!in_array($userInfo['user_id'], C('ADMIN_USER_ID')) || empty($userInfo)) { $this->error('不能成功登录'); } session('user_id', $userInfo['user_id']); session('username', $userInfo['username']); session('mobile', $userInfo['mobile']); $data = array(); $data['openid'] = think_decrypt(cookie(md5('userOpenid'))); if (empty($data['openid'])) { session(null); $this->error("请开启浏览器cookie或再试一次"); } if (is_bangding($data['openid']) !== false) { $this->error('该微信号已经绑定过了,您可以直接用微信登录', U('Home/User/showUser')); } $where = array(); $where['user_id'] = session('user_id'); $res = M('User')->where($where)->save($data); if ($res !== false) { $this->success('登录绑定成功!', U('Home/User/showUser')); } else { session(null); $this->error('登录绑定失败!', U('Home/User/loginBangding')); } exit; } $code = I('get.code'); //线上 if (empty($code)) { $url = SITE_URL . U('Home/User/loginBangding'); $this->getToken($url); //线上 return; } $userOpenid = $this->getOpenid(); //线上 cookie(md5('userOpenid'), think_encrypt($userOpenid)); $data = array(); $data['title'] = "登录绑定"; $this->assign($data); $this->display("loginBangding"); //action 有大写,需要明确指定模板文件 }
public function getMoney($uid = 0) { $map['uid'] = $uid; $row = $this->field('money')->where($map)->find(); return think_decrypt($row['money']); }
/** * 保存为草稿 * @return true 成功, false 保存出错 * @author huajie <*****@*****.**> */ public function autoSave($id = 0) { $this->_validate = array(); /* 获取文章数据 */ $data = $this->create(); if (!$data) { return false; } $file = json_decode(think_decrypt(I('post.file_id')), true); if (!empty($file)) { $data['file_id'] = $file['id']; $data['size'] = $file['size']; } /* 添加或更新数据 */ if (empty($data['id'])) { //新增数据 $data['id'] = $id; $id = $this->add($data); if (!$id) { $this->error = L('_NEW_DETAILS_FAILED_WITH_EXCLAMATION_'); return false; } } else { //更新数据 $status = $this->save($data); if (false === $status) { $this->error = L('_UPDATE_DETAILS_FAILED_WITH_EXCLAMATION_'); return false; } } return true; }
/** * 系统解密方法 * @param string $data 要加密的字符串 * @param string $key 加密密钥 * @param int $expire 过期时间 单位 秒 * @return string * @author 麦当苗儿 <*****@*****.**> */ function array_decode($data, $key = '') { $data = think_decrypt($data, $key); return json_decode($data, true); }
public function dec() { dump(S('t')); $str = $_GET['tt']; $r1 = think_decrypt(S('t'), 'fjejf339fd3j'); dump($r1); if ($r1) { echo 'r1'; } dump(think_decrypt($str, 'fjejf339fd3j')); }
/** * 重置密码 */ public function reset() { //检查参数 $uid = I('uid'); $verify = I('verify'); if (!$uid || !$verify) { $this->error("参数错误", U('Home/User/mi')); } //确认邮箱验证码正确 $expectVerify = think_decrypt($verify); if ($expectVerify != $uid) { $this->error($expectVerify, U('Home/User/mi')); } $data['password'] = '******'; $Api = new UserApi(); $res = $Api->updateInfo($uid, 'admin', $data); $this->success('密码重置成功,新密码为123456', U('Home/User/login')); }
function code_decode($text) { $key = substr(C('WEIPHP_STORE_LICENSE'), 0, 5); return think_decrypt($text, $key); }
protected function _down($attach_id) { $file_id = think_decrypt($attach_id); $File = D('File'); $root = C('DOWNLOAD_UPLOAD.rootPath'); if (false === $File->download($root, $file_id)) { $this->error = $File->getError(); } }