Esempio n. 1
0
 private function _getUserInfoList($res, $type, $uid, $viewUid, $page, $pageSize, $sortType, $longitude, $latitude, $radius)
 {
     $res['list'] = $this->_getUserList($type, $uid, $viewUid, $page, $pageSize, $sortType, $longitude, $latitude, $radius);
     $count = $this->_getUserListCount($type, $uid, $viewUid, $page, $pageSize);
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     return $res;
 }
 private function _getImageInfoList($res, $landUid, $uid, $page, $pageSize, $albumId)
 {
     $list = array();
     $imageList = UserPhotoInfo::getImageListByAlbumId($albumId, $uid, $page, $pageSize);
     foreach ($imageList as $image) {
         $tempimageInfo = PhotoUtils::getPhotoInfo($image);
         // $imageInfo['board_id'] = (Int)$albumId;
         $imageInfo['pic_id'] = (int) $image;
         $imageInfo['title'] = $tempimageInfo['title'] == "" ? $tempimageInfo['filename'] : $tempimageInfo['title'];
         $imageInfo['title'] = WebUtils::emptyHtml($imageInfo['title']);
         $imageInfo['user_id'] = (int) $uid;
         $imageInfo['release_date'] = $tempimageInfo['dateline'] . "000";
         $lastReplyDate = PhotoUtils::getReplyDate($image);
         $imageInfo['last_update_date'] = $lastReplyDate['last_reply_date'] . "000";
         $imageInfo['user_nick_name'] = $tempimageInfo['username'];
         $imageInfo['hot'] = (int) $tempimageInfo['hot'];
         $imageInfo['replies'] = (int) PhotoUtils::getReplyCount($image);
         $imageInfo['thumb_pic'] = PhotoUtils::getImageCover($image);
         $imageInfo['origin_pic'] = PhotoUtils::getPhotosoRiginCover($tempimageInfo);
         $list[] = $imageInfo;
     }
     global $_G;
     if ($_G['adminid'] != 1) {
         $albumInfo = UserPhotoInfo::getAlbumInfo($uid, $albumId);
         switch ($albumInfo['friend']) {
             case 0:
                 $list;
                 break;
             case 1:
                 UserUtils::isFriend($uid, $landUid) || $landUid == $uid ? $list : ($list = 1);
                 break;
             case 2:
                 $list = PhotoUtils::judgeDesignatedFriends($albumInfo, $landUid, $uid, $list);
                 break;
             case 3:
                 $uid == $landUid ? $list : ($list = 3);
                 break;
             case 4:
                 $landUid == $uid ? $list : ($list = 4);
                 break;
         }
     }
     $res['list'] = $list;
     if ($albumId == 0) {
         $count = UserPhotoInfo::getImageListCountByAlbumId($uid);
     } else {
         $count = UserPhotoInfo::getImageListCount($albumId, $uid);
     }
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     if (empty($res['list'])) {
         if ($albumId == 0) {
             return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_defaultAlbum_does_not_exist');
         }
         return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_photo_does_not_exist');
     } elseif ($res['list'] == 1 || $res['list'] == 2 || $res['list'] == 3 || $res['list'] == 4) {
         $res['list'] = array();
         return WebUtils::makeErrorInfo_oldVersion($res, 'to_view_the_photo_set_privacy', array('{username}' => $albumInfo['username']));
     }
     return $res;
 }
 private function _getImageList($res, $page, $pageSize)
 {
     $res['list'] = $this->_getImageInfoByTids($page, $pageSize);
     $count = $this->_getImageInfoCount();
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     return $res;
 }
 private function _getTopicList($res, $type, $idType, $uid, $page, $pageSize, $idtype)
 {
     $res['list'] = $this->_getUserTopicList($type, $idType, $uid, $page, $pageSize);
     $count = $this->_getUserTopicListCount($type, $idType, $uid, $idtype);
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     return $res;
 }
Esempio n. 5
0
 private function _getUserPostFriendPagingListInfo($res, $friendList, $followList, $page, $pageSize)
 {
     $res['list'] = $this->_getUserPostFriendPagingList($friendList, $followList, $page, $pageSize);
     $count = $this->_getUserPostFriendListCount($friendList, $followList);
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     return $res;
 }
