private function _getAnnouncementInfo($res, $id) { global $_G; require_once libfile('function/discuzcode'); $announce = DzForumAnnouncement::getAnnouncementByUid($id); if (!count($announce)) { $res = $this->makeErrorInfo($res, 'announcement_nonexistence'); } else { $tempAnnounce = array(); $tempAnnounce['author'] = $announce['author']; $tmp = explode('.', dgmdate($announce['starttime'], 'Y.m')); $months[$tmp[0] . $tmp[1]] = $tmp; if (!empty($_GET['m']) && $_GET['m'] != dgmdate($announce['starttime'], 'Ym')) { continue; } $tempAnnounce['starttime'] = dgmdate($announce['starttime'], 'd'); $tempAnnounce['endtime'] = $announce['endtime'] ? dgmdate($announce['endtime'], 'd') : ''; $tempAnnounce['title'] = WebUtils::emptyHtml($announce['subject']); $uid = DzCommonMember::getUidByUsername($announce['author']); $tempAnnounce['icon'] = UserUtils::getUserAvatar($uid); $announceMessage = $announce['type'] == 1 ? "{$announce[message]}" : $announceMessage; $announceMessage = nl2br(discuzcode($announce['message'], 0, 0, 1, 1, 1, 1, 1)); $announceType = array(); $announceType['infor'] = WebUtils::emptyHtml($announceMessage); $announce['type'] == 1 ? $announceType['type'] = 'url' : ($announceType['type'] = 'text'); $tempAnnounce['content'] = $announceType; $res['body']['list'] = $tempAnnounce; } return $res; }
private function _getUserInfos($uid, $longitude, $latitude, $radius, $page, $pageSize) { $userInfos = array('count' => 0, 'list' => array()); $count = SurroundingInfo::getUserCountByUid($uid, $longitude, $latitude, $radius); $surroundUsers = SurroundingInfo::getAllUsersByUid($uid, $longitude, $latitude, $radius, $page, $pageSize); $list = array(); foreach ($surroundUsers as $user) { $userInfo = array(); $tmpUid = (int) $user['object_id']; $userInfo['uid'] = $tmpUid; $userInfo['distance'] = $user['distance']; $userInfo['location'] = $user['location']; $userInfo['nickname'] = UserUtils::getUserName($tmpUid); $userInfo['gender'] = UserUtils::getUserGender($tmpUid); $userInfo['status'] = UserUtils::getUserLoginStatus($tmpUid) == UserUtils::STATUS_ONLINE ? 1 : 0; $userInfo['icon'] = UserUtils::getUserAvatar($tmpUid); // $userInfo['is_friend'] = UserUtils::isFriend($uid, $tmpUid) ? 1 : 0; $userInfo['is_friend'] = UserUtils::isFollow($uid, $tmpUid) ? 1 : 0; $userInfo['is_black'] = UserUtils::isBlacklist($uid, $tmpUid) ? 1 : 0; $list[] = $userInfo; } $userInfos['count'] = $count; $userInfos['list'] = $list; return $userInfos; }
private function _getImageInfoByTids($page, $pageSize) { $imageList = $this->_getImageTidsByFids($page, $pageSize); $list = array(); global $_G; $forum = $_G['forum']; foreach ($imageList as $image) { $tmpImageInfo = ForumUtils::getTopicInfo($image); $imageSummary = ForumUtils::getTopicCover((int) $image); $imageInfo['board_id'] = (int) $tmpImageInfo['fid']; $imageInfo['board_name'] = $fid != 0 ? $forum['name'] : ForumUtils::getForumName($tmpImageInfo['fid']); $imageInfo['board_name'] = WebUtils::emptyHtml($imageInfo['board_name']); $imageInfo['topic_id'] = (int) $image; $imageInfo['title'] = WebUtils::emptyHtml($tmpImageInfo['subject']); $imageInfo['user_id'] = (int) $tmpImageInfo['authorid']; $imageInfo['last_reply_date'] = $tmpImageInfo['lastpost'] . "000"; $imageInfo['user_nick_name'] = $tmpImageInfo['author']; $imageInfo['hits'] = (int) $tmpImageInfo['views']; $imageInfo['replies'] = (int) $tmpImageInfo['replies']; $imageInfo['top'] = (int) ForumUtils::isTopTopic($image) ? 1 : 0; $imageInfo['status'] = (int) $tmpImageInfo['status']; $imageInfo['essence'] = (int) $tmpImageInfo['digest'] ? 1 : 0; $imageInfo['hot'] = (int) $tmpImageInfo['highlight'] ? 1 : 0; $tempImageInfo = ImageUtils::getThumbImageEx($imageSummary, 15, true, false); $imageInfo['pic_path'] = $tempImageInfo['image']; $imageInfo['ratio'] = $tempImageInfo['ratio']; $imageInfo['userAvatar'] = UserUtils::getUserAvatar($tmpImageInfo['authorid']); $imageInfo['recommendAdd'] = (int) ForumUtils::getRecommendAdd($image); $imageInfo['isHasRecommendAdd'] = (int) ForumUtils::isHasRecommendAdd($image); $imageInfo['imageList'] = array(); $imageInfo['sourceWebUrl'] = (string) ForumUtils::getSourceWebUrl($image, 'topic'); $list[] = $imageInfo; } return $list; }
private function _login($res, $username, $password, $mobile, $code, $isValidation) { global $_G; $username = rawurldecode($username); $password = rawurldecode($password); if ($username == MOBCENT_HACKER_USER && $password == MOBCENT_HACKER_PASSWORD) { $token = isset($_GET['accessToken']) ? $_GET['accessToken'] : ''; $secret = isset($_GET['accessSecret']) ? $_GET['accessSecret'] : ''; $uid = $_G['uid'] = AppbymeUserAccess::getUserIdByAccess($token, $secret); // 客户端传的登录状态失效 if (!$uid) { return $this->makeErrorInfo($res, 'mobcent_login_status'); } $result['member'] = getuserbyuid($uid); $_G['username'] = $result['member']['username']; // 把登录信息写入cookie中,并且更新登录的状态 UserUtils::updateCookie($result['member'], $uid); // 需要整理token和secret再返回给客户端 $userInfo = array('token' => $token, 'secret' => $secret); } else { $username = WebUtils::t($username); $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { UserUtils::delUserAccessByUsername($username); return $this->makeErrorInfo($res, $logInfo['message']); } if ($isValidation == 1) { // 是否开启了登录手机验证 $isLoginValidation = WebUtils::getDzPluginAppbymeAppConfig('mobcent_login_validation'); if ($isLoginValidation) { $userMobileBind = AppbymeSendsms::getBindInfoByUid($_G['uid']); if (!$userMobileBind) { // 当前登录的用户没有绑定手机号码 if ($mobile == '' && $code == '') { $res['isValidation'] = 1; return $this->makeErrorInfo($res, '', array('noError' => 0, 'alert' => 0)); } $checkInfo = UserUtils::checkMobileCode($res, $mobile, $code); if ($checkInfo['rs'] == 0) { return $this->makeErrorInfo($res, $checkInfo['errcode']); } $updataArr = array('uid' => $_G['uid']); AppbymeSendsms::updateMobile($mobile, $updataArr); } } } $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); } $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['isValidation'] = 0; $res['token'] = (string) $userInfo['token']; $res['secret'] = (string) $userInfo['secret']; $res['uid'] = (int) $_G['uid']; $res['avatar'] = (string) $userAvatar; $res['userName'] = (string) $_G['username']; return $res; }
private function _getUserInfo($uid) { $userInfo = array('uid' => 0, 'name' => '', 'avatar' => ''); $user = UserUtils::getUserInfo($uid); if (!empty($user)) { $userInfo['uid'] = (int) $uid; $userInfo['name'] = $user['username']; $userInfo['avatar'] = UserUtils::getUserAvatar($uid, 'small'); } return $userInfo; }
private function _switchVest($res, $username) { global $_G; $username = WebUtils::t(rawurldecode($username)); $_GET['username'] = $username; $myrepeatsusergroups = (array) dunserialize($_G['cache']['plugin']['myrepeats']['usergroups']); if (!in_array($_G['groupid'], $myrepeatsusergroups)) { $users = C::t('#myrepeats#myrepeats')->fetch_all_by_username($_G['username']); if (!$users) { return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'usergroup_disabled')); } else { $permusers = array(); foreach ($users as $user) { $permusers[] = $user['uid']; } $member = C::t('common_member')->fetch_by_username($_GET['username']); if (!$member || !in_array($member['uid'], $permusers)) { return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'usergroup_disabled')); } } } $user = C::t('#myrepeats#myrepeats')->fetch_all_by_uid_username($_G['uid'], $_GET['username']); $user = current($user); $olddiscuz_uid = $_G['uid']; $olddiscuz_user = $_G['username']; $olddiscuz_userss = $_G['member']['username']; if (!$user) { $newuid = C::t('common_member')->fetch_uid_by_username($_GET['username']); if (C::t('#myrepeats#myrepeats')->count_by_uid_username($newuid, $olddiscuz_userss)) { // 第一次登录,需要输入密码 } //return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'user_nonexistence')); } elseif ($user['locked']) { return $this->makeErrorInfo($res, lang('plugin/myrepeats', 'user_locked', array('user' => $_GET['username']))); } list($password, $questionid, $answer) = explode("\t", authcode($user['logindata'], 'DECODE', $_G['config']['security']['authkey'])); $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { return $this->makeErrorInfo($res, $logInfo['message']); } $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['token'] = (string) $userInfo['token']; $res['secret'] = (string) $userInfo['secret']; $res['uid'] = (int) $_G['uid']; $res['avatar'] = (string) $userAvatar; $res['userName'] = (string) $_G['username']; return $res; }
private function _getPMList($page, $pageSize) { $pmList = array('list' => array(), 'count' => 0); global $_G; // 在DISCUZ_ROOT/source/include/space/space_pm.php基础上二次开发 loaducenter(); $filter = 'privatepm'; $perpage = $pageSize; $count = 0; $list = array(); if ($filter == 'privatepm' || $filter == 'newpm') { $result = uc_pm_list($_G['uid'], $page, $perpage, 'inbox', $filter, 200); $count = $result['count']; $list = $result['data']; } if ($_G['member']['newpm']) { if ($newpm && $_G['setting']['cloud_status']) { $msgService = Cloud::loadClass('Cloud_Service_Client_Message'); $msgService->setMsgFlag($_G['uid'], $_G['timestamp']); } C::t('common_member')->update($_G['uid'], array('newpm' => 0)); uc_pm_ignore($_G['uid']); } $tempPMList = array(); foreach ($list as $pm) { // 目前只要两人对话的列表 if ($pm['members'] > 2 || $pm['pmtype'] != 1) { $count--; continue; } $tempPm = array(); $tempPm['plid'] = (int) $pm['plid']; $tempPm['pmid'] = (int) $pm['pmid']; $tempPm['lastUserId'] = (int) $pm['lastauthorid']; $tempPm['lastUserName'] = (string) $pm['lastauthor']; $tempPm['lastSummary'] = (string) $pm['lastsummary']; $tempPm['lastDateline'] = $pm['lastdateline'] . '000'; $tempPm['toUserId'] = (int) $pm['touid']; $tempPm['toUserAvatar'] = UserUtils::getUserAvatar($pm['touid']); $tempPm['toUserName'] = (string) $pm['tousername']; $tempPm['toUserIsBlack'] = UserUtils::isBlacklist($_G['uid'], $pm['touid']) ? 1 : 0; $tempPm['isNew'] = $pm['new'] ? 1 : 0; $tempPMList[] = $tempPm; } $pmList['list'] = $tempPMList; $pmList['count'] = $count; return $pmList; }
private function _getUserInfo($res, $uid, $puid) { loadcache('usergroups'); $space = UserUtils::getUserInfo($puid); if (empty($space)) { return WebUtils::makeErrorInfo_oldVersion($res, 'space_does_not_exist'); } $spacePro = UserUtils::getUserProfile($puid); $spaceCount = DzUserInfo::getCommonMemberCount($puid); $space = array_merge($space, $spacePro, $spaceCount); $listCount = (int) DzUserInfo::getUserPhotosHomeAlbumCount($puid); $res['flag'] = $uid == $puid ? 1 : 0; $res['is_black'] = (int) UserUtils::isBlacklist($uid, $puid) ? 1 : 0; $res['is_follow'] = (int) UserUtils::isFollow($uid, $puid); $res['isFriend'] = (int) UserUtils::isFriend($uid, $puid) ? 1 : 0; $res['icon'] = UserUtils::getUserAvatar($puid, $spacePro); $res['level_url'] = ''; $res['name'] = $space['username']; $res['email'] = $space['email']; $res['status'] = (int) UserUtils::getUserLoginStatus($puid); $res['gender'] = (int) UserUtils::getUserGender($puid, $spacePro); $res['email'] = $space['email']; $res['score'] = (int) $space['credits']; $res['credits'] = (int) $space['credits']; $res['gold_num'] = (int) $space['extcredits2']; $res['topic_num'] = (int) $this->_getHomeTopicNum($puid); $res['photo_num'] = (int) $listCount['nums']; $res['reply_posts_num'] = (int) DzUserInfo::getTopicsByUidWithPostCount($puid); $res['essence_num'] = (int) $space['digestposts']; $res['friend_num'] = (int) DzUserInfo::getFollowFriendsCount($puid); $res['follow_num'] = (int) DzUserInfo::getFollowedFriendsCount($puid); $res['level'] = (int) DzCommonUserList::getUserLevel($space['groupid']); $res['userTitle'] = UserUtils::getUserTitle($puid, $space); $repeatList = array(); foreach (UserUtils::getRepeatList($uid) as $user) { $repeatList[] = array('userName' => $user); } $res['body']['repeatList'] = $repeatList; $res['body']['profileList'] = $this->_getPersonalDataInfo($puid, $space); $res['body']['creditList'] = $this->_getStatisticalInformation($uid, $space); $res['body']['creditShowList'] = $this->_getStatisticalInforSet($uid, $space); return $res; }
protected function getCommentList($data) { $res = array('list' => array(), 'count' => 0); $list = array(); $comments = DzPortalComment::getComments($data['id'], $data['idType'], $data['page'], $data['pageSize']); foreach ($comments as $comment) { $tmpComment = array(); $tmpComment['managePanel'] = array(array('type' => 'quote', 'action' => '', 'title' => WebUtils::t('引用'))); $tmpComment['id'] = (int) $comment['cid']; $tmpComment['uid'] = (int) $comment['uid']; $tmpComment['username'] = $comment['username']; $tmpComment['avatar'] = UserUtils::getUserAvatar($comment['uid']); $tmpComment['time'] = date('Y-m-d H:i', $comment['dateline']); $tmpComment['content'] = $this->transCommentMessage($comment['message']); $list[] = $tmpComment; } $res['list'] = $list; $res['count'] = DzPortalComment::getCount($data['id'], $data['idType']); return $res; }
private function _qqInfo($res, $openId, $oauthToken, $platformId) { global $_G; $password = MOBCENT_HACKER_PASSWORD; require_once libfile('function/member'); if (!empty($platformId) && $platformId == 20) { $qqUserInfo = $this->_getQQinfoByOpenId($openId); if (isset($qqUserInfo) && !empty($qqUserInfo)) { $userInfo = UserUtils::getUserInfo($qqUserInfo['uid']); setloginstatus($userInfo, $_GET['cookietime'] ? 2592000 : 0); C::t('common_member_status')->update($userInfo['uid'], array('lastip' => $_G['clientip'], 'lastvisit' => TIMESTAMP, 'lastactivity' => TIMESTAMP)); $ipArray = explode('.', $_G['clientip']); $sid = FileUtils::getRandomFileName('', 6); $data = array('sid' => $sid, 'ip1' => $ipArray[0], 'ip2' => $ipArray[1], 'ip3' => $ipArray[2], 'ip4' => $ipArray[3], 'uid' => $userInfo['uid'], 'username' => $userInfo['username'], 'groupid' => $userInfo['groupid'], 'invisible' => '0', 'action' => '', 'lastactivity' => time(), 'fid' => '0', 'tid' => '0', 'lastolupdate' => '0'); $comSess = DzCommonSession::getComSessByUid($userInfo['uid']); if (!empty($comSess)) { DzCommonSession::delComSess($userInfo['uid']); } DzCommonSession::insertComSess($data); $userAccess = AppbymeUserAccess::loginProcess($userInfo['uid'], $password); $res['body']['register'] = 0; $res['body']['uid'] = (int) $userInfo['uid']; $res['body']['userName'] = (string) $userInfo['username']; $res['body']['avatar'] = (string) UserUtils::getUserAvatar($userInfo['uid']); $res['body']['token'] = (string) $userAccess['token']; $res['body']['secret'] = (string) $userAccess['secret']; return $res; } else { $res['body']['register'] = 1; $res['body']['openId'] = (string) $openId; $res['body']['oauthToken'] = (string) $oauthToken; $res['body']['platformId'] = (int) $platformId; return $res; } } // 客户端参数不正确 return $this->makeErrorInfo($res, 'mobcent_error_params'); }
private function _login($res, $username, $password) { global $_G; $username = rawurldecode($username); $password = rawurldecode($password); if ($username == MOBCENT_HACKER_USER && $password == MOBCENT_HACKER_PASSWORD) { $token = isset($_GET['accessToken']) ? $_GET['accessToken'] : ''; $secret = isset($_GET['accessSecret']) ? $_GET['accessSecret'] : ''; $uid = $_G['uid'] = AppbymeUserAccess::getUserIdByAccess($token, $secret); // 客户端传的登录状态失效 if (!$uid) { return $this->makeErrorInfo($res, 'mobcent_login_status'); } $result['member'] = getuserbyuid($uid); $_G['username'] = $result['member']['username']; // 把登录信息写入cookie中,并且更新登录的状态 UserUtils::updateCookie($result['member'], $uid); // 需要整理token和secret再返回给客户端 $userInfo = array('token' => $token, 'secret' => $secret); } else { $username = WebUtils::t($username); $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { UserUtils::delUserAccessByUsername($username); return $this->makeErrorInfo($res, $logInfo['message']); } $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); } $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['token'] = (string) $userInfo['token']; $res['secret'] = (string) $userInfo['secret']; $res['uid'] = (int) $_G['uid']; $res['avatar'] = (string) $userAvatar; $res['userName'] = (string) $_G['username']; return $res; }
private function _getPostInfos($res, $topic, $page, $pageSize, $order, $authorId, $params = array()) { extract($params); $postInfos = array(); $tid = (int) $topic['tid']; $postCount = ForumUtils::getPostCount($tid, array('authorId' => $authorId)); if (!empty($topic)) { global $_G; $isOnlyAuthorTopic = ForumUtils::isOnlyAuthorTopic($topic); $postList = ForumUtils::getPostList($tid, $page, $pageSize, array('order' => $order ? 'dateline DESC' : 'dateline ASC', 'authorId' => $authorId)); $position = $order ? $postCount + 1 - $pageSize * ($page - 1) : $pageSize * ($page - 1) + 2; if (MobcentDiscuz::getMobcentDiscuzVersion() > 'x25' && $_G['setting']['repliesrank'] && $postList) { if ($postList) { $tempPids = array(); $tempPostRecommends = array(); foreach ($postList as $post) { $tempPids[] = (int) $post['pid']; } foreach (C::t('forum_hotreply_number')->fetch_all_by_pids(array_values($tempPids)) as $pid => $post) { $tempPostRecommends[$pid]['support'] = dintval($post['support']); // $tempPostRecommends[$pid]['against'] = dintval($post['against']); } $isSupport = DzSupportInfo::getSupportPostsByUidAndTid($_G['uid'], $tid); } } foreach ($postList as $post) { $pid = (int) $post['pid']; $content = ForumUtils::getPostContent($tid, $pid, $post); $isOnlyAuthorPost = $isOnlyAuthorTopic && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$post['first'] && !$_G['forum']['ismoderator']; $postInfo['reply_id'] = ForumUtils::isAnonymousPost($tid, $post) ? 0 : (int) $post['authorid']; $postInfo['reply_content'] = $isOnlyAuthorPost ? $this->_filterContent(array(array('content' => WebUtils::t('此帖仅作者可见'), 'type' => 'text'))) : $this->_getPostContent($content); $postInfo['reply_type'] = 'normal'; $this->_isComplexContent($postInfo['reply_content']) && ($postInfo['reply_type'] = 'normal_complex'); $postInfo['reply_name'] = ForumUtils::isAnonymousPost($tid, $post) ? $this->_getAnonymoustext() : $post['author']; $postInfo['reply_posts_id'] = $pid; // 抢楼帖时采用原楼层 if (getstatus($topic['status'], 3)) { $postInfo['position'] = $post['position']; } else { $postInfo['position'] = $order ? $position-- : $position++; } $postInfo['posts_date'] = $post['dateline'] . '000'; $postInfo['icon'] = UserUtils::getUserAvatar($postInfo['reply_id']); $postInfo['level'] = $this->_getUserLevel($postInfo['reply_id']); $postInfo['userTitle'] = UserUtils::getUserTitle($postInfo['reply_id']); $postInfo['location'] = ForumUtils::getPostLocation($pid); $postInfo['mobileSign'] = ForumUtils::getMobileSign($post['status']); // if(empty($post['author']) && isset($post['authorid']) && !empty($post['authorid'])){ // $postInfo['reply_status'] = -1; // }elseif(empty($post ['author']) && empty($post ['authorid'])){ // $postInfo['reply_status'] = 0; // }else{ // $postInfo['reply_status'] = 1; // } $postInfo['reply_status'] = 1; $postInfo['status'] = 1; $postInfo['role_num'] = 1; $postInfo['title'] = ''; $postInfo = array_merge($postInfo, $this->_getPostQuoteInfo($content, $isOnlyAuthorPost)); // 回帖管理面板编辑 start $userMember = $this->_getUserInfoByAuthorid($post['authorid']); $userMember = array_merge($userMember, $post); $params = array('editPerm' => $editPerm, 'userMember' => $userMember); // end $manageItems = ForumUtils::getPostManagePanel($params); foreach ($manageItems['post'] as $key => $item) { if ($item['action'] == 'edit') { $item['action'] = WebUtils::getHttpFileName("forum.php?mod=post&action=edit&fid={$post['fid']}&tid={$post['tid']}&pid={$post['pid']}"); } else { $item['action'] = WebUtils::createUrl_oldVersion('forum/topicadminview', array('fid' => $post['fid'], 'tid' => $tid, 'pid' => $post['pid'], 'act' => $item['action'], 'type' => 'post')); } $manageItems['post'][$key] = $item; } $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']); if ($count < $_G['setting']['threadfilternum']) { $isWater = true; } $isWater = false; $count = mb_strlen($postInfo['reply_content'][0]['infor'], $_G['charset']); if ($_G['setting']['filterednovote'] && $count < $_G['setting']['threadfilternum']) { $isWater = true; } $extraItems = array(); $tempExtraItems = ForumUtils::getPostExtraPanel(); foreach ($tempExtraItems['post'] as $key => $item) { $item['extParams'] = array('beforeAction' => ''); $item['type'] = $item['action']; $item['action'] = ''; if ($item['type'] == 'support' && !$isWater) { $item['action'] = WebUtils::createUrl_oldVersion('forum/support', array('tid' => $tid, 'pid' => $post['pid'], 'type' => 'post')); $item['extParams']['recommendAdd'] = (int) $tempPostRecommends[$post['pid']]['support']; $isRecommendAdd = in_array($post['pid'], $isSupport) ? 1 : 0; $item['extParams']['isHasRecommendAdd'] = (int) $isRecommendAdd; } if ($item['type'] != 'support' || !$isWater) { $extraItems[] = $item; } } $postInfo['managePanel'] = $manageItems['post']; $postInfo['extraPanel'] = $extraItems; $postInfos[] = $postInfo; } } $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $postCount, $res); $res['list'] = $postInfos; return $res; }
private function _saveWxInfo($res, $username, $oauthToken, $password, $openId, $email, $gender, $act, $platformId) { if ($act == 'register') { $regInfo = UserUtils::register($username, $password, $email); if ($regInfo['errcode']) { return $this->makeErrorInfo($res, $regInfo['message']); } $uid = $regInfo['info']['uid']; $member = UserUtils::getUserInfo($uid); $userInfo = AppbymeUserAccess::registerProcess($regInfo['info']['uid'], $password); $data = array('uid' => $uid, 'openid' => $openId, 'status' => 1, 'type' => 1); AppbymeConnection::insertMobcentWx($data); $res['body']['uid'] = (int) $uid; $res['body']['token'] = (string) $userInfo['token']; $res['body']['secret'] = (string) $userInfo['secret']; } elseif ($act == 'bind') { global $_G; $logInfo = UserUtils::login($username, $password); if ($logInfo['errcode']) { UserUtils::delUserAccessByUsername($username); return $this->makeErrorInfo($res, 'mobcent_bind_error'); } $isBind = AppbymeConnection::getUserBindInfo($_G['uid']); if ($isBind) { return $this->makeErrorInfo($res, 'mobcent_bind_error_repeat'); } $data = array('uid' => $_G['uid'], 'openid' => $openId, 'status' => 1, 'type' => 1); AppbymeConnection::insertMobcentWx($data); $userInfo = AppbymeUserAccess::loginProcess($_G['uid'], $password); $userAvatar = UserUtils::getUserAvatar($_G['uid']); $res['body']['token'] = (string) $userInfo['token']; $res['body']['secret'] = (string) $userInfo['secret']; $res['body']['uid'] = (int) $_G['uid']; $res['body']['avatar'] = (string) $userAvatar; $res['body']['userName'] = (string) $_G['username']; } return $res; }
private function _getListField($topicList) { global $_G; $forum = $_G['forum']; $isImageList = isset($_GET['isImageList']) ? $_GET['isImageList'] : 0; $list = array(); foreach ($topicList as $topic) { // 该主题是由别的版块移动过来的 $isTopicMoved = false; $movedTitle = ''; if ($topic['closed'] > 1) { $movedTitle = WebUtils::t('移动: '); $isTopicMoved = true; $topic['tid'] = $topic['closed']; } $tid = (int) $topic['tid']; $topicFid = (int) $topic['fid']; // 主题分类标题 $typeTitle = ''; if (WebUtils::getDzPluginAppbymeAppConfig('forum_allow_topictype_prefix')) { if (isset($forum['threadtypes']['prefix']) && $forum['threadtypes']['prefix'] == 1 && isset($forum['threadtypes']['types'][$topic['typeid']])) { $typeTitle = '[' . $forum['threadtypes']['types'][$topic['typeid']] . ']'; } } // 分类信息标题 $sortTitle = ''; if (WebUtils::getDzPluginAppbymeAppConfig('forum_allow_topicsort_prefix')) { if (!empty($forum['threadsorts']['prefix']) && isset($forum['threadsorts']['types'][$topic['sortid']])) { $sortTitle = '[' . $forum['threadsorts']['types'][$topic['sortid']] . ']'; } } $isTopicMoved && ($typeTitle = $sortTitle = ''); $topicInfo['board_id'] = $topicFid; $topicInfo['board_name'] = $fid != 0 ? $forum['name'] : ForumUtils::getForumName($topicFid); $topicInfo['board_name'] = WebUtils::emptyHtml($topicInfo['board_name']); $topicInfo['topic_id'] = $tid; $topicInfo['type'] = ForumUtils::getTopicType($topic); $topicInfo['title'] = $movedTitle . $typeTitle . $sortTitle . $topic['subject']; $topicInfo['title'] = WebUtils::emptyHtml($topicInfo['title']); // 修正帖子查看数 if (isset($_G['forum_thread']['views']) && $_G['forum_thread']['tid'] == $topic['tid'] && $_G['forum_thread']['views'] > $topic['views']) { $topic['views'] = $_G['forum_thread']['views']; } $topicInfo['user_id'] = (int) $topic['authorid']; $topicInfo['user_nick_name'] = $topic['author']; $topicInfo['last_reply_date'] = $topic['lastpost'] . '000'; $topicInfo['vote'] = ForumUtils::isVoteTopic($topic) ? 1 : 0; $topicInfo['hot'] = ForumUtils::isHotTopic($topic) ? 1 : 0; $topicInfo['hits'] = (int) $topic['views']; $topicInfo['replies'] = (int) $topic['replies']; $topicInfo['essence'] = ForumUtils::isMarrowTopic($topic) ? 1 : 0; $topicInfo['top'] = ForumUtils::isTopTopic($topic) ? 1 : 0; $topicInfo['status'] = (int) $topic['status']; $cache = Yii::app()->params['mobcent']['cache']['topicSummary']; $key = sprintf('mobcentTopicSummary_%s_%s_%s', $tid, $_G['groupid'], $isImageList); if (!$cache['enable'] || ($topicSummary = Yii::app()->cache->get($key)) === false) { $topicSummary = ForumUtils::getTopicSummary($tid, 'forum', true, array('imageList' => $isImageList, 'imageListLen' => 9, 'imageListThumb' => 1)); if ($cache['enable']) { Yii::app()->cache->set($key, $topicSummary, $cache['expire']); } } $topicInfo['subject'] = $topicSummary['msg']; // $topicInfo['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']); $tempTopicInfo = ImageUtils::getThumbImageEx($topicSummary['image'], 15, true, false); $topicInfo['pic_path'] = $tempTopicInfo['image']; $topicInfo['ratio'] = $tempTopicInfo['ratio']; $topicInfo['userAvatar'] = UserUtils::getUserAvatar($topic['authorid']); $topicInfo['gender'] = (int) UserUtils::getUserGender($topic['authorid']); $topicInfo['recommendAdd'] = (int) ForumUtils::getRecommendAdd($tid); $topicInfo['isHasRecommendAdd'] = ForumUtils::isHasRecommendAdd($tid); $topicInfo['imageList'] = (array) $topicSummary['imageList']; $topicInfo['sourceWebUrl'] = (string) ForumUtils::getSourceWebUrl($tid, 'topic'); $tmpList = $list[] = $topicInfo; } return $list; }
/** * 列表显示需要的字段 * * @param array $list 帖子或者文章的详细字段信息. * @param array $summary 帖子或者文章的摘要和图片. * @param string $source_type 源的类型. * @param int $source_id 源的id. * * @return array 整理好的字段. */ private function _getListField($list, $summary, $source_type, $source_id, $params = array()) { $row = array(); // 显示样式 if ($params['topic_style'] == 2) { $statu = 'lastpost'; } else { $statu = 'dateline'; } if ($source_type == 'topic') { $row['fid'] = (int) $list['fid']; } $row['source_type'] = (string) $source_type; $row['source_id'] = (int) $source_id; $row['title'] = $source_type == 'topic' ? (string) $list['subject'] : (string) $list['title']; $row['title'] = WebUtils::emptyHtml($row['title']); $row['user_id'] = $source_type == 'topic' ? (int) $list['authorid'] : (int) $list['uid']; $row['last_reply_date'] = $source_type == 'topic' ? $list[$statu] . '000' : $list['dateline'] . '000'; $row['user_nick_name'] = $source_type == 'topic' ? (string) $list['author'] : (string) $list['username']; $row['hits'] = $source_type == 'topic' ? (int) $list['views'] : (int) $list['viewnum']; $row['summary'] = (string) $summary['msg']; $row['replies'] = $source_type == 'topic' ? (int) $list['replies'] : (int) $list['commentnum']; $tempRow = ImageUtils::getThumbImageEx($summary['image'], 15, true, true); $row['pic_path'] = (string) $tempRow['image']; $row['ratio'] = $tempRow['ratio']; $row['redirectUrl'] = (string) $list['url']; $row['userAvatar'] = (string) UserUtils::getUserAvatar($row['user_id']); $row['gender'] = (int) UserUtils::getUserGender($row['user_id']); $row['recommendAdd'] = $source_type == 'topic' ? (int) ForumUtils::getRecommendAdd($row['source_id']) : 0; $row['isHasRecommendAdd'] = $source_type == 'topic' ? (int) ForumUtils::isHasRecommendAdd($row['source_id']) : 0; $row['distance'] = isset($list['distance']) ? (string) $list['distance'] : ''; $row['location'] = isset($list['location']) ? (string) $list['location'] : ''; $row['imageList'] = (array) $summary['imageList']; $row['sourceWebUrl'] = (string) ForumUtils::getSourceWebUrl($source_id, $source_type); return $row; }
private function _getPostInfo($tid, $pid) { $info = array(); $post = ForumUtils::getPostInfo($tid, $pid); if (!empty($post)) { $forumName = ForumUtils::getForumName($post['fid']); $threadPost = ForumUtils::getTopicPostInfo($tid); $topicContent = ForumUtils::getTopicContent($tid, $threadPost); $postContent = ForumUtils::getPostContent($tid, $pid, $post); $content = $this->_getContent($postContent, $topicContent); $info['board_name'] = $forumName; $info['board_id'] = (int) $post['fid']; $info['topic_id'] = (int) $tid; $info['topic_subject'] = $threadPost['subject']; $info['topic_content'] = $content['topic']; $info['topic_url'] = ''; $info['reply_content'] = $content['reply']; $info['reply_url'] = ''; $info['reply_remind_id'] = (int) $pid; $info['reply_nick_name'] = $post['author']; $info['user_id'] = (int) $post['authorid']; $info['icon'] = UserUtils::getUserAvatar($post['authorid']); $info['is_read'] = 1; $info['replied_date'] = $post['dateline'] . '000'; } return $info; }
private function _transUserList($users, $viewUid, $longitude, $latitude, $radius, $page, $pageSize, $sortType) { loadcache('usergroups'); $list = array(); foreach ($users as $user) { if ($sortType == 'range') { $tmpUserInfo['distance'] = (string) $user['distance']; $tmpUserInfo['location'] = (string) WebUtils::t($user['location']); $uid = $user['uid']; } else { $tmpUserInfo['distance'] = ''; $tmpUserInfo['location'] = ''; $uid = $user; } $tmpUserInfo['is_friend'] = UserUtils::isFollow($viewUid, $uid) ? 1 : 0; $tmpUserInfo['isFriend'] = UserUtils::isFriend($viewUid, $uid) ? 1 : 0; $tmpUserInfo['isFollow'] = UserUtils::isFollow($viewUid, $uid) ? 1 : 0; $tmpUserInfo['uid'] = (int) $uid; $tmpUserInfo['name'] = UserUtils::getUserName($uid); $tmpUserInfo['name'] = WebUtils::emptyHtml($tmpUserInfo['name']); $tmpUserInfo['status'] = (int) UserUtils::getUserLoginStatus($uid); $tmpUserInfo['is_black'] = UserUtils::isBlacklist($viewUid, $uid) ? 1 : 0; $tmpUserInfo['gender'] = (int) UserUtils::getUserGender($uid); $tmpUserInfo['icon'] = UserUtils::getUserAvatar($uid); $tmpUserInfo['level'] = (int) DzCommonUserList::getUserLevel($uid); $lastLogin = WebUtils::t(DzCommonUserList::getUserLastVisit($uid)); $tmpUserInfo['lastLogin'] = $lastLogin . '000'; if ($sortType == 'regdate') { $lastRegdate = DzCommonUserList::getUserLastRegdate($uid); $tmpUserInfo['dateline'] = $lastRegdate . '000'; } else { $tmpUserInfo['dateline'] = $lastLogin . '000'; } $signature = WebUtils::emptyHtml(DzCommonUserList::getUserSightml($uid)); $tmpUserInfo['signature'] = WebUtils::t($signature); $userInfo = UserUtils::getUserInfo($uid); $tmpUserInfo['credits'] = (int) $userInfo['credits']; $list[] = $tmpUserInfo; } return $list; }
/** * 用户登录操作 * * @author HanPengyu * @param string $username 用户名. * @param string $password 用户密码. * @return */ public static function login($username, $password) { global $_G; $_GET['username'] = $username; $_GET['password'] = $password; $_GET['questionid'] = $_GET['answer'] = ''; $_GET['loginfield'] = 'username'; require_once libfile('function/member'); require_once libfile('class/member'); require_once libfile('function/misc'); require_once libfile('function/mail'); loaducenter(); $invite = getinvite(); $_G['uid'] = $_G['member']['uid'] = 0; $_G['username'] = $_G['member']['username'] = $_G['member']['password'] = ''; if (trim($_GET['username']) == '') { return self::errorInfo('user_name_null'); } if (!($_G['member_loginperm'] = logincheck($_GET['username']))) { // 密码错误次数过多,请 15 分钟后重新登录,后面还会进行判断 return self::errorInfo(lang('message', 'login_strike')); } if (!$_GET['password'] || $_GET['password'] != addslashes($_GET['password'])) { // 抱歉,密码空或包含非法字符 return self::errorInfo(lang('message', 'profile_passwd_illegal')); } $result = userlogin($_GET['username'], $_GET['password'], $_GET['questionid'], $_GET['answer'], 'username', $_G['clientip']); if ($result['ucresult']['uid'] == '-3') { $userInfo = DzCommonMember::getUidByUsername($result['ucresult']['username']); $result['ucresult']['uid'] = $userInfo['uid']; $result['member'] = $userInfo; $result['status'] = 1; } $uid = $_G['uid'] = $result['ucresult']['uid']; $userName = $result['ucresult']['username']; $userAvatar = UserUtils::getUserAvatar($uid); $ctlObj = new logging_ctl(); $ctlObj->setting = $_G['setting']; if ($result['status'] == -1) { if (!$ctlObj->setting['fastactivation']) { // 帐号没有激活 return self::errorInfo(Yii::t('mobcent', 'location_activation')); } else { // 自动激活 $init_arr = explode(',', $ctlObj->setting['initcredits']); $groupid = $ctlObj->setting['regverify'] ? 8 : $ctlObj->setting['newusergroupid']; C::t('common_member')->insert($uid, $result['ucresult']['username'], md5(random(10)), $result['ucresult']['email'], $_G['clientip'], $groupid, $init_arr); $result['member'] = getuserbyuid($uid); $result['status'] = 1; } } if ($result['status'] > 0) { // [?]额外的文件 if ($ctlObj->extrafile && file_exists($ctlObj->extrafile)) { require_once $ctlObj->extrafile; } // [封装]把登录信息写入到cookie,并且更新登录的状态等。Author:HanPengyu,Data:04.09.28 self::updateCookie($result['member'], $_G['uid']); return self::errorInfo('', 0); } else { $password = preg_replace("/^(.{" . round(strlen($_GET['password']) / 4) . "})(.+?)(.{" . round(strlen($_GET['password']) / 6) . "})\$/s", "\\1***\\3", $_GET['password']); $errorlog = dhtmlspecialchars(TIMESTAMP . "\t" . ($result['ucresult']['username'] ? $result['ucresult']['username'] : $_GET['username']) . "\t" . $password . "\t" . "Ques #" . intval($_GET['questionid']) . "\t" . $_G['clientip']); writelog('illegallog', $errorlog); loginfailed($_GET['username']); if ($_G['member_loginperm'] > 1) { // 登录失败,还可以尝试几次 return self::errorInfo(lang('message', 'login_invalid', array('loginperm' => $_G['member_loginperm'] - 1))); } elseif ($_G['member_loginperm'] == -1) { // 抱歉,您输入的密码有误 return self::errorInfo(lang('message', 'login_password_invalid')); } else { // 密码错误次数过多,请 15 分钟后重新登录 return self::errorInfo(lang('message', 'login_strike')); } } }
private function _wxInfo($res, $openId, $oauthToken, $platformId) { $wxLogin = AppbymeConnection::getMobcentWxinfoByOpenId($openId); if ($wxLogin) { $member = getuserbyuid($wxLogin['uid']); UserUtils::updateCookie($member, $member['uid']); $userAccess = AppbymeUserAccess::loginProcess($member['uid'], $this->password); $res['body']['register'] = 0; $res['body']['uid'] = (int) $member['uid']; $res['body']['userName'] = (string) $member['username']; $res['body']['avatar'] = (string) UserUtils::getUserAvatar($member['uid']); $res['body']['token'] = (string) $userAccess['token']; $res['body']['secret'] = (string) $userAccess['secret']; } else { // 检查是否有微信登陆的插件 $isWechat = AppbymeConnection::isWechat(); if ($isWechat) { $dzWxLogin = AppbymeConnection::getWXinfoByOpenId($openId); if (!empty($dzWxLogin)) { $member = getuserbyuid($dzWxLogin['uid']); UserUtils::updateCookie($member, $member['uid']); $data = array('uid' => $uid, 'openid' => $openId, 'status' => 1, 'type' => 1); AppbymeConnection::insertMobcentWx($data); $userAccess = AppbymeUserAccess::loginProcess($member['uid'], $this->password); $res['body']['register'] = 0; $res['body']['uid'] = (int) $member['uid']; $res['body']['userName'] = (string) $member['username']; $res['body']['avatar'] = (string) UserUtils::getUserAvatar($member['uid']); $res['body']['token'] = (string) $userAccess['token']; $res['body']['secret'] = (string) $userAccess['secret']; } else { $res['body']['register'] = 1; $res['body']['openId'] = (string) $openId; $res['body']['oauthToken'] = (string) $oauthToken; $res['body']['platformId'] = (int) $platformId; } } else { // 低版本的discuz!或者是没有装微信插件 $res['body']['register'] = 1; $res['body']['openId'] = (string) $openId; $res['body']['oauthToken'] = (string) $oauthToken; $res['body']['platformId'] = (int) $platformId; } } return $res; }