checkCloudStatus();
} catch (Cloud_Service_AppException $e) {
if($operation == 'doctor' || $operation == 'siteinfo') {
} else {
cpmsg_error('cloud_status_error');
}
}
$forceOpen = !empty($_GET['force_open']) ? true : false;
if(!$operation || $operation == 'open') {
if($cloudstatus == 'cloud' && !$forceOpen) {
cpmsg('cloud_turnto_applist', '', 'succeed', array(), '
'.cplang('message_redirect').'
');
} else {
if ($_GET['getConfirmInfo']) {
ajaxshowheader();
ajaxshowfooter();
}
$step = max(1, intval($_GET['step']));
$type = $cloudstatus == 'upgrade' ? 'upgrade' : 'open';
if($step == 1) {
$utilService->generateUniqueId();
if($cloudstatus == 'upgrade' || ($cloudstatus == 'cloud' && $forceOpen)) {
shownav('navcloud', 'menu_cloud_upgrade');
$itemtitle = cplang('menu_cloud_upgrade');
} else {
shownav('navcloud', 'menu_cloud_open');
$itemtitle = cplang('menu_cloud_open');
}
echo '
'.$lang['cloud_page_loading'].'
';
showformheader('', 'onsubmit="return submitForm();"');
if($cloudstatus == 'upgrade' || ($cloudstatus == 'cloud' && $forceOpen)) {
echo '';
}
showtableheader('', '', 'id="mainArea" style="display:none;"');
echo '
|
' . cplang('read_protocal') . '
|
';
showsubmit('submit', 'cloud_will_open', '', ' '.cplang('cloud_waiting').'');
showtablefooter();
showformfooter();
echo '
';
showformheader('cloud&operation=open&step=2'.(($cloudstatus == 'cloud' && $forceOpen) ? '&force_open=1' : ''), '');
echo '
'.cplang('jump_to_cloud').'
';
showformfooter();
echo "
";
echo <<
EOT;
$introUrl = $cloudDomain.'/cloud/introduction';
if($cloudstatus == 'upgrade') {
$params = array('type' => 'upgrade');
if ($_G['setting']['my_app_status']) {
$params['apps']['manyou'] = array('status' => true);
}
if (isset($_G['setting']['my_search_status'])) {
$params['apps']['search'] = array('status' => !empty($_G['setting']['my_search_status']) ? true : false);
$oldSiteId = empty($_G['setting']['my_siteid_old'])?'':$_G['setting']['my_siteid_old'];
$oldSitekeySign = empty($_G['setting']['my_sitekey_sign_old'])?'':$_G['setting']['my_sitekey_sign_old'];
if($oldSiteId && $oldSiteId != $_G['setting']['my_siteid'] && $oldSitekeySign) {
$params['apps']['search']['oldSiteId'] = $oldSiteId;
$params['apps']['search']['searchSig'] = $oldSitekeySign;
}
}
if (isset($_G['setting']['connect'])) {
$params['apps']['connect'] = array('status' => !empty($_G['setting']['connect']['allow']) ? true : false);
$oldSiteId = empty($_G['setting']['connectsiteid'])?'':$_G['setting']['connectsiteid'];
$oldSitekey = empty($_G['setting']['connectsitekey'])?'':$_G['setting']['connectsitekey'];
if($oldSiteId && $oldSiteId != $_G['setting']['my_siteid'] && $oldSitekey) {
$params['apps']['connect']['oldSiteId'] = $oldSiteId;
$params['apps']['connect']['connectSig'] = substr(md5(substr(md5($oldSiteId.'|'.$oldSitekey), 0, 16)), 16, 16);
}
}
$params['ADTAG'] = 'CP.DISCUZ.INTRODUCTION';
$signUrl = $utilService->generateSiteSignUrl($params);
$introUrl .= '?'.$signUrl;
}
echo '';
$doctorService = Cloud::loadClass('Service_Doctor');
$doctorService->showCloudDoctorJS('open');
} elseif($step == 2) {
$statsUrl = $cloudDomain . '/cloud/stats/registerclick';
echo '';
try {
if($_G['setting']['my_siteid'] && $_G['setting']['my_sitekey']) {
if($_G['setting']['my_app_status']) {
$manyouClient = Cloud::loadClass('Service_Client_Manyou');
$manyouClient->sync();
}
$cloudClient->upgradeManyou(trim($_GET['cloud_api_ip']));
} else {
$cloudClient->registerCloud(trim($_GET['cloud_api_ip']));
}
} catch (Cloud_Service_Client_RestfulException $exception) {
switch ($exception->getCode()) {
case 1:
cpmsg('cloud_unknown_dns', '', 'error');
case 2:
$msgValues = array(
'errorMessage' => $exception->getMessage(),
'errorCode' => $exception->getCode()
);
cpmsg('cloud_network_busy', '', 'error', $msgValues);
default:
$msgValues = array();
$errorMessage = $exception->getMessage();
$checkUrl = preg_match('/.+?<\/a>/i', $errorMessage, $results);
if($checkUrl) {
foreach($results as $key => $result) {
$errorMessage = str_replace($result, '{replace_' . $key . '}', $errorMessage);
$msgValues = array('replace_' . $key => $result);
}
}
cpmsg($errorMessage, '', 'error', $msgValues);
}
}
$params['ADTAG'] = 'CP.CLOUD.BIND.INDEX';
$bindUrl = $cloudDomain . '/bind/index?' . $utilService->generateSiteSignUrl($params);
echo '';
}
}
} elseif($operation == 'applist') {
if($cloudstatus != 'cloud') {
cpmsg('cloud_open_first', '', 'succeed', array(), ''.cplang('message_redirect').'
');
}
$signParams = array('refer' => $_G['siteurl'], 'ADTAG' => 'CP.DISCUZ.APPLIST');
$signUrl = $utilService->generateSiteSignUrl($signParams);
$utilService->redirect($cloudDomain . '/cloud/appList/?' . $signUrl);
} elseif(in_array($operation, array('siteinfo', 'doctor'))) {
require libfile("cloud/$operation", 'admincp');
} elseif(in_array($operation, array('manyou', 'connect', 'security', 'stats', 'search', 'smilies', 'qqgroup', 'union', 'storage'))) {
if($cloudstatus != 'cloud') {
cpmsg('cloud_open_first', '', 'succeed', array(), ''.cplang('message_redirect').'
');
}
if($operation != 'security') {
$apps = $appService->getCloudApps();
if(empty($apps) || empty($apps[$operation]) || $apps[$operation]['status'] == 'close') {
cpmsg('cloud_application_close', 'action=plugins', 'error');
}
if($apps[$operation]['status'] == 'disable') {
cpmsg('cloud_application_disable', 'action=plugins', 'error');
}
}
require libfile("cloud/$operation", 'admincp');
} else {
exit('Access Denied');
}