function display() { $task = JRequest::getCmd('task', 'default'); $act = JRequest::getCmd('act', 'start'); // Set the toolbar title JToolBarHelper::title(JText::_('JOOMLAPACK') . ':: <small><small>' . JText::_('BACKUP') . '</small></small>'); // Load the util helper $this->loadHelper('utils'); switch ($task) { case 'backup': if (!class_exists('JoomlapackModelRegistry')) { jpimport('models.registry', true); } $registry =& JoomlapackModelRegistry::getInstance(); $this->assign('backupMethod', $registry->get('backupMethod')); break; case 'error': $this->assign('errormessage', JRequest::getString('message')); JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option')); break; case 'finised': JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option')); JToolBarHelper::spacer(); JoomlapackHelperUtils::addLiveHelp('backup'); break; default: // Add some buttons JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option')); JToolBarHelper::spacer(); JoomlapackHelperUtils::addLiveHelp('backup'); // Load model $model =& $this->getModel('backup'); // Load the Status Helper jpimport('helpers.status', true); $helper =& JoomlapackHelperStatus::getInstance(); // Pass on data $this->assign('haserrors', !$helper->status); $this->assign('hasquirks', $helper->hasQuirks()); $this->assign('quirks', $helper->getQuirksCell(!$helper->status)); $this->assign('description', $model->getDescription()); $this->assign('comment', $model->getComment()); $this->assign('profile', $model->getProfileID()); $this->assign('profilelist', $model->getProfilesList()); break; } $css = JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'; $document =& JFactory::getDocument(); $document->addStyleSheet($css); parent::display(JRequest::getCmd('tpl', null)); }
function display() { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.path'); // Get the folder to browse $folder = JRequest::getString('folder', ''); if (empty($folder)) { $folder = ''; $isFolderThere = false; $isInRoot = false; $isOpenbasedirRestricted = false; } else { // Normalise name $folder = JPath::clean($folder); if (JFolder::exists($folder)) { $isFolderThere = true; } else { $isFolderThere = false; } JRequest::setVar('folder', $folder); // Check if it's a subdirectory of the site's root $isInRoot = strpos($folder, JPATH_SITE) === 0; // Check if it's restricted by open_basedir restrictions jpimport('helpers.status', true); $statusHelper =& JoomlapackHelperStatus::getInstance(); $isOpenbasedirRestricted = $statusHelper->_checkOpenBasedirs($folder); } // Writable check and contents listing if it's in site root and not restricted if ($isFolderThere && !$isOpenbasedirRestricted) { // Get writability status $isWritable = is_writable($folder); // Get contained folders $subfolders = JFolder::folders($folder); } else { if ($isFolderThere && !$isOpenbasedirRestricted) { $isWritable = is_writable($folder); } else { $isWritable = false; } $subfolders = array(); } // Get parent directory $pathparts = explode(DS, $folder); if (is_array($pathparts)) { $path = ''; foreach ($pathparts as $part) { $path .= DS . $part; if (empty($part)) { $part = DS; } $crumb['label'] = $part; $crumb['folder'] = $path; $breadcrumbs[] = $crumb; } $junk = array_pop($pathparts); $parent = implode(DS, $pathparts); } else { // Can't indetify parent dir, use ourselves. $parent = $folder; $breadcrumbs = array(); } $this->assign('folder', $folder); $this->assign('parent', $parent); $this->assign('exists', $isFolderThere); $this->assign('inRoot', $isInRoot); $this->assign('openbasedirRestricted', $isOpenbasedirRestricted); $this->assign('writable', $isWritable); $this->assign('subfolders', $subfolders); $this->assign('breadcrumbs', $breadcrumbs); parent::display(); }
/** * 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; }
function display() { $registry =& JoomlapackModelRegistry::getInstance(); if ($registry->get('easymode', false)) { // Set the toolbar title; add a help button JToolBarHelper::title(JText::_('JOOMLAPACKEASY')); JoomlapackHelperUtils::addLiveHelp('cpanel'); // Add submenus (those nifty text links below the toolbar!) // -- Configuration $link = JURI::base() . '?option=' . JRequest::getCmd('option') . '&view=configeasy'; JSubMenuHelper::addEntry(JText::_('CONFIGURATION'), $link); } else { // Set the toolbar title; add a help button JToolBarHelper::title(JText::_('JOOMLAPACK')); JoomlapackHelperUtils::addLiveHelp('cpanel'); // Add submenus (those nifty text links below the toolbar!) // -- Configuration $link = JURI::base() . '?option=' . JRequest::getCmd('option') . '&view=config'; JSubMenuHelper::addEntry(JText::_('CONFIGURATION'), $link); } // -- Backup Now $link = JURI::base() . '?option=' . JRequest::getCmd('option') . '&view=backup'; JSubMenuHelper::addEntry(JText::_('BACKUP'), $link); // -- Administer Backup Files $link = JURI::base() . '?option=' . JRequest::getCmd('option') . '&view=buadmin'; JSubMenuHelper::addEntry(JText::_('BUADMIN'), $link); // -- View log $link = JURI::base() . '?option=' . JRequest::getCmd('option') . '&view=log'; JSubMenuHelper::addEntry(JText::_('VIEWLOG'), $link); // Load the helper classes $this->loadHelper('utils'); $this->loadHelper('status'); $statusHelper = JoomlapackHelperStatus::getInstance(); // Load the model jpimport('models.statistics', true); $model =& $this->getModel(); $statmodel = new JoomlapackModelStatistics(); $this->assign('icondefs', $model->getIconDefinitions()); // Icon definitions $this->assign('profileid', $model->getProfileID()); // Active profile ID $this->assign('profilelist', $model->getProfilesList()); // List of available profiles $this->assign('statuscell', $statusHelper->getStatusCell()); // Backup status $this->assign('newscell', $statusHelper->getNewsCell()); // News $this->assign('detailscell', $statusHelper->getQuirksCell()); // Details (warnings) $this->assign('statscell', $statmodel->getLatestBackupDetails()); $this->assign('easymode', $registry->get('easymode', false)); if ($model->isLastBackupFailed()) { $this->assign('troubleshooterstyle', 'display: block'); $this->assign('showtroubleshooter', true); $mode = $model->nextSettingsMode(); if (is_null($mode)) { $this->assign('troubleshootertext', JText::_('CPANEL_TROUBLESHOOTER_NOACTION')); $this->assign('troubleshooterurl', 'http://forum.joomlapack.net'); } else { switch ($mode) { case 'optimistic': $modetext = JText::_('CONFIGEZ_OPT_SMOPTIMISTIC'); break; case 'normal': $modetext = JText::_('CONFIGEZ_OPT_SMNORMAL'); break; case 'conservative': $modetext = JText::_('CONFIGEZ_OPT_SMCONSERVATIVE'); break; } $this->assign('troubleshootertext', JText::sprintf('CPANEL_TROUBLESHOOTER_SETTING', $modetext)); $this->assign('troubleshooterurl', JURI::base() . 'index.php?option=com_joomlapack&view=cpanel&task=troubleshooter'); } } else { $this->assign('showtroubleshooter', false); $this->assign('troubleshooterstyle', 'display: none'); $this->assign('troubleshootertext', ''); $this->assign('troubleshooterurl', ''); } $css = JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'; $document =& JFactory::getDocument(); $document->addStyleSheet($css); parent::display(); }