123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- <?php
- /**
- * [Discuz!] (C)2001-2099 Comsenz Inc.
- * This is NOT a freeware, use is subject to license terms
- *
- * $Id: group_index.php 36284 2016-12-12 00:47:50Z nemohou $
- */
- if(!defined('IN_DISCUZ')) {
- exit('Access Denied');
- }
- $navtitle = '';
- $gid = intval(getgpc('gid'));
- $sgid = intval(getgpc('sgid'));
- $groupids = $typelist = array();
- $groupnav = '';
- $selectorder = array('default' => '', 'thread' => '', 'membernum' => '', 'dateline' => '', 'activity' => '');
- if(!empty($_GET['orderby'])) {
- $selectorder[$_GET['orderby']] = 'selected';
- } else {
- $selectorder['default'] = 'selected';
- }
- $first = &$_G['cache']['grouptype']['first'];
- $second = &$_G['cache']['grouptype']['second'];
- require_once libfile('function/group');
- $url = $_G['basescript'].'.php';
- if($gid) {
- if(!empty($first[$gid])) {
- $curtype = $first[$gid];
- if($curtype['secondlist']) {
- foreach($curtype['secondlist'] as $fid) {
- $typelist[$fid] = $second[$fid];
- }
- $groupids = $first[$gid]['secondlist'];
- }
- $groupids[] = $gid;
- $url .= '?gid='.$gid;
- $fup = $gid;
- } else {
- $gid = 0;
- }
- } elseif($sgid) {
- if(!empty($second[$sgid])) {
- $curtype = $second[$sgid];
- $fup = $curtype['fup'];
- $groupids = array($sgid);
- $url .= '?sgid='.$sgid;
- } else {
- $sgid = 0;
- }
- }
- if(empty($curtype)) {
- if($_G['uid'] && empty($_G['mod'])) {
- $usergroups = getuserprofile('groups');
- if(!empty($usergroups)) {
- dheader('Location:group.php?mod=my');
- exit;
- }
- }
- $curtype = array();
- } else {
- $nav = get_groupnav($curtype);
- $groupnav = $nav['nav'];
- $_G['grouptypeid'] = $curtype['fid'];
- $perpage = 10;
- if($curtype['forumcolumns'] > 1) {
- $curtype['forumcolwidth'] = (floor(100 / $curtype['forumcolumns']) - 0.1).'%';
- $perpage = $curtype['forumcolumns'] * 10;
- }
- }
- $seodata = array('first' => $nav['first']['name'], 'second' => $nav['second']['name']);
- list($navtitle, $metadescription, $metakeywords) = get_seosetting('group', $seodata);
- $_G['cache']['groupindex'] = '';
- $data = $randgrouplist = $randgroupdata = $grouptop = $newgrouplist = array();
- $topgrouplist = $_G['cache']['groupindex']['topgrouplist'];
- $lastupdategroup = $_G['cache']['groupindex']['lastupdategroup'];
- $todayposts = intval($_G['cache']['groupindex']['todayposts']);
- $groupnum = intval($_G['cache']['groupindex']['groupnum']);
- $cachetimeupdate = TIMESTAMP - intval($_G['cache']['groupindex']['updateline']);
- if(empty($_G['cache']['groupindex']) || $cachetimeupdate > 3600 || empty($lastupdategroup)) {
- $data['randgroupdata'] = $randgroupdata = grouplist('lastupdate', array('ff.membernum', 'ff.icon'), 80);
- $data['topgrouplist'] = $topgrouplist = grouplist('activity', array('f.commoncredits', 'ff.membernum', 'ff.icon'), 10);
- $data['updateline'] = TIMESTAMP;
- $groupdata = C::t('forum_forum')->fetch_group_counter();
- $data['todayposts'] = $todayposts = $groupdata['todayposts'];
- $data['groupnum'] = $groupnum = $groupdata['groupnum'];
- foreach($first as $id => $toptype) {
- if(empty($toptype['secondlist'])) $toptype['secondlist'][] = $id;
- $query = C::t('forum_forum')->fetch_all_sub_group_by_fup($toptype['secondlist']);
- foreach($query as $row) {
- $data['lastupdategroup'][$id][] = $row;
- }
- if(empty($data['lastupdategroup'][$id])) $data['lastupdategroup'][$id] = array();
- }
- $lastupdategroup = $data['lastupdategroup'];
- savecache('groupindex', $data);
- }
- $list = array();
- if($groupids) {
- $orderby = in_array(getgpc('orderby'), array('membernum', 'dateline', 'thread', 'activity')) ? getgpc('orderby') : 'displayorder';
- $page = intval(getgpc('page')) ? intval($_GET['page']) : 1;
- $page = $page > 65535 ? 1 : $page;
- $start = ($page - 1) * $perpage;
- $getcount = grouplist('', '', '', $groupids, 1, 1);
- if($getcount) {
- $list = grouplist($orderby, '', array($start, $perpage), $groupids, 1);
- $multipage = multi($getcount, $perpage, $page, $url."&orderby=$orderby");
- }
- }
- $endrows = $curtype['forumcolumns'] > 1 ? str_repeat('<td width="'.$curtype['forumcolwidth'].'"></td>', $curtype['forumcolumns'] - count($list) % $curtype['forumcolumns']) : '';
- $groupviewed_list = get_viewedgroup();
- if(empty($sgid) && empty($gid)) {
- foreach($first as $key => $val) {
- if(is_array($val['secondlist']) && !empty($val['secondlist'])) {
- $first[$key]['secondlist'] = array_slice($val['secondlist'], 0, 8);
- }
- }
- }
- if(!$navtitle || !empty($sgid) || !empty($gid)) {
- if(!$navtitle) {
- $navtitle = !empty($gid) ? $nav['first']['name'] : (!empty($sgid) ? $nav['second']['name'] : '');
- }
- $navtitle = (!empty($sgid) || !empty($gid) ? helper_seo::get_title_page($navtitle, $_G['page']).' - ' : '').$_G['setting']['navs'][3]['navname'];
- $nobbname = false;
- } else {
- $nobbname = true;
- }
- if(!$metakeywords) {
- $metakeywords = $_G['setting']['navs'][3]['navname'];
- }
- if(!$metadescription) {
- $metadescription = $_G['setting']['navs'][3]['navname'];
- }
- if(empty($curtype)) {
- if(!empty($_GET['province'])) {
- $_G['sg'] = [];
- $_G['sg']['group_list'] = C::t('forum_forum')->fetch_all_for_grouplist_by_province($_GET['province'], 'displayorder', '*', 10);
- include template('diy:group/area');
- } else {
- include template('diy:group/index');
- }
- } else {
- if(empty($sgid)) {
- include template('diy:group/type:'.$gid);
- } else {
- include template('diy:group/type:'.$fup);
- }
- }
- ?>
|