model('cloud');
load()->func('communication');
load()->func('db');
load()->model('system');
$cloud_ready = cloud_prepare();
if (is_error($cloud_ready)) {
message($cloud_ready['message'], url('cloud/diagnose'), 'error');
}
$dos = array('upgrade', 'get_upgrade_info', 'get_error_file_list');
$do = in_array($do, $dos) ? $do : 'upgrade';
if ($do == 'upgrade') {
if (empty($_W['setting']['cloudip']) || $_W['setting']['cloudip']['expire'] < TIMESTAMP) {
// $cloudip = gethostbyname('api-upgrade.w7.cc');
$cloudip = '127.0.0.1';
if (empty($cloudip) || !preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $cloudip)) {
itoast('云服务域名解析失败,请查看服务器DNS设置或是在“云服务诊断”中手动设置云服务IP', url('cloud/diagnose'), 'error');
}
setting_save(array('ip' => $cloudip, 'expire' => TIMESTAMP + 3600), 'cloudip');
}
$path = IA_ROOT . '/data/patch/' . date('Ymd') . '/';
if (is_dir($path)) {
if ($handle = opendir($path)) {
while (false !== ($patchpath = readdir($handle))) {
if ($patchpath != '.' && $patchpath != '..') {
if(is_dir($path.$patchpath)){
$patchs[] = $patchpath;
}
}
}
}
if (!empty($patchs)) {
sort($patchs, SORT_NUMERIC);
}
}
$scrap_file = system_scrap_file();
$have_no_permission_file = array();
foreach ($scrap_file as $key => $file) {
if (!file_exists(IA_ROOT . $file)) {
continue;
}
$result = @unlink(IA_ROOT . $file);
if (!$result) {
$have_no_permission_file[] = $file;
}
}
if ($have_no_permission_file) {
itoast(implode('
', $have_no_permission_file) . '
以上废弃文件删除失败,可尝试将文件权限设置为777,再行删除!', referer(), 'error');
}
}
if ($do == 'get_error_file_list') {
$error_file_list = array();
cloud_file_permission_pass($error_file_list);
iajax(0, !empty($error_file_list) ? $error_file_list : '');
}
if ($do == 'get_upgrade_info') {
$notice_str = '