Пример #1
0
 /**
  * Implements the abstract _prepare() method
  */
 protected final function _prepare()
 {
     parent::__construct();
     if (count($this->_parametersArray) > 0) {
         foreach ($this->_parametersArray as $key => $value) {
             switch ($key) {
                 case 'filename':
                     // Archive's absolute filename
                     $this->filename = $value;
                     break;
                 case 'restore_permissions':
                     // Should I restore permissions?
                     $this->flagRestorePermissions = $value;
                     break;
                 case 'post_proc':
                     // Should I use FTP?
                     $this->postProcEngine = AKFactory::getpostProc($value);
                     break;
                 case 'add_path':
                     // Path to prepend
                     $this->addPath = $value;
                     $this->addPath = str_replace('\\', '/', $this->addPath);
                     $this->addPath = rtrim($this->addPath, '/');
                     if (!empty($this->addPath)) {
                         $this->addPath .= '/';
                     }
                     break;
                 case 'rename_files':
                     // Which files to rename (hash array)
                     $this->renameFiles = $value;
                     break;
                 case 'rename_dirs':
                     // Which files to rename (hash array)
                     $this->renameDirs = $value;
                     break;
                 case 'skip_files':
                     // Which files to skip (indexed array)
                     $this->skipFiles = $value;
                     break;
             }
         }
     }
     $this->scanArchives();
     $this->readArchiveHeader();
     $errMessage = $this->getError();
     if (!empty($errMessage)) {
         $this->setState('error', $errMessage);
     } else {
         $this->runState = AK_STATE_NOFILE;
         $this->setState('prepared');
     }
 }
Пример #2
0
 /**
  * Implements the abstract _prepare() method
  */
 protected final function _prepare()
 {
     parent::__construct();
     if (count($this->_parametersArray) > 0) {
         foreach ($this->_parametersArray as $key => $value) {
             switch ($key) {
                 // Archive's absolute filename
                 case 'filename':
                     $this->filename = $value;
                     // Sanity check
                     if (!empty($value)) {
                         $value = strtolower($value);
                         if (strlen($value) > 6) {
                             if (substr($value, 0, 7) == 'http://' || substr($value, 0, 8) == 'https://' || substr($value, 0, 6) == 'ftp://' || substr($value, 0, 7) == 'ssh2://' || substr($value, 0, 6) == 'ssl://') {
                                 $this->setState('error', 'Invalid archive location');
                             }
                         }
                     }
                     break;
                     // Should I restore permissions?
                 // Should I restore permissions?
                 case 'restore_permissions':
                     $this->flagRestorePermissions = $value;
                     break;
                     // Should I use FTP?
                 // Should I use FTP?
                 case 'post_proc':
                     $this->postProcEngine = AKFactory::getpostProc($value);
                     break;
                     // Path to add in the beginning
                 // Path to add in the beginning
                 case 'add_path':
                     $this->addPath = $value;
                     $this->addPath = str_replace('\\', '/', $this->addPath);
                     $this->addPath = rtrim($this->addPath, '/');
                     if (!empty($this->addPath)) {
                         $this->addPath .= '/';
                     }
                     break;
                     // Which files to rename (hash array)
                 // Which files to rename (hash array)
                 case 'rename_files':
                     $this->renameFiles = $value;
                     break;
                     // Which files to rename (hash array)
                 // Which files to rename (hash array)
                 case 'rename_dirs':
                     $this->renameDirs = $value;
                     break;
                     // Which files to skip (indexed array)
                 // Which files to skip (indexed array)
                 case 'skip_files':
                     $this->skipFiles = $value;
                     break;
                     // Which directories to ignore when we can't write files in them (indexed array)
                 // Which directories to ignore when we can't write files in them (indexed array)
                 case 'ignoredirectories':
                     $this->ignoreDirectories = $value;
                     break;
             }
         }
     }
     $this->scanArchives();
     $this->readArchiveHeader();
     $errMessage = $this->getError();
     if (!empty($errMessage)) {
         $this->setState('error', $errMessage);
     } else {
         $this->runState = AK_STATE_NOFILE;
         $this->setState('prepared');
     }
 }