private function _HttpError($msg, $level, $errno = null) { $trace = ''; $backtrace = debug_backtrace; foreach ($backtrace as $trace) { $trace .= sprintf("in [file: '%s'][function: '%s'][line: %s];\n", $trace['file'], $trace['function'], $trace['line']); } $msg = sprintf('%s\\n%s: [errno: %s]: %s', $trace, error2string($level), $errno, $msg); if ($this->with_exceptions) { throw new httpException($msg, $errno); } else { trigger_error($msg, $level); return array(false, $msg); } }
/** * Initialises CUBE to start a new backup * */ function start($description, $comment) { global $mainframe; // Load registry $configuration =& JoomlapackModelRegistry::getInstance(); $configuration->reload(); // Load engine provisioning object $this->provisioning =& JoomlapackCUBEProvisioning::getInstance(); // Initialize statistics model $this->statmodel =& JoomlapackModelStatistics::getInstance(); // Initialize private fields $this->_activeDomain = 'init'; $this->_object = null; $this->_isFinished = false; // Load JP version JoomlapackHelperUtils::getJoomlaPackVersion(); // Initialise log file JoomlapackLogger::ResetLog(); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------"); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack " . _JP_VERSION . ' (' . _JP_DATE . ')'); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Got backup?"); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------"); // PHP configuration variables are tried to be logged only for debug and info log levels if ($configuration->get('logLevel') >= 2) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--- System Information ---"); if (function_exists('phpversion')) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, "PHP Version :" . phpversion()); } if (function_exists('php_uname')) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, "OS Version :" . php_uname('s')); } $db =& JFactory::getDBO(); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "DB Version :" . $db->getVersion()); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "DB Collation :" . $db->getCollation()); if (isset($_SERVER['SERVER_SOFTWARE'])) { $server = $_SERVER['SERVER_SOFTWARE']; } else { if ($sf = getenv('SERVER_SOFTWARE')) { $server = $sf; } else { $server = JText::_('n/a'); } } JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Web Server :" . $server); if (function_exists('php_sapi_name')) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, "PHP Interface :" . php_sapi_name()); } $version = new JVersion(); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Joomla! version :" . $version->getLongVersion()); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "User agent :" . phpversion() <= "4.2.1" ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT']); 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, "Error reporting :" . error2string()); 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, "JPATH_BASE :" . JPATH_BASE); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JPATH_ROOT :" . JPATH_ROOT); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JPATH_CACHE :" . JPATH_CACHE); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Output directory :" . $configuration->get('OutputDirectory')); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Temporary directory:" . $configuration->getTemporaryDirectory()); $temp = JoomlapackCUBETables::_getBase64() ? 'Available; will be used for temp vars' : 'Not available'; JoomlapackLogger::WriteLog(_JP_LOG_INFO, "BASE64 Encoding :" . $temp); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------"); } jpimport('helpers.status', true); $statushelper =& JoomlapackHelperStatus::getInstance(); if ($statushelper->hasQuirks()) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack has detected the following potential problems:"); foreach ($statushelper->quirks as $q) { JoomlapackLogger::WriteLog(_JP_LOG_INFO, '- ' . $q['code'] . ' ' . $q['description'] . ' (' . $q['severity'] . ')'); } JoomlapackLogger::WriteLog(_JP_LOG_INFO, "You probably do not have to worry about them, but you should be aware of them."); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "--------------------------------------------------------------------------------"); } // Get current profile ID $session =& JFactory::getSession(); $profile_id = $session->get('profile', null, 'joomlapack'); JoomlapackLogger::WriteLog(_JP_LOG_INFO, "Loading profile #{$profile_id}"); // Get archive name switch ($configuration->get('BackupType')) { case 'dbonly': JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack is starting a new database backup"); $extension = '.sql'; break; case 'full': JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack is starting a new full site backup"); // Instanciate archiver, only if not in DB only mode $archiver =& $this->provisioning->getArchiverEngine(true); if ($this->provisioning->getError()) { $this->setError($this->provisioning->getError()); return; } $extension = $this->provisioning->archiveExtension; break; case 'extradbonly': JoomlapackLogger::WriteLog(_JP_LOG_INFO, "JoomlaPack is starting a new extra databases only backup"); // Instanciate archiver, only if not in DB only mode $archiver =& $this->provisioning->getArchiverEngine(true); if ($this->provisioning->getError()) { $this->setError($this->provisioning->getError()); return; } $extension = $this->provisioning->archiveExtension; break; } $relativeArchiveName = JoomlapackHelperUtils::getExpandedTarName($extension, false); $absoluteArchiveName = JoomlapackHelperUtils::getExpandedTarName($extension, true); // ==== Stats initialisation === $this->statmodel->setId(0); // Detect backup origin if ($mainframe->isAdmin()) { $origin = 'backend'; } else { $origin = 'frontend'; } // Get profile $session =& JFactory::getSession(); $profile_id = $session->get('profile', null, 'joomlapack'); unset($session); // Create an initial stats entry jimport('joomla.utilities.date'); $jdate = new JDate(); switch ($configuration->get('BackupType')) { case 'full': $backupType = 'full'; break; case 'dbonly': $backupType = 'dbonly'; break; case 'extradbonly': $backupType = 'extradbonly'; break; } JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Backup type is now set to '" . $backupType . "'"); $temp = array('description' => $description, 'comment' => $comment, 'backupstart' => $jdate->toMySQL(), 'status' => 'run', 'origin' => $origin, 'type' => $backupType, 'profile_id' => $profile_id, 'archivename' => $relativeArchiveName, 'absolute_path' => $absoluteArchiveName); // Save the entry $this->statmodel->save($temp); if ($this->statmodel->getError()) { $this->setError($this->statmodel->getError()); return; } unset($temp); // Get the ID! $temp = $this->statmodel->getSavedTable(); $this->_statID = $temp->id; // Initialize the archive. if ($configuration->get('BackupType') != 'dbonly') { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Expanded archive file name: " . $absoluteArchiveName); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Seeding archive with installer"); $installerPackage = JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . "installers" . DS . $configuration->get('InstallerPackage'); $archiver->initialize($installerPackage, $absoluteArchiveName); $archiver->setComment($comment); // Add the comment to the archive itself. if ($archiver->getError()) { $this->setError($archiver->getError()); return; } } $this->_initialised = true; }