function action()
 {
     $uid = $this->getUid();
     if ($uid == 0) {
         $this->showErrorJson(ErrorConf::noLogin());
     }
     $nickname = trim($this->getRequest('nickname'));
     if ($nickname == "") {
         $this->showErrorJson(ErrorConf::nickNameisEmpty());
     }
     $NicknameMd5Obj = new NicknameMd5();
     $existnicknameuid = $NicknameMd5Obj->checkNameIsExist($nickname);
     if ($existnicknameuid > 0 && $existnicknameuid != $uid) {
         $this->showErrorJson(ErrorConf::nickNameIsExist());
     }
     $this->showSuccJson();
 }
示例#2
0
 public function initQqLoginUser($qc, $accessToken, $openId, $nickName)
 {
     if (empty($qc) || empty($accessToken) || empty($openId) || empty($nickName)) {
         return false;
     }
     $NicknameMd5Obj = new NicknameMd5();
     if ($NicknameMd5Obj->checkNameIsExist($nickName)) {
         $this->setError(ErrorConf::nickNameIsExist());
         return false;
     }
     $qqUserInfo = $this->getQqInfo($qc);
     if (empty($qqUserInfo)) {
         return false;
     }
     $gender = $qqUserInfo['gender'];
     $province = $qqUserInfo['province'];
     $city = $qqUserInfo['city'];
     $year = $qqUserInfo['year'];
     $qqavatar = $qqUserInfo['qqAvatar'];
     $birthday = '';
     if (!empty($year)) {
         $birthday = $year . "-01-01";
     }
     $addtime = date('Y-m-d H:i:s');
     $db = DbConnecter::connectMysql('share_passport');
     $qquserpasword = md5('QL' . time());
     $sql = "insert into passport (username,password,addtime) values (?,?,?)";
     $st = $db->prepare($sql);
     $st->execute(array('QL', $qquserpasword, $addtime));
     $uid = $db->lastInsertId() + 0;
     if ($uid == 0) {
         return false;
     }
     $sql = "insert into qqrelation (open_id,uid,access_token,addtime) values (?,?,?,?)";
     $st = $db->prepare($sql);
     $st->execute(array($openId, $uid, $accessToken, $addtime));
     $NicknameMd5Obj->addOne($nickName, $uid);
     $avatartime = 0;
     if ($qqavatar != "") {
         // 			$ch = curl_init();
         // 			curl_setopt($ch, CURLOPT_URL, $qqavatar);	 //
         // 			curl_setopt($ch, CURLOPT_TIMEOUT, 10);	 //
         // 			curl_setopt($ch, CURLOPT_USERAGENT, "Baiduspider+(+ http://www.baidu.com/search/spider.htm)");
         // 			curl_setopt($ch, CURLOPT_REFERER, $qqavatar);
         // 			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         // 			$content = curl_exec($ch);
         // 			curl_close($ch);
         // 			$avatarfile = "/alidata/tmpavatarfile/{$uid}";
         // 			file_put_contents(	$avatarfile, $content);
         // 			if(is_file($avatarfile))
         // 			{
         // 				$obj = new alioss_sdk();
         // 				//$obj->set_debug_mode(FALSE);
         // 				$bucket = 'tutuavatar';
         // 				$responseObj = $obj->upload_file_by_file($bucket,$uid,$avatarfile);
         // 				if ($responseObj->status==200){
         // 					$avatartime = time();
         // 				}
         // 			}
         QueueManager::pushLoadUserQqavatar($uid, $qqavatar);
     }
     $UserObj = new User();
     $UserObj->initQQLoginUser($uid, $nickName, $avatartime, $gender, $birthday, $province, $city, $addtime);
     $this->setSsoCookie(array('uid' => $uid, 'pasword' => $qquserpasword), array('nickname' => $nickName));
     $return = array('uid' => $uid, 'nickname' => $nickName, 'avatartime' => time());
     QueueManager::pushAfterRegQueue($uid);
     QueueManager::pushUserInfoToSearch($uid);
     return $return;
 }
示例#3
0
 public function setUserNickname($uid, $nickname)
 {
     $NicknameMd5Obj = new NicknameMd5();
     $existnicknameuid = $NicknameMd5Obj->checkNameIsExist($nickname);
     if ($existnicknameuid > 0 && $existnicknameuid != $uid) {
         $this->setError(ErrorConf::nickNameIsExist());
         return false;
     } else {
         $NicknameMd5Obj->addOne($nickname, $uid);
     }
     $db = DbConnecter::connectMysql('share_user');
     $sql = "update `userinfo` set nickname=? where uid={$uid} ";
     $st = $db->prepare($sql);
     $st->execute(array($nickname));
     $this->clearUserCache($uid);
     QueueManager::pushUserInfoToSearch($uid);
     // 添加到审核队列
     QueueManager::pushAuditTextAction($uid, 1);
     QueueManager::pushUserToUpdateUserSysFriendLog($uid);
     return true;
 }