public function logout() { $_REQUEST = array_merge($_GET, $_POST); if (!empty($_REQUEST['uid'])) { //帐号、密码通过加密 $username = desdecrypt(t($_REQUEST['uid']), $this->getRequestKey()); } //判断帐号类型 if ($this->isValidEmail($username)) { $map['email'] = $username; } else { $map['uname'] = $username; } //判断密码是否正确 $user = model('User')->where($map)->field('uid')->find(); if ($user) { $data['oauth_token'] = getOAuthToken($user['uid']); $data['oauth_token_secret'] = getOAuthTokenSecret(); $data['uid'] = $user['uid']; D('')->table(C('DB_PREFIX') . 'login')->where("uid=" . $user['uid'] . " AND type='location'")->save($data); return 1; } else { return 0; } }
function authorize() { if ($_POST['uid'] && $_POST['passwd']) { // 杨德升添加 $isIphone = $_REQUEST['isIphone'] === '1'; $username = $isIphone ? $_POST['uid'] : desdecrypt($_POST['uid'], $this->getRequestKey()); if (is_numeric($username)) { $map['uid'] = $username; } elseif (is_string($username)) { $map['email'] = h($username); } else { return; } $map['password'] = $isIphone ? $_POST['passwd'] : md5(desdecrypt(h($_POST['passwd']), $this->getRequestKey())); $user = M('user')->where($map)->field('uid')->find(); if ($user) { if ($login = M('login')->where("uid=" . $user['uid'] . " AND type='location'")->find()) { $data['oauth_token'] = $login['oauth_token']; $data['oauth_token_secret'] = $login['oauth_token_secret']; $data['uid'] = $user['uid']; } else { $data['oauth_token'] = md5($user['uid'] . 'thinksns'); $data['oauth_token_secret'] = md5(time() . 'thinksns'); $data['uid'] = $user['uid']; $savedata['type'] = 'location'; $savedata = array_merge($savedata, $data); M('login')->add($savedata); } return $data; } else { $this->verifyError(); } } else { $this->verifyError(); } }
/** * 解密函数 * @param string $txt 待解密的字符串 * @param string $key 解密密钥,默认读取SECURE_CODE配置 * @return string 解密后的字符串 */ private function jiemi($txt, $key = null) { empty($key) && ($key = C('SECURE_CODE')); //有mcrypt扩展时 if (function_exists('mcrypt_module_open')) { return desdecrypt($txt, $key); } //无mcrypt扩展时 return tsauthcode($text, 'DECODE', $key); }
/** * 获取附件信息 * * @return array * @author Medz Seven <*****@*****.**> **/ public function getAttach() { list($hash, $method) = array($_REQUEST['hash'], $_REQUEST['method']); list($hash, $method) = array($hash, t($method)); $method or $method = 'stream'; // stream, url, redirect // # 解密成ID $hash = @desdecrypt($hash, C('SECURE_CODE')); if (!$hash) { $this->error(array('status' => '-1', 'msg' => '没有传递需要获取的附件ID')); } elseif (!in_array($method, array('stream', 'url', 'redirect'))) { $this->error(array('status' => '-2', 'msg' => '没有正确的传递获取模式')); } elseif (!($attach = model('Attach')->getAttachById(intval($hash)))) { $this->error(array('status' => '-3', 'msg' => '没有这个附件')); } elseif ($method == 'stream') { ob_end_clean(); header('Content-type:' . $attach['type']); echo file_get_contents(getAttachUrl($attach['save_path'] . $attach['save_name'])); exit; } elseif ($method == 'redirect') { ob_end_clean(); header('Location:' . getAttachUrl($attach['save_path'] . $attach['save_name'])); exit; } return array('status' => '1', 'url' => getAttachUrl($attach['save_path'] . $attach['save_name']), 'msg' => '获取成功'); }
public function index() { $de = desencrypt('*****@*****.**', 'SociaxV1'); echo desdecrypt($de, 'SociaxV1'); }
/** * 解密函数 * @param string $txt 待解密的字符串 * @param string $key 解密密钥,默认读取SECURE_CODE配置 * @return string 解密后的字符串 */ private function jiemi($txt, $key = null) { empty($key) && ($key = C('SECURE_CODE')); //有mcrypt扩展时 if (function_exists('mcrypt_module_open')) { return desdecrypt($txt, $key); } //无mcrypt扩展时 $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-=_"; $ch = $txt[0]; $nh = strpos($chars, $ch); $mdKey = md5($key . $ch); $mdKey = substr($mdKey, $nh % 8, $nh % 8 + 7); $txt = substr($txt, 1); $tmp = ''; $i = 0; $j = 0; $k = 0; for ($i = 0; $i < strlen($txt); $i++) { $k = $k == strlen($mdKey) ? 0 : $k; $j = strpos($chars, $txt[$i]) - $nh - ord($mdKey[$k++]); while ($j < 0) { $j += 64; } $tmp .= $chars[$j]; } return base64_decode($tmp); }
/** * 上传群组头像接口 * * @return array * @author Seven Du <*****@*****.**> **/ public function uploadGroupLogo() { $data = $this->uploadFile('image', 'message_group_logo', 'jpg', 'png', 'bmp', 'jpeg', 'gif'); if ($data['status'] != '1' or !isset($data['list']) or !$data['list'] or !is_array($data['list'])) { return $data; } $data = $data['list']; $data = array_pop($data); $data = @desdecrypt($data, C('SECURE_CODE')); if (!$data) { return array('status' => 0, 'mes' => '上传失败'); } return array('status' => 1, 'logo' => $data); }