示例#1
0
 /**
  * Extend the bootstrap code to add some define's used by the JPS format engine
  * @see backend/akeeba/abstract/AEAbstractArchiver#__bootstrap_code()
  */
 protected function __bootstrap_code()
 {
     if (!defined('_JPS_MAJOR')) {
         define('_JPS_MAJOR', 1);
         // JPS Format major version number
         define('_JPS_MINOR', 9);
         // JPS Format minor version number
     }
     parent::__bootstrap_code();
 }
示例#2
0
	public function  __bootstrap_code() {
		parent::__bootstrap_code();

		// So that the first run doesn't crash!
		if(empty($this->_dataFileName)) return;

		// Try to reopen the ZIP
		$this->zip = new ZipArchive;
		if(!file_exists($this->_dataFileName)) {
			$res = $this->zip->open($this->_dataFileName, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE);
		} else {
			$res = $this->zip->open($this->_dataFileName);
		}

		if($res !== TRUE) {
			switch($res) {
				case ZipArchive::ER_EXISTS:
					$this->setError("The archive {$this->_dataFileName} already exists");
					break;
				case ZipArchive::ER_INCONS:
					$this->setError("Inconsistent archive {$this->_dataFileName} detected");
					break;
				case ZipArchive::ER_INVAL:
					$this->setError("Invalid archive {$this->_dataFileName} detected");
					break;
				case ZipArchive::ER_MEMORY:
					$this->setError("Not enough memory to process archive {$this->_dataFileName}");
					break;
				case ZipArchive::ER_NOENT:
					$this->setError("Unexpected ZipArchive::ER_NOENT error processing archive {$this->_dataFileName}");
					break;
				case ZipArchive::ER_NOZIP:
					$this->setError("File {$this->_dataFileName} is not a ZIP archive!");
					break;
				case ZipArchive::ER_OPEN:
					$this->setError("Could not open archive file {$this->_dataFileName} for writing");
					break;
				case ZipArchive::ER_READ:
					$this->setError("Could not read from archive file {$this->_dataFileName}");
					break;
				case ZipArchive::ER_SEEK:
					$this->setError("Could not seek into position while processing archive file {$this->_dataFileName}");
					break;

			}

			return false;
		}
	}
示例#3
0
文件: jpa.php 项目: bizanto/Hooked
 /**
  * Extend the bootstrap code to add some define's used by the JPA format engine
  * @see backend/akeeba/abstract/AEAbstractArchiver#__bootstrap_code()
  */
 protected function __bootstrap_code()
 {
     if (!defined('_AKEEBA_COMPRESSION_THRESHOLD')) {
         $config =& AEFactory::getConfiguration();
         define("_AKEEBA_COMPRESSION_THRESHOLD", $config->get('engine.archiver.common.big_file_threshold'));
         // Don't compress files over this size
         /**
          * Akeeba Backup and JPA Format version change chart:
          * Akeeba Backup 3.0: JPA Format 1.1 is used
          * Akeeba Backup 3.1: JPA Format 1.2 with file modification timestamp is used
          */
         define('_JPA_MAJOR', 1);
         // JPA Format major version number
         define('_JPA_MINOR', 2);
         // JPA Format minor version number
     }
     parent::__bootstrap_code();
 }
示例#4
0
文件: zip.php 项目: 01J/topm
 /**
  * Class constructor - initializes internal operating parameters
  */
 public function __construct()
 {
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AEArchiverZip :: New instance");
     // Get chunk override
     $registry = AEFactory::getConfiguration();
     if ($registry->get('engine.archiver.common.chunk_size', 0) > 0) {
         $this->AkeebaPackerZIP_CHUNK_SIZE = AKEEBA_CHUNK;
     } else {
         // Try to use as much memory as it's possible for CRC32 calculation
         $memLimit = ini_get("memory_limit");
         if (strstr($memLimit, 'M')) {
             $memLimit = (int) $memLimit * 1048576;
         } elseif (strstr($memLimit, 'K')) {
             $memLimit = (int) $memLimit * 1024;
         } elseif (strstr($memLimit, 'G')) {
             $memLimit = (int) $memLimit * 1073741824;
         } else {
             $memLimit = (int) $memLimit;
         }
         if (is_numeric($memLimit) && $memLimit < 0) {
             $memLimit = "";
         }
         // 1.2a3 -- Rare case with memory_limit < 0, e.g. -1Mb!
         if ($memLimit == "") {
             // No memory limit, use 2Mb chunks (fairly large, right?)
             $this->AkeebaPackerZIP_CHUNK_SIZE = 2097152;
         } elseif (function_exists("memory_get_usage")) {
             // PHP can report memory usage, see if there's enough available memory; Joomla! alone eats about 5-6Mb! This code is called on files <= 1Mb
             $memLimit = $this->_return_bytes($memLimit);
             $availableRAM = $memLimit - memory_get_usage();
             if ($availableRAM <= 0) {
                 // Some PHP implemenations also return the size of the httpd footprint!
                 if ($memLimit - 6291456 > 0) {
                     $this->AkeebaPackerZIP_CHUNK_SIZE = $memLimit - 6291456;
                 } else {
                     $this->AkeebaPackerZIP_CHUNK_SIZE = 2097152;
                 }
             } else {
                 $this->AkeebaPackerZIP_CHUNK_SIZE = $availableRAM * 0.5;
             }
         } else {
             // PHP can't report memory usage, use a conservative 512Kb
             $this->AkeebaPackerZIP_CHUNK_SIZE = 524288;
         }
     }
     // NEW 2.3: Should we enable Split ZIP feature?
     $fragmentsize = $registry->get('engine.archiver.common.part_size', 0);
     if ($fragmentsize >= 65536) {
         // If the fragment size is AT LEAST 64Kb, enable Split ZIP
         $this->_useSplitZIP = true;
         $this->_fragmentSize = $fragmentsize;
         // Indicate that we have at least 1 part
         $statistics = AEFactory::getStatistics();
         $statistics->updateMultipart(1);
     }
     // NEW 2.3: Should I use Symlink Target Storage?
     $dereferencesymlinks = $registry->get('engine.archiver.common.dereference_symlinks', true);
     if (!$dereferencesymlinks) {
         // We are told not to dereference symlinks. Are we on Windows?
         if (function_exists('php_uname')) {
             $isWindows = stristr(php_uname(), 'windows');
         } else {
             $isWindows = DIRECTORY_SEPARATOR == '\\';
         }
         // If we are not on Windows, enable symlink target storage
         $this->_symlink_store_target = !$isWindows;
     }
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "Chunk size for CRC is now " . $this->AkeebaPackerZIP_CHUNK_SIZE . " bytes");
     parent::__construct();
 }