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; }
public function getTopicSort($threadsortshow) { $sort = array('title' => '', 'summary' => ''); if ($threadsortshow['optionlist']) { if ($threadsortshow['optionlist'] == 'expire') { $sort['summary'] = WebUtils::t("该信息已经过期\n"); } else { global $_G; $sort['title'] = $_G['forum']['threadsorts']['types'][$_G['forum_thread']['sortid']]; if (is_array($threadsortshow['optionlist'])) { foreach ($threadsortshow['optionlist'] as $option) { if ($option['type'] != 'info') { $sort['summary'] .= sprintf("%s :\t", $option['title']); if ($option['value'] || $option['type'] == 'number' && $option['value'] !== '') { $option['value'] = WebUtils::emptyHtml($option['value']); $sort['summary'] .= $option['value'] . $option['unit']; } $sort['summary'] .= "\n"; } } } } } return $sort; }
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 _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 _getNotifyInfo($uid, $type, $page, $pageSize) { $info = array('count' => 0, 'list' => array(), 'data' => array()); $count = DzHomeNotification::getCountByUid($uid, $type); $notifyData = DzHomeNotification::getAllNotifyByUid($uid, $type, $page, $pageSize); foreach ($notifyData as $data) { $isAllowData = true; $actions = array(); $matches = array(); preg_match('/<a onclick="showWindow.+?>(\\S+)<\\/a>/mi', $data['note'], $matches); if (!empty($matches)) { $actions = array(); $action = array('redirect' => '', 'title' => $matches[1], 'type' => ''); // 添加好友按钮 $tempMatches = array(); preg_match('/ac=friend&op=(\\w+)&uid=(\\d+)/mi', $matches[0], $tempMatches); if (!empty($tempMatches)) { $action['redirect'] = WebUtils::createUrl_oldVersion('user/useradminview', array('act' => $tempMatches[1], 'uid' => $tempMatches[2])); $action['type'] = self::NOTIFY_TYPE_FRIEND; } $data['note'] = str_replace($matches[1], '', $data['note']); // 暂时屏蔽已经是好友的动作 if (friend_check($tempMatches[2])) { $isAllowData = false; $count--; } $actions[] = $action; } if ($isAllowData) { $tmpData['dateline'] = $data['dateline'] . '000'; $tmpData['type'] = $data['type']; $tmpData['note'] = WebUtils::emptyHtml($data['note']); $tmpData['fromId'] = (int) $data['from_id']; $tmpData['fromIdType'] = $data['from_idtype']; $tmpData['author'] = $data['author']; $tmpData['authorId'] = (int) $data['authorid']; $tmpData['authorAvatar'] = UserUtils::getUserAvatar($data['authorid']); $tmpData['actions'] = $actions; $info['data'][] = $tmpData; } } if ($type == self::NOTIFY_TYPE_POST || $type == self::NOTIFY_TYPE_AT) { foreach ($notifyData as $data) { $matches = array(); preg_match_all('/&ptid=(\\d+?)&pid=(\\d+?)"/i', $data['note'], $matches); $ptid = $matches[1][0]; $pid = $matches[2][0]; $postInfo = $this->_getPostInfo($ptid, $pid); if (!empty($postInfo)) { $info['list'][] = $postInfo; } else { --$count; } } } $info['count'] = $count; return $info; }
public static function getUserTitle($uid, $userInfo = array()) { $userTitle = ''; empty($userInfo) && ($userInfo = self::getUserInfo($uid)); if (!empty($userInfo)) { $groupId = $userInfo['groupid']; $userGroup = UserUtils::getUserGroupsByGids($groupId); $userTitle = (string) WebUtils::emptyHtml($userGroup[$groupId]['grouptitle']); } return $userTitle; }
public static function makeErrorInfo($res, $message, $params = array()) { $errInfo = explode(':', Yii::t('mobcent', $message, $params), 2); if (count($errInfo) == 1) { $errInfo[1] = $errInfo[0]; $errInfo[0] = isset($params['noError']) && $params['noError'] > 0 ? MOBCENT_ERROR_NONE : MOBCENT_ERROR_DEFAULT; } $res['head']['errCode'] = !empty($errInfo[0]) ? $errInfo[0] : ''; $res['head']['errInfo'] = !empty($errInfo[1]) ? WebUtils::emptyHtml($errInfo[1]) : ''; $res['head']['alert'] = isset($params['alert']) ? (int) $params['alert'] : 1; return $res; }
private function _getAlbumInfoList($res, $landUid, $uid, $page, $pageSize) { $list = array(); $albumList = UserAlbumInfo::getAlbumList($uid, $page, $pageSize); foreach ($albumList as $album) { $albumInfo['album_id'] = (int) $album['albumid']; $albumInfo['user_id'] = (int) $uid; $albumInfo['release_date'] = $album['dateline'] . "000"; $albumInfo['last_update_date'] = $album['updatetime'] . "000"; $albumInfo['user_nick_name'] = $album['username']; $albumInfo['title'] = WebUtils::emptyHtml($album['albumname']); $albumInfo['info'] = $album['depict']; $albumPic = $this->getAlbumImagePic($album); $albumInfo['thumb_pic'] = PhotoUtils::getPhotoAlbumCover($albumPic); $list[] = $albumInfo; } $count = UserAlbumInfo::getAlbumListCount($uid) + 1; if ($page == ceil($count / $pageSize) && $landUid == $uid) { $list[] = $this->getDefaultAlbum($uid); } return $list; }
private function _sendPostResult($jsonInfo, $act) { $res = $this->initWebApiArray(); switch ($act) { case 'new': $res['head']['errInfo'] = WebUtils::t('发贴成功'); break; case 'reply': $res['head']['errInfo'] = WebUtils::t('回贴成功'); break; default: $res['head']['errInfo'] = WebUtils::t('编辑成功'); break; } $app = Yii::app()->getController()->mobcentDiscuzApp; $app->loadForum($jsonInfo['fid'], $jsonInfo['tid']); if (($checkMessage = mobcent_cknewuser()) != '') { return $this->makeErrorInfo($res, WebUtils::emptyHtml($checkMessage)); } require_once libfile('class/credit'); require_once libfile('function/post'); global $_G; if ($_G['forum']['simple'] & 1 || $_G['forum']['redirect']) { return $this->makeErrorInfo($res, lang('message', 'forum_disablepost')); } /*初始化变量*/ $pid = 0; $sortid = 0; $typeid = 0; $special = 0; $readperm = 0; $_GET['tid'] = $jsonInfo['tid']; $_GET['fid'] = $jsonInfo['fid']; $_G['tid'] = $jsonInfo['tid']; $_GET['typeoption'] = WebUtils::jsonDecode(rawurldecode($jsonInfo['typeOption'])); $typeInfo = array(); foreach ($_GET['typeoption'] as $k => $v) { $typeInfo[$k] = WebUtils::t($v); } $_GET['typeoption'] = $typeInfo; $_GET['isanonymous'] = $jsonInfo['isAnonymous']; $_GET['hiddenreplies'] = $jsonInfo['isOnlyAuthor']; $_GET['usesig'] = 1; $_GET['allownoticeauthor'] = 1; if ($jsonInfo['typeId']) { $typeid = $jsonInfo['typeId']; } //copy dz from source/module/forum/forum_post.php $postinfo = array('subject' => ''); $thread = array('readperm' => '', 'pricedisplay' => '', 'hiddenreplies' => ''); $_G['forum_dtype'] = $_G['forum_checkoption'] = $_G['forum_optionlist'] = $tagarray = $_G['forum_typetemplate'] = array(); if ($jsonInfo['sortId'] && $jsonInfo['sortId'] > 0) { $sortid = $jsonInfo['sortId']; require_once libfile('post/threadsorts', 'include'); } /*找出哪项是图片上传项和多项选择项,拼接成所想要的数组类型*/ $optionId = DB::fetch_all("SELECT optionid FROM " . DB::table('forum_typevar') . " WHERE sortid=%d", array($sortid)); foreach ($optionId as $key => $value) { $type = DB::fetch_first("SELECT identifier,type FROM " . DB::table('forum_typeoption') . " WHERE optionid=%d", array($value['optionid'])); if ($type['type'] == 'image') { $attachImg = DB::fetch_first("SELECT attachment FROM " . DB::table('forum_attachment_unused') . " WHERE aid = %d ", array($_GET['typeoption'][$type['identifier']])); $attachImg = $_G['setting']['attachurl'] . 'forum/' . $attachImg['attachment']; $_GET['typeoption'][$type['identifier']] = array('aid' => $_GET['typeoption'][$type['identifier']], 'url' => $attachImg); } if ($type['type'] == 'checkbox') { $_GET['typeoption'][$type['identifier']] = explode(',', $_GET['typeoption'][$type['identifier']]); } } require_once libfile('function/discuzcode'); if ($act == 'edit' || $act == 'reply') { $thread = C::t('forum_thread')->fetch($_G['tid']); if (!$_G['forum_auditstatuson'] && !($thread['displayorder'] >= 0 || in_array($thread['displayorder'], array(-4, -2)) && $thread['authorid'] == $_G['uid'])) { $thread = array(); } if (!empty($thread)) { if ($thread['readperm'] && $thread['readperm'] > $_G['group']['readaccess'] && !$_G['forum']['ismoderator'] && $thread['authorid'] != $_G['uid']) { return WebUtils::makeErrorInfo_oldVersion($res, 'thread_nopermission', array('{readperm}' => $thread['readperm'])); } $_G['fid'] = $thread['fid']; $special = $thread['special']; } else { return WebUtils::makeErrorInfo_oldVersion($res, 'thread_nonexistence'); } if ($thread['closed'] == 1 && !$_G['forum']['ismoderator']) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_thread_closed'); } } if ($jsonInfo['isQuote'] && $jsonInfo['replyId'] > 0) { $_GET['repquote'] = $jsonInfo['replyId']; $language = lang('forum/misc'); $noticeauthor = $noticetrimstr = ''; $thaquote = C::t('forum_post')->fetch('tid:' . $_G['tid'], $_GET['repquote']); if (!($thaquote && ($thaquote['invisible'] == 0 || $thaquote['authorid'] == $_G['uid'] && $thaquote['invisible'] == -2))) { $thaquote = array(); } if ($thaquote['tid'] != $_G['tid']) { return WebUtils::makeErrorInfo_oldVersion($res, 'reply_quotepost_error'); } if (getstatus($thread['status'], 2) && $thaquote['authorid'] != $_G['uid'] && $_G['uid'] != $thread['authorid'] && $thaquote['first'] != 1 && !$_G['forum']['ismoderator']) { return WebUtils::makeErrorInfo_oldVersion($res, 'reply_quotepost_error'); } if (!($thread['price'] && !$thread['special'] && $thaquote['first'])) { $quotefid = $thaquote['fid']; $message = $thaquote['message']; if ($_G['setting']['bannedmessages'] && $thaquote['authorid']) { $author = getuserbyuid($thaquote['authorid']); if (!$author['groupid'] || $author['groupid'] == 4 || $author['groupid'] == 5) { $message = $language['post_banned']; } elseif ($thaquote['status'] & 1) { $message = $language['post_single_banned']; } } $time = dgmdate($thaquote['dateline']); $message = messagecutstr($message, 100); $message = implode("\n", array_slice(explode("\n", $message), 0, 3)); $thaquote['useip'] = substr($thaquote['useip'], 0, strrpos($thaquote['useip'], '.')) . '.x'; if ($thaquote['author'] && $thaquote['anonymous']) { $thaquote['author'] = lang('forum/misc', 'anonymoususer'); } elseif (!$thaquote['author']) { $thaquote['author'] = lang('forum/misc', 'guestuser') . ' ' . $thaquote['useip']; } else { $thaquote['author'] = $thaquote['author']; } $post_reply_quote = lang('forum/misc', 'post_reply_quote', array('author' => $thaquote['author'], 'time' => $time)); $noticeauthormsg = dhtmlspecialchars($message); if (!defined('IN_MOBILE')) { $message = "[quote][size=2][color=#999999]{$post_reply_quote}[/color] [url=forum.php?mod=redirect&goto=findpost&pid={$_GET['repquote']}&ptid={$_G['tid']}][img]static/image/common/back.gif[/img][/url][/size]\n{$message}[/quote]"; } else { $message = "[quote][color=#999999]{$post_reply_quote}[/color]\n[color=#999999]{$message}[/color][/quote]"; } $quotemessage = discuzcode($message, 0, 0); $noticeauthor = dhtmlspecialchars(authcode('q|' . $thaquote['authorid'], 'ENCODE')); $noticetrimstr = dhtmlspecialchars($message); $_GET['noticetrimstr'] = $noticetrimstr; $_GET['noticeauthor'] = $noticeauthor; } } //periodscheck('postbanperiods'); if ($_G['forum']['password'] && $_G['forum']['password'] != $_G['cookie']['fidpw' . $_G['fid']]) { return WebUtils::makeErrorInfo_oldVersion($res, 'forum_passwd'); } if (empty($_G['forum']['allowview'])) { if (!$_G['forum']['viewperm'] && !$_G['group']['readaccess']) { return WebUtils::makeErrorInfo_oldVersion($res, 'group_nopermission', array('{grouptitle}' => $_G['group']['grouptitle'])); } elseif ($_G['forum']['viewperm'] && !forumperm($_G['forum']['viewperm'])) { $msg = mobcent_showmessagenoperm('viewperm', $_G['fid']); return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']); } } elseif ($_G['forum']['allowview'] == -1) { return WebUtils::makeErrorInfo_oldVersion($res, 'forum_access_view_disallow'); } $msg = mobcent_formulaperm($_G['forum']['formulaperm']); if ($msg['message'] != '') { return WebUtils::makeErrorInfo_oldVersion($res, $msg['message'], $msg['params']); } //formulaperm($_G['forum']['formulaperm']); if (!$_G['adminid'] && $_G['setting']['newbiespan'] && (!getuserprofile('lastpost') || TIMESTAMP - getuserprofile('lastpost') < $_G['setting']['newbiespan'] * 60) && TIMESTAMP - $_G['member']['regdate'] < $_G['setting']['newbiespan'] * 60) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_newbie_span', array('{newbiespan}' => $_G['setting']['newbiespan'])); } $special = $special > 0 && $special < 7 || $special == 127 ? intval($special) : 0; $jsonInfo['title'] = rawurldecode($jsonInfo['title']); $subject = isset($jsonInfo['title']) ? dhtmlspecialchars(censor(trim($jsonInfo['title']))) : ''; $subject = !empty($subject) ? str_replace("\t", ' ', $subject) : $subject; $subject = WebUtils::t($subject); /*贴子内容处理*/ $_GET['attachnew'] = array(); $aid = $jsonInfo['aid']; if (isset($aid) && !empty($aid)) { $aid_Img = explode(',', $aid); foreach ($aid_Img as $key => $value) { $_GET['attachnew'][$value] = array('description' => ''); } } $message = ''; $i = 0; if ($act == 'new') { $act = 'newthread'; } $jsonInfo['content'] = WebUtils::jsonDecode(rawurldecode($jsonInfo['content'])); foreach ($jsonInfo['content'] as $k => $v) { switch ($v["type"]) { case 0: // 解析文本的超链接 // @author: xjp $v['infor'] = preg_replace('/(https?:\\/\\/\\S+)/i', '[url=$1]$1[/url]', $v['infor']); $message .= $v["infor"] . "\r\n"; break; case 1: if (empty($aid_Img)) { if ($aid != 0) { $message .= '[attachimg]' . $aid . '[/attachimg]'; } else { $message .= '[img]' . $v['infor'] . '[/img]'; } } else { if ($aid_Img[$i] != 0) { $message .= '[attachimg]' . $aid_Img[$i] . '[/attachimg]'; } else { $message .= '[img]' . $v['infor'] . '[/img]'; } $i = $i + 1; } $attachment = 2; $message .= "\r\n"; break; case 3: $message .= "[audio]" . $v["infor"] . "[/audio]"; break; } } //表情处理 $message = $this->smilesReplace($message); WebUtils::getDzPluginAppbymeAppConfig('forum_allow_gbk_special') && ($message = mb_convert_encoding($message, 'HTML-ENTITIES', 'UTF-8')); $message = WebUtils::t($message); $readperm = isset($_GET['readperm']) ? intval($_GET['readperm']) : 0; $price = isset($_GET['price']) ? intval($_GET['price']) : 0; if (empty($bbcodeoff) && !$_G['group']['allowhidecode'] && !empty($message) && preg_match("/\\[hide=?\\d*\\].*?\\[\\/hide\\]/is", preg_replace("/(\\[code\\](.+?)\\[\\/code\\])/is", ' ', $message))) { return WebUtils::makeErrorInfo_oldVersion($res, 'post_hide_nopermission'); } $modnewthreads = $modnewreplies = 0; if (($subject || $message) && empty($_GET['save'])) { $extramessage = ($special == 5 ? "\t" . $_GET['affirmpoint'] . "\t" . $_GET['negapoint'] : '') . ($special == 4 ? "\t" . $_GET['activityplace'] . "\t" . $_GET['activitycity'] . "\t" . $_GET['activityclass'] : '') . ($special == 2 ? "\t" . $_GET['item_name'] . "\t" . $_GET['item_locus'] : '') . ($_GET['typeoption'] ? "\t" . implode("\t", $_GET['typeoption']) : '') . ($_GET['polloptions'] || $_GET['polloption'] ? "\t" . implode("\t", $_GET['tpolloption'] == 2 ? explode("\n", $_GET['polloptions']) : $_GET['polloption']) : ''); list($modnewthreads, $modnewreplies) = threadmodstatus($subject . "\t" . $message . $extramessage); unset($extramessage); } $urloffcheck = $usesigcheck = $smileyoffcheck = $codeoffcheck = $htmloncheck = $emailcheck = ''; $seccodecheck = $_G['setting']['seccodestatus'] & 4 && (!$_G['setting']['seccodedata']['minposts'] || getuserprofile('posts') < $_G['setting']['seccodedata']['minposts']); $secqaacheck = $_G['setting']['secqaa']['status'] & 2 && (!$_G['setting']['secqaa']['minposts'] || getuserprofile('posts') < $_G['setting']['secqaa']['minposts']); $_G['group']['allowpostpoll'] = $_G['group']['allowpost'] && $_G['group']['allowpostpoll'] && $_G['forum']['allowpostspecial'] & 1; $_G['group']['allowposttrade'] = $_G['group']['allowpost'] && $_G['group']['allowposttrade'] && $_G['forum']['allowpostspecial'] & 2; $_G['group']['allowpostreward'] = $_G['group']['allowpost'] && $_G['group']['allowpostreward'] && $_G['forum']['allowpostspecial'] & 4; $_G['group']['allowpostactivity'] = $_G['group']['allowpost'] && $_G['group']['allowpostactivity'] && $_G['forum']['allowpostspecial'] & 8; $_G['group']['allowpostdebate'] = $_G['group']['allowpost'] && $_G['group']['allowpostdebate'] && $_G['forum']['allowpostspecial'] & 16; $usesigcheck = $_G['uid'] && $_G['group']['maxsigsize'] ? 'checked="checked"' : ''; $ordertypecheck = !empty($thread['tid']) && getstatus($thread['status'], 4) ? 'checked="checked"' : ''; $specialextra = !empty($_GET['specialextra']) ? $_GET['specialextra'] : ''; $_G['forum']['threadplugin'] = dunserialize($_G['forum']['threadplugin']); $_G['group']['allowanonymous'] = $_G['forum']['allowanonymous'] || $_G['group']['allowanonymous'] ? 1 : 0; if ($specialextra) { $special = 127; } if ($act == 'newthread') { $policykey = 'post'; } elseif ($act == 'reply') { $policykey = 'reply'; } else { $policykey = ''; } if ($policykey) { $postcredits = $_G['forum'][$policykey . 'credits'] ? $_G['forum'][$policykey . 'credits'] : $_G['setting']['creditspolicy'][$policykey]; } if ($act == 'reply') { $allow = $this->check_allow_action($res, 'allowreply'); } else { $allow = $this->check_allow_action($res, 'allowpost'); } if ($allow) { return $allow; } if (!empty($jsonInfo['location'])) { $jsonInfo['location'] = WebUtils::t(rawurldecode($jsonInfo['location'])); } $extract = array('modnewthreads' => $modnewthreads, 'modnewreplies' => $modnewreplies, 'thread' => $thread, 'res' => $res, 'special' => $special, 'subject' => $subject, 'message' => $message, 'jsonInfo' => $jsonInfo, 'sortid' => $sortid, 'typeid' => $typeid); switch ($act) { case 'newthread': $result = $this->sendPost($extract); break; case 'reply': $result = $this->replyPost($extract); break; case 'edit': $result = $this->editPost($extract); break; } if ($result['errcode'] != WebUtils::t('发贴成功')) { return $result; } $res = array_merge($result, $res); return $res; }
private function _getTopicTypeSortInfos() { $infos = array(); $fields = DbUtils::getDzDbUtils(true)->queryAll(' SELECT fid, threadtypes, threadsorts FROM %t WHERE fid IN (%n) ', array('forum_forumfield', DzForumForum::getFids())); foreach ($fields as $field) { if (!empty($field)) { $info = array('fid' => (int) $field['fid'], 'types' => array(), 'sorts' => array()); $types = unserialize($field['threadtypes']); if (!empty($types['types'])) { foreach ($types['types'] as $key => $value) { // 控制管理组专用 // if ($types['moderators'][$key] == 1) { // continue; // } $info['types'][] = array('id' => $key, 'title' => WebUtils::emptyHtml($value)); } } $sorts = unserialize($field['threadsorts']); if (!empty($sorts['types'])) { foreach ($sorts['types'] as $key => $value) { $info['sorts'][] = array('id' => $key, 'title' => WebUtils::emptyHtml($value)); } } $infos[$info['fid']] = $info; } } return $infos; }
private function _transMessage($msgString) { $msg = array('type' => 'text', 'content' => ''); $matches = array(); preg_match_all('/<img.*?src="(.*?)".*?\\/>/s', $msgString, $matches, PREG_SET_ORDER); if (!empty($matches)) { foreach ($matches as $match) { $match[1] = WebUtils::getHttpFileName($match[1]); if (strpos($match[0], 'static/image/smiley') !== false || strpos($match[0], 'mobcent/app/data/phiz') !== false) { $msgString = str_replace($match[0], sprintf('[mobcent_phiz=%s]', $match[1]), $msgString); } else { $msg['type'] = 'image'; $msgString = ImageUtils::getThumbImage($match[1]); break; } } } $matches = array(); preg_match_all('/<a href="(.*?)".*?>(.*?)<\\/a>/s', $msgString, $matches, PREG_SET_ORDER); if (!empty($matches)) { foreach ($matches as $match) { $match[1] = WebUtils::getHttpFileName($match[1]); if (strpos($match[0], UploadUtils::getUploadAudioBaseUrlPath()) !== false) { $msg['type'] = 'audio'; $msgString = $match[1]; break; } else { // $msgString = str_replace($match[0], sprintf('[mobcent_url=%s]%s[/mobcent_url]', $match[1], $match[2]), $msgString); $msgString = str_replace($match[0], sprintf(' %s %s ', $match[2], $match[1]), $msgString); } } } $msg['content'] = WebUtils::emptyHtml($msgString); return $msg; }
protected function _init_misc() { if ($this->config['security']['urlxssdefend'] && !defined('DISABLEXSSCHECK')) { $this->_xss_check(); } // if(!$this->init_misc) { // return false; // } lang('core'); if ($this->init_setting && $this->init_user) { if (!isset($this->var['member']['timeoffset']) || $this->var['member']['timeoffset'] == 9999 || $this->var['member']['timeoffset'] === '') { $this->var['member']['timeoffset'] = $this->var['setting']['timeoffset']; } } $timeoffset = $this->init_setting ? $this->var['member']['timeoffset'] : $this->var['setting']['timeoffset']; $this->var['timenow'] = array('time' => dgmdate(TIMESTAMP), 'offset' => $timeoffset >= 0 ? $timeoffset == 0 ? '' : '+' . $timeoffset : $timeoffset); $this->timezone_set($timeoffset); $this->var['formhash'] = formhash(); define('FORMHASH', $this->var['formhash']); if ($this->init_user) { $allowvisitflag = in_array(CURSCRIPT, array('member')) || defined('ALLOWGUEST') && ALLOWGUEST; if ($this->var['group'] && isset($this->var['group']['allowvisit']) && !$this->var['group']['allowvisit']) { if ($this->var['uid'] && !$allowvisitflag) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } elseif ((!defined('ALLOWGUEST') || !ALLOWGUEST) && !in_array(CURSCRIPT, array('member', 'api')) && !$this->var['inajax']) { if (!defined('IN_MOBILE_API')) { dheader('location: member.php?mod=logging&action=login&referer=' . rawurlencode($this->var['siteurl'] . $this->var['basefilename'] . ($_SERVER['QUERY_STRING'] ? '?' . $_SERVER['QUERY_STRING'] : ''))); } else { mobile_core::result(array('error' => 'to_login')); } } } if (isset($this->var['member']['status']) && $this->var['member']['status'] == -1 && !$allowvisitflag) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } } if ($this->var['setting']['ipaccess'] && !ipaccess($this->var['clientip'], $this->var['setting']['ipaccess'])) { if (!defined('IN_MOBILE_API')) { showmessage('user_banned'); } else { mobile_core::result(array('error' => 'user_banned')); } } if ($this->var['setting']['bbclosed']) { if ($this->var['uid'] && ($this->var['group']['allowvisit'] == 2 || $this->var['groupid'] == 1)) { } elseif (in_array(CURSCRIPT, array('admin', 'member', 'api')) || defined('ALLOWGUEST') && ALLOWGUEST) { } else { $closedreason = C::t('common_setting')->fetch('closedreason'); $closedreason = str_replace(':', ':', $closedreason); if (!defined('IN_MOBILE_API')) { // showmessage($closedreason ? $closedreason : 'board_closed', NULL, array('adminemail' => $this->var['setting']['adminemail']), array('login' => 1)); $closedreason = $closedreason ? $closedreason : lang('message', 'board_closed'); WebUtils::endAppWithErrorInfo(array(), WebUtils::emptyHtml($closedreason)); } else { mobile_core::result(array('error' => $closedreason ? $closedreason : 'board_closed')); } } } if (CURSCRIPT != 'admin' && !in_array($this->var['mod'], array('logging', 'seccode'))) { periodscheck('visitbanperiods'); } if (defined('IN_MOBILE')) { $this->var['tpp'] = $this->var['setting']['mobile']['mobiletopicperpage'] ? intval($this->var['setting']['mobile']['mobiletopicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['mobile']['mobilepostperpage'] ? intval($this->var['setting']['mobile']['mobilepostperpage']) : 5; } else { $this->var['tpp'] = $this->var['setting']['topicperpage'] ? intval($this->var['setting']['topicperpage']) : 20; $this->var['ppp'] = $this->var['setting']['postperpage'] ? intval($this->var['setting']['postperpage']) : 10; } if ($this->var['setting']['nocacheheaders']) { @header("Expires: -1"); @header("Cache-Control: no-store, private, post-check=0, pre-check=0, max-age=0", FALSE); @header("Pragma: no-cache"); } if ($this->session->isnew && $this->var['uid']) { updatecreditbyaction('daylogin', $this->var['uid']); include_once libfile('function/stat'); updatestat('login', 1); if (defined('IN_MOBILE')) { updatestat('mobilelogin', 1); } if ($this->var['setting']['connect']['allow'] && $this->var['member']['conisbind']) { updatestat('connectlogin', 1); } } if (isset($this->var['member']['conisbind']) && $this->var['member']['conisbind'] && $this->var['setting'] && $this->var['setting']['connect']['newbiespan'] !== '') { $this->var['setting']['newbiespan'] = $this->var['setting']['connect']['newbiespan']; } $lastact = TIMESTAMP . "\t" . dhtmlspecialchars(basename($this->var['PHP_SELF'])) . "\t" . dhtmlspecialchars($this->var['mod']); dsetcookie('lastact', $lastact, 86400); setglobal('currenturl_encode', base64_encode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'])); if ((!empty($_GET['fromuid']) || !empty($_GET['fromuser'])) && ($this->var['setting']['creditspolicy']['promotion_visit'] || $this->var['setting']['creditspolicy']['promotion_register'])) { require_once libfile('misc/promotion', 'include'); } $this->var['seokeywords'] = !empty($this->var['setting']['seokeywords'][CURSCRIPT]) ? $this->var['setting']['seokeywords'][CURSCRIPT] : ''; $this->var['seodescription'] = !empty($this->var['setting']['seodescription'][CURSCRIPT]) ? $this->var['setting']['seodescription'][CURSCRIPT] : ''; }
private function _pmSend($res, $data) { global $_G; $touid = (int) $data['toUid']; $pmid = (int) $data['pmid']; $_GET['topmuid'] = $touid; $_POST['message'] = $this->_transMessage($data['msg']); $_POST['subject'] = ''; $users = array(); $type = 0; $waittime = interval_check('post'); if ($waittime > 0) { // showmessage('message_can_not_send_2', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_2')); } if (($checkMessage = mobcent_cknewuser()) != '') { return $this->makeErrorInfo($res, WebUtils::emptyHtml($checkMessage)); } if (!checkperm('allowsendpm')) { // showmessage('no_privilege_sendpm', '', array(), array('return' => true)); return $this->makeErrorInfo($res, 'no_privilege_sendpm'); } if ($touid) { if (isblacklist($touid)) { // showmessage('is_blacklist', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'is_blacklist')); } } // !($_G['group']['exempt'] & 1) && checklowerlimit('sendpm', 0, $coef); $message = (!empty($_POST['messageappend']) ? $_POST['messageappend'] . "\n" : '') . trim($_POST['message']); if (empty($message)) { // showmessage('unable_to_send_air_news', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'unable_to_send_air_news')); } // $message = censor($message); loadcache(array('smilies', 'smileytypes')); foreach ($_G['cache']['smilies']['replacearray'] as $key => $smiley) { $_G['cache']['smilies']['replacearray'][$key] = '[img]' . $_G['siteurl'] . 'static/image/smiley/' . $_G['cache']['smileytypes'][$_G['cache']['smilies']['typearray'][$key]]['directory'] . '/' . $smiley . '[/img]'; } $message = preg_replace($_G['cache']['smilies']['searcharray'], $_G['cache']['smilies']['replacearray'], $message); $subject = ''; if ($type == 1) { $subject = dhtmlspecialchars(trim($_POST['subject'])); } include_once libfile('function/friend'); $return = 0; if ($touid || $pmid) { if ($touid) { if ($value = getuserbyuid($touid)) { $value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2); if ($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || $value['onlyacceptfriendpm'] == 1 && friend_check($touid)) { $return = sendpm($touid, $subject, $message, '', 0, 0, $type); } else { // showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_onlyfriend')); } } else { // showmessage('message_bad_touid', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_bad_touid')); } } else { $topmuid = intval($_GET['topmuid']); $return = sendpm($topmuid, $subject, $message, '', $pmid, 0); } } elseif ($users) { $newusers = $uidsarr = $membersarr = array(); if ($users) { $membersarr = C::t('common_member')->fetch_all_by_username($users); foreach ($membersarr as $aUsername => $aUser) { $uidsarr[] = $aUser['uid']; } } if (empty($membersarr)) { showmessage('message_bad_touser', '', array(), array('return' => true)); } if (isset($membersarr[$_G['uid']])) { showmessage('message_can_not_send_to_self', '', array(), array('return' => true)); } friend_check($uidsarr); foreach ($membersarr as $key => $value) { $value['onlyacceptfriendpm'] = $value['onlyacceptfriendpm'] ? $value['onlyacceptfriendpm'] : ($_G['setting']['onlyacceptfriendpm'] ? 1 : 2); if ($_G['group']['allowsendallpm'] || $value['onlyacceptfriendpm'] == 2 || $value['onlyacceptfriendpm'] == 1 && $_G['home_friend_' . $value['uid'] . '_' . $_G['uid']]) { $newusers[$value['uid']] = $value['username']; unset($users[array_search($value['username'], $users)]); } } if (empty($newusers)) { showmessage('message_can_not_send_onlyfriend', '', array(), array('return' => true)); } foreach ($newusers as $key => $value) { if (isblacklist($key)) { showmessage('is_blacklist', '', array(), array('return' => true)); } } $coef = count($newusers); $return = sendpm(implode(',', $newusers), $subject, $message, '', 0, 1, $type); } else { // showmessage('message_can_not_send_9', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_9')); } if ($return > 0) { include_once libfile('function/stat'); updatestat('sendpm', 0, $coef); C::t('common_member_status')->update($_G['uid'], array('lastpost' => TIMESTAMP)); !($_G['group']['exempt'] & 1) && updatecreditbyaction('sendpm', 0, array(), '', $coef); if (!empty($newusers)) { if ($type == 1) { $returnurl = 'home.php?mod=space&do=pm&filter=privatepm'; } else { $returnurl = 'home.php?mod=space&do=pm'; } showmessage(count($users) ? 'message_send_result' : 'do_success', $returnurl, array('users' => implode(',', $users), 'succeed' => count($newusers))); } else { if (!defined('IN_MOBILE')) { // showmessage('do_success', 'home.php?mod=space&do=pm&subop=view&touid='.$touid, array('pmid' => $return), $_G['inajax'] ? array('msgtype' => 3, 'showmsg' => false) : array()); } else { // showmessage('do_success', 'home.php?mod=space&do=pm&subop=view'.(intval($_POST['touid']) ? '&touid='.intval($_POST['touid']) : ( intval($_POST['plid']) ? '&plid='.intval($_POST['plid']).'&daterange=1&type=1' : '' ))); } $res = $this->makeErrorInfo($res, 'do_success', array('noError' => 1, 'alert' => 0)); $msgInfo = uc_pm_viewnode($_G['uid'], $type, $return); $res['body']['plid'] = (int) $msgInfo['plid']; $res['body']['pmid'] = (int) $msgInfo['pmid']; $res['body']['sendTime'] = $msgInfo['dateline'] . '000'; // ios push UserUtils::pushIOSMessage($touid, 'pm', $_G['username'] . WebUtils::t(' 对 您 说: ') . $message); } } else { if (in_array($return, range(-16, -1))) { // showmessage('message_can_not_send_'.abs($return)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send_' . abs($return))); } else { // showmessage('message_can_not_send', '', array(), array('return' => true)); return $this->makeErrorInfo($res, lang('message', 'message_can_not_send')); } } return $res; }
public static function transArticleContent($content) { $content = PortalUtils::parseArticleContent($content); $newContent = array(); $matches = array(); preg_match_all('/(.+?)\\[mobcent_br\\]/s', $content, $matches); foreach ($matches[1] as $match) { $tempMatches = array(); $tempContent = array('type' => 'text', 'content' => ''); preg_match('/\\[mobcent_(audio|video|image)=(.*?)\\]/', $match, $tempMatches); if (!empty($tempMatches)) { $tempContent['type'] = $tempMatches[1]; $tempContent['content'] = $tempMatches[2]; if ($tempContent['type'] == 'image') { $tempContent['extraInfo']['source'] = $tempMatches[2]; $tempContent['content'] = ImageUtils::getThumbImage($tempMatches[2]); } } else { $match = preg_replace('/(<p>|<\\/p>|<div>|<\\/div>|<br>|<br\\/>)/i', PortalUtils::CONTENT_DELIMITER, $match); $match .= PortalUtils::CONTENT_DELIMITER; $tempText = ''; $tempMatches = array(); preg_match_all('/(.+?)\\[mobcent_br\\]/s', $match, $tempMatches); foreach ($tempMatches[1] as $value) { $value = str_replace(PortalUtils::CONTENT_DELIMITER, '', $value); $tempText .= $value . "\r\n"; } $tempText = WebUtils::emptyHtml($tempText); $tempText = (string) trim($tempText); $tempContent['content'] = $tempText; } $tempContent['content'] != '' && ($newContent[] = $tempContent); } return $newContent; }
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; }
private function _getSortInfo($thread) { // from forum_viewthread template $sort = array('title' => '', 'summary' => ''); global $_G; $threadsort = $thread['sortid'] && isset($_G['forum']['threadsorts']['types'][$thread['sortid']]) ? 1 : 0; if ($threadsort) { require_once libfile('function/threadsort'); $threadsortshow = threadsortshow($thread['sortid'], $_G['tid']); } if ($threadsort && $threadsortshow) { if ($threadsortshow['typetemplate']) { //echo $threadsortshow['typetemplate']; $sort = $this->_getSortByTemplate($threadsortshow); } elseif ($threadsortshow['optionlist']) { if ($threadsortshow['optionlist'] == 'expire') { $sort['summary'] = WebUtils::t("该信息已经过期\n"); } else { $sort['title'] = $_G['forum']['threadsorts']['types'][$_G['forum_thread']['sortid']]; if (is_array($threadsortshow['optionlist'])) { foreach ($threadsortshow['optionlist'] as $option) { if ($option['type'] != 'info') { $sort['summary'] .= sprintf("%s :\t", $option['title']); if ($option['value'] || $option['type'] == 'number' && $option['value'] !== '') { $matches = array(); preg_match('/action=protectsort.+?optionid=(\\d+)/', $option['value'], $matches); if (!empty($matches)) { $option['value'] = $this->_getProtectSortOptionListValue($_G['tid'], $matches[1]); } else { $option['value'] = WebUtils::emptyHtml($option['value']); } $sort['summary'] .= $option['value'] . $option['unit']; } $sort['summary'] .= "\n"; } } } } } } return $sort; }
private function _getCommentMessage($quoteComment) { $quoteComment['message'] = WebUtils::emptyReturnLine($quoteComment['message'], ' '); $quoteComment['message'] = preg_replace('/<blockquote>.*?<\\/blockquote>/s', '', $quoteComment['message']); $quoteComment['message'] = preg_replace('/<div class="quote">.*?<\\/div>/s', '', $quoteComment['message']); $quoteComment['message'] = WebUtils::emptyHtml($quoteComment['message']); $quoteComment['message'] = $quoteComment['username'] . ': ' . $quoteComment['message']; $quoteComment['message'] = '[quote]' . $quoteComment['message'] . "[/quote]\r\n"; return $quoteComment['message']; }
private function _getForumInfo($forum) { $fid = (int) $forum['fid']; $forum = array_merge($forum, DzForumForum::getForumFieldByFid($fid)); $dateline = $this->_getDateLine($forum); // 判断该版块是否有权限访问 if (!forum($forum)) { return array(); } $matches = array(); preg_match('/<img src="(.+?)"/', $forum['icon'], $matches); $image = !empty($matches[1]) ? $matches[1] : ''; // $dateline = '0'; // if (is_array($forum['lastpost'])) { // $matches = array(); // preg_match('/<span title="(.+?)"/', $forum['lastpost']['dateline'], $matches); // $dateline = !empty($matches[1]) ? $matches[1] : $forum['lastpost']['dateline']; // $dateline = strtotime($dateline); // $dateline !== false or $dateline = '0'; // } $forumSubList = ForumUtils::getForumSubList($fid); $forumInfo = array(); $forumInfo['board_id'] = (int) $fid; $forumInfo['board_name'] = WebUtils::emptyHtml($forum['name']); $forumInfo['description'] = (string) WebUtils::emptyHtml($forum['description']); $forumInfo['board_child'] = count($forumSubList) > 0 ? 1 : 0; $forumInfo['board_img'] = WebUtils::getHttpFileName($image); $forumInfo['last_posts_date'] = !empty($dateline) ? $dateline . '000' : ''; $forumInfo['board_content'] = $forum['threads'] != 0 && !($forum['simple'] & 1) ? 1 : 0; $forumInfo['forumRedirect'] = $forum['redirect']; $todayPosts = (int) $forum['todayposts']; $threads = (int) $forum['threads']; $posts = (int) $forum['posts']; foreach ($forumSubList as $value) { $todayPosts += $value['todayposts']; $threads += $value['threads']; $posts += $value['posts']; } $forumInfo['td_posts_num'] = $todayPosts; $forumInfo['topic_total_num'] = $threads; $forumInfo['posts_total_num'] = $posts; return $forumInfo; }
private function _fieldInfo($topics) { $row = $rows = array(); foreach ($topics as $v) { $topicSummary = ForumUtils::getTopicSummary($v['tid']); $row['board_id'] = (int) $v['fid']; $row['topic_id'] = (int) $v['tid']; $row['type_id'] = (int) $v['typeid']; $row['sort_id'] = (int) $v['sortid']; $row['vote'] = ForumUtils::isVoteTopic($v['tid']) ? 1 : 0; $row['title'] = (string) WebUtils::emptyHtml($v['subject']); $row['subject'] = (string) WebUtils::emptyReturnLine($topicSummary['msg']); $row['user_id'] = (int) $v['authorid']; $row['last_reply_date'] = $v['lastpost'] . "000"; if ($row['last_reply_date'] == '000') { $row['last_reply_date'] = $v['dateline'] . "000"; } $row['user_nick_name'] = (string) $v['author']; $row['hits'] = (int) $v['views']; $row['replies'] = (int) $v['replies']; $row['top'] = ForumUtils::isTopTopic($v['tid']) ? 1 : 0; $row['status'] = (int) $v['status']; $row['essence'] = (int) $v['digest']; $row['hot'] = ForumUtils::isHotTopic($v['tid']) ? 1 : 0; $row['pic_path'] = ImageUtils::getThumbImage($topicSummary['image']); $rows[] = $row; } return $rows; }
private function _emptyHtml($message) { $message = str_replace('<br />', "\r\n", $message); $message = WebUtils::emptyHtml($message); return $message; }
private static function _getActivityApplyListHelper($activity, $verified) { $list = WebUtils::getWebApiResPadding(); $activityList = $verified ? $activity['mobcent']['applyListVerified'] : $activity['mobcent']['applyList']; if (!empty($activityList)) { $list['title'] = $verified ? WebUtils::t('暂未通过 (' . $activity['mobcent']['noVerifiedNums'] . ' 人)') : WebUtils::t('已通过 (' . $activity['mobcent']['applyNums'] . ' 人)'); $list['summary'] = ''; $list['content'] = array(); // $list['summary'] .= sprintf(WebUtils::t("\t\t留言\t%s申请时间\n"), $activity['cost'] ? WebUtils::t("每人花销\t") : ''); $list['summary'] .= sprintf(WebUtils::t("\t\t申请时间\n")); global $_G; foreach ($activityList as $member) { $list['summary'] .= sprintf("%s\t%s\t%s\t%s\n", $member['username'], '', '', WebUtils::emptyHtml($member['dateline'])); } } return $list; }
private function _getForumInfo($fid) { global $_G; $forum = $_G['forum']; require_once libfile('function/forumlist'); $forumImage = get_forumimg($forum['icon']); $forumImage = (string) WebUtils::getHttpFileName($forumImage); $forumInfo = array(); $forumInfo['id'] = (int) $fid; $forumInfo['title'] = $fid != 0 ? (string) WebUtils::emptyHtml($forum['name']) : ''; $forumInfo['description'] = (string) WebUtils::emptyHtml($forum['description']); $forumInfo['icon'] = (string) $forumImage; return $forumInfo; }
private function _getPersonalDataInfo($puid, $space) { global $_G; $res['body']['PersonalData'] = array(); require_once libfile('function/spacecp'); space_merge($space, 'count'); space_merge($space, 'field_home'); space_merge($space, 'field_forum'); space_merge($space, 'profile'); space_merge($space, 'status'); $space['buyerrank'] = 0; if ($space['buyercredit']) { foreach ($_G['setting']['ec_credit']['rank'] as $level => $credit) { if ($space['buyercredit'] <= $credit) { $space['buyerrank'] = $level; break; } } } $space['sellerrank'] = 0; if ($space['sellercredit']) { foreach ($_G['setting']['ec_credit']['rank'] as $level => $credit) { if ($space['sellercredit'] <= $credit) { $space['sellerrank'] = $level; break; } } } require_once libfile('function/friend'); $isfriend = friend_check($space['uid'], 1); loadcache('profilesetting'); include_once libfile('function/profile'); $profiles = array(); $privacy = $space['privacy']['profile'] ? $space['privacy']['profile'] : array(); if ($_G['setting']['verify']['enabled']) { space_merge($space, 'verify'); } if ($_G['uid'] == $space['uid'] || $_G['group']['allowviewip']) { foreach ($_G['cache']['profilesetting'] as $fieldid => $field) { if (!$field['available'] || $field['invisible'] || in_array($fieldid, array('birthmonth', 'birthyear'))) { continue; } $val = profile_show($fieldid, $space); $profiles[] = array('type' => $fieldid, 'title' => $field['title'], 'data' => WebUtils::emptyHtml($val)); } } else { foreach ($_G['cache']['profilesetting'] as $fieldid => $field) { if (!$field['available'] || in_array($fieldid, array('birthprovince', 'birthdist', 'birthcommunity', 'resideprovince', 'residedist', 'residecommunity'))) { continue; } if ($field['available'] && (strlen($space[$fieldid]) > 0 || ($fieldid == 'birthcity' && strlen($space['birthprovince']) || $fieldid == 'residecity' && strlen($space['resideprovince']))) && ($space['self'] || empty($privacy[$fieldid]) || $isfriend && $privacy[$fieldid] == 1) && (!$_G['inajax'] && !$field['invisible'] || $_G['inajax'] && $field['showincard'])) { $val = profile_show($fieldid, $space); if ($val !== false) { if ($fieldid == 'realname' && $_G['uid'] != $space['uid'] && !ckrealname(1)) { continue; } if ($field['formtype'] == 'file' && $val) { $imgurl = getglobal('setting/attachurl') . './profile/' . $val; $val = '<span><a href="' . $imgurl . '" target="_blank"><img src="' . $imgurl . '" style="max-width: 500px;" /></a></span>'; } $profiles[] = array('type' => $fieldid, 'title' => $field['title'], 'data' => WebUtils::emptyHtml($val)); } } } } return $profiles; }
private function _fieldPicList($fid, $source_type, $source_id, $title, $pic_path, $pic_toUrl = '') { $row = array(); $row['fid'] = (int) $fid; $row['source_type'] = (string) $source_type; $row['source_id'] = (int) $source_id; $row['title'] = WebUtils::emptyHtml($title); $row['pic_path'] = (string) $pic_path; if ($source_type == 'weblink') { $row['pic_toUrl'] = (string) $pic_toUrl; } return $row; }
public static function getTopicActivityInfoByTid($tid) { $activity = array(); $topic = self::_getTopicInfo($tid); global $_G; $_G['tid'] = $topic['tid']; $app = Yii::app()->getController()->mobcentDiscuzApp; $app->loadForum($topic['fid'], $topic['tid']); require_once libfile('thread/activity', 'include'); $activity['starttimefrom'] = WebUtils::emptyHtml($activity['starttimefrom']); $activity['mobcent']['allApplyNums'] = $allapplynum; $activity['mobcent']['leftNums'] = $aboutmembers; $activity['mobcent']['applyNums'] = $applynumbers; $activity['mobcent']['applied'] = $applied; $activity['mobcent']['options'] = $settings; $activity['mobcent']['applyInfo'] = $applyinfo; $activity['mobcent']['isVerified'] = $isverified; $activity['mobcent']['isActivityClose'] = $activityclose; $activity['mobcent']['applyList'] = $applylist; $activity['mobcent']['noVerifiedNums'] = $noverifiednum; $activity['mobcent']['applyListVerified'] = $applylistverified; return $activity; }
private function _renderTemplates($tid, $pid, $errorMsg = '') { global $_G; require_once libfile('function/misc'); //今日剩余积分 $maxratetoday = $this->_getratingleft($_G['group']['raterange']); //评分栏目列表 $ratelist = $this->_getratelist($_G['group']['raterange']); $ratelist = WebUtils::emptyHtml($ratelist); //评分理由 $selectreason = explode("\n", modreasonselect(0, 'userreasons')); $selectreason = str_replace('</li>', '', $selectreason); $selectreason = explode('<li>', $selectreason[0]); $this->getController()->renderPartial('topicRate', array('formUrl' => WebUtils::createUrl_oldVersion('forum/topicrate', array('tid' => $tid, 'pid' => $pid)), 'errorMsg' => $errorMsg, 'ratelist' => $ratelist, 'maxratetoday' => $maxratetoday, 'selectreason' => $selectreason)); }
/** * 获取获取设置客户端尾巴 */ public static function getMobileSign($status) { if (!WebUtils::getDzPluginAppbymeAppConfig('mobile_allow_app_sign')) { return ''; } $postSigns = array('android' => WebUtils::t('来自安卓手机客户端'), 'apple' => WebUtils::t('来自苹果手机客户端')); $postSignText = WebUtils::getDzPluginAppbymeAppConfig('mobile_sign_post'); $postSignText = WebUtils::emptyReturnLine($postSignText); $matches = array(); preg_match_all('/\\[title_(all|android|apple)\\](.*?)\\[\\/title_\\1\\]/', $postSignText, $matches, PREG_SET_ORDER); foreach ($matches as $matche) { if ($matche[1] == 'all') { $postSigns['android'] = $postSigns['apple'] = $matche[2]; break; } else { if ($matche[1] == 'android' || $matche[1] == 'apple') { $postSigns[$matche[1]] = $matche[2]; } } } $postSign = ''; // if ($status & DzForumPost::STATUS_SEND_FROM_APP_ANDROID) { if (getstatus($status, 16)) { $postSign = $postSigns['android']; // } else if ($status & DzForumPost::STATUS_SEND_FROM_APP_APPLE) { } else { if (getstatus($status, 15)) { $postSign = $postSigns['apple']; } else { $postSign = ''; } } return WebUtils::emptyHtml($postSign); }
private function getClassificationInfo($list) { for ($i = 0; $i < count($list); $i++) { $ClassificationName = UserTopicInfo::getUserThreadTypeBySort($list[$i]['sort_id']); foreach ($ClassificationName as $tmpName) { $ClassName = $tmpName['name']; $list[$i]['title'] = WebUtils::emptyHtml("[" . $ClassName . "]" . $list[$i]['title']); } } for ($i = 0; $i < count($list); $i++) { $ClassificationType = UserTopicInfo::getUserThreadClassByType($list[$i]['type_id']); foreach ($ClassificationType as $tmpType) { $ClassName = $tmpType['name']; $list[$i]['title'] = WebUtils::emptyHtml("[" . $ClassName . "]" . $list[$i]['title']); } } return $list; }
private function _getNewsInfo($article, $page) { global $_G; $newsInfo = array(); $aid = $article['aid']; $articleUrl = $this->_fetchArticleUrl($aid); // 门户静态化,暂时去掉这个跳转,因为有些用户不支持wap版的门户页面 /* if(!empty($_G['setting']['makehtml']['flag']) && $article['htmlmade'] && !isset($_G['makehtml']) && empty($_GET['diy']) && empty($article['url'])) { // dheader('location:'. fetch_article_url($article)); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } */ $article_count = C::t('portal_article_count')->fetch($aid); if ($article_count) { $article = array_merge($article_count, $article); } if ($article_count) { C::t('portal_article_count')->increase($aid, array('viewnum' => 1)); unset($article_count); } else { C::t('portal_article_count')->insert(array('aid' => $aid, 'catid' => $article['catid'], 'viewnum' => 1)); } if ($article['url']) { // if(!isset($_G['makehtml'])) { // dheader("location:{$article['url']}"); // } // exit(); $newsInfo['redirectUrl'] = $article['url']; return $newsInfo; } $cat = category_remake($article['catid']); $article['pic'] = pic_get($article['pic'], '', $article['thumb'], $article['remote'], 1, 1); if ($page < 1) { $page = 1; } $org = array(); if ($article['idtype'] == 'blogid') { $org = C::t('home_blog')->fetch($article['id']); if (empty($org)) { C::t('portal_article_title')->update($aid, array('id' => 0, 'idtype' => '')); // dheader('location: '. fetch_article_url($article)); // exit(); $newsInfo['redirectUrl'] = $articleUrl; return $newsInfo; } } $article['allowcomment'] = !empty($cat['allowcomment']) && !empty($article['allowcomment']) ? 1 : 0; $article['timestamp'] = $article['dateline']; $article['dateline'] = dgmdate($article['dateline']); $newsInfo['redirectUrl'] = ''; $newsInfo['catName'] = WebUtils::t('文章详情'); $newsInfo['title'] = WebUtils::emptyHtml($article['title']); $newsInfo['dateline'] = $article['dateline']; $newsInfo['author'] = $article['username']; $newsInfo['viewNum'] = (int) $article['viewnum']; $newsInfo['commentNum'] = (int) $article['commentnum']; $newsInfo['allowComment'] = $article['allowcomment'] ? 1 : 0; $newsInfo['summary'] = $article['summary']; $newsInfo['pageCount'] = (int) $article['contents']; $newsInfo['from'] = $article['from']; $newsInfo['articleUrl'] = $articleUrl; $newsInfo['content'] = $this->_transContent(PortalUtils::getNewsContent($article, $page)); return $newsInfo; }
private function _userFavoriteSetting($res, $id, $idType) { global $_G; $uid = $_G['uid']; if (($checkMessage = mobcent_cknewuser()) != '') { return $this->makeErrorInfo($res, WebUtils::emptyHtml($checkMessage)); } $spaceuid = empty($_GET['spaceuid']) ? 0 : intval($_GET['spaceuid']); $title = ''; switch ($idType) { case 'tid': $idType = 'tid'; $thread = C::t('forum_thread')->fetch($id); $title = $thread['subject']; break; case 'fid': $idType = 'fid'; $foruminfo = C::t('forum_forum')->fetch($id); loadcache('forums'); $forum = $_G['cache']['forums'][$id]; if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm']) || strstr($forum['users'], "\t{$_G['uid']}\t")) { $title = $foruminfo['status'] != 3 ? $foruminfo['name'] : ''; // $icon = '<img src="static/image/feed/discuz.gif" alt="forum" class="vm" /> '; } break; case 'blog': $idType = 'blogid'; $bloginfo = C::t('home_blog')->fetch($id); $title = $bloginfo['uid'] == $spaceuid ? $bloginfo['subject'] : ''; break; case 'group': $idType = 'gid'; $foruminfo = C::t('forum_forum')->fetch($id); $title = $foruminfo['status'] == 3 ? $foruminfo['name'] : ''; break; case 'album': $idType = 'albumid'; $result = C::t('home_album')->fetch($id, $spaceuid); $title = $result['albumname']; break; case 'space': $idType = 'uid'; $_member = getuserbyuid($id); $title = $_member['username']; $unset($_member); break; case 'article': $idType = 'aid'; $article = C::t('portal_article_title')->fetch($id); $title = $article['title']; break; default: break; } if (empty($title)) { return $this->makeErrorInfo($res, 'favorite_cannot_favorite'); } else { $fav = C::t('home_favorite')->fetch_by_id_idtype($id, $idType, $uid); if ($fav) { $res = $this->makeErrorInfo($res, 'favorite_repeat'); } else { $description = ''; $description_show = nl2br($description); $fav_count = C::t('home_favorite')->count_by_id_idtype($id, $idType); require_once libfile('function/home'); $description = WebUtils::t('用手机客户端收藏'); $arr = array('uid' => intval($uid), 'idtype' => $idType, 'id' => $id, 'spaceuid' => $thread['authorid'], 'title' => getstr($title, 255), 'description' => getstr($description, '', 0, 0, 1), 'dateline' => TIMESTAMP); $favid = C::t('home_favorite')->insert($arr, true); if ($_G['setting']['cloud_status']) { $favoriteService = Cloud::loadClass('Service_Client_Favorite'); $favoriteService->add($arr['uid'], $favid, $arr['id'], $arr['idtype'], $arr['title'], $arr['description'], TIMESTAMP); } switch ($idType) { case 'tid': C::t('forum_thread')->increase($id, array('favtimes' => 1)); require_once libfile('function/forum'); update_threadpartake($id); break; case 'fid': C::t('forum_forum')->update_forum_counter($id, 0, 0, 0, 0, 1); // $extrajs = '<script type="text/javascript">$("number_favorite_num").innerHTML = parseInt($("number_favorite_num").innerHTML)+1;$("number_favorite").style.display="";</script>'; dsetcookie('nofavfid', '', -1); break; case 'blog': C::t('home_blog')->increase($id, $spaceuid, array('favtimes' => 1)); break; case 'group': C::t('forum_forum')->update_forum_counter($id, 0, 0, 0, 0, 1); break; case 'album': C::t('home_album')->update_num_by_albumid($id, 1, 'favtimes', $spaceuid); break; case 'space': C::t('common_member_status')->increase($id, array('favtimes' => 1)); break; case 'article': C::t('portal_article_count')->increase($id, array('favtimes' => 1)); break; default: break; } $params['noError'] = 1; $res = $this->makeErrorInfo($res, 'favorite_do_success', $params); } } return $res; }