Ejemplo n.º 1
0
 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'));
 }
Ejemplo n.º 2
0
 /**
  * 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';
 }
 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);
 }
Ejemplo n.º 4
0
    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'));
    }
Ejemplo n.º 5
0
 /**
  * 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;
 }