function display() { $task = JRequest::getCmd('task', 'default'); switch ($task) { case 'showcomment': JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option') . '&view=buadmin'); JoomlapackHelperUtils::addLiveHelp('buadmin'); $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'); jpimport('models.statistics', true); $model =& JoomlapackModelStatistics::getInstance('Statistics', 'JoomlapackModel'); $model->setId(JRequest::getInt('id')); $record =& $model->getStatistic(); $this->assignRef('record', $record); JRequest::setVar('tpl', 'comment'); break; case 'restore': JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); JRequest::setVar('tpl', 'restore'); $this->assign('password', JRequest::getVar('password')); $this->assign('link', JRequest::getVar('linktarget')); break; default: $registry =& JoomlapackModelRegistry::getInstance(); $easy = $registry->get('easymode', false); if (!$easy) { JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); } else { JToolBarHelper::title(JText::_('JOOMLAPACKEASY') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); } JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option')); JToolBarHelper::spacer(); JToolBarHelper::deleteList(); JToolBarHelper::custom('deletefiles', 'delete.png', 'delete_f2.png', JText::_('STATS_LABEL_DELETEFILES'), true); JToolBarHelper::save('download', JText::_('STATS_LOG_DOWNLOAD')); if (!$easy) { JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_VIEWCOMMENT')); if (JPSPECIALEDITION) { JToolBarHelper::publish('restore', JText::_('STATS_LOG_RESTORE')); } } JToolBarHelper::spacer(); if (!$easy) { JoomlapackHelperUtils::addLiveHelp('buadmin'); } else { JoomlapackHelperUtils::addLiveHelp('buadmineasy'); } $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'); jpimport('models.statistics', true); $model =& JoomlapackModelStatistics::getInstance('Statistics', 'JoomlapackModel'); $list =& $model->getStatisticsListWithMeta(); $this->assignRef('list', $list); $this->assignRef('pagination', $model->getPagination()); $this->assign('easy', $easy); break; } parent::display(JRequest::getVar('tpl')); }
function _finalise() { global $mainframe; $this->_enforce_minexectime(true); // The backup is over. Did we encounter any errors? if ($this->getError()) { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Can't finalise due to errors"); // Notify Super Administrators if it's a front-end backup if (!$mainframe->isAdmin()) { $this->_mailToSuperAdministrators($this->getError()); } // Oops! Have to reset() because of the error $this->reset(); } else { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup started"); // Notify Super Administrators if it's a front-end backup if (!$mainframe->isAdmin()) { $this->_mailToSuperAdministrators(); } // Remove temp files JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Removing temporary files"); JoomlapackCUBETempfiles::deleteTempFiles(); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Updating statistics"); // We finished normally. Fetch the stats record $this->statmodel = null; $this->statmodel = new JoomlapackModelStatistics($this->_statID); $this->statmodel->setId($this->_statID); $statRecord =& $this->statmodel->getStatistic(); jimport('joomla.utilities.date'); $jdate = new JDate(); $statRecord->backupend = $jdate->toMySQL(); $statRecord->status = 'complete'; $this->statmodel->save($statRecord); // Apply quotas $errorReporting = @error_reporting(0); $quotaFiles = $this->statmodel->getOldBackupsToDelete(); if (count($quotaFiles) > 0) { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Applying quotas"); jimport('joomla.filesystem.file'); foreach ($quotaFiles as $file) { if (!@unlink($file)) { // FIX 2.0: Using JFile::delete raised warnings which messed up XMLRPC output. After all, we write backup files from PHP, using FTP should not be necessary to delete them! $this->addWarning("Failed to remove old backup file " . $file); } } } @error_reporting($errorReporting); // Set internal variables and go to bed... er... I mean, return control to the user $this->_isFinished = true; $this->_activeDomain = 'finale'; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "CUBE - Finalising backup ended"); } $this->_enforce_minexectime(false); }
/** * Was the last backup a failed one? Used to apply magic settings as a means of * troubleshooting. * * @return bool */ function isLastBackupFailed() { $db =& $this->getDBO(); $query = 'SELECT max(id) FROM #__jp_stats'; $db->setQuery($query); $id = $db->loadResult(); if (empty($id)) { return false; } jpimport('models.statistics', true); $statmodel =& JoomlapackModelStatistics::getInstance(); $statmodel->setId($id); $record =& $statmodel->getStatistic(); return $record->status == 'fail'; }
/** * Find where to store the backup files */ function _getBackupFilePaths() { $configuration =& JoomlapackModelRegistry::getInstance(); switch ($configuration->get('BackupType')) { case '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"); // Fix 2.0: Backup file name MUST be taken from the statitics record! $cube =& JoomlapackCUBE::getInstance(); $statID = $cube->_statID; $statModel = new JoomlapackModelStatistics($statID); $statModel->setId($statID); $statRecord =& $statModel->getStatistic(); $this->_tempFile = $statRecord->absolute_path; $this->_saveAsName = ''; break; case 'full': 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 = JoomlapackCUBETempfiles::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 = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . 'joomla.sql'))); $this->_saveAsName = 'installation/sql/joomla.sql'; } else { // External databases, we use the database's name JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: External database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql'))); $this->_saveAsName = 'installation/sql/' . $this->_database . '.sql'; } } break; case 'extradbonly': 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 = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_dumpFile))); $this->_saveAsName = $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 = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . 'joomla.sql'))); $this->_saveAsName = 'joomla.sql'; } else { // External databases, we use the database's name JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackDumperDefault :: External database"); $this->_tempFile = JoomlapackCUBETempfiles::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql'))); $this->_saveAsName = $this->_database . '.sql'; } } break; } 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); }
function save() { $id = JRequest::getInt('id'); $description = JRequest::getString('description'); $comment = JRequest::getVar('comment', null, 'default', 'string', 4); jpimport('models.statistics', true); $model =& JoomlapackModelStatistics::getInstance('Statistics', 'JoomlapackModel'); $model->setId(JRequest::getInt('id')); $record =& $model->getStatistic(); $record->description = $description; $record->comment = $comment; $ok = $model->save($record); if ($ok) { $message = JText::_('STATS_LOG_SAVEDOK'); $type = 'message'; } else { $message = JText::_('STATS_LOG_SAVEERROR'); $type = 'error'; } $this->setRedirect(JURI::base() . 'index.php?option=com_joomlapack&view=buadmin', $message, $type); }
function display() { $task = JRequest::getCmd('task', 'default'); switch ($task) { case 'showcomment': JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option') . '&view=buadmin'); JToolBarHelper::save(); JToolBarHelper::cancel(); JoomlapackHelperUtils::addLiveHelp('buadmin'); $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'); jpimport('models.statistics', true); $model =& JoomlapackModelStatistics::getInstance('Statistics', 'JoomlapackModel'); $model->setId(JRequest::getInt('id')); $record =& $model->getStatistic(); $this->assignRef('record', $record); JRequest::setVar('tpl', 'comment'); break; case 'restore': JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); JRequest::setVar('tpl', 'restore'); $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'); $this->assign('password', JRequest::getVar('password')); $this->assign('link', JRequest::getVar('linktarget')); break; default: $registry =& JoomlapackModelRegistry::getInstance(); $easy = $registry->get('easymode', false); if (!$easy) { JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); } else { JToolBarHelper::title(JText::_('JOOMLAPACKEASY') . ': <small><small>' . JText::_('BUADMIN') . '</small></small>'); } JToolBarHelper::back('Back', 'index.php?option=' . JRequest::getCmd('option')); JToolBarHelper::spacer(); JToolBarHelper::deleteList(); JToolBarHelper::custom('deletefiles', 'delete.png', 'delete_f2.png', JText::_('STATS_LABEL_DELETEFILES'), true); // "Show warning first" download button. Joomlantastic! //JToolBarHelper::save('download',JText::_('STATS_LOG_DOWNLOAD')); $confirmationText = addcslashes(JText::_('STATS_LOG_DOWNLOAD_CONFIRM'), "\n'"); $baseURI = JURI::base(); $js = <<<ENDSCRIPT function confirmDownloadButton() { \tvar answer = confirm('{$confirmationText}'); \tif(answer) submitbutton('download'); } function confirmDownload(id, part) { \tvar answer = confirm('{$confirmationText}'); \tvar newURL = '{$baseURI}'; \tif(answer) { \t\tnewURL += 'index.php?option=com_joomlapack&view=buadmin&task=download&id='+id; \t\tif( part != '' ) newURL += '&part=' + part \t\twindow.location = newURL; \t} } ENDSCRIPT; $document =& JFactory::getDocument(); $document->addScriptDeclaration($js); $bar =& JToolBar::getInstance('toolbar'); $bar->appendButton('link', 'save', JText::_('STATS_LOG_DOWNLOAD'), "javascript:confirmDownloadButton();"); if (!$easy) { JToolBarHelper::editList('showcomment', JText::_('STATS_LOG_EDITCOMMENT')); if (JPSPECIALEDITION) { JToolBarHelper::publish('restore', JText::_('STATS_LOG_RESTORE')); } } JToolBarHelper::spacer(); if (!$easy) { JoomlapackHelperUtils::addLiveHelp('buadmin'); } else { JoomlapackHelperUtils::addLiveHelp('buadmineasy'); } $document =& JFactory::getDocument(); $document->addStyleSheet(JURI::base() . 'components/com_joomlapack/assets/css/joomlapack.css'); jpimport('models.statistics', true); $model =& JoomlapackModelStatistics::getInstance('Statistics', 'JoomlapackModel'); $list =& $model->getStatisticsListWithMeta(); $this->assignRef('list', $list); $this->assignRef('pagination', $model->getPagination()); $this->assign('easy', $easy); break; } parent::display(JRequest::getVar('tpl')); }
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(); }