예제 #1
0
 /**
  * Find where to store the backup files
  */
 function _getBackupFilePaths()
 {
     $configuration = JoomlapackConfiguration::getInstance();
     if ($this->_DBOnly) {
         // On DB Only backups we use different naming, no matter what's the setting
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Only dump database mode detected");
         $this->_tempFile = JoomlapackAbstraction::getExpandedTarName('.sql');
         $this->_saveAsName = '';
     } else {
         if ($this->_dumpFile != '') {
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Forced filename using dumpFile found.");
             // If the dumpFile was set, forcibly use this value
             $this->_tempFile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $this->_dumpFile)));
             $this->_saveAsName = 'installation/sql/' . $this->_dumpFile;
         } else {
             if ($this->_isJoomla) {
                 // Joomla! Core Database, use the JoomlaPack way of figuring out the filenames
                 JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: Core database");
                 $this->_tempFile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $configuration->AltInstaller->BaseDump)));
                 $this->_saveAsName = 'installation/sql/' . $configuration->AltInstaller->BaseDump;
             } else {
                 // External databases, we use the database's name
                 JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: External database");
                 $this->_tempFile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql')));
                 $this->_saveAsName = 'installation/sql/' . $this->_database . '.sql';
             }
         }
     }
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDomainDBBackup :: SQL temp file is " . $this->_tempFile);
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDomainDBBackup :: SQL file location in archive is " . $this->_saveAsName);
 }
예제 #2
0
 /**
  * Creates a new instance of the CUBE object and empties the temporary
  * database tables
  *
  * @param boolean $OnlyDBMode Should we backup only the database contents?
  * @return JoomlapackCUBE
  */
 function JoomlapackCUBE($OnlyDBMode = false)
 {
     $configuration =& JoomlapackConfiguration::getInstance();
     $this->_OnlyDBMode = $OnlyDBMode;
     // Remove old entries from 'packvars' table
     JoomlapackTables::DeleteMultipleVars('%CUBE%');
     // Initialize internal variables
     $this->_currentDomain = "init";
     // Current domain of operation
     $this->_currentObject = null;
     // Nullify current object
     $this->_isFinished = false;
     //$this->_Error = false;
     // Load the filters manager
     $this->FilterManager = new JoomlapackFilterManager();
     // Create a lock time stamp
     JoomlapackTables::WriteVar('CUBELock', time());
     // Get JoomlaPack version data
     JoomlapackAbstraction::getJoomlaPackVersion();
     JoomlapackLogger::ResetLog();
     JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------");
     JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack " . _JP_VERSION . ' (' . _JP_DATE . ')');
     JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Your one for all backup solution");
     JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------");
     // PHP configuration variables are tried to be logged only for debug log levels
     if ($configuration->logLevel >= 3) {
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--- PHP Configuration Values ---");
         if (function_exists('php_version')) {
             JoomlapackLogger::WriteLog(_JP_LOG_INFO, "PHP Version        :" . phpversion());
         }
         if (function_exists('php_uname')) {
             JoomlapackLogger::WriteLog(_JP_LOG_INFO, "OS Version         :" . php_uname('s'));
         }
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Safe mode          :" . ini_get("safe_mode"));
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Display errors     :" . ini_get("display_errors"));
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Disabled functions :" . ini_get("disable_functions"));
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "open_basedir restr.:" . ini_get('open_basedir'));
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Max. exec. time    :" . ini_get("max_execution_time"));
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Memory limit       :" . ini_get("memory_limit"));
         if (function_exists("memory_get_usage")) {
             JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Current mem. usage :" . memory_get_usage());
         }
         if (function_exists("gzcompress")) {
             JoomlapackLogger::WriteLog(_JP_LOG_INFO, "GZIP Compression   : available (good)");
         } else {
             JoomlapackLogger::WriteLog(_JP_LOG_INFO, "GZIP Compression   : n/a (no compression)");
         }
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------");
     }
     if ($this->_OnlyDBMode) {
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack is starting a new database backup");
     } else {
         JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack is starting a new full site backup");
         // Instanciate archiver, only if not in DB only mode
         $archiver =& $this->getArchiverEngine();
         $archiveFile = JoomlapackAbstraction::getExpandedTarName($this->_archiveExtension);
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Expanded archive file name: " . $archiveFile);
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Seeding archive with installer");
         $installerPackage = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . "installers" . DS . $configuration->AltInstaller->Package;
         $archiver->initialize($installerPackage, $archiveFile);
         if ($archiver->hasError()) {
             $this->_Error = $archiver->getError();
         }
     }
 }