コード例 #1
0
ファイル: zip.php プロジェクト: ASDAFF/entask.ru
 private function _processFiles($arFileList, $addPath, $removePath)
 {
     $addPath = str_replace("\\", "/", $addPath);
     $removePath = str_replace("\\", "/", $removePath);
     if (!$this->zipfile) {
         $this->arErrors[] = array("ERR_DFILE", GetMessage("MAIN_ZIP_ERR_DFILE"));
         return false;
     }
     if (!is_array($arFileList) || count($arFileList) <= 0) {
         return true;
     }
     $j = -1;
     if (!isset($this->tempres)) {
         $this->tempres = "started";
     }
     //files and directory scan
     while ($j++ < count($arFileList) && $this->tempres === "started") {
         $filename = $arFileList[$j];
         if (strlen($filename) <= 0) {
             continue;
         }
         if (!file_exists($filename)) {
             $this->arErrors[] = array("ERR_NO_FILE", str_replace("#FILE_NAME#", $filename, GetMessage("MAIN_ZIP_ERR_NO_FILE")));
             continue;
         }
         //is file
         if (!@is_dir($filename)) {
             $filename = str_replace("//", "/", $filename);
             //jumping to startFile, if it's specified
             if (strlen($this->startFile) != 0) {
                 if ($filename != $this->startFile) {
                     //don't pack - jump to the next file
                     continue;
                 } else {
                     //if startFile is found, continue to pack files and folders without startFile, starting from next
                     unset($this->startFile);
                     continue;
                 }
             }
             //check product permissions
             if ($this->checkBXPermissions) {
                 if (!CBXArchive::HasAccess($filename, true)) {
                     continue;
                 }
             }
             if ($this->_haveTime()) {
                 if (!$this->_addFile($filename, $arFileHeaders, $this->add_path, $this->remove_path, array(), $arP)) {
                     //$arErrors is filled in the _addFile method
                     $this->tempres = false;
                 } else {
                     //remember last file
                     $this->arPackedFiles[] = $filename;
                     $this->arHeaders[] = $arFileHeaders;
                 }
             } else {
                 $this->tempres = 'continue';
                 return $this->tempres;
             }
         } else {
             if (!($handle = opendir($filename))) {
                 $this->arErrors[] = array("ERR_DIR_OPEN_FAIL", str_replace("#DIR_NAME#", $filename, GetMessage("MAIN_ZIP_ERR_DIR_OPEN_FAIL")));
                 continue;
             }
             if ($this->checkBXPermissions) {
                 if (!CBXArchive::HasAccess($filename, false)) {
                     continue;
                 }
             }
             while (false !== ($dir = readdir($handle))) {
                 if ($dir != "." && $dir != "..") {
                     $arFileList_tmp = array();
                     if ($filename != ".") {
                         $arFileList_tmp[] = $filename . '/' . $dir;
                     } else {
                         $arFileList_tmp[] = $dir;
                     }
                     $this->_processFiles($arFileList_tmp, $addPath, $removePath);
                 }
             }
             unset($arFileList_tmp);
             unset($dir);
             unset($handle);
         }
     }
     return $this->tempres;
 }