/** * 查询laiwang帐号信息 * 注意为了兼容旧的phpwind代码,当设置项中不存在ios的appkey时,返回空的结果。 * * @access public * @return void */ public function getLaiwangInfoAction() { $config = Wekit::C()->getValues('wukong'); if (empty($config) || !isset($config['ios.appKey'])) { $data = array('info' => ''); } else { $cont = array('appToken' => $config['appToken'], 'org' => $config['org'], 'domain' => $config['domain'], 'Android' => array('appKey' => $config['android.appKey'], 'appSecret' => $config['android.appSecret']), 'iOS' => array('appKey' => $config['ios.appKey'], 'appSecret' => $config['ios.appSecret'])); $cont = serialize($cont); $_securityKey = Wekit::C()->getConfigByName('site', 'securityKey'); $cont = Pw::encrypt($cont, $_securityKey['value']); $data = array('info' => $cont ? $cont : ''); } $this->setOutput($data, 'data'); $this->showMessage("success"); }
/** * 获得基本用户信息 * * @param mixed $uid * @access private * @return void */ protected function _getUserInfo($laiwangOK = true) { // $_userInfo = $this->_getUserAllInfo(PwUser::FETCH_MAIN + PwUser::FETCH_INFO); //登录成功后,加密身份key $_idInfo = array('username' => $_userInfo['username'], 'password' => $_userInfo['password']); $securityKey = Pw::encrypt(serialize($_idInfo), $this->_securityKey); //laiwang $wk_setting = PwLaiWangSerivce::$wk_setting; $wk_setting['openid'] = $_userInfo['uid']; $wk_setting['secretToken'] = PwLaiWangSerivce::getSecretToken($_userInfo['uid'], $_userInfo['password']); // 是否已经成功同步用户到来往 $wk_setting['laiwangOK'] = $laiwangOK; //返回数据 $_data = array('securityKey' => $securityKey, 'userinfo' => array('uid' => $_userInfo['uid'], 'username' => $_userInfo['username'], 'avatar' => Pw::getAvatar($_userInfo['uid'], 'big'), 'gender' => $_userInfo['gender']), 'laiwangSetting' => $wk_setting); return $_data; }
/** * 标记一个访问者 * * @param string $ip * @param int $createdTime * @param int $modifyTime */ public function signVisitor($ip, $createdTime, $modifyTime, $extension = array()) { $ip = ip2long($ip); $sign = Pw::encrypt($ip . '_' . $createdTime . '_' . $modifyTime . '_' . serialize($extension)); return Pw::setCookie('visitor', $sign); }
/** * 构造用户标志 * * @param int $uid 用户ID * @param string $pwd 用户密码 * @return string */ public static function createRegistIdentify($uid, $pwd) { $code = Pw::encrypt($uid . "\t" . Pw::getPwdCode($pwd)); return rawurlencode($code); }
private function _saveVerifyCode() { Wind::import('LIB:utility.verifycode.PwBaseCode'); $code = WindConvert::convert(PwBaseCode::getCode(), Wekit::V('charset'), 'UTF-8'); $code = Pw::encrypt(strtolower($code)); //Wind::import('WIND:http.session.WindSession'); Pw::setCookie('Pw_verify_code', $code, 3600); /*$session = new WindSession(); $session->set('verifycode', $code);*/ }
/** * 后台用户登录服务 * * 后台用户登录服务,并返回用户对象.参数信息:<code> * $loginInfo: AdminUser * </code> * * @param string $username 用户名 * @param string $password 密码 * @return boolean */ public function login($username, $password) { $conf = $this->loadFounderService()->getFounders(); if (isset($conf[$username])) { $r = $this->loadFounderService()->checkPwd($conf[$username], $password); if (!$r) { return new PwError('ADMIN:login.fail.user.illegal'); } $cookie = Pw::encrypt(self::FOUNDER . "\t" . $username . "\t" . Pw::getPwdCode($r)); } else { if (!$this->loadSafeService()->ipLegal(Wekit::app()->clientIp)) { return new PwError('ADMIN:login.fail.ip'); } $user = $this->loadUserService()->verifyUser($username, $password); if ($user instanceof PwError) { return new PwError('ADMIN:login.fail.user.illegal'); } /* @var $auth AdminAuth */ $auth = Wekit::load('ADMIN:service.AdminAuth'); if (!$auth->findByUid($user['uid'])) { return new PwError('ADMIN:login.fail.allow'); } $u = $this->loadUserService()->getUserByUid($user['uid']); $cookie = Pw::encrypt(self::USER . "\t" . $user['uid'] . "\t" . Pw::getPwdCode($u['password'])); } Pw::setCookie($this->cookieName, $cookie, 1800); return true; }
/** * 创建登录用户标识 * * @param int $uid 用户ID * @param string $password 用户密码 * @return boolean */ public function createIdentity($uid, $password) { $identity = Pw::encrypt($uid . "\t" . Pw::getPwdCode($password)); return Pw::setCookie('winduser', $identity, 31536000); }
/** * 创建登录标识 * * @param array $userInfo 用户信息 * @return string */ public static function createLoginIdentify($userInfo) { $code = Pw::encrypt($userInfo['uid'] . "\t" . Pw::getPwdCode($userInfo['password']) . "\t" . Pw::getTime()); return rawurlencode($code); }
/** * 创建找回密码的唯一标识 * * @param string $username 需要找回密码的用户名 * @param string $way 找回方式标识 * @param string $value 找回方式对应的值 * @return string */ public static function createFindPwdIdentify($username, $way, $value) { $code = Pw::encrypt($username . '|' . $way . '|' . $value, Wekit::C('site', 'hash') . '___findpwd'); return rawurlencode($code); }
/** * 后台用户登录服务 * * 后台用户登录服务,并返回用户对象.参数信息:<code> * $loginInfo: AdminUser * </code> * * @param string $username 用户名 * @param string $password 密码 * @return boolean */ public function login($username, $password) { $srv = $this->loadFounderService(); if (!$srv->isFounder($username)) { $srv = $this->loadManagerService(); } if (($result = $srv->login($username, $password)) instanceof PwError) { return $result; } Pw::setCookie($this->cookieName, Pw::encrypt(implode("\t", $result)), 1800); return true; }
/** * 创建登录用户标识 * * @param int $uid 用户ID * @param string $password 用户密码 * @param int $rememberme 是否采用记住当前用户,记住则保存1年 * @return boolean */ public function createIdentity($uid, $password, $rememberme = 0) { $identity = Pw::encrypt($uid . "\t" . Pw::getPwdCode($password)); return Pw::setCookie('winduser', $identity, $rememberme ? 31536000 : NULL); }
/** * 创建找回密码的唯一标识 * * @param string $uid 需要找回密码的用户名 * @param string $way 找回方式标识 * @param string $value 找回方式对应的值 * @return string */ public static function createIdentify($uid, $type, $passwd) { $code = Pw::encrypt($uid . '|' . $type . '|' . $passwd, Wekit::C('site', 'hash') . '___verify'); return rawurlencode($code); }
private function _saveVerifyCode() { Wind::import('LIB:utility.verifycode.PwBaseCode'); $code = WindConvert::convert(PwBaseCode::getCode(), Wekit::V('charset'), 'UTF-8'); $code = Pw::encrypt(strtolower($code), $this->_config['key']); // $verify_session_id = Pw::getCookie('Pw_verify_code'); if (!$verify_session_id) { $verify_session_id = md5($code); Pw::setCookie('Pw_verify_code', md5($code), 3600); } //session 保存验证码 Wind::import('WIND:http.session.WindSession'); $session = new WindSession(); $session->set('verifycode', $code); }