cloud_doctor.php
10.1 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<?php
/**
* [Discuz!] (C)2001-2099 Comsenz Inc.
* This is NOT a freeware, use is subject to license terms
*
* $Id: cloud_doctor.php 33991 2013-09-16 07:25:00Z nemohou $
*/
if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
exit('Access Denied');
}
@set_time_limit(0);
$op = trim($_GET['op']);
if(submitcheck('setidkeysubmit')) {
if (!isfounder()) {
cpmsg('action_noaccess', '', 'error');
}
$siteId = intval(trim($_GET['my_siteid']));
if($siteId && strcmp($_GET['my_siteid'], $siteId) !== 0) {
cpmsg('cloud_idkeysetting_siteid_failure', '', 'error');
}
$_GET['my_sitekey'] = trim($_GET['my_sitekey']);
if(empty($_GET['my_sitekey'])) {
$siteKey = '';
} elseif(strpos($_GET['my_sitekey'], '***')) {
$siteKey = false;
} elseif(preg_match('/^[0-9a-f]{32}$/', $_GET['my_sitekey'])) {
$siteKey = $_GET['my_sitekey'];
} else {
cpmsg('cloud_idkeysetting_sitekey_failure', '', 'error');
}
$settings = array();
if($siteKey !== false) {
$settings['my_sitekey'] = $siteKey;
}
if($_G['setting']['my_siteid'] != $siteId) {
$settings['my_siteid'] = $siteId;
}
if($_G['setting']['cloud_status'] != $_GET['cloud_status']) {
$settings['cloud_status'] = intval(trim($_GET['cloud_status']));;
}
if($settings) {
C::t('common_setting')->update_batch($settings);
updatecache('setting');
}
$locationUrl = ADMINSCRIPT.'?frames=yes&action=cloud&operation=doctor';
cpmsg('cloud_idkeysetting_success', '', 'succeed', array(), '<p class="marginbot"><a href="###" onclick="top.location = \''.$locationUrl.'\'" class="lightlink">'.cplang('message_redirect').'</a></p><script type="text/JavaScript">setTimeout("top.location = \''.$locationUrl.'\'", 3000);</script>');
} elseif($op == 'apitest') {
$doctorService =Cloud::loadClass('Service_Doctor');
$APIType = intval($_GET['api_type']);
$APIIP = trim($_GET['api_ip']);
$startTime = microtime(true);
$testStatus = $doctorService->testAPI($APIType, $APIIP, $_G['setting']);
$endTime = microtime(true);
$otherTips = '';
if($APIIP) {
if ($_GET['api_description']) {
$otherTips = diconv(trim($_GET['api_description']), 'UTF-8');
}
} else {
if($APIType == 1) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_api_test\')">'.$lang['cloud_doctor_api_test_other'].'</a>';
} elseif($APIType == 2) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_manyou_test\')">'.$lang['cloud_doctor_manyou_test_other'].'</a>';
} elseif($APIType == 3) {
$otherTips = '<a href="javascript:;" onClick="display(\'cloud_tbody_qzone_test\')">'.$lang['cloud_doctor_qzone_test_other'].'</a>';
}
}
ajaxshowheader();
if($testStatus) {
printf($lang['cloud_doctor_api_test_success'], $lang['cloud_doctor_result_success'], $APIIP, $endTime - $startTime, $otherTips);
} else {
printf($lang['cloud_doctor_api_test_failure'], $lang['cloud_doctor_result_failure'], $APIIP, $otherTips);
}
ajaxshowfooter();
} elseif($op == 'setidkey') {
ajaxshowheader();
echo '
<h3 class="flb" id="fctrl_showblock" style="cursor: move;">
<em id="return_showblock" fwin="showblock">'.$lang['cloud_doctor_setidkey'].'</em>
<span><a title="'.$lang['close'].'" onclick="hideWindow(\'cloudApiIpWin\');return false;" class="flbc" href="javascript:;">'.$lang['close'].'</a></span>
</h3>
';
echo '<div style="margin: 0 10px; width: 700px;">';
showtips('cloud_doctor_setidkey_tips');
showformheader('cloud');
showhiddenfields(array('operation' => $operation));
showhiddenfields(array('op' => $op));
showtableheader();
showsetting('cloud_site_id', 'my_siteid', $_G['setting']['my_siteid'], 'text');
showsetting('cloud_site_key', 'my_sitekey', preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['my_sitekey']), 'text');
showsetting('cloud_site_status', array('cloud_status', array(array('0', $lang['cloud_doctor_status_0']), array('1', $lang['cloud_doctor_status_1']), array('2', $lang['cloud_doctor_status_2']))), $_G['setting']['cloud_status'], 'select');
showsubmit('setidkeysubmit');
showtablefooter();
showformfooter();
echo '</div>';
ajaxshowfooter();
} else {
$appService = Cloud::loadClass('Service_App');
$doctorService = Cloud::loadClass('Service_Doctor');
require_once DISCUZ_ROOT.'./source/discuz_version.php';
shownav('tools', 'menu_cloud_doctor');
showsubmenu('menu_cloud_doctor');
showtips('cloud_doctor_tips');
echo '<script type="text/javascript">var disallowfloat = "";</script>';
showtableheader();
showformheader('cloud');
showhiddenfields(array('operation' => 'siteinfo'));
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_status');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_url').'</strong>',
$_G['siteurl'].
(isfounder() ? ' <input type="submit" class="btn" id="submit_syncsubmit" name="syncsubmit" value="'.$lang['cloud_sync'].'" /> ' : '')
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_id').'</strong>',
$_G['setting']['my_siteid']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_key').'</strong>',
preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['my_sitekey']).' '.$lang['cloud_site_key_safetips']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_status').'</strong>',
(isfounder() ? $doctorService->showCloudStatus($_G['setting']['cloud_status']).' <a href="javascript:;" onClick="showWindow(\'cloudApiIpWin\', \''.ADMINSCRIPT.'?action=cloud&operation=doctor&op=setidkey\'); return false;">'.$lang['cloud_doctor_modify_siteidkey'].'</a>' : $doctorService->showCloudStatus($_G['setting']['cloud_status'])).
(isfounder() ? ' <input type="submit" class="btn" id="submit_resetsubmit" name="resetsubmit" value="'.$lang['cloud_resetkey'].'" />' : '')
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('setting_basic_bbclosed').'</strong>',
$_G['setting']['bbclosed'] ? $lang['cloud_doctor_close_yes'] : $lang['no']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_site_version').'</strong>',
DISCUZ_VERSION.' '.DISCUZ_RELEASE
));
if(isfounder()) {
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_change_info').'</strong>',
'<a href="'.$doctorService->changeQQUrl().'" target="_blank">'.cplang('cloud_change_qq').'</a>',
));
}
showtagfooter('tbody');
showformfooter();
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_result');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_timecheck').'</strong>',
'<span id="cloud_time_check">' . cplang('cloud_doctor_time_check', array('imgdir' => $_G['style']['imgdir'])) .'</span>',
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_gethostbyname_function').'</strong>',
function_exists('gethostbyname') ? $lang['cloud_doctor_result_success'].' '.$lang['available'] : $lang['cloud_doctor_result_failure'].$lang['cloud_doctor_function_disable']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_api').'</strong>',
$doctorService->checkDNSResult(1, $_G['setting'])
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_api_test').'</strong>',
$doctorService->showTestJS(1)
));
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_api_test', false);
showtagfooter('tbody');
showtagheader('tbody', '', true);
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_manyou').'</strong>',
$doctorService->checkDNSResult(2, $_G['setting'])
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_manyou_test').'</strong>',
$doctorService->showTestJS(2)
));
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_manyou_test', false);
showtagfooter('tbody');
showtagheader('tbody', '', true);
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_qzone').'</strong>',
$doctorService->checkDNSResult(3, $_G['setting'])
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_dns_qzone_test').'</strong>',
$doctorService->showTestJS(3)
));
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_qzone_test', false);
showtagfooter('tbody');
showtagheader('tbody', 'cloud_tbody_site_test', true);
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_site_test').'</strong>',
cplang('cloud_doctor_site_test_result', array('imgdir' => $_G['style']['imgdir']))
));
showtagfooter('tbody');
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_plugin');
$doctorService->showPlugins();
showtagfooter('tbody');
if($appService->getCloudAppStatus('connect')) {
if ($op == 'fixGuest') {
$doctorService->fixGuestGroup(cplang('connect_guest_group_name'));
}
showtagheader('tbody', '', true);
showtitle('cloud_doctor_title_connect');
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_app_id').'</strong>',
!empty($_G['setting']['connectappid']) ? $_G['setting']['connectappid'] : $lang['cloud_doctor_connect_reopen']
));
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_app_key').'</strong>',
!empty($_G['setting']['connectappkey']) ? preg_replace('/(\w{2})\w*(\w{2})/', '\\1****\\2', $_G['setting']['connectappkey']).' '.$lang['cloud_site_key_safetips'] : $lang['cloud_doctor_connect_reopen']
));
$guestGroupStr = cplang('cloud_doctor_result_success') .' '. cplang('cloud_doctor_normal');
if (!$doctorService->checkGuestGroup()) {
$guestGroupStr = cplang('cloud_doctor_result_failure') . ' ' . cplang('cloud_doctor_connect_fix');
}
showtablerow('', array('class="td24"'), array(
'<strong>'.cplang('cloud_doctor_connect_guestgroup').'</strong>',
$guestGroupStr,
));
showtagfooter('tbody');
}
showtablefooter();
$doctorService->showCloudDoctorJS();
}