Exemplo n.º 1
0
 private function processingDownloadFile($upgradeInfo, $updateMd5FileList, $updateFileList, $urlParam)
 {
     if (EnvUtil::getRequest("downloadStart")) {
         $fileSeq = intval(EnvUtil::getRequest("fileseq"));
         $fileSeq = $fileSeq ? $fileSeq : 1;
         $position = intval(EnvUtil::getRequest("position"));
         $position = $position ? $position : 0;
         $offset = 100 * 1024;
         $data["step"] = 2;
         if (count($updateFileList) < $fileSeq) {
             if ($upgradeInfo["isupdatedb"]) {
                 UpgradeUtil::downloadFile($upgradeInfo, "update.php", "utils");
             }
             $data["data"] = array("IsSuccess" => true, "msg" => Ibos::lang("Upgrade download complete to compare"), "url" => $this->createUrl("upgrade/index", array_merge(array("step" => 3), $urlParam)));
             $data["step"] = 3;
             return $this->ajaxReturn($data, "json");
         } else {
             $curFile = $updateFileList[$fileSeq - 1];
             $curMd5File = $updateMd5FileList[$fileSeq - 1];
             $percent = sprintf("%2d", 100 * $fileSeq / count($updateFileList)) . "%";
             $downloadStatus = UpgradeUtil::downloadFile($upgradeInfo, $curFile, "upload", $curMd5File, $position, $offset);
             if ($downloadStatus == 1) {
                 $data["data"] = array("IsSuccess" => true, "msg" => Ibos::lang("Upgrade downloading file", "", array("{file}" => $curFile, "{percent}" => $percent)), "url" => $this->createUrl("upgrade/index", array_merge(array("step" => 2, "fileseq" => $fileSeq, "position" => $position + $offset), $urlParam)));
             } elseif ($downloadStatus == 2) {
                 $data["data"] = array("IsSuccess" => true, "msg" => Ibos::lang("Upgrade downloading file", "", array("{file}" => $curFile, "{percent}" => $percent)), "url" => $this->createUrl("upgrade/index", array_merge(array("step" => 2, "fileseq" => $fileSeq + 1), $urlParam)));
             } else {
                 $data["data"] = array("IsSuccess" => false, "msg" => Ibos::lang("Upgrade redownload", "", array("{file}" => $curFile)), "url" => $this->createUrl("upgrade/index", array_merge(array("step" => 2, "fileseq" => $fileSeq), $urlParam)));
             }
             return $this->ajaxReturn($data, "json");
         }
     } else {
         UpgradeUtil::recordStep(2);
         $downloadUrl = $this->createUrl("upgrade/index", array_merge(array("step" => 2), $urlParam));
         $this->render("upgradeDownload", array("downloadUrl" => $downloadUrl));
     }
 }