function _cloud_build_params() { global $_W, $_GPC; $pars = array(); $pars['host'] = $_SERVER['HTTP_HOST']; $pars['family'] = IMS_FAMILY; $pars['version'] = IMS_VERSION; $pars['release'] = IMS_RELEASE_DATE; $pars['key'] = $_W['setting']['site']['key']; $pars['password'] = md5($_W['setting']['site']['key'] . $_W['setting']['site']['token']); $auth = array(); $auth['username'] = $_GPC['username']; $auth['password'] = $_GPC['password']; $pars['auth'] = base64_encode(json_encode($auth)); $clients = cloud_client_define(); $string = ''; foreach ($clients as $cli) { $string .= md5_file(IA_ROOT . $cli); } $pars['client'] = md5($string); return $pars; }
function cloud_build() { $pars = _cloud_build_params(); $pars['method'] = 'application.build'; $pars['extra'] = cloud_extra_data(); $dat = cloud_request('http://v2.addons.we7.cc/gateway.php', $pars); $file = IA_ROOT . '/data/application.build'; $ret = _cloud_shipping_parse($dat, $file); if (!is_error($ret)) { if ($ret['state'] == 'warning') { $ret['files'] = cloud_client_define(); unset($ret['schemas']); unset($ret['scripts']); } else { $files = array(); if (!empty($ret['files'])) { foreach ($ret['files'] as $file) { $entry = IA_ROOT . $file['path']; if (!is_file($entry) || md5_file($entry) != $file['checksum']) { $files[] = $file['path']; } } } $ret['files'] = $files; $schemas = array(); if (!empty($ret['schemas'])) { load()->func('db'); foreach ($ret['schemas'] as $remote) { $name = substr($remote['tablename'], 4); $local = db_table_schema(pdo(), $name); unset($remote['increment']); unset($local['increment']); if (empty($local)) { $schemas[] = $remote; } else { $sqls = db_table_fix_sql($local, $remote); if (!empty($sqls)) { $schemas[] = $remote; } } } } $ret['schemas'] = $schemas; } if ($ret['family'] == 'x' && IMS_FAMILY == 'v') { load()->model('setting'); setting_upgrade_version('x', IMS_VERSION, IMS_RELEASE_DATE); message('您已经购买了商业授权版本, 系统将转换为商业版, 并重新运行自动更新程序.', 'refresh'); } $ret['upgrade'] = false; if (!empty($ret['files']) || !empty($ret['schemas']) || !empty($ret['scripts'])) { $ret['upgrade'] = true; } $upgrade = array(); $upgrade['upgrade'] = $ret['upgrade']; $upgrade['lastupdate'] = TIMESTAMP; cache_write('upgrade', $upgrade); } return $ret; }
if ($upgrade['upgrade']) { message("检测到新版本: <strong>{$upgrade['version']} (Release {$upgrade['release']})</strong>, 请立即更新.", 'refresh'); } else { message('检查结果: 恭喜, 你的程序已经是最新版本. ', 'refresh'); } exit; } cache_load('upgrade'); if (!empty($_W['cache']['upgrade'])) { $upgrade = iunserializer($_W['cache']['upgrade']); } if (empty($upgrade) || TIMESTAMP - $upgrade['lastupdate'] >= 3600 * 24 || $upgrade['upgrade']) { $upgrade = cloud_upgrade(); } if (is_array($upgrade['attachments']) && $upgrade['attachments'][0] == 'error-client') { $clients = cloud_client_define(); $upgrade['attachments'] = $clients; } if (!empty($upgrade) && !empty($upgrade['upgrade'])) { $offlineok = false; if (is_array($upgrade['attachments'])) { $upfile = IA_ROOT . '/data/upgrade.zip'; if (is_file($upfile)) { $ret = cloud_upgrade_verify($upgrade['attachments']); if (is_array($ret) && !empty($ret['announcement'])) { $sign = md5(md5_file($upfile) . $_W['setting']['site']['token']); if ($ret['announcement'] == $sign) { $offlineok = true; } } }