Esempio n. 1
0
 public function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     loadcache('forums');
     foreach ($GLOBALS['data']['hot']['threadlist'] as $tid => &$thread) {
         if (!isset($_G['cache']['stamps'][$thread['icon']]['url'])) {
             $thread['icon'] = -1;
         }
         $thread['forum_name'] = $_G['cache']['forums'][$thread['fid']]['name'];
     }
     //echo json_encode($GLOBALS['data']['hot']['threadlist']);
     //die(0);
     unset($thread);
     $GLOBALS['data']['hot']['threadlist'] = bigapp_core::getvalues($GLOBALS['data']['hot']['threadlist'], array('/^\\d+$/'), array('tid', 'attachment', 'avatar', 'subject', 'author', 'views', 'replies', 'forum_name', 'authorid', 'dateline'));
     if (is_null($GLOBALS['data']['hot']['threadlist']) || !is_array($GLOBALS['data']['hot']['threadlist'])) {
         $GLOBALS['data']['hot']['threadlist'] = array();
     }
     foreach ($GLOBALS['data']['hot']['threadlist'] as $tid => $thread) {
         $GLOBALS['data']['hot']['threadlist'][$tid]['avatar'] = avatar($thread['authorid'], 'big', true);
         $GLOBALS['data']['hot']['threadlist'][$tid]['dateline'] = str_replace(' ', '', $GLOBALS['data']['hot']['threadlist'][$tid]['dateline']);
     }
     /////////////////////////////////////////////////////////////////
     BigAppAPI::_getDetails($GLOBALS['data']['hot']['threadlist']);
     /////////////////////////////////////////////////////////////////
     $variable = array('data' => array_values($GLOBALS['data']['hot']['threadlist']), 'perpage' => $GLOBALS['perpage']);
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 2
0
 function output()
 {
     global $_G;
     $GLOBALS['space']['avatar'] = '';
     if (isset($GLOBALS['space']['uid']) && !empty($GLOBALS['space']['uid'])) {
         $GLOBALS['space']['avatar'] = avatar($GLOBALS['space']['uid'], 'big', true);
         $GLOBALS['space']['avatar'] = str_replace("\r", '', $GLOBALS['space']['avatar']);
         $GLOBALS['space']['avatar'] = str_replace("\n", '', $GLOBALS['space']['avatar']);
     }
     $tmp = bigapp_core::getvalues($GLOBALS['space'], array('uid', 'username', 'regdate', 'avatar', 'credits', 'gender', 'posts', 'threads', 'constellation', 'realname', 'group', 'self', 'friends', 'feedfriend'));
     $tmp['self'] = strval($tmp['self']);
     foreach ($_G['setting']['extcredits'] as $idx => $detail) {
         if (isset($GLOBALS['space']['extcredits' . $idx])) {
             $tmp['extcredits'][] = array('value' => $GLOBALS['space']['extcredits' . $idx], 'name' => $detail['title']);
         }
     }
     if (!isset($tmp['posts'])) {
         $tmp['posts'] = 0;
     }
     if (!isset($tmp['threads'])) {
         $tmp['threads'] = 0;
     }
     $tmp['posts'] = $tmp['posts'] - $tmp['threads'];
     if ($tmp['posts'] < 0) {
         $tmp['posts'] = 0;
     }
     $GLOBALS['space'] = $tmp;
     $GLOBALS['space']['group'] = bigapp_core::getvalues($GLOBALS['space']['group'], array('grouptitle'));
     if (empty($GLOBALS['space']['group'])) {
         unset($GLOBALS['space']['group']);
     } else {
         $GLOBALS['space']['group']['grouptitle'] = preg_replace('/<.*?\\>/', '', $GLOBALS['space']['group']['grouptitle']);
     }
     if (!isset($GLOBALS['space']['constellation'])) {
         $GLOBALS['space']['constellation'] = '';
     }
     $GLOBALS['space']['is_my_friend'] = 0;
     if (isset($GLOBALS['space']['feedfriend']) && $GLOBALS['space']['feedfriend'] != "") {
         $member_uid = $_G['uid'];
         $feedfriend = $GLOBALS['space']['feedfriend'];
         if ($member_uid == $feedfriend) {
             $GLOBALS['space']['is_my_friend'] = 1;
         } else {
             $arr = explode(",", $feedfriend);
             if (count($arr) > 0 && in_array($member_uid, $arr)) {
                 $GLOBALS['space']['is_my_friend'] = 1;
             }
         }
     }
 }
Esempio n. 3
0
 function output()
 {
     //最多展示100个
     global $_G;
     $ret['user_list'] = @bigapp_core::getvalues($GLOBALS['list'], array('/^\\d+$/'), array('uid', 'username', 'adminid', 'groupid'));
     foreach ($ret['user_list'] as &$user) {
         $user['avatar'] = avatar($user['uid'], 'big', true);
         $user['groupname'] = 'unknown';
         if (isset($_G['cache']['usergroups'][$user['groupid']]['grouptitle'])) {
             $user['groupname'] = strip_tags($_G['cache']['usergroups'][$user['groupid']]['grouptitle']);
         }
     }
     $ret['user_list'] = array_values($ret['user_list']);
     unset($user);
     @bigapp_core::result(bigapp_core::variable($ret));
 }
Esempio n. 4
0
 function output()
 {
     $search = array("'<script[^>]*?>.*?</script>'si", "'<img.*src=\"(.*)\" .*>'iU", "'<a.*href=\"(.*)\".*target=\"_blank\">(.*)<\\/a>'iU", "'<[\\/\\!]*?[^<>]*?>'si", "'&(quot|#34);'i", "'&(amp|#38);'i", "'&(lt|#60);'i", "'&(gt|#62);'i", "'&(nbsp|#160);'i", "'&(iexcl|#161);'i", "'&(cent|#162);'i", "'&(pound|#163);'i", "'&(copy|#169);'i", "'\\\\r\\\\n'i");
     $replace = array("", "[img]\\1[/img]", "[url]\\1[/url]", "", "\"", "&", "<", ">", " ", chr(161), chr(162), chr(163), chr(169), "\r\n");
     foreach ($GLOBALS['list'] as &$value) {
         if (isset($value['message'])) {
             $message = preg_replace($search, $replace, $value['message']);
             $message = preg_replace_callback("/&#(\\d+);/i", function ($m) {
                 return chr($m[1]);
             }, $message);
             if (function_exists('iconv')) {
                 $message = iconv(CHARSET, 'UTF-8//ignore', $message);
             } else {
                 $message = mb_convert_encoding($message, 'UTF-8', CHARSET);
             }
             $message = $ret = preg_replace_callback('/\\[img](.*)\\[\\/img]/U', 'BigAppAPI::callback', $message);
             $value['message'] = '__DONT_DICONV_TO_UTF8___' . $message;
         }
         if (isset($value['msgtoid'])) {
             $value['msgtoid_avatar'] = avatar($value['msgtoid'], 'big', 'true');
             $value['msgtoid_avatar'] = str_replace("\r", '', $value['msgtoid_avatar']);
             $value['msgtoid_avatar'] = str_replace("\n", '', $value['msgtoid_avatar']);
         }
         if (isset($value['msgfromid'])) {
             $value['msgfromid_avatar'] = avatar($value['msgfromid'], 'big', 'true');
             $value['msgfromid_avatar'] = str_replace("\r", '', $value['msgfromid_avatar']);
             $value['msgfromid_avatar'] = str_replace("\n", '', $value['msgfromid_avatar']);
         }
     }
     unset($value);
     $variable = array('list' => bigapp_core::getvalues($GLOBALS['list'], array('/^\\d+$/'), array('plid', 'isnew', 'pmnum', 'lastupdate', 'lastdateline', 'authorid', 'author', 'pmtype', 'subject', 'members', 'dateline', 'touid', 'pmid', 'lastauthorid', 'lastauthor', 'lastsummary', 'msgfromid', 'msgfrom', 'message', 'msgtoid', 'msgtoid_avatar', 'msgfromid_avatar', 'tousername')), 'count' => $GLOBALS['count'], 'perpage' => $GLOBALS['perpage'], 'page' => intval($GLOBALS['page']));
     $start = $variable['perpage'] * ($variable['page'] - 1);
     $end = count($variable['list']) + $start;
     if ($end >= $variable['count']) {
         $variable['need_more'] = 0;
     } else {
         $variable['need_more'] = 1;
     }
     if ($_GET['subop']) {
         $variable = array_merge($variable, array('pmid' => $GLOBALS['pmid']));
     }
     $variable['list'] = array_values($variable['list']);
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 5
0
 function output()
 {
     global $_G;
     $perpage = 20;
     $page = isset($_G['page']) ? $_G['page'] : 1;
     $start = $perpage * ($page - 1);
     $view = $_GET['view'];
     $data[$view] = BigAppAPI::get_guide_list($view, $start, $perpage);
     $threadsInfo = isset($data[$view]['threadlist']) ? $data[$view]['threadlist'] : array();
     //数据映射
     foreach ($threadsInfo as $tid => &$thread) {
         if (!isset($_G['cache']['stamps'][$thread['icon']]['url'])) {
             $thread['icon'] = -1;
         }
         $thread['forum_name'] = $_G['cache']['forums'][$thread['fid']]['name'];
     }
     unset($thread);
     $threadsInfo = bigapp_core::getvalues($threadsInfo, array('/^\\d+$/'), array('tid', 'fid', 'posttableid', 'attachment', 'avatar', 'subject', 'author', 'views', 'replies', 'forum_name', 'authorid', 'icon', 'digest', 'dateline'));
     if (is_null($threadsInfo) || !is_array($threadsInfo)) {
         $threadsInfo = array();
     }
     foreach ($threadsInfo as $tid => $thread) {
         $threadsInfo[$tid]['avatar'] = avatar($thread['authorid'], 'big', true);
         $threadsInfo[$tid]['dateline'] = str_replace('&nbsp;', '', $threadsInfo[$tid]['dateline']);
         $threadsInfo[$tid]['dateline'] = preg_replace('/<.*?\\>/', '', $threadsInfo[$tid]['dateline']);
     }
     //filter &quot
     foreach ($threadsInfo as &$thread) {
         $thread['subject'] = str_replace('&quot;', '"', $thread['subject']);
     }
     BigAppAPI::_getDetails($threadsInfo);
     $thread_count = isset($data[$view]['threadcount']) ? $data[$view]['threadcount'] : 0;
     $need_more = $perpage * $page < $thread_count ? '1' : '0';
     $pic_mode = isset($_GET['style']) ? $_GET['style'] : '2';
     foreach ($threadsInfo as $tid => &$thread) {
         if ('2' == $pic_mode) {
             //无图模式
             $thread['attachment_urls'] = array();
             $thread['message_abstract'] = "";
         }
     }
     $variable = array("data" => array_values($threadsInfo), "count" => $thread_count, "page" => $page, "need_more" => $need_more, "pic_mode" => $pic_mode);
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 6
0
 function output()
 {
     global $_G;
     $type = $_GET['view'];
     foreach ($GLOBALS['data'][$type]['threadlist'] as $tid => &$thread) {
         if (!isset($_G['cache']['stamps'][$thread['icon']]['url'])) {
             $thread['icon'] = -1;
         }
         $thread['forum_name'] = $_G['cache']['forums'][$thread['fid']]['name'];
     }
     unset($thread);
     $GLOBALS['data'][$type]['threadlist'] = bigapp_core::getvalues($GLOBALS['data'][$type]['threadlist'], array('/^\\d+$/'), array('tid', 'fid', 'attachment', 'avatar', 'subject', 'author', 'views', 'replies', 'forum_name', 'authorid', 'dateline'));
     if (is_null($GLOBALS['data'][$type]['threadlist']) || !is_array($GLOBALS['data'][$type]['threadlist'])) {
         $GLOBALS['data'][$type]['threadlist'] = array();
     }
     foreach ($GLOBALS['data'][$type]['threadlist'] as $tid => $thread) {
         $GLOBALS['data'][$type]['threadlist'][$tid]['avatar'] = avatar($thread['authorid'], 'big', true);
         $GLOBALS['data'][$type]['threadlist'][$tid]['dateline'] = str_replace('&nbsp;', '', $GLOBALS['data'][$type]['threadlist'][$tid]['dateline']);
         $GLOBALS['data'][$type]['threadlist'][$tid]['dateline'] = preg_replace('/<.*?\\>/', '', $GLOBALS['data'][$type]['threadlist'][$tid]['dateline']);
     }
     //filter &quot
     foreach ($GLOBALS['data'][$type]['threadlist'] as &$thread) {
         $thread['subject'] = str_replace('&quot;', '"', $thread['subject']);
     }
     BigAppAPI::_getDetails($GLOBALS['data'][$type]['threadlist']);
     $variable = array('data' => array_values($GLOBALS['data'][$type]['threadlist']), 'perpage' => $GLOBALS['perpage']);
     if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) {
         $variable['open_image_mode'] = 0;
     }
     //$tmp = array();
     //foreach ($variable['data'] as $_v){
     //if(isset($_v['fid']) && in_array($_v['fid'], array(4, 217))){ //韬客论坛
     //if(isset($_v['fid']) && !in_array($_v['fid'], array(28, 81, 18, 19, 33, 17))){ //中羽论坛
     //continue;
     //}
     //$tmp[] = $_v;
     //}
     //$variable['data'] = $tmp;
     bigapp_core::result(mobile_core::variable($variable));
 }
Esempio n. 7
0
 function output()
 {
     global $_G;
     global $GLOBALS;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     $GLOBALS['list'] = (array) $GLOBALS['list'];
     foreach ($GLOBALS['list'] as &$value) {
         $value['dateline'] = str_replace('&nbsp;', '', $value['dateline']);
         $value['dateline'] = preg_replace('/<.*?\\>/', '', $value['dateline']);
         $value['lastpost'] = str_replace('&nbsp;', '', $value['lastpost']);
         $value['lastpost'] = preg_replace('/<.*?\\>/', '', $value['lastpost']);
         $value['forum_name'] = $value['forumname'];
         unset($value['forumname']);
     }
     unset($value);
     $GLOBALS['list'] = bigapp_core::getvalues($GLOBALS['list'], array('/^\\d+$/'), array('author', 'forum_name', 'message', 'pid', 'subject', 'dateline', 'tid', 'replies', 'views', 'avatar', 'lastpost', 'lastposter', 'authorid', 'fid'));
     $GLOBALS['posts'] = (array) $GLOBALS['posts'];
     foreach ($GLOBALS['posts'] as &$value) {
         $value['dateline'] = date('Y-m-d H:i:s', $value['dateline']);
     }
     $GLOBALS['posts'] = bigapp_core::getvalues($GLOBALS['posts'], array('/^\\d+$/'), array('author', 'forum_name', 'message', 'pid', 'subject', 'dateline', 'tid', 'replies', 'views', 'avatar', 'lastpost', 'lastposter', 'authorid', 'fid'));
     unset($value);
     if (!empty($_GET['uid'])) {
         $variable['avatar'] = avatar($_GET['uid'], 'big', 'true');
     } else {
         $variable['avatar'] = avatar($_G['uid'], 'big', 'true');
     }
     $variable['avatar'] = str_replace("\r", '', $variable['avatar']);
     $variable['avatar'] = str_replace("\n", '', $variable['avatar']);
     $variable['data'] = (array) $GLOBALS['list'];
     foreach ($GLOBALS['posts'] as $value) {
         if (isset($variable['data'][$value['tid']])) {
             $variable['data'][$value['tid']]['details'][] = $value;
         }
     }
     $variable['data'] = array_values($variable['data']);
     bigapp_core::result($variable);
 }
Esempio n. 8
0
 function process()
 {
     global $_G;
     //1. try to get user mask
     $authority = array();
     if ($_G['uid'] && !empty($_G['member']['accessmasks'])) {
         loadcache('plugin');
         $bucketNum = 100003;
         $expire = 5;
         $userBucket = $_G['uid'] % $bucketNum;
         loadcache('bigapp_authority_' . $userBucket);
         if (!isset($_G['cache']['bigapp_authority_' . $userBucket]) || TIMESTAMP - $_G['cache']['bigapp_authority_' . $userBucket]['expiration'] > $expire) {
             $sql = 'SELECT uid, fid, allowview FROM ' . DB::table('forum_access') . ' WHERE uid % ' . $bucketNum . ' = ' . $userBucket;
             $query = DB::query($sql);
             $authorities = array();
             while ($tmp = DB::fetch($query)) {
                 $authorities[$tmp['uid']][$tmp['fid']] = $tmp['allowview'];
             }
             savecache('bigapp_authority_' . $userBucket, array('variable' => $authorities, 'expiration' => TIMESTAMP));
         } else {
             $authorities = $_G['cache']['bigapp_authority_' . $userBucket]['variable'];
         }
         if (isset($authorities[$_G['uid']])) {
             $authority = $authorities[$_G['uid']];
         }
     }
     //2. try to get all forums
     $forums = array();
     loadcache('bigapp_forumnav');
     $expire = 5;
     if (!isset($_G['cache']['bigapp_forumnav']) || empty($_G['cache']['bigapp_forumnav']) || TIMESTAMP - $_G['cache']['bigapp_forumnav']['expiration'] > $expire) {
         //need update all forums from database
         $sql = "SELECT f.fid, f.type, f.name, f.fup, f.status, f.threads, f.posts, f.todayposts, " . "ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts, ff.icon, ff.description, ff.moderators FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid) WHERE f.status='1' ORDER BY f.type, f.displayorder";
         $query = DB::query($sql);
         while ($forum = DB::fetch($query)) {
             if ($forum['redirect'] || $forum['password']) {
                 continue;
             }
             if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) {
                 if ($forum['threadsorts']) {
                     $forum['threadsorts'] = bigapp_core::getvalues(unserialize($forum['threadsorts']), array('required', 'types'));
                 }
                 if ($forum['threadtypes']) {
                     $forum['threadtypes'] = unserialize($forum['threadtypes']);
                     $unsetthreadtype = false;
                     if ($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) {
                         $unsetthreadtype = true;
                     }
                     if ($_G['adminid'] == 0) {
                         $unsetthreadtype = true;
                     }
                     if ($unsetthreadtype) {
                         foreach ($forum['threadtypes']['moderators'] as $k => $v) {
                             if (!empty($v)) {
                                 unset($forum['threadtypes']['types'][$k]);
                             }
                         }
                     }
                     $flag = 0;
                     foreach ($forum['threadtypes']['types'] as $k => $v) {
                         if ($k == 0) {
                             $flag = 1;
                             break;
                         }
                     }
                     if ($flag == 1) {
                         krsort($forum['threadtypes']['types']);
                     }
                     $forum['threadtypes'] = bigapp_core::getvalues($forum['threadtypes'], array('required', 'types'));
                 }
                 $moderators = explode("\t", $forum['moderators']);
                 if (!is_array($moderators) || 0 === count($moderators)) {
                     $forum['moderators'] = array();
                 } else {
                     foreach ($moderators as &$_v) {
                         $_v = "'{$_v}'";
                     }
                     unset($_v);
                     $sql = 'SELECT username, uid FROM ' . DB::table('common_member') . ' WHERE username IN (' . implode(', ', $moderators) . ')';
                     $subQuery = DB::query($sql);
                     $forum['moderators'] = array();
                     while ($moderator = DB::fetch($subQuery)) {
                         $forum['moderators'][] = array('uid' => $moderator['uid'], 'username' => $moderator['username']);
                     }
                 }
                 $forums[] = bigapp_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes', 'icon', 'description', 'threads', 'posts', 'todayposts', 'moderators'));
             }
         }
         //add result to syscache
         savecache('bigapp_forumnav', array('variable' => $forums, 'expiration' => TIMESTAMP));
     } else {
         $forums = $_G['cache']['bigapp_forumnav']['variable'];
     }
     //3. judge which forum should be displayed
     $retData = array();
     if (!empty($authority)) {
         foreach ($forums as $forum) {
             if (isset($authority[$forum['fid']]) && -1 == $authority[$forum['fid']]) {
                 continue;
             }
             $retData[] = $forum;
         }
     } else {
         $retData = $forums;
     }
     foreach ($retData as &$value) {
         BigAppAPI::_textDescription($value);
     }
     unset($value);
     $variable['forums'] = array_values(BigAppAPI::_sortResult($retData));
     $variable['forum_list'] = array();
     BigAppAPI::_doSearch($variable, 'forums', $variable['forum_list']);
     unset($variable['forums']);
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 9
0
 function output()
 {
     $total = 0;
     if (isset($GLOBALS['index']['num'])) {
         $total = $GLOBALS['index']['num'];
     }
     $ret['tpp'] = BigAppAPI::$tpp;
     $ret['page'] = BigAppAPI::$page;
     $ret['need_more'] = 1;
     if (($ret['page'] - 1) * $ret['tpp'] + count($GLOBALS['threadlist']) >= $total) {
         $ret['need_more'] = 0;
     }
     $ret['thread_list'] = @bigapp_core::getvalues($GLOBALS['threadlist'], array('/^\\d+$/'), array('tid', 'fid', 'author', 'authorid', 'subject', 'dateline', 'lastpost', 'lastposter', 'views', 'replies', 'heats', 'forumname', 'message'));
     foreach ($ret['thread_list'] as &$thread) {
         if (!isset($thread['message'])) {
             $thread['message'] = '';
         }
         if (!isset($thread['subject'])) {
             $thread['subject'] = '';
         }
         $thread['message'] = preg_replace('/<.*?>/', '', $thread['message']);
         $thread['subject'] = preg_replace('/<.*?>/', '', $thread['subject']);
         $thread['avatar'] = avatar($thread['authorid'], 'big', true);
     }
     unset($thread);
     $ret['thread_list'] = array_values($ret['thread_list']);
     /////////////////////////////////////////////////////////////////
     //BigAppAPI::_getDetails($ret['thread_list']);
     /////////////////////////////////////////////////////////////////
     @bigapp_core::result(bigapp_core::variable($ret));
 }
Esempio n. 10
0
 function output()
 {
     global $_G, $thread;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     if ($GLOBALS['hiddenreplies']) {
         foreach ($GLOBALS['postlist'] as $k => $post) {
             if (!$post['first'] && $_G['uid'] != $post['authorid'] && $_G['uid'] != $_G['forum_thread']['authorid'] && !$_G['forum']['ismoderator']) {
                 $GLOBALS['postlist'][$k]['message'] = lang('plugin/mobile', 'mobile_post_author_visible');
                 $GLOBALS['postlist'][$k]['attachments'] = array();
             }
         }
     }
     $_G['thread']['lastpost'] = dgmdate($_G['thread']['lastpost']);
     $_G['thread']['ordertype'] = $GLOBALS['ordertype'];
     if (!empty($_GET['viewpid'])) {
         $GLOBALS['postlist'][$_GET['viewpid']] = $GLOBALS['post'];
     }
     if (!$_G['thread']['maxposition']) {
         $_G['thread']['maxposition'] = "1";
     }
     if ($GLOBALS['rushreply']) {
         $_G['thread']['rushreply'] = $GLOBALS['rushreply'];
         $_G['thread']['rushresult'] = $GLOBALS['rushresult'];
     }
     foreach ($GLOBALS['comments'] as $pid => $comments) {
         $comments = bigapp_core::getvalues($comments, array('/^\\d+$/'), array('id', 'tid', 'pid', 'author', 'authorid', 'dateline', 'comment', 'avatar'));
         foreach ($comments as $k => $c) {
             $comments[$k]['avatar'] = avatar($c['authorid'], 'small', true);
             $comments[$k]['dateline'] = dgmdate($c['dateline'], 'u');
         }
         $GLOBALS['comments'][$pid] = $comments;
     }
     $variable = array('thread' => $_G['thread'], 'fid' => $_G['fid'], 'postlist' => array_values(bigapp_core::getvalues($GLOBALS['postlist'], array('/^\\d+$/'), array('uid', 'pid', 'tid', 'author', 'first', 'dbdateline', 'dateline', 'username', 'adminid', 'memberstatus', 'authorid', 'username', 'groupid', 'memberstatus', 'status', 'message', 'number', 'memberstatus', 'groupid', 'attachment', 'attachments', 'attachlist', 'imagelist', 'anonymous', 'extcredits2', 'posts', 'threads', 'authortitle', 'position', 'postreview', 'isWater'))), 'allowpostcomment' => $_G['setting']['allowpostcomment'], 'comments' => $GLOBALS['comments'], 'commentcount' => $GLOBALS['commentcount'], 'imagelist' => array(), 'ppp' => $_G['ppp'], 'totalpage' => $GLOBALS['totalpage'], 'setting_rewriterule' => $_G['setting']['rewriterule'], 'setting_rewritestatus' => $_G['setting']['rewritestatus'], 'forum_threadpay' => $_G['forum_threadpay'], 'cache_custominfo_postno' => $_G['cache']['custominfo']['postno']);
     //帖子举报
     $variable['report']['enable'] = '1';
     $variable['report']['handlekey'] = 'miscreport' . $variable['postlist'][0]['tid'];
     $language_file = 'source/language/lang_template.php';
     if (file_exists($language_file)) {
         require_once $language_file;
     }
     $report_msg = explode(",", $lang['report_reason_message']);
     foreach ($report_msg as $key => $msg) {
         #$report_msg[$key] = preg_replace('/[|\'/', '', $msg);
         $msg = str_replace('[', '', $msg);
         $msg = str_replace(']', '', $msg);
         $msg = str_replace("'", "", $msg);
         $report_msg[$key] = $msg;
     }
     if (empty($report_msg[0])) {
         $variable['report']['content'] = array();
     } else {
         $variable['report']['content'] = $report_msg;
     }
     foreach ($variable['postlist'] as &$_item) {
         $_item['dateline'] = preg_replace('/<.*?\\>/', '', $_item['dateline']);
     }
     unset($_item);
     if (!empty($GLOBALS['threadsortshow'])) {
         $optionlist = array();
         foreach ($GLOBALS['threadsortshow']['optionlist'] as $key => $val) {
             $val['optionid'] = $key;
             $optionlist[] = $val;
         }
         if (!empty($optionlist)) {
             $GLOBALS['threadsortshow']['optionlist'] = $optionlist;
             $GLOBALS['threadsortshow']['threadsortname'] = $_G['forum']['threadsorts']['types'][$thread['sortid']];
         }
     }
     $threadsortshow = bigapp_core::getvalues($GLOBALS['threadsortshow'], array('/^(?!typetemplate).*$/'));
     if (!empty($threadsortshow)) {
         $variable['threadsortshow'] = $threadsortshow;
     }
     foreach ($variable['postlist'] as $k => &$post) {
         if (!$_G['forum']['ismoderator'] && $_G['setting']['bannedmessages'] & 1 && ($post['authorid'] && !$post['username'] || $_G['thread']['digest'] == 0 && ($post['groupid'] == 4 || $post['groupid'] == 5 || $post['memberstatus'] == '-1'))) {
             $message = lang('forum/template', 'message_banned');
         } elseif (!$_G['forum']['ismoderator'] && $post['status'] & 1) {
             $message = lang('forum/template', 'message_single_banned');
         } elseif ($GLOBALS['needhiddenreply']) {
             $message = lang('forum/template', 'message_ishidden_hiddenreplies');
         } elseif ($post['first'] && $_G['forum_threadpay']) {
             $message = lang('forum/template', 'pay_threads') . ' ' . $GLOBALS['thread']['price'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['unit'] . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'];
         } elseif ($_G['forum_discuzcode']['passwordlock']) {
             $message = lang('forum/template', 'message_password_exists');
         } else {
             $message = '';
         }
         //回帖举报
         ##############################
         /*if($_G['uid'] != $variable['postlist'][$k]['authorid']) {
         				$variable['postlist'][$k]['report']['enable'] = '1';
         				$variable['postlist'][$k]['report']['handlekey']='miscreport'.$variable['postlist'][$k]['pid'];
         				$variable['postlist'][$k]['report']['content'] = lang('plugin/bigapp', 'report_reason_message');
         		} else {
         				$variable['postlist'][$k]['report']['enable'] = '0';
         		}*/
         ##############################
         if ($message) {
             $variable['postlist'][$k]['message'] = $message;
         }
         if ($post['anonymous'] && !$_G['forum']['ismoderator']) {
             $variable['postlist'][$k]['username'] = $variable['postlist'][$k]['author'] = $_G['setting']['anonymoustext'];
             $variable['postlist'][$k]['adminid'] = $variable['postlist'][$k]['groupid'] = $variable['postlist'][$k]['authorid'] = 0;
             if ($post['first']) {
                 $variable['thread']['authorid'] = 0;
             }
         }
         if (strpos($variable['postlist'][$k]['message'], '[/tthread]') !== FALSE) {
             $matches = array();
             preg_match('/\\[tthread=(.+?),(.+?)\\](.*?)\\[\\/tthread\\]/', $variable['postlist'][$k]['message'], $matches);
             $variable['postlist'][$k]['message'] = preg_replace('/\\[tthread=(.+?)\\](.*?)\\[\\/tthread\\]/', lang('plugin/qqconnect', 'connect_tthread_message', array('username' => $matches[1], 'nick' => $matches[2])), $variable['postlist'][$k]['message']);
         }
         $variable['postlist'][$k]['message'] = preg_replace("/<a\\shref=\"([^\"]+?)\"\\starget=\"_blank\">\\[viewimg\\]<\\/a>/is", "<img src=\"\\1\" />", $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = BigAppAPI::_findimg($variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('!post_hide_reply_hidden!', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = str_replace('post_hide_reply_hidden', lang('plugin/bigapp', 'post_hide_reply_hide'), $variable['postlist'][$k]['message']);
         if ($GLOBALS['aimgs'][$post['pid']]) {
             $imagelist = array();
             foreach ($GLOBALS['aimgs'][$post['pid']] as $aid) {
                 $extra = '';
                 $url = BigAppAPI::_parseimg('', $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['attachment'], '');
                 if ($GLOBALS['postlist'][$post['pid']]['attachments'][$aid]['thumb']) {
                     $extra = 'file="' . $url . '" ';
                     $url .= '.thumb.jpg';
                 }
                 $extra .= 'attach="' . $post['pid'] . '" ';
                 if (strexists($variable['postlist'][$k]['message'], '[attach]' . $aid . '[/attach]')) {
                     $variable['postlist'][$k]['message'] = str_replace('[attach]' . $aid . '[/attach]', '<div class="img"><img src="' . $url . '" ' . $extra . '/></div>', $variable['postlist'][$k]['message']);
                     unset($variable['postlist'][$k]['attachments'][$aid]);
                 } elseif (!in_array($aid, $_G['forum_attachtags'][$post['pid']])) {
                     $imagelist[] = $aid;
                 }
             }
             $variable['postlist'][$k]['imagelist'] = $imagelist;
         }
         $variable['postlist'][$k]['message'] = preg_replace("/\\[attach\\]\\d+\\[\\/attach\\]/i", '', $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['message'] = preg_replace('/(&nbsp;){2,}/', '', $variable['postlist'][$k]['message']);
         $variable['postlist'][$k]['dateline'] = strip_tags($post['dateline']);
         $variable['postlist'][$k]['groupiconid'] = bigapp_core::usergroupIconId($post['groupid']);
         if ($post['first']) {
             $post['recommends'] = $_G['thread']['recommends'];
             $post['recommend_add'] = $_G['thread']['recommend_add'];
             $post['recommend_sub'] = $_G['thread']['recommend_sub'];
             $post['enable_recommend'] = 0;
             if (($_G['group']['allowrecommend'] || !$_G['uid']) && $_G['setting']['recommendthread']['status']) {
                 $post['enable_recommend'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             $post['addtext'] = $_G['setting']['recommendthread']['addtext'];
             $post['subtext'] = $_G['setting']['recommendthread']['subtracttext'];
             $post['recommend_value'] = $_G['group']['allowrecommend'];
             $post['recommended'] = 0;
             if (C::t('forum_memberrecommend')->fetch_by_recommenduid_tid($_G['uid'], $post['tid'])) {
                 $post['recommended'] = 1;
             }
         } else {
             $post['enable_support'] = 0;
             @preg_match('/^x([0-9\\.]+)/i', $_G['setting']['version'], $matches);
             $num = 0;
             if (isset($matches[1])) {
                 $num = $matches[1];
             }
             if ($num >= 3.1 && !$_G['forum_thread']['special'] && !$rushreply && !$hiddenreplies && $_G['setting']['repliesrank'] && !$post['first'] && !($post['isWater'] && $_G['setting']['filterednovote'])) {
                 $post['enable_support'] = 1;
                 $post['click2login'] = 0;
                 if (!$_G['uid']) {
                     $post['click2login'] = 1;
                 }
             }
             if (function_exists('iconv')) {
                 $post['supporttext'] = iconv('UTF-8', CHARSET . '//ignore', '支持');
                 $post['opposetext'] = iconv('UTF-8', CHARSET . '//ignore', '反对');
             } else {
                 $post['supporttext'] = mb_convert_encoding('支持', CHARSET, 'UTF-8');
                 $post['opposetext'] = mb_convert_encoding('反对', CHARSET, 'UTF-8');
             }
             $post['support'] = 0;
             $post['oppose'] = 0;
             if (isset($post['postreview']['support'])) {
                 $post['support'] = $post['postreview']['support'];
             }
             if (isset($post['postreview']['against'])) {
                 $post['oppose'] = $post['postreview']['against'];
             }
             unset($post['isWater']);
             unset($post['postreview']);
         }
     }
     unset($post);
     foreach ($GLOBALS['aimgs'] as $pid => $aids) {
         foreach ($aids as $aid) {
             $variable['imagelist'][] = $GLOBALS['postlist'][$pid]['attachments'][$aid]['url'] . $GLOBALS['postlist'][$pid]['attachments'][$aid]['attachment'];
         }
     }
     $variable['special_poll'] = BigAppAPI::getPollInfo();
     if (!empty($GLOBALS['rewardprice'])) {
         $variable['special_reward']['rewardprice'] = $GLOBALS['rewardprice'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]['title'];
         $variable['special_reward']['bestpost'] = $GLOBALS['bestpost'];
     }
     if (!empty($GLOBALS['trades'])) {
         $variable['special_trade'] = $GLOBALS['trades'];
     }
     if (!empty($GLOBALS['debate'])) {
         $variable['special_debate'] = $GLOBALS['debate'];
     }
     if (!empty($GLOBALS['activity'])) {
         $variable['special_activity'] = $GLOBALS['activity'];
         $variable['special_activity']['allapplynum'] = $GLOBALS['allapplynum'];
         if ($_G['setting']['activitycredit'] && $GLOBALS['activity']['credit'] && !$GLOBALS['applied']) {
             $variable['special_activity']['creditcost'] = $GLOBALS['activity']['credit'] . ' ' . $_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'];
         }
         $setting = array();
         foreach ($GLOBALS['activity']['ufield']['userfield'] as $field) {
             $setting[$field] = $_G['cache']['profilesetting'][$field];
         }
         $variable['special_activity']['joinfield'] = bigapp_core::getvalues($setting, array('/./'), array('fieldid', 'formtype', 'available', 'title', 'formtype', 'choices'));
         $variable['special_activity']['userfield'] = $GLOBALS['ufielddata']['userfield'];
         $variable['special_activity']['extfield'] = $GLOBALS['ufielddata']['extfield'];
         $variable['special_activity']['basefield'] = bigapp_core::getvalues($GLOBALS['applyinfo'], array('message', 'payment'));
         $variable['special_activity']['closed'] = $GLOBALS['activityclose'];
         if ($GLOBALS['applied'] && $GLOBALS['isverified'] < 2) {
             if (!$GLOBALS['isverified']) {
                 $variable['special_activity']['status'] = 'wait';
             } else {
                 $variable['special_activity']['status'] = 'joined';
             }
             if (!$GLOBALS['activityclose']) {
                 $variable['special_activity']['button'] = 'cancel';
             }
         } elseif (!$GLOBALS['activityclose']) {
             if ($GLOBALS['isverified'] != 2) {
                 $variable['special_activity']['status'] = 'join';
             } else {
                 $variable['special_activity']['status'] = 'complete';
             }
             $variable['special_activity']['button'] = 'join';
         }
     }
     $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
     BigAppAPI::modifyPost2($variable['postlist']);
     if (isset($variable['thread']['tid'])) {
         $variable['thread']['share_url'] = rtrim(ApiUtils::getDzRoot(), '/') . '/forum.php?mod=viewthread&tid=' . $variable['thread']['tid'];
     } else {
         $variable['thread']['share_url'] = '';
     }
     $variable['jump#pid'] = isset($_G['jump#pid']) ? $_G['jump#pid'] : "0";
     $variable['page'] = isset($_G['page']) ? $_G['page'] : "1";
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 11
0
 function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     $needMore = 1;
     $total = $_G['forum_threadcount'];
     $start = $_G['tpp'] * ($_G['page'] - 1);
     if ($start + count($_G['forum_threadlist']) >= $total) {
         $needMore = 0;
     }
     $tids = array();
     $threadList = array();
     BigAppAPI::_getDetails($_G['forum_threadlist']);
     foreach ($_G['forum_threadlist'] as $k => $thread) {
         $_G['forum_threadlist'][$k]['tid'] = $thread['icontid'];
         if ($thread['displayorder'] <= 0) {
             unset($_G['forum_threadlist'][$k]);
             continue;
         }
         if (!isset($_G['cache']['stamps'][$thread['icon']])) {
             $_G['forum_threadlist'][$k]['icon'] = -1;
         }
         $typeIcon = '';
         if (isset($_G['forum']['threadtypes']['icons'][$thread['typeid']])) {
             $typeIcon = $_G['forum']['threadtypes']['icons'][$thread['typeid']];
         }
         $tids[] = $thread['tid'];
         $threadList[$thread['tid']] = $_G['forum_threadlist'][$k];
         $threadList[$thread['tid']]['avatar'] = avatar($_G['forum_threadlist'][$k]['authorid'], 'big', 'true');
         $threadList[$thread['tid']]['avatar'] = str_replace("\r", '', $threadList[$thread['tid']]['avatar']);
         $threadList[$thread['tid']]['avatar'] = str_replace("\n", '', $threadList[$thread['tid']]['avatar']);
         $threadList[$thread['tid']]['lastpost'] = str_replace('&nbsp;', '', $threadList[$thread['tid']]['lastpost']);
         $threadList[$thread['tid']]['dateline'] = str_replace('&nbsp;', '', $threadList[$thread['tid']]['dateline']);
         $threadList[$thread['tid']]['typeicon'] = $typeIcon;
     }
     $_G['forum_threadlist'] = array_values($threadList);
     $moderators = explode("\t", $_G['forum']['moderators']);
     if (!is_array($moderators) || 0 === count($moderators)) {
         $_G['forum']['moderators'] = array();
     } else {
         foreach ($moderators as &$_v) {
             $_v = "'{$_v}'";
         }
         unset($_v);
         $sql = 'SELECT username, uid FROM ' . DB::table('common_member') . ' WHERE username IN (' . implode(', ', $moderators) . ')';
         $subQuery = DB::query($sql);
         $_G['forum']['moderators'] = array();
         while ($moderator = DB::fetch($subQuery)) {
             $_G['forum']['moderators'][] = array('uid' => $moderator['uid'], 'username' => $moderator['username']);
         }
     }
     $variable = array('forum' => bigapp_core::getvalues($_G['forum'], array('fid', 'fup', 'name', 'threads', 'posts', 'rules', 'autoclose', 'password', 'todayposts', 'yesterdayposts', 'moderators')), 'group' => bigapp_core::getvalues($_G['group'], array('groupid', 'grouptitle')), 'forum_threadlist' => bigapp_core::getvalues(array_values($_G['forum_threadlist']), array('/^\\d+$/'), array('fid', 'tid', 'author', 'authorid', 'subject', 'dbdateline', 'dateline', 'dblastpost', 'lastpost', 'lastposter', 'attachment', 'replies', 'readperm', 'views', 'heats', 'icon', 'threadimage', 'avatar', 'message_abstract', 'attachment_urls', 'typeid', 'typename', 'typeicon', 'mobile', 'highlight', 'digest')), 'sublist' => bigapp_core::getvalues($GLOBALS['sublist'], array('/^\\d+$/'), array('fid', 'name', 'threads', 'todayposts', 'posts')), 'tpp' => $_G['tpp'], 'page' => $GLOBALS['page'], 'need_more' => $needMore);
     if (!empty($_G['forum']['threadtypes']) || !empty($_GET['debug'])) {
         $variable['threadtypes'] = $_G['forum']['threadtypes'];
         unset($variable['threadtypes']['types']);
         foreach ($_G['forum']['threadtypes']['types'] as $typeId => $typeValue) {
             $variable['threadtypes']['types'][] = array('typeid' => $typeId, 'typename' => $typeValue);
         }
         unset($variable['threadtypes']['icons']);
         foreach ($_G['forum']['threadtypes']['icons'] as $typeId => $icon) {
             $variable['threadtypes']['icons'][] = array('typeid' => $typeId, 'typeicon' => $icon);
         }
     }
     if (isset($variable['threadtypes']) && (empty($variable['threadtypes']) || isset($variable['threadtypes'][0]) && empty($variable['threadtypes'][0]) || isset($variable['threadtypes']['types']) && empty($variable['threadtypes']['types']) || isset($variable['threadtypes']['icons']) && empty($variable['threadtypes']['icons']))) {
         unset($variable['threadtypes']);
     }
     if (!empty($_G['forum']['threadsorts']) || !empty($_GET['debug'])) {
         $variable['threadsorts'] = $_G['forum']['threadsorts'];
     }
     $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 12
0
 function output()
 {
     global $_G;
     if (true === BigAppConf::$debug) {
         $_G['trace'][] = __CLASS__ . '::' . __FUNCTION__;
     }
     $needMore = 1;
     if ('1' == $_G['page'] && count($_G['forum_threadlist']) < $_G['tpp']) {
         $needMore = 0;
     }
     $total = $_G['forum_threadcount'];
     $start = $_G['tpp'] * ($_G['page'] - 1);
     if ($start + count($_G['forum_threadlist']) >= $total) {
         $needMore = 0;
     }
     $tids = array();
     $threadList = array();
     BigAppAPI::_getDetails($_G['forum_threadlist']);
     foreach ($_G['forum_threadlist'] as $k => $thread) {
         $_G['forum_threadlist'][$k]['tid'] = $thread['icontid'];
         if ($thread['displayorder'] > 0) {
             unset($_G['forum_threadlist'][$k]);
             continue;
         }
         if (!isset($_G['cache']['stamps'][$thread['icon']])) {
             $_G['forum_threadlist'][$k]['icon'] = -1;
         }
         $typeIcon = '';
         if (isset($_G['forum']['threadtypes']['icons'][$thread['typeid']])) {
             $typeIcon = $_G['forum']['threadtypes']['icons'][$thread['typeid']];
         }
         $tids[] = $thread['tid'];
         $threadList[$thread['tid']] = $_G['forum_threadlist'][$k];
         $threadList[$thread['tid']]['avatar'] = avatar($_G['forum_threadlist'][$k]['authorid'], 'big', 'true');
         $threadList[$thread['tid']]['avatar'] = str_replace("\r", '', $threadList[$thread['tid']]['avatar']);
         $threadList[$thread['tid']]['avatar'] = str_replace("\n", '', $threadList[$thread['tid']]['avatar']);
         $threadList[$thread['tid']]['lastpost'] = str_replace('&nbsp;', '', $threadList[$thread['tid']]['lastpost']);
         $threadList[$thread['tid']]['dateline'] = str_replace('&nbsp;', '', $threadList[$thread['tid']]['dateline']);
         $threadList[$thread['tid']]['dateline'] = preg_replace('/<.*?\\>/', '', $threadList[$thread['tid']]['dateline']);
         $threadList[$thread['tid']]['typeicon'] = $typeIcon;
         $threadList[$thread['tid']]['forum_name'] = isset($_G['forum']['name']) ? $_G['forum']['name'] : "";
         if (!isset($thread['subject'])) {
             $threadList[$thread['tid']]['subject'] = "";
             //hack
         } else {
             //filter &quot
             $threadList[$thread['tid']]['subject'] = str_replace('&quot;', '"', $thread['subject']);
         }
     }
     $_G['forum_threadlist'] = array_values($threadList);
     $moderators = explode("\t", $_G['forum']['moderators']);
     if (!is_array($moderators) || 0 === count($moderators)) {
         $_G['forum']['moderators'] = array();
     } else {
         foreach ($moderators as &$_v) {
             $_v = "'{$_v}'";
         }
         unset($_v);
         $sql = 'SELECT username, uid FROM ' . DB::table('common_member') . ' WHERE username IN (' . implode(', ', $moderators) . ')';
         $subQuery = DB::query($sql);
         $_G['forum']['moderators'] = array();
         while ($moderator = DB::fetch($subQuery)) {
             $_G['forum']['moderators'][] = array('uid' => $moderator['uid'], 'username' => $moderator['username']);
         }
     }
     $variable = array('forum' => bigapp_core::getvalues($_G['forum'], array('fid', 'fup', 'name', 'threads', 'posts', 'rules', 'autoclose', 'password', 'todayposts', 'yesterdayposts', 'moderators', 'allowspecialonly')), 'group' => bigapp_core::getvalues($_G['group'], array('groupid', 'grouptitle')), 'open_image_mode' => 1, 'forum_threadlist' => bigapp_core::getvalues(array_values($_G['forum_threadlist']), array('/^\\d+$/'), array('fid', 'tid', 'author', 'authorid', 'subject', 'dbdateline', 'dateline', 'dblastpost', 'lastpost', 'lastposter', 'attachment', 'replies', 'readperm', 'views', 'heats', 'icon', 'threadimage', 'avatar', 'message_abstract', 'attachment_urls', 'typeid', 'typename', 'typeicon', 'mobile', 'highlight', 'digest', 'forum_name')), 'sublist' => bigapp_core::getvalues($GLOBALS['sublist'], array('/^\\d+$/'), array('fid', 'name', 'threads', 'todayposts', 'posts')), 'tpp' => $_G['tpp'], 'page' => $GLOBALS['page'], 'need_more' => $needMore);
     $variable['activity_config'] = array('allowpostactivity' => 0, 'credit_title' => '', 'activitytype' => array(), 'activityfield' => array(), 'activityextnum' => 0, 'activitypp' => 1);
     if (isset($_G['group']['allowpostactivity']) && $_G['group']['allowpostactivity'] && $_G['forum']['allowpostspecial'] & 8) {
         $variable['activity_config']['allowpostactivity'] = 1;
         if (isset($_G['setting']['activitycredit']) && isset($_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'])) {
             $variable['activity_config']['credit_title'] = $_G['setting']['extcredits'][$_G['setting']['activitycredit']]['title'];
         }
         if (isset($_G['setting']['activitytype'])) {
             $variable['activity_config']['activitytype'] = explode("\r\n", $_G['setting']['activitytype']);
         }
         if (isset($_G['setting']['activityfield'])) {
             $variable['activity_config']['activityfield'] = unserialize($_G['setting']['activityfield']);
             $tmp = array();
             foreach ($variable['activity_config']['activityfield'] as $k => $v) {
                 $tmp[] = array('fieldid' => $k, 'fieldtext' => $v);
             }
             $variable['activity_config']['activityfield'] = $tmp;
         }
         if (isset($_G['setting']['activityextnum'])) {
             $variable['activity_config']['activityextnum'] = $_G['setting']['activityextnum'];
         }
         if (isset($_G['setting']['activitypp'])) {
             $variable['activity_config']['activitypp'] = $_G['setting']['activitypp'];
         }
     }
     $variable['poll_config']['allowpostpoll'] = 0;
     if (isset($_G['group']['allowpostpoll'])) {
         $variable['poll_config']['allowpostpoll'] = intval($_G['group']['allowpostpoll']);
     }
     if (isset($_G['setting']['maxpolloptions']) && $_G['setting']['maxpolloptions'] > 0) {
         $variable['poll_config']['maxpolloptions'] = intval($_G['setting']['maxpolloptions']);
     } else {
         $variable['poll_config']['maxpolloptions'] = 0;
         $variable['poll_config']['allowpostpoll'] = 0;
     }
     if (isset($_G['setting']['bigapp_settings']['threadlist_image_mode']) && !$_G['setting']['bigapp_settings']['threadlist_image_mode']) {
         $variable['open_image_mode'] = 0;
     }
     if (!empty($_G['forum']['threadtypes']) || !empty($_GET['debug'])) {
         $variable['threadtypes'] = $_G['forum']['threadtypes'];
         unset($variable['threadtypes']['types']);
         foreach ($_G['forum']['threadtypes']['types'] as $typeId => $typeValue) {
             $typeValue = preg_replace('/<.*?>/', '', $typeValue);
             $variable['threadtypes']['types'][] = array('typeid' => $typeId, 'typename' => $typeValue);
         }
         unset($variable['threadtypes']['icons']);
         foreach ($_G['forum']['threadtypes']['icons'] as $typeId => $icon) {
             $variable['threadtypes']['icons'][] = array('typeid' => $typeId, 'typeicon' => $icon);
         }
     }
     if (!empty($_G['forum']['threadsorts']) || !empty($_GET['debug'])) {
         $variable['threadsorts'] = $_G['forum']['threadsorts'];
     }
     foreach ($variable['forum_threadlist'] as &$tl) {
         if (!isset($tl['message_abstract'])) {
             $tl['message_abstract'] = '';
         }
         if (!isset($tl['attachment_urls'])) {
             $tl['attachment_urls'] = array();
         }
         $tl['typename'] = preg_replace('/<.*?>/', '', $tl['typename']);
         $tl['author_display'] = $tl['author'];
     }
     unset($tl);
     $variable['forum']['password'] = $variable['forum']['password'] ? '1' : '0';
     $variable['forum']['icon'] = '';
     if (!empty($_G['forum']['icon'])) {
         $variable['forum']['icon'] = ApiUtils::getDzRoot() . $_G['setting']['attachurl'] . 'common/' . $_G['forum']['icon'];
     }
     if (isset($variable['threadtypes']) && (empty($variable['threadtypes']) || isset($variable['threadtypes'][0]) && empty($variable['threadtypes'][0]) || isset($variable['threadtypes']['types']) && empty($variable['threadtypes']['types']) || isset($variable['threadtypes']['icons']) && empty($variable['threadtypes']['icons']))) {
         unset($variable['threadtypes']);
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 13
0
 function process()
 {
     global $_G;
     //1. try to get user mask
     $authority = array();
     if ($_G['uid'] && !empty($_G['member']['accessmasks'])) {
         loadcache('plugin');
         $bucketNum = 100003;
         $expire = 5;
         $userBucket = $_G['uid'] % $bucketNum;
         loadcache('bigapp_authority_' . $userBucket);
         if (!isset($_G['cache']['bigapp_authority_' . $userBucket]) || TIMESTAMP - $_G['cache']['bigapp_authority_' . $userBucket]['expiration'] > $expire) {
             $sql = 'SELECT uid, fid, allowview FROM ' . DB::table('forum_access') . ' WHERE uid % ' . $bucketNum . ' = ' . $userBucket;
             $query = DB::query($sql);
             $authorities = array();
             while ($tmp = DB::fetch($query)) {
                 $authorities[$tmp['uid']][$tmp['fid']] = $tmp['allowview'];
             }
             savecache('bigapp_authority_' . $userBucket, array('variable' => $authorities, 'expiration' => TIMESTAMP));
         } else {
             $authorities = $_G['cache']['bigapp_authority_' . $userBucket]['variable'];
         }
         if (isset($authorities[$_G['uid']])) {
             $authority = $authorities[$_G['uid']];
         }
     }
     //2. try to get all forums
     $forums = array();
     $cacheKey = 'bigapp_forumnav';
     if (isset($_G['adminid'])) {
         $cacheKey = 'bigapp_forumnav_' . $_G['adminid'];
     }
     loadcache($cacheKey);
     $expire = 5;
     if (!isset($_G['cache'][$cacheKey]) || empty($_G['cache'][$cacheKey]) || TIMESTAMP - $_G['cache'][$cacheKey]['expiration'] > $expire) {
         //need update all forums from database
         $sql = "SELECT f.fid, f.type, f.name, f.fup, f.status, f.threads, f.posts, f.todayposts, f.allowpostspecial, f.allowspecialonly, " . "ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts, ff.icon, ff.description, ff.moderators FROM " . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff USING(fid) WHERE f.status='1' ORDER BY f.type, f.displayorder";
         $query = DB::query($sql);
         while ($forum = DB::fetch($query)) {
             if ($forum['redirect'] || $forum['password']) {
                 continue;
             }
             if (!$forum['viewperm'] || $forum['viewperm'] && forumperm($forum['viewperm'])) {
                 if ($forum['threadsorts']) {
                     $forum['threadsorts'] = bigapp_core::getvalues(unserialize($forum['threadsorts']), array('required', 'types'));
                 }
                 if ($forum['threadtypes']) {
                     $forum['threadtypes'] = unserialize($forum['threadtypes']);
                     $unsetthreadtype = false;
                     if ($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) {
                         $unsetthreadtype = true;
                     }
                     if ($_G['adminid'] == 0) {
                         $unsetthreadtype = true;
                     }
                     if ($unsetthreadtype) {
                         foreach ($forum['threadtypes']['moderators'] as $k => $v) {
                             if (!empty($v)) {
                                 unset($forum['threadtypes']['types'][$k]);
                             }
                         }
                     }
                     $flag = 0;
                     foreach ($forum['threadtypes']['types'] as $k => $v) {
                         if ($k == 0) {
                             $flag = 1;
                             break;
                         }
                     }
                     if ($flag == 1) {
                         krsort($forum['threadtypes']['types']);
                     }
                     $forum['threadtypes'] = bigapp_core::getvalues($forum['threadtypes'], array('required', 'types'));
                 }
                 loadforum($forum['fid'], null);
                 if (!empty($_G['forum']['threadtypes']) || !empty($_GET['debug'])) {
                     $forum['threadtypes_detail'] = $_G['forum']['threadtypes'];
                     unset($forum['threadtypes_detail']['types']);
                     foreach ($_G['forum']['threadtypes']['types'] as $typeId => $typeValue) {
                         $typeValue = preg_replace('/<.*?>/', '', $typeValue);
                         if (isset($_G['forum']['threadtypes']['moderators'][$typeId]) && !empty($_G['forum']['threadtypes']['moderators'][$typeId])) {
                             if (isset($_G['adminid']) && $_G['adminid'] != $_G['forum']['threadtypes']['moderators'][$typeId]) {
                                 continue;
                             }
                         }
                         $forum['threadtypes_detail']['types'][] = array('typeid' => $typeId, 'typename' => $typeValue);
                     }
                     unset($forum['threadtypes_detail']['icons']);
                     foreach ($_G['forum']['threadtypes']['icons'] as $typeId => $icon) {
                         $forum['threadtypes_detail']['icons'][] = array('typeid' => $typeId, 'typeicon' => $icon);
                     }
                 }
                 $moderators = explode("\t", $forum['moderators']);
                 if (!is_array($moderators) || 0 === count($moderators)) {
                     $forum['moderators'] = array();
                 } else {
                     foreach ($moderators as &$_v) {
                         $_v = "'{$_v}'";
                     }
                     unset($_v);
                     $sql = 'SELECT username, uid FROM ' . DB::table('common_member') . ' WHERE username IN (' . implode(', ', $moderators) . ')';
                     $subQuery = DB::query($sql);
                     $forum['moderators'] = array();
                     while ($moderator = DB::fetch($subQuery)) {
                         $forum['moderators'][] = array('uid' => $moderator['uid'], 'username' => $moderator['username']);
                     }
                 }
                 $forums[] = bigapp_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes', 'threadtypes_detail', 'icon', 'description', 'threads', 'allowpostspecial', 'allowspecialonly', 'posts', 'todayposts', 'moderators'));
             }
         }
         //add result to syscache
         savecache($cacheKey, array('variable' => $forums, 'expiration' => TIMESTAMP));
     } else {
         $forums = $_G['cache'][$cacheKey]['variable'];
     }
     //3. judge which forum should be displayed
     $retData = array();
     if (!empty($authority)) {
         foreach ($forums as $forum) {
             if (isset($authority[$forum['fid']]) && -1 == $authority[$forum['fid']]) {
                 continue;
             }
             $retData[] = $forum;
         }
     } else {
         $retData = $forums;
     }
     //4. AppDegin 论坛视图设置过滤
     $res = C::t('common_setting')->fetch("bigapp_view_2", true);
     if (isset($res['displayid']) && isset($res['forbiddenid'])) {
         //获取论坛视图配置
         $displayArr = array();
         $forbiddenArr = array();
         if (!empty($res['displayid'])) {
             $displayArr = explode(',', $res['displayid']);
         }
         if (!empty($res['forbiddenid'])) {
             $forbiddenArr = explode(',', $res['forbiddenid']);
         }
         $retData = BigAppAPI::_filterResult($retData, $displayArr, $forbiddenArr);
     }
     $activityForum = array();
     foreach ($retData as $forum) {
         if (isset($_G['group']['allowpostactivity']) && $_G['group']['allowpostactivity'] && $forum['allowpostspecial'] & 8) {
             $activityForum[] = $forum;
         }
     }
     foreach ($retData as &$value) {
         BigAppAPI::_textDescription($value);
     }
     unset($value);
     $variable['forums'] = array_values(BigAppAPI::_sortResult($retData));
     $variable['activity_forums'] = $activityForum;
     if (isset($_G['setting']['bigapp_settings'])) {
         $_G['setting']['bigapp_settings'] = unserialize($_G['setting']['bigapp_settings']);
     }
     $res = C::t('common_setting')->fetch("bigapp_view_2", true);
     if (isset($res[0]) && empty($res[0])) {
         //没有获取论坛视图配置
         $variable['display_style'] = strval(isset($_G['setting']['bigapp_settings']['display_style']) ? $_G['setting']['bigapp_settings']['display_style'] : 0);
     } else {
         $variable['display_style'] = isset($res["type"]) ? strval(intval($res["type"]) - 1) : '0';
     }
     bigapp_core::result(bigapp_core::variable($variable));
 }
Esempio n. 14
0
 function getvalues($variables, $keys, $subkeys = array())
 {
     $return = array();
     $variables = (array) $variables;
     foreach ($variables as $key => $value) {
         foreach ($keys as $k) {
             if ($k[0] == '/' && preg_match($k, $key) || $key == $k) {
                 if ($subkeys) {
                     $return[$key] = bigapp_core::getvalues($value, $subkeys);
                 } else {
                     if (!empty($value) || !empty($_GET['debug']) || is_numeric($value) && intval($value) === 0) {
                         $return[$key] = is_array($value) ? bigapp_core::arraystring($value) : (string) $value;
                     }
                 }
             }
         }
     }
     return $return;
 }