private function processingUpdateFile($upgradeInfo, $updateFileList, $upgradeStep, $urlParam) { if (EnvUtil::getRequest("coverStart")) { $data["step"] = 4; $confirm = EnvUtil::getRequest("confirm"); $startUpgrade = EnvUtil::getRequest("startupgrade"); if (!$confirm) { if (EnvUtil::getRequest("ftpsetting")) { $param = array("step" => 4, "confirm" => "ftp"); if ($startUpgrade) { $param["startupgrade"] = 1; } $data["data"]["status"] = "ftpsetup"; $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge($param, $urlParam)); $this->ajaxReturn($data, "json"); } if ($upgradeInfo["isupdatedb"]) { $fileList = array("data/update.php"); $checkUpdateFileList = array_merge($fileList, $updateFileList); } else { $checkUpdateFileList = $updateFileList; } if (FileUtil::checkFolderPerm($checkUpdateFileList)) { $confirm = "file"; } else { $data["data"]["status"] = "no_access"; $data["data"]["msg"] = Ibos::lang("Upgrade cannot access file"); $data["data"]["retryUrl"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4), $urlParam)); $data["data"]["ftpUrl"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4, "ftpsetting" => 1), $urlParam)); $this->ajaxReturn($data, "json"); } } $ftpParam = array(); $ftpSetup = EnvUtil::getRequest("ftpsetup"); if ($ftpSetup) { foreach ($ftpSetup as $key => $value) { $ftpParam["ftp[{$key}]"] = $value; } } if (!$startUpgrade) { if (!EnvUtil::getRequest("backfile")) { $param = array("step" => 4, "backfile" => 1, "confirm" => $confirm); $data["data"]["status"] = "upgrade_backuping"; $data["data"]["msg"] = Ibos::lang("Upgrade backuping"); $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge($ftpParam, $param, $urlParam)); $this->ajaxReturn($data, "json"); } foreach ($updateFileList as $updateFile) { $destFile = PATH_ROOT . "/" . $updateFile; $backFile = PATH_ROOT . "/data/back/IBOS" . VERSION . " Release[" . VERSION_DATE . "]/" . $updateFile; if (is_file($destFile)) { if (!UpgradeUtil::copyFile($destFile, $backFile, "file")) { $data["data"]["status"] = "upgrade_backup_error"; $data["data"]["msg"] = Ibos::lang("Upgrade backup error"); $this->ajaxReturn($data, "json"); } } } $data["data"]["status"] = "upgrade_backup_complete"; $data["data"]["msg"] = Ibos::lang("Upgrade backup complete"); $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge(array("step" => 4, "startupgrade" => 1, "confirm" => $confirm), $ftpParam, $urlParam)); $this->ajaxReturn($data, "json"); } $param = array("step" => 4, "startupgrade" => 1); $url = $this->createUrl("upgrade/index", array_merge($param, $urlParam, $ftpParam, array("confirm" => $confirm))); $ftpUrl = $this->createUrl("upgrade/index", array_merge($param, $urlParam, array("ftpsetting" => 1))); foreach ($updateFileList as $updateFile) { $srcFile = PATH_ROOT . "/data/update/IBOS" . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/" . $updateFile; if ($confirm == "ftp") { $destFile = $updateFile; } else { $destFile = PATH_ROOT . "/" . $updateFile; } if (!UpgradeUtil::copyFile($srcFile, $destFile, $confirm)) { Cache::model()->deleteByPk("upgrade_step"); Cache::model()->deleteByPk("upgrade_run"); $data["data"]["ftpUrl"] = $ftpUrl; $data["data"]["retryUrl"] = $url; if ($confirm == "ftp") { $data["data"]["status"] = "upgrade_ftp_upload_error"; $data["data"]["msg"] = Ibos::lang("Upgrade ftp upload error", "", array("{file}" => $updateFile)); } else { $data["data"]["status"] = "upgrade_copy_error"; $data["data"]["msg"] = Ibos::lang("Upgrade copy error", "", array("{file}" => $updateFile)); } $this->ajaxReturn($data, "json"); } } if ($upgradeInfo["isupdatedb"]) { $dbUpdateFileArr = array("update.php"); foreach ($dbUpdateFileArr as $dbUpdateFile) { $srcFile = PATH_ROOT . "/data/update/IBOS" . $urlParam["version"] . " Release[" . $urlParam["release"] . "]/" . $dbUpdateFile; $dbUpdateFile = $dbUpdateFile == "update.php" ? "data/update.php" : $dbUpdateFile; if ($confirm == "ftp") { $destFile = $dbUpdateFile; } else { $destFile = PATH_ROOT . "/" . $dbUpdateFile; } if (!UpgradeUtil::copyFile($srcFile, $destFile, $confirm)) { $data["data"]["ftpUrl"] = $ftpUrl; $data["data"]["retryUrl"] = $url; if ($confirm == "ftp") { $data["data"]["status"] = "upgrade_ftp_upload_error"; $data["data"]["msg"] = Ibos::lang("Upgrade ftp upload error", "", array("{file}" => $dbUpdateFile)); } else { $data["data"]["status"] = "upgrade_copy_error"; $data["data"]["msg"] = Ibos::lang("Upgrade copy error", "", array("{file}" => $dbUpdateFile)); } $this->ajaxReturn($data, "json"); } } $upgradeStep["step"] = 4; Cache::model()->add(array("cachekey" => "upgrade_step", "cachevalue" => serialize($upgradeStep), "dateline" => TIMESTAMP), false, true); $dbReturnUrl = $this->createUrl("upgrade/index", array_merge(array("step" => 5), $urlParam)); $param = array("step" => "prepare", "from" => rawurlencode($dbReturnUrl), "frommd5" => md5(rawurlencode($dbReturnUrl) . Ibos::app()->setting->get("config/security/authkey"))); $data["data"]["status"] = "upgrade_database"; $data["data"]["url"] = "data/update.php?" . http_build_query($param); $data["data"]["msg"] = Ibos::lang("Upgrade file successful"); $this->ajaxReturn($data, "json"); } $data["data"]["status"] = "upgrade_file_successful"; $data["data"]["url"] = $this->createUrl("upgrade/index", array_merge(array("step" => 5), $urlParam)); $data["step"] = 5; $this->ajaxReturn($data, "json"); } else { UpgradeUtil::recordStep(4); $coverUrl = $this->createUrl("upgrade/index", array_merge(array("step" => 4), $urlParam)); $this->render("upgradeCover", array("coverUrl" => $coverUrl)); } }