Ejemplo n.º 1
0
 /**
  * Get a list of all files in the compressed file, add the file info to the DB.
  *
  * @return bool
  */
 protected function _processCompressedFileList()
 {
     // Get a list of files inside the Compressed file.
     $files = $this->_archiveInfo->getArchiveFileList();
     if (!is_array($files) || count($files) === 0) {
         return false;
     }
     // Loop through the files.
     foreach ($files as $file) {
         if ($this->_releaseHasPassword === true) {
             break;
         }
         if (isset($file['name'])) {
             if (isset($file['error'])) {
                 $this->_debug("Error: {$file['error']} (in: {$file['source']})");
                 continue;
             }
             if ($file['pass'] == true) {
                 $this->_releaseHasPassword = true;
                 $this->_passwordStatus[] = Releases::PASSWD_RAR;
                 break;
             }
             if ($this->_innerFileBlacklist !== false && preg_match($this->_innerFileBlacklist, $file['name'])) {
                 $this->_releaseHasPassword = true;
                 $this->_passwordStatus[] = Releases::PASSWD_POTENTIAL;
                 break;
             }
             $fileName = [];
             if (preg_match('/[^\\/\\\\]*\\.[a-zA-Z0-9]*$/', $file['name'], $fileName)) {
                 $fileName = $fileName[0];
             } else {
                 $fileName = '';
             }
             if ($this->_extractUsingRarInfo === true) {
                 // Extract files from the rar.
                 if (isset($file['compressed']) && $file['compressed'] == 0) {
                     @file_put_contents($this->tmpPath . mt_rand(10, 999999) . '_' . $fileName, $this->_archiveInfo->getFileData($file['name'], $file['source']));
                 } else {
                     $this->_archiveInfo->extractFile($file['name'], $this->tmpPath . mt_rand(10, 999999) . '_' . $fileName);
                 }
             }
         }
         $this->_addFileInfo($file);
     }
     if ($this->_addedFileInfo > 0) {
         $this->sphinx->updateRelease($this->_release['id'], $this->pdo);
     }
     return $this->_totalFileInfo > 0 ? true : false;
 }
Ejemplo n.º 2
0
 /**
  * Work out if a rar is passworded
  */
 public function isRar($rarfile)
 {
     // returns 0 if not rar
     // returns 1 if encrypted rar
     // returns 2 if passworded rar
     // returns array of files in the rar if normal rar
     $filelist = array();
     $rar = new ArchiveInfo();
     if ($rar->open($rarfile)) {
         if (!empty($rar->isEncrypted)) {
             return 1;
         } else {
             $files = $rar->getArchiveFileList();
             foreach ($files as $file) {
                 if (isset($file['pass']) && isset($file["name"])) {
                     $filelist[] = $file['name'];
                     if ($file['pass'] == true) {
                         return 2;
                         // passworded
                     }
                 }
             }
             return $filelist;
             // normal rar
         }
     } else {
         return 0;
         // not a rar
     }
 }