admincp_membersplit.php
4.46 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_membersplit.php 29851 2012-05-02 02:18:40Z zhangguosheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if(!$operation) {
$operation = 'check';
}
loadcache(array('membersplitdata', 'userstats'));
if(!empty($_G['cache']['membersplitstep'])) {
cpmsg('membersplit_split_in_backstage', 'action=membersplit&operation=check', 'loadingform');
}
if($operation == 'check') {
shownav('founder', 'nav_membersplit');
showsubmenu('membersplit');
showtips('membersplit_check_tips');
showformheader('membersplit&operation=manage');
showtableheader('membersplit_table_orig');
$membercount = $_G['cache']['userstats']['totalmembers'];
showsubtitle(array('','','membersplit_count', 'membersplit_lasttime_check'));
if($membercount < 20000) {
$color = 'green';
$msg = $lang['membersplit_without_optimization'];
} else {
$color = empty($_G['cache']['membersplitdata']) || $_G['cache']['membersplitdata']['dateline'] < TIMESTAMP - 86400*10 ?
'red' : 'green';
$msg = empty($_G['cache']['membersplitdata']) ? $lang['membersplit_has_no_check'] : dgmdate($_G['cache']['membersplitdata']['dateline']);
}
showtablerow('', '', array('','', number_format($membercount), '<span style="color:'.$color.'">'.$msg.'</span>'));
if($membercount >= 20000) {
showsubmit('membersplit_check_submit', 'membersplit_check');
}
showtablefooter();
showformfooter();
} else if($operation == 'manage') {
shownav('founder', 'nav_membersplit');
if(!submitcheck('membersplit_split_submit', 1)) {
showsubmenu('membersplit');
showtips('membersplit_tips');
showformheader('membersplit&operation=manage');
showtableheader('membersplit_table_orig');
if($_G['cache']['membersplitdata'] && $_G['cache']['membersplitdata']['dateline'] > TIMESTAMP - 86400) {
$zombiecount = $_G['cache']['membersplitdata']['zombiecount'];
} else {
$zombiecount = C::t('common_member')->count_zombie();
savecache('membersplitdata', array('zombiecount' => $zombiecount, 'dateline' => TIMESTAMP));
}
$membercount = $_G['cache']['userstats']['totalmembers'];
$percentage = round($zombiecount/$membercount, 4)*100;
showsubtitle(array('','','membersplit_count', 'membersplit_combie_count', 'membersplit_splitnum'));
$color = $percentage > 0 ? 'red' : 'green';
if($percentage == 0) {
$msg = $lang['membersplit_message0'];
} else if($percentage < 10) {
$msg = $lang['membersplit_message10'];
} else {
$msg = $lang['membersplit_message100'];
}
showtablerow('', '',
array('','', number_format($membercount), '<span style="color:'.$color.'">'.number_format($zombiecount).'('.$percentage.'%) '.$msg.'</span>', '<input name="splitnum" value="200" type="text" class="txt"/>'));
if($percentage > 0) {
showsubmit('membersplit_split_submit', 'membersplit_archive');
}
showtablefooter();
showformfooter();
} else {
$step = intval($_GET['step'])+1;
$splitnum = max(10, intval($_GET['splitnum']));
if(!$_GET['nocheck'] && $step == 1 && !C::t('common_member_archive')->check_table()) {
cpmsg('membersplit_split_check_table', 'action=membersplit&operation=rebuildtable&splitnum='.$splitnum, 'loadingform', array());
cpmsg('', 'action=membersplit&operation=manage', 'error');
}
if(!C::t('common_member')->split($splitnum)) {
cpmsg('membersplit_split_succeed', 'action=membersplit&operation=manage', 'succeed');
}
cpmsg('membersplit_split_doing', 'action=membersplit&operation=manage&membersplit_split_submit=1&step='.$step.'&splitnum='.$splitnum, 'loadingform', array('num' => $step*$splitnum));
}
} else if($operation == 'rebuildtable') {
$step = intval($_GET['step']);
$splitnum = max(10, intval($_GET['splitnum']));
$ret = C::t('common_member_archive')->rebuild_table($step);
if($ret === false) {
cpmsg('membersplit_split_check_table_done', 'action=membersplit&operation=manage&membersplit_split_submit=1&nocheck=1&splitnum='.$splitnum, 'loadingform');
} else if($ret === true) {
cpmsg('membersplit_split_checking_table', 'action=membersplit&operation=rebuildtable&splitnum='.$splitnum.'&step='.($step+1), 'loadingform', array('step' => $step+1));
} else {
cpmsg('membersplit_split_check_table_fail', 'action=membersplit&operation=manage&splitnum='.$splitnum, 'error', array('tablename' => $ret));
}
}
?>