예제 #1
0
파일: c.php 프로젝트: huqq1987/clone-lemon
 protected function showErrorJson($data)
 {
     if (empty($data)) {
         $data = ErrorConf::systemError();
     }
     echo json_encode($data);
     exit;
 }
예제 #2
0
 public function action()
 {
     $accessToken = $this->getRequest('accessToken', '');
     $openId = $this->getRequest('openId', '');
     if ($accessToken == "" || $openId == "") {
         $this->showErrorJson();
     }
     $SsoObj = new Sso();
     $isfirst = $SsoObj->checkQqLoginFirst($openId);
     if ($isfirst === true) {
         $errorInfo = ErrorConf::qqAuthInfoEmpty();
         $this->showErrorJson($errorInfo);
     } else {
         $userinfo = $SsoObj->qqlogin($accessToken, $openId);
     }
     $this->showSuccJson($userinfo);
 }
예제 #3
0
 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();
 }
예제 #4
0
 function action()
 {
     // 获取当前登录用户uid
     $uid = $this->getUid();
     if ($uid == 0) {
         // 返回错误json
         $this->showErrorJson(ErrorConf::noLogin());
     }
     // 接收参数
     $nickname = trim($this->getRequest('nickname'));
     if ($nickname == "") {
         $this->showErrorJson(ErrorConf::nickNameisEmpty());
     }
     // 调用类的方法,类方法在model中,底层数据操作在方法中实现
     $aliossobj = new AliOss();
     $res = $aliossobj->xxx($nickname);
     // 返回成功json
     $this->showSuccJson();
 }
예제 #5
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;
 }
예제 #6
0
 public function uploadVideo($file, $id)
 {
     if (empty($file)) {
         $this->setError(ErrorConf::topicContentImageEmpty());
         return false;
     }
     $obj = new alioss_sdk();
     $obj->set_debug_mode(FALSE);
     $bucket = $this->OSS_BUCKET_VIDEO;
     $tmpFile = $file['tmp_name'];
     $getID3 = new getID3();
     $id3Info = $getID3->analyze($tmpFile);
     $ext = $id3Info['fileformat'];
     if (!in_array($ext, $this->OSS_VIDEO_ENABLE)) {
         $this->setError(ErrorConf::topicContentVideoInvalidateType());
     }
     $times = ceil(@$id3Info['playtime_seconds'] + 0);
     $width = @$id3Info['video']['resolution_x'] + 0;
     $height = @$id3Info['video']['resolution_y'] + 0;
     $size = @$id3Info['filesize'];
     $from = $this->LOCAL_TMP_PATH . $id . rand(1, 100) . '.' . $ext;
     move_uploaded_file($tmpFile, $from);
     $to = $this->formatVideoFile($id, $ext);
     $responseObj = $obj->upload_file_by_file($bucket, $to, $from);
     if ($responseObj->status == 200) {
         $return['videopath'] = $to;
         $return['width'] = $width;
         $return['height'] = $height;
         $return['size'] = $size;
         $return['times'] = $times;
         return $return;
     } else {
         $this->setError(ErrorConf::topicContentImageEmpty());
         return false;
     }
 }
예제 #7
0
 protected function showErrorJson($data = array())
 {
     if (empty($data)) {
         $data = ErrorConf::systemError();
     }
     echo json_encode($data);
     //$this->endXhprof();
     exit;
 }
예제 #8
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;
 }