Example #1
0
 /**
  * Class constructor - initializes internal operating parameters
  */
 public function __construct()
 {
     AEUtilLogger::WriteLog(_AE_LOG_DEBUG, "AEArchiverZipnative :: New instance");
     if (!class_exists('ZipArchive')) {
         $this->setError('Your server does not support the ZipArchive extension. Please use a different Archiver Engine and retry backing up your site');
     }
     parent::__construct();
 }
Example #2
0
File: zip.php Project: 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();
 }