Esempio n. 6
0
 private function _getUserAlbumList($res, $landUid, $uid, $page, $pageSize)
 {
     $res['list'] = $this->_getAlbumInfoList($res, $landUid, $uid, $page, $pageSize);
     $count = UserAlbumInfo::getAlbumListCount($uid);
     if ($landUid != $uid) {
         $count = $count - 1;
     }
     $res = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count, $res);
     return $res;
 }
 public function run($type = 'post', $page = 1, $pageSize = 20)
 {
     require_once libfile('function/friend');
     $res = WebUtils::initWebApiArray_oldVersion();
     $uid = $this->getController()->uid;
     $notifyInfo = $this->_getNotifyInfo($uid, $type, $page, $pageSize);
     $list = $notifyInfo['list'];
     $count = $notifyInfo['count'];
     $res = array_merge($res, WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count));
     $res['list'] = $list;
     $res['body']['data'] = $notifyInfo['data'];
     // $transaction = Yii::app()->dbDz->beginTransaction();
     // try {
     echo WebUtils::outputWebApi($res, '', false);
     $this->_updateReadStatus($uid, $type);
     //  $transaction->commit();
     // } catch(Exception $e) {
     //  var_dump($e);
     //     $transaction->rollback();
     // }
     Yii::app()->end();
 }
Esempio n. 8
0
 public function run($longitude, $latitude, $poi = 'user', $page = 1, $pageSize = 10, $radius = 100000)
 {
     $res = WebUtils::initWebApiArray();
     $res = array_merge(array('rs' => 1, 'errcode' => 0), $res);
     $uid = $this->getController()->uid;
     $SurroundingType = $poi;
     // get infos with type
     $infos = array();
     switch ($SurroundingType) {
         case 'user':
             $infos = $this->_getUserInfos($uid, $longitude, $latitude, $radius, $page, $pageSize);
             break;
         case 'topic':
             $infos = $this->_getTopicInfos($uid, $longitude, $latitude, $radius, $page, $pageSize);
             break;
         default:
             break;
     }
     $list = $infos['list'];
     $count = $infos['count'];
     $res['pois'] = $list;
     $res = array_merge($res, WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count));
     echo WebUtils::outputWebApi($res, '', false);
 }
 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;
 }
Esempio n. 10
0
 protected function getResult($params)
 {
     extract($params);
     $res = $this->initWebApiArray();
     if ($page == 1) {
         $res['piclist'] = $this->_getPicList($mid);
     } else {
         $res['piclist'] = array();
     }
     $portals = AppbymePortalModuleSource::getPortalByMid($mid);
     $handCount = $this->_handCount($mid, $portals);
     $autoAdd = AppbymePortalModuleSource::getAutoAdd($mid);
     $params = unserialize(AppbymePoralModule::getModuleParam($mid));
     $params == false && ($params = array());
     // 对错误mid的处理
     if (empty($portals)) {
         $res['list'] = array();
         return $res;
     }
     $count = 0;
     // 自动添加的数目
     if (!empty($autoAdd)) {
         if ($autoAdd[0]['idtype'] == 'fid') {
             // [add]板块设置用户组权限后,针对当前用户进行过滤(在列表中是否显示)Author:HanPengyu,Data:14.11.28
             require_once libfile('function/forumlist');
             foreach ($autoAdd as $auto) {
                 $forum = DzForumForum::getForumFieldByFid($auto['id']);
                 forum($forum) && ($fids[] = $auto['id']);
             }
             $count = DzForumThread::getByFidCount($fids, $params, $longitude, $latitude, $radius);
             // Mobcent::dumpSql();
         } else {
             foreach ($autoAdd as $auto) {
                 $catids[] = $auto['id'];
             }
             $count = DzPortalArticle::getByCatidCount($catids, $params);
         }
     }
     $total = $handCount + $count;
     // 没有查到数据
     if ($total == 0) {
         $res['list'] = array();
         return $res;
     }
     $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $total);
     $res = array_merge($res, $pageInfo);
     $offset = ($page - 1) * $pageSize;
     if ($page == 1) {
         if ($handCount <= self::HANDPAGE) {
             $autoData = array();
             $handData = $handCount != 0 && ($page = 1) ? $this->_handData($mid, $offset, $handCount, $params) : array();
             $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $handCount);
             $res = array_merge($res, $pageInfo);
             if ($count != 0) {
                 if ($autoAdd[0]['idtype'] == 'fid') {
                     $autoData = $this->_autoFidData($fids, $offset, $pageSize, $params, $longitude, $latitude, $radius);
                 } else {
                     $autoData = $this->_autoCatidData($catids, $offset, $pageSize, $params);
                 }
                 $total = $count != 0 ? $count + $handCount : $handCount;
                 $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $total);
                 $res = array_merge($res, $pageInfo);
             }
             $rows = array_merge((array) $handData, (array) $autoData);
             $res['list'] = $rows;
             return $res;
         }
         $total = $count != 0 ? $count + $handCount : $handCount;
         $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $total);
         $res = array_merge($res, $pageInfo);
         $res['list'] = $this->_handData($mid, $offset, $handCount);
         return $res;
     }
     $page = $handCount <= self::HANDPAGE ? $page : $page - 1;
     $offset = ($page - 1) * $pageSize;
     if ($count != 0) {
         if ($autoAdd[0]['idtype'] == 'fid') {
             $autoData = $this->_autoFidData($fids, $offset, $pageSize, $params, $longitude, $latitude, $radius);
         } else {
             $autoData = $this->_autoCatidData($catids, $offset, $pageSize, $params);
         }
         $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count);
         $res = array_merge($res, $pageInfo);
         $res['list'] = $autoData;
     } else {
         $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, $handCount, $handCount);
         $res = array_merge($res, $pageInfo);
         $res['list'] = array();
     }
     return $res;
 }
Esempio n. 11
0
 private function _zhSearchData($kw, $page, $pagesize, $res, $searchparams)
 {
     $keyword = dhtmlspecialchars(trim($kw));
     $keyword = WebUtils::t($keyword);
     require_once libfile('function/search');
     require_once libfile('function/misc');
     require_once libfile('function/post');
     // $searchHelper = Cloud::loadClass('Service_SearchHelper');
     // $searchparams = $searchHelper->makeSearchSignUrl();
     $appService = Cloud::loadClass('Service_App');
     if ($appService->getCloudAppStatus('search') && $searchparams) {
         $source = 'discuz';
         $params = array();
         $params['source'] = $source;
         $params['q'] = $keyword;
         $params['module'] = 'forum';
         $searchparams['params'] = array_merge($searchparams['params'], $params);
         $utilService = Cloud::loadClass('Service_Util');
         $url = $searchparams['url'] . '?' . $utilService->httpBuildQuery($searchparams['params'], '', '&');
     }
     $url = $url . '&page=' . $page;
     // $pageInfo = WebUtils::emptyReturnLine(file_get_contents($url));
     $pageInfo = WebUtils::emptyReturnLine(WebUtils::httpRequest($url));
     $pregIds = '/&tid=(\\d*)"/';
     $pregCount = '/<div class="allnum">(.*?)<\\/div>/';
     //取出搜索结果总数
     preg_match_all($pregIds, $pageInfo, $id);
     $ids = $id[1];
     if (empty($ids)) {
         return WebUtils::makeErrorInfo_oldVersion($res, 'search_no_results');
     }
     preg_match_all($pregCount, $pageInfo, $count);
     $countStr = trim($count[1][0]);
     preg_match_all('/\\d/', $countStr, $total);
     $total_num = (int) str_replace(',', '', implode(',', $total[0]));
     $ids = $id[1];
     $data = $topicInfo = $topicSummary = array();
     foreach ($ids as $v) {
         $topicInfo = ForumUtils::getTopicInfo($v);
         // $topicInfo['lastpost'] = dgmdate($topicInfo['lastpost'], 'u');
         $topicInfos[] = $topicInfo;
     }
     unset($ids);
     $rows = $this->_fieldInfo($topicInfos);
     $pageInfo = WebUtils::getWebApiArrayWithPage_oldVersion($page, 10, $total_num);
     $res['searchid'] = 0;
     $res = array_merge($res, $pageInfo);
     $res['list'] = $rows;
     return $res;
 }
Esempio n. 12
0
 protected function getResult($params = array())
 {
     extract($params);
     $res = WebUtils::initWebApiArray_oldVersion();
     if ($fid != 0) {
         ForumUtils::initForum($fid);
         // check permisson
         global $_G;
         if (empty($_G['forum']['fid'])) {
             return $this->_makeErrorInfo($res, 'forum_nonexistence');
         }
         if ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm']) && !$_G['forum']['allowview']) {
             $msg = mobcent_showmessagenoperm('viewperm', $_G['fid'], $_G['forum']['formulaperm']);
             return $this->_makeErrorInfo($res, $msg['message'], $msg['params']);
         } elseif ($_G['forum']['formulaperm']) {
             $msg = mobcent_formulaperm($_G['forum']['formulaperm']);
             if ($msg['message'] != '') {
                 return $this->_makeErrorInfo($res, $msg['message'], $msg['params']);
             }
         }
         if ($_G['forum']['password']) {
             if ($_GET['action'] == 'pwverify') {
                 if ($_GET['pw'] != $_G['forum']['password']) {
                     showmessage('forum_passwd_incorrect', NULL);
                 } else {
                     dsetcookie('fidpw' . $_G['fid'], $_GET['pw']);
                     showmessage('forum_passwd_correct', "forum.php?mod=forumdisplay&fid={$_G['fid']}");
                 }
                 // } elseif($_G['forum']['password'] != $_G['cookie']['fidpw'.$_G['fid']]) {
             } else {
                 // include template('forum/forumdisplay_passwd');
                 // exit();
                 return $this->_makeErrorInfo($res, 'mobcent_forum_passwd');
             }
         }
         if ($_G['forum']['price'] && !$_G['forum']['ismoderator']) {
             $membercredits = C::t('common_member_forum_buylog')->get_credits($_G['uid'], $_G['fid']);
             $paycredits = $_G['forum']['price'] - $membercredits;
             if ($paycredits > 0) {
                 // if($_GET['action'] == 'paysubmit') {
                 //     updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$paycredits), 1, 'FCP', $_G['fid']);
                 //     C::t('common_member_forum_buylog')->update_credits($_G['uid'], $_G['fid'], $_G['forum']['price']);
                 //     showmessage('forum_pay_correct', "forum.php?mod=forumdisplay&fid=$_G[fid]");
                 // } else {
                 if (getuserprofile('extcredits' . $_G['setting']['creditstransextra'][1]) < $paycredits) {
                     return $this->makeErrorInfo($res, lang('message', 'forum_pay_incorrect', array('paycredits' => $paycredits, 'credits' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'])));
                 } else {
                     return $this->makeErrorInfo($res, 'forum_pay_incorrect_paying', array('{paycredits}' => $paycredits, '{credits}' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title']));
                     // include template('forum/forumdisplay_pay');
                     // exit();
                 }
                 // }
             }
         }
     }
     $res['newTopicPanel'] = $this->_getNewTopicPanel();
     $topicClassfications = $this->_getTopicClassificationInfos($fid);
     $res['classificationTop_list'] = $topicClassfications['sorts'];
     $res['classificationType_list'] = $topicClassfications['types'];
     $res['isOnlyTopicType'] = $topicClassfications['requireTypes'] ? 1 : 0;
     // 获取公告列表
     $hasAnnouncements = $fid != 0 && $page == 1;
     $res['anno_list'] = !$hasAnnouncements ? array() : $this->_getAnnouncementList($sort);
     $topicInfos = $this->_getTopicInfos($fid, $page, $pageSize, $sort, $filterType, $filterId, $isImageList, $topOrder);
     $list = $topicInfos['list'];
     $topTopicList = $topicInfos['topTopicList'];
     $count = $topicInfos['count'];
     $res['forumInfo'] = $this->_getForumInfo($fid);
     $res['topTopicList'] = $topTopicList;
     $res['list'] = $list;
     $res = array_merge($res, WebUtils::getWebApiArrayWithPage_oldVersion($page, $pageSize, $count));
     return $res;
 }