/** * Common code which gets called on instance creation or wake-up (unserialization). Reloads the component's * parameters. * * @return void */ protected function __bootstrap_code() { if (is_null($this->generateDiff)) { \JLoader::import('joomla.html.parameter'); \JLoader::import('joomla.application.component.helper'); $db = \JFactory::getDbo(); $sql = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_admintools')); $db->setQuery($sql); $rawparams = $db->loadResult(); $params = new \JRegistry(); $params->loadString($rawparams, 'JSON'); $this->generateDiff = $params->get('scandiffs', false); $this->ignoreNonThreats = $params->get('scanignorenonthreats', false); $email = $params->get('scanemail', ''); \Akeeba\Engine\Factory::getConfiguration()->set('admintools.scanner.email', $email); } parent::__bootstrap_code(); }
/** * Extend the bootstrap code to add some define's used by the JPA format engine * * @codeCoverageIgnore * * @return void */ protected function __bootstrap_code() { if (!defined('_AKEEBA_COMPRESSION_THRESHOLD')) { $config = Factory::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(); }
/** * Class constructor - initializes internal operating parameters * * @return Zip */ public function __construct() { Factory::getLog()->log(LogLevel::DEBUG, __CLASS__ . " :: New instance"); // Get chunk override $registry = Factory::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; } // 1.2a3 -- Rare case with memory_limit < 0, e.g. -1Mb! if (is_numeric($memLimit) && $memLimit < 0) { $memLimit = ""; } 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; the containing application / CMS 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 = Factory::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; } Factory::getLog()->log(LogLevel::DEBUG, "Chunk size for CRC is now " . $this->AkeebaPackerZIP_CHUNK_SIZE . " bytes"); parent::__construct(); }