Exemple #1
0
 protected function _getUser()
 {
     $authkey = 'winduser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     list($uid, $password) = explode("\t", Pw::decrypt(urldecode($winduser)));
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return null;
     }
     unset($user->info['password']);
     return $user;
 }
 /**
  * 本地安装 - 上传
  */
 public function uploadAction()
 {
     $authkey = 'AdminUser';
     $pre = Wekit::C('site', 'cookie.pre');
     $pre && ($authkey = $pre . '_' . $authkey);
     $winduser = $this->getInput($authkey, 'post');
     if (!$winduser) {
         $this->showError('login.not');
     }
     list($type, $u, $pwd) = explode("\t", Pw::decrypt(urldecode($winduser)));
     if ($type == 'founder') {
         $founders = Wekit::load('ADMIN:service.srv.AdminFounderService')->getFounders();
         if (!isset($founders[$u])) {
             $this->showError('login.not');
         }
         list($md5pwd, $salt) = explode('|', $founders[$u], 2);
         if (Pw::getPwdCode($md5pwd) != $pwd) {
             $this->showError('login.not');
         }
     } else {
         $r = Wekit::load('user.PwUser')->getUserByUid($u);
         if (!$r) {
             $this->showError('login.not');
         }
         if (Pw::getPwdCode($r['password']) != $pwd) {
             $this->showError('login.not');
         }
     }
     Wind::import('SRC:applications.appcenter.service.srv.helper.PwApplicationUpload');
     $upload = new PwApplicationUpload();
     $upload->dir = Wind::getRealDir($this->_installService()->getConfig('tmp_dir'), true) . '/';
     $uploaddb = $upload->execute();
     if ($uploaddb instanceof PwError) {
         $this->showError($uploaddb->getError());
     }
     if (empty($uploaddb)) {
         $this->showError('upload.fail');
     }
     $this->setOutput(array('filename' => $uploaddb[0]['name'], 'file' => $uploaddb[0]['fileuploadurl']), 'data');
     $this->showMessage('success');
 }
Exemple #3
0
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('AdminUser'))) {
         $password = '';
         $us = new AdminUserSourceDb(0);
     } else {
         list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie));
         if ($type == AdminUserService::FOUNDER) {
             $us = new AdminUserSourceFounder($uid);
         } else {
             $us = new AdminUserSourceDb($uid);
         }
     }
     Pw::setCookie('AdminUser', $userCookie, 1800);
     $user = new AdminUserBo($us);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
 /**
  * 获取本地的访问标记
  * 
  * @param $isRefresh  bool 是否强制刷新
  * @return bool|array
  */
 public function getVisitor($isRefresh = false)
 {
     $sign = Pw::getCookie('visitor');
     if (empty($sign)) {
         return true;
     }
     $sign = Pw::decrypt($sign);
     $signs = explode('_', $sign);
     if ($isRefresh) {
         return $signs;
     }
     list($ip, $createdTime, $modifyTime) = $signs;
     $modifyTime = (int) $modifyTime;
     $createdTime = (int) $createdTime;
     if ($createdTime < 1 || $modifyTime < 1) {
         return true;
     }
     $onlineTime = $this->time - $modifyTime;
     if ($createdTime == $modifyTime && $onlineTime >= $this->isVisitorTime) {
         return $signs;
     }
     if ($onlineTime >= $this->spaceTime) {
         return $signs;
     }
     return false;
 }
 /**
  * 保存phpwind.aliyun.com帮站长申请关于悟空的im应用密匙 
  * 
  * @param mixed $key 
  * @static
  * @access public
  * @return void
  */
 public static function saveAppekySetting($key)
 {
     $config = Wekit::C()->getConfigByName('site', 'info.url');
     $_uri = self::PW_CREATER_URI . '/api/getlaiwanginfo?siteurl=' . urlencode($config['value']);
     $unsecurityKey = WindidUtility::buildRequest($_uri, array(), true, self::WK_TIMEOUT, 'get');
     $unsecurityKey = json_decode($unsecurityKey, true);
     if ($unsecurityKey && $unsecurityKey['status'] == 200) {
         $_unsecurityKey = Pw::decrypt($unsecurityKey['data']['info'], $key);
         $appSettingData = unserialize($_unsecurityKey);
         // 解密错了或者其他情况不保存空的数据到数据库
         if (!$appSettingData) {
             return array();
         }
         // 保存laiwang appkey等
         $config = new PwConfigSet('wukong');
         $config->set('appToken', $appSettingData['appToken'])->set('domain', $appSettingData['domain'])->set('org', $appSettingData['org'])->set('android.appKey', $appSettingData['Android']['appKey'])->set('android.appSecret', $appSettingData['Android']['appSecret'])->set('ios.appKey', $appSettingData['iOS']['appKey'])->set('ios.appSecret', $appSettingData['iOS']['appSecret'])->flush();
         return $appSettingData;
     }
     return array();
 }
 /** 
  * 检查用户标志
  *
  * @param string $identify
  * @return array array($uid, $password);
  */
 public static function parserRegistIdentify($identify)
 {
     return explode("\t", Pw::decrypt(rawurldecode($identify)));
 }
 /**
  * 认证sessionKey是否合法 
  * 
  * @access protected
  * @return integer
  */
 protected function authSessionKey()
 {
     $unsecurityKey = $this->getInput('securityKey');
     //
     //        if(isset($_SERVER['CONTENT_TYPE']) && strpos($_SERVER['CONTENT_TYPE'],'multipart/form-data')!==false){
     //            //$unsecurityKey = urldecode($unsecurityKey);
     //        }
     if ($unsecurityKey) {
         $securityKey = unserialize(Pw::decrypt($unsecurityKey, $this->_securityKey));
         if (is_array($securityKey) && isset($securityKey['username']) && isset($securityKey['password'])) {
             $_userInfo = $this->_getUserDs()->getUserByName($securityKey['username'], PwUser::FETCH_MAIN);
             if ($_userInfo['username'] == $securityKey['username'] && $_userInfo['password'] == $securityKey['password']) {
                 $this->uid = $_userInfo['uid'];
             }
         }
     }
     return $this->uid;
 }
Exemple #8
0
 /**
  * 获得大概年前登录用户对象
  *
  * @return PwUserBo
  */
 protected function _getLoginUser()
 {
     if (!($userCookie = Pw::getCookie('winduser'))) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($userCookie));
     }
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         $user->reset();
     } else {
         unset($user->info['password']);
     }
     return $user;
 }
 public function checkCookie($cookie)
 {
     if (empty($cookie)) {
         $uid = $password = '';
     } else {
         list($uid, $password) = explode("\t", Pw::decrypt($cookie));
     }
     Wind::import('SRV:user.bo.PwUserBo');
     $user = new PwUserBo($uid);
     if (!$user->isExists() || Pw::getPwdCode($user->info['password']) != $password) {
         return $this->buildResponse(-1, 'cookie非法');
     } else {
         return $this->buildResponse(0, array('uid' => $uid, 'username' => $user->username));
     }
 }
Exemple #10
0
 protected function _getLoginUser()
 {
     $userCookie = Pw::getCookie('AdminUser');
     /* @var $adminUserService AdminUserService */
     $adminUserService = Wekit::load('ADMIN:service.srv.AdminUserService');
     if ($userCookie) {
         list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie));
         /* @var $founderService AdminFounderService */
         $founderService = Wekit::load('ADMIN:service.srv.AdminFounderService');
         if ($founderService->isFounder($uid)) {
             $founders = $founderService->getFounders();
             list($md5pwd) = explode('|', $founders[$uid], 2);
             $userinfo = $adminUserService->verifyUserByUsername($uid);
             $userinfo['password'] = $md5pwd;
         } else {
             $userinfo = $adminUserService->loadUserService()->getUserByUid($uid);
         }
     } else {
         $password = '';
         $userinfo = array();
     }
     Wind::import('ADMIN:service.bo.AdminDefaultUserBo');
     $user = new AdminDefaultUserBo($userinfo);
     if (!$user->isExists() || Pw::getPwdCode($userinfo['password']) != $password) {
         $user->reset();
     }
     return $user;
 }
 /**
  * 解析登录标识
  *
  * @param string $identify 需要解析的标识
  * @return array array($uid, $password)
  */
 public static function parseLoginIdentify($identify)
 {
     $args = explode("\t", Pw::decrypt(rawurldecode($identify)));
     if (Pw::getTime() - $args[2] > 300) {
         return array(0, '');
     } else {
         return $args;
     }
 }
Exemple #12
0
 /**
  * 解析找回密码的标识
  *
  * @param string $identify
  * @return array array($username, $way, $value)
  */
 public static function parserFindPwdIdentify($identify)
 {
     return explode("|", Pw::decrypt(rawurldecode($identify), Wekit::C('site', 'hash') . '___findpwd'));
 }
 public function isLogin()
 {
     if (!($userCookie = Pw::getCookie('AdminUser'))) {
         return array();
     }
     list($type, $uid, $password) = explode("\t", Pw::decrypt($userCookie));
     if ($type == AdminUserService::FOUNDER) {
         $srv = $this->loadFounderService();
     } else {
         $srv = $this->loadManagerService();
     }
     Pw::setCookie('AdminUser', $userCookie, 1800);
     return $srv->isLogin($uid, $password);
 }