public function after($fileList, $useFtp, $oldList) { if (Wekit::cache()->get('system_upgrade_replace')) { return true; } $relativePath_1 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH, Wind::getRealPath('SRC:wekit')); $relativePath_2 = PwSystemHelper::resolveRelativePath(PUBLIC_PATH . 'aCloud', Wind::getRealPath('SRC:wekit')); $strtr = $this->getMoveWay(); $move = array(); $entrance = array('index.php', 'read.php', 'install.php', 'windid.php', 'admin.php', 'alipay.php', 'pay99bill.php', 'paypal.php', 'tenpay.php'); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { foreach ($oldList as $v) { $v = trim($v, '/'); $v = str_replace('/', DIRECTORY_SEPARATOR, $v); $_v = ROOT_PATH . $v; $file = $v; foreach ($strtr as $search => $replace) { if (0 === strpos($_v, $search)) { $file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search))); $file = str_replace('//', '/', $file); break; } } $move[$file] = $_v; if (in_array(basename($_v), $entrance)) { $content = WindFile::read($_v); if (strpos($content, '../../src/wekit.php')) { $content = str_replace('../../src/wekit.php', $relativePath_2, $content); } else { $content = str_replace('../src/wekit.php', $relativePath_1, $content); } $tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3)); WindFile::write($tmp, $content); $move[$file] = $tmp; } } } else { foreach ($fileList as $f => $hash) { $_v = ROOT_PATH . $f; if (in_array(basename($_v), $entrance)) { $content = WindFile::read($_v); if (strpos($content, '../../src/wekit.php')) { $content = str_replace('../../src/wekit.php', $relativePath_2, $content); } else { $content = str_replace('../src/wekit.php', $relativePath_1, $content); } $tmp = tempnam($this->tmpPath, basename($_v) . WindUtility::generateRandStr(3)); WindFile::write($tmp, $content); $move[$f] = $tmp; } } } // MD5SUM $md5File = WindFile::read(CONF_PATH . 'md5sum'); $sourceMd5 = PwSystemHelper::resolveMd5($md5File); $data = ''; foreach ($sourceMd5 as $v => $md5) { $v = trim($v, '/'); $v = str_replace('/', DIRECTORY_SEPARATOR, $v); $_v = ROOT_PATH . $v; $file = $v; foreach ($strtr as $search => $replace) { if (0 === strpos($_v, $search)) { $file = str_replace(ROOT_PATH, '', $replace . substr($_v, strlen($search))); $file = str_replace('//', '/', $file); break; } } $data .= PwSystemHelper::md5content($md5, $file); } $tmp = tempnam($this->tmpPath, 'md5temp'); WindFile::write($tmp, $data); $move[str_replace(ROOT_PATH, '', CONF_PATH . 'md5sum')] = $tmp; // 入口文件 if ($useFtp) { try { $ftp = $useFtp['sftp'] ? new PwSftpSave($useFtp) : new PwFtpSave($useFtp); } catch (WindFtpException $e) { return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage()))); } } foreach ($move as $k => $v) { if ($useFtp) { try { $r = $ftp->upload($v, $k); if ($useFtp['sftp'] && !$r && ($e = $ftp->getError())) { return new PwError('APPCENTER:upgrade.upload.fail', array($v . var_export($e, true))); } } catch (WindFtpException $e) { return new PwError(array('APPCENTER:upgrade.ftp.fail', array($e->getMessage()))); } } else { copy($v, ROOT_PATH . $k); } } $useFtp && $ftp->close(); return true; }