group_index.php
5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: group_index.php 25246 2011-11-02 03:34:53Z zhangguosheng $
*/
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
$navtitle = '';
$gid = intval(getgpc('gid'));
$sgid = intval(getgpc('sgid'));
$groupids = array();
$groupnav = $typelist = '';
$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;
$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)) {
include template('diy:group/index');
} else {
if(empty($sgid)) {
include template('diy:group/type:'.$gid);
} else {
include template('diy:group/type:'.$fup);
}
}
?>