cachelist = $cachelist; $discuz->init_cron = false; $discuz->init_setting = true; $discuz->init_user = false; $discuz->init_session = false; $discuz->init(); if ($_POST) { $fromCloud = $_POST['fromCloud']; if ($fromCloud) { if (is_file(DISCUZ_ROOT . './data/discuzx_utility.lock')) { echo "LOCK"; } else { echo "OK"; } exit; } $siteUrl = $_POST['siteUrl']; $action = $_POST['action']; if ($action == 'restore') { $my_siteid = $_POST['my_siteid']; $my_sitekey = $_POST['my_sitekeys'][$my_siteid]; $cloud_status = intval($_POST['cloud_status'][$my_siteid]); if (!$my_siteid || !$my_sitekey) { echo "无效的my_siteid或my_sitekey"; exit; } DB::query("REPLACE INTO " . DB::table('common_setting') . " (skey, svalue) VALUES ('my_siteid', '{$my_siteid}'), ('my_sitekey', '{$my_sitekey}'), ('cloud_status', $cloud_status)"); // C::t('common_setting')->update_batch(array('my_siteid' => $my_siteid, 'my_sitekey' =>$my_sitekey ,'cloud_status' => $cloud_status)); require_once libfile('function/cache'); updatecache('setting'); my_show_message("Discuz!云平台站点信息恢复成功 (请立即到管理后台云平台同步站点信息)"); } } else { if ($_GET['q'] == 'forgot') { $sites = my_site_restore(); my_forgot($sites); } else { my_index(); } } function my_header() { header("Content-Type: text/html; charset=utf-8"); echo << DISCUZ X站点注册工具 | 找回(恢复)站点信息、删除站点信息 \n EOT; } function my_footer() { global $_G; echo <<

注意事项

  • 请勿随意公开该文件地址
  • 使用完毕之后,请立即删除该文件

返回我的网站 | 支持论坛

\n EOT; } function my_index() { global $_G; $siteUrl = $_G['siteurl']; $my_siteid = $_G['setting']['my_siteid'] ? $_G['setting']['my_siteid'] : '无'; $my_sitekey = $_G['setting']['my_sitekey'] ? $_G['setting']['my_sitekey'] : '无'; $cloud_status = $_G['setting']['cloud_status'] ? ($_G['setting']['cloud_status'] ? '开启': '关闭') : '无';; $uri = my_get_uri(); my_header(); echo <<
当前站点地址:
$siteUrl
当前站点ID:
$my_siteid
当前站点Key:
$my_sitekey
当前云平台状态:
$cloud_status

如果您要恢复Discuz!云平台数据,请点这里继续

以上操作可能导致Discuz!云平台中当前站点服务无法使用、用户信息丢失!

EOT; my_footer(); } function my_forgot($sites) { global $_G; my_header(); my_title('恢复Discuz!云平台上的站点信息'); $siteUrl = $_G['siteurl']; $table = ""; foreach($sites as $site) { $sId = $site['sId']; $table .= ""; } $table .= "
站点ID 站点Key 站点uniqueid 创建时间 状态
{$site['sId']} {$site['sKey']} {$site['sSiteKey']} {$site['sCreated']} {$site['status']}
\n"; echo << $table

EOT; my_footer(); } function my_title($title = 'index') { echo "

$title

\n"; return true; } function my_site_restore() { if (class_exists('Cloud')) { // X2.5 修复 $cloudClient = Cloud::loadClass('Service_Client_Cloud'); try { $result = $cloudClient->resume(); } catch (Exception $e) { $msg = sprintf('操作失败:%s (#%s)', $e->getMessage(), $e->getCode()); my_show_message($msg); } } else { // X2 修复 require_once DISCUZ_ROOT.'/api/manyou/Manyou.php'; $cloudClient = new Discuz_Cloud_Client(); $result = $cloudClient->resume(); if(!$result || $cloudClient->errno) { $msg = sprintf('操作失败:%s (#%s)', $cloudClient->errmsg, $cloudClient->errno); my_show_message($msg); } } // lock file $fp = fopen(DISCUZ_ROOT . './data/discuzx_utility.lock', 'w'); if ($fp === false) { my_show_message(sprintf('请确保 %s/data/discuzx_utility.lock 文件可写!', DISCUZ_ROOT)); } fclose($fp); return $result; } function my_show_message($msg) { my_header(); printf('

%s

', $msg); my_footer(); exit; } function my_get_uri() { $uri = $_SERVER['REQUEST_URI']?$_SERVER['REQUEST_URI']:($_SERVER['PHP_SELF']?$_SERVER['PHP_SELF']:$_SERVER['SCRIPT_NAME']); return $uri; } ?>