admincp_tools.php
4.8 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
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: admincp_tools.php 33301 2013-05-23 03:10:20Z andyzheng $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
cpheader();
if($operation == 'updatecache') {
$step = max(1, intval($_GET['step']));
shownav('tools', 'nav_updatecache');
showsubmenusteps('nav_updatecache', array(
array('nav_updatecache_confirm', $step == 1),
array('nav_updatecache_verify', $step == 2),
array('nav_updatecache_completed', $step == 3)
));
showtips('tools_updatecache_tips');
if($step == 1) {
cpmsg("<input type=\"checkbox\" name=\"type[]\" value=\"data\" id=\"datacache\" class=\"checkbox\" checked /><label for=\"datacache\">".$lang[tools_updatecache_data]."</label><input type=\"checkbox\" name=\"type[]\" value=\"tpl\" id=\"tplcache\" class=\"checkbox\" checked /><label for=\"tplcache\">".$lang[tools_updatecache_tpl]."</label><input type=\"checkbox\" name=\"type[]\" value=\"blockclass\" id=\"blockclasscache\" class=\"checkbox\" /><label for=\"blockclasscache\">".$lang[tools_updatecache_blockclass].'</label>', 'action=tools&operation=updatecache&step=2', 'form', '', FALSE);
} elseif($step == 2) {
$type = implode('_', (array)$_GET['type']);
cpmsg(cplang('tools_updatecache_waiting'), "action=tools&operation=updatecache&step=3&type=$type", 'loading', '', FALSE);
} elseif($step == 3) {
$type = explode('_', $_GET['type']);
if(in_array('data', $type)) {
updatecache();
require_once libfile('function/group');
$groupindex['randgroupdata'] = $randgroupdata = grouplist('lastupdate', array('ff.membernum', 'ff.icon'), 80);
$groupindex['topgrouplist'] = $topgrouplist = grouplist('activity', array('f.commoncredits', 'ff.membernum', 'ff.icon'), 10);
$groupindex['updateline'] = TIMESTAMP;
$groupdata = C::t('forum_forum')->fetch_group_counter();
$groupindex['todayposts'] = $groupdata['todayposts'];
$groupindex['groupnum'] = $groupdata['groupnum'];
savecache('groupindex', $groupindex);
C::t('forum_groupfield')->truncate();
savecache('forum_guide', '');
if($_G['setting']['grid']['showgrid']) {
savecache('grids', array());
}
}
if(in_array('tpl', $type) && $_G['config']['output']['tplrefresh']) {
cleartemplatecache();
}
if(in_array('blockclass', $type)) {
include_once libfile('function/block');
blockclass_cache();
}
cpmsg('update_cache_succeed', '', 'succeed', '', FALSE);
}
} elseif($operation == 'fileperms') {
$step = max(1, intval($_GET['step']));
shownav('tools', 'nav_fileperms');
showsubmenusteps('nav_fileperms', array(
array('nav_fileperms_confirm', $step == 1),
array('nav_fileperms_verify', $step == 2),
array('nav_fileperms_completed', $step == 3)
));
if($step == 1) {
cpmsg(cplang('fileperms_check_note'), 'action=tools&operation=fileperms&step=2', 'button', '', FALSE);
} elseif($step == 2) {
cpmsg(cplang('fileperms_check_waiting'), 'action=tools&operation=fileperms&step=3', 'loading', '', FALSE);
} elseif($step == 3) {
showtips('fileperms_tips');
$entryarray = array(
'data',
'data/attachment',
'data/attachment/album',
'data/attachment/category',
'data/attachment/common',
'data/attachment/forum',
'data/attachment/group',
'data/attachment/portal',
'data/attachment/profile',
'data/attachment/swfupload',
'data/attachment/temp',
'data/cache',
'data/log',
'data/template',
'data/threadcache',
'data/diy'
);
$result = '';
foreach($entryarray as $entry) {
$fullentry = DISCUZ_ROOT.'./'.$entry;
if(!is_dir($fullentry) && !file_exists($fullentry)) {
continue;
} else {
if(!dir_writeable($fullentry)) {
$result .= '<li class="error">'.(is_dir($fullentry) ? $lang['dir'] : $lang['file'])." ./$entry $lang[fileperms_unwritable]</li>";
}
}
}
$result = $result ? $result : '<li>'.$lang['fileperms_check_ok'].'</li>';
echo '<div class="colorbox"><ul class="fileperms">'.$result.'</ul></div>';
}
}
function jsinsertunit() {
?>
<script type="text/JavaScript">
function isUndefined(variable) {
return typeof variable == 'undefined' ? true : false;
}
function insertunit(text, obj) {
if(!obj) {
obj = 'jstemplate';
}
$(obj).focus();
if(!isUndefined($(obj).selectionStart)) {
var opn = $(obj).selectionStart + 0;
$(obj).value = $(obj).value.substr(0, $(obj).selectionStart) + text + $(obj).value.substr($(obj).selectionEnd);
} else if(document.selection && document.selection.createRange) {
var sel = document.selection.createRange();
sel.text = text.replace(/\r?\n/g, '\r\n');
sel.moveStart('character', -strlen(text));
} else {
$(obj).value += text;
}
}
</script>
<?php
}
?>