Пример #1
0
 /**
  * Calculates the absolute path to the log file
  */
 function logName()
 {
     if (!class_exists('JoomlapackModelLog')) {
         jpimport('models.log', true);
     }
     return JoomlapackModelLog::getLogFilename();
 }
Пример #2
0
 /**
  * Returns the contents of a directory and their exclusion status
  * @param $root string Start from this folder
  * @return array Directories and their status
  */
 function getDirectory($root)
 {
     // If there's no root directory specified, use the site's root
     $root = is_null($root) ? JPATH_SITE : $root;
     // Initialize filter list
     $this->init();
     // Initialize directories array
     $arDirs = array();
     // Get subfolders
     jpimport('classes.engine.lister.default');
     $FS = new JoomlapackListerAbstraction();
     $allFilesAndDirs = $FS->getDirContents($root);
     if (!($allFilesAndDirs === false)) {
         foreach ($allFilesAndDirs as $fileName) {
             if (is_dir($fileName)) {
                 $fileName = basename($fileName);
                 if (JoomlapackAbstraction::TranslateWinPath($root) == JoomlapackAbstraction::TranslateWinPath(JPATH_SITE) && ($fileName == "." || $fileName == "..")) {
                 } else {
                     if ($this->_folderFilters == "") {
                         $arDirs[$fileName] = false;
                     } else {
                         $arDirs[$fileName] = in_array(JoomlapackAbstraction::TranslateWinPath($root . DS . $fileName), $this->_folderFilters);
                     }
                 }
             }
             // if
         }
         // foreach
     }
     // if
     ksort($arDirs);
     return $arDirs;
 }
Пример #3
0
 /**
  * Selects the algorithm to use based on the domain name
  *
  * @param string $domain The domain to return algorithm for
  * @return string The algorithm to use
  */
 function selectAlgorithm($domain)
 {
     if (!class_exists('JoomlapackModelregistry')) {
         jpimport('models.registry', true);
     }
     $registry =& JoomlapackModelRegistry::getInstance();
     switch ($domain) {
         case "installer":
             switch ($registry->get('BackupType')) {
                 case 'full':
                     return 'smart';
                     break;
                 default:
                     return '(null)';
                     break;
             }
             break;
         case "PackDB":
             return $registry->get('dbAlgorithm');
             break;
         case "Packing":
             switch ($registry->get('BackupType')) {
                 case 'full':
                     return $registry->get('packAlgorithm');
                     break;
                 default:
                     return '(null)';
                     break;
             }
             break;
         default:
             return "(null)";
             break;
     }
 }
Пример #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');
             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 display()
 {
     // Decide what to do; delegate data loading to private methods
     $task = JRequest::getCmd('task', 'display');
     $layout = JRequest::getCmd('layout', 'default');
     JToolBarHelper::title(JText::_('JOOMLAPACK') . ': <small><small>' . JText::_('CRONMAN') . '</small></small>');
     switch ($layout) {
         case 'default_edit':
             // Get the CRON configuration definition
             if ($task == 'add') {
                 $definition = null;
                 $registry =& JoomlapackModelRegistry::getInstance();
                 $secret = $registry->get('secret_key');
                 $this->assign('secret', $secret);
             } else {
                 $id = JRequest::getInt('id', 0);
                 $model =& $this->getModel('cronman');
                 $definition = $model->getConfiguration($id);
             }
             $this->assign('definition', $definition);
             // Get some lists and pass them on
             $model =& $this->getModel('cronman');
             $postops = $model->getPostOpList();
             $this->assign('postops', $postops);
             // Add the buttons
             JToolBarHelper::save();
             JToolBarHelper::apply();
             JToolBarHelper::cancel();
             break;
         case 'default':
         default:
             $this->_default();
             break;
     }
     // Load the util helper
     $this->loadHelper('utils');
     // Add a spacer, a help button and show the template
     JToolBarHelper::spacer();
     JoomlapackHelperUtils::addLiveHelp('profiles');
     // Load a list of profiles
     $model =& $this->getModel('cronman');
     jpimport('models.profiles', true);
     $profilesmodel = new JoomlapackModelProfiles();
     $profiles_objects = $profilesmodel->getProfilesList(true);
     $profiles = array();
     foreach ($profiles_objects as $profile) {
         $id = $profile->id;
         $profiles[(string) $id] = $profile->description;
     }
     unset($profiles_objects);
     unset($profilesmodel);
     $this->assign('profiles', $profiles);
     // Add JoomlaPack CSS
     $document =& JFactory::getDocument();
     $document->addStyleSheet(JURI::base() . '/components/com_joomlapack/assets/css/joomlapack.css');
     // Show the view
     parent::display();
 }
Пример #6
0
function addWarning($warning)
{
    jpimport('core.cube');
    jpimport('helpers.backup', true);
    $cube =& JoomlapackCUBE::getInstance();
    $cube->addWarning($warning);
    $cube->save();
    return;
}
Пример #7
0
 function renderFormattedLog()
 {
     // -- Get the log's file name
     // Make sure the model is loaded
     if (!class_exists('JoomlapackModelLog')) {
         jpimport('models.log', true);
     }
     // Get log's file name
     $model = new JoomlapackModelLog();
     $logName = $model->getLogFilename();
     // Load JFile class
     jimport('joomla.filesystem.file');
     if (!JFile::exists($logName)) {
         // Oops! The log doesn't exist!
         echo '<p>' . JText::_('LOG_ERROR_LOGFILENOTEXISTS') . '</p>';
         return;
     } else {
         // Allright, let's load and render it
         $fp = fopen($logName, "rt");
         if ($fp === FALSE) {
             // Oops! The log isn't readable?!
             echo '<p>' . JText::_('LOG_ERROR_UNREADABLE') . '</p>';
             return;
         }
         while (!feof($fp)) {
             $line = fgets($fp);
             if (!$line) {
                 return;
             }
             $exploded = explode("|", $line, 3);
             unset($line);
             switch (trim($exploded[0])) {
                 case "ERROR":
                     $fmtString = "<span style=\"color: red; font-weight: bold;\">[";
                     break;
                 case "WARNING":
                     $fmtString = "<span style=\"color: #D8AD00; font-weight: bold;\">[";
                     break;
                 case "INFO":
                     $fmtString = "<span style=\"color: black;\">[";
                     break;
                 case "DEBUG":
                     $fmtString = "<span style=\"color: #666666; font-size: small;\">[";
                     break;
                 default:
                     $fmtString = "<span style=\"font-size: small;\">[";
                     break;
             }
             $fmtString .= $exploded[1] . "] " . htmlspecialchars($exploded[2]) . "</span><br/>\n";
             unset($exploded);
             echo $fmtString;
             unset($fmtString);
             ob_flush();
         }
     }
 }
Пример #8
0
 function echoHTML()
 {
     jpimport('classes.engine.lister.default');
     $lister = new JoomlapackListerAbstraction();
     echo "<h2>Default method</h2>";
     $data = $lister->getDirContents('/');
     $this->do_dump($data);
     echo "<h2>glob</h2>";
     $data = $lister->_getDirContents_glob('/');
     $this->do_dump($data);
 }
Пример #9
0
 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));
 }
Пример #10
0
function testFTPConnection($host, $port, $user, $pass, $initdir, $usessl, $passive)
{
    jpimport('abstract.enginearchiver');
    jpimport('engine.packer.directftp');
    jpimport('core.utility.logger');
    $config = array('host' => $host, 'port' => $port, 'user' => $user, 'pass' => $pass, 'initdir' => $initdir, 'usessl' => $usessl, 'passive' => $passive);
    $test = new JoomlapackPackerDirectftp();
    $test->initialize('', '', $config);
    $errors = $test->getError();
    if (empty($errors)) {
        return true;
    } else {
        return $errors;
    }
}
Пример #11
0
 function getLogFilename()
 {
     // Make sure the registry model is loaded
     if (!class_exists('JoomlapackModelRegistry')) {
         jpimport('models.registry', true);
     }
     // Get output directory
     $registry =& JoomlapackModelRegistry::getInstance();
     $outdir = $registry->get('OutputDirectory');
     // Get log's file name
     $logName = $outdir . DS . 'joomlapack.log';
     // Tidy up the path to the file
     jimport('joomla.filesystem.file');
     return $logName;
 }
Пример #12
0
 /**
  * Check that the user has sufficient permissions, or die in error
  *
  */
 function _checkPermissions()
 {
     jpimport('models.registry', true);
     $registry =& JoomlapackModelRegistry::getInstance();
     // Is frontend backup enabled?
     $febEnabled = $registry->get('enableFrontend');
     if (!$febEnabled) {
         die('403 ' . JText::_('ERROR_NOT_ENABLED'));
     }
     // Is the key good?
     $key = JRequest::getVar('key');
     $validKey = $registry->get('secretWord');
     if ($key != $validKey) {
         die('403 ' . JText::_('ERROR_INVALID_KEY'));
     }
 }
Пример #13
0
function _processCUBE()
{
    jpimport('core.cube');
    $cube =& JoomlapackCUBE::getInstance();
    $array = $cube->getCUBEArray();
    if ($array['Error'] != '') {
        $action = 'error';
        $message = $array['Error'];
    } elseif ($array['HasRun'] == 1) {
        $action = 'finished';
        $message = '';
    } else {
        $action = 'step';
        $message = '';
    }
    return array($action, $message);
}
Пример #14
0
    function echoHTML()
    {
        jpimport('helpers.lang');
        $errorStack = array();
        // Initialize an errors stack
        // Cleanup locks
        jpimport('classes.core.cube');
        JoomlapackCUBE::cleanup();
        // Test for the existence of a default temporary folder
        if (!is_dir(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup')) {
            // Temp dir doesn't exist; try to create one
            if (!@mkdir(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup')) {
                $errorStack[] = JoomlapackLangManager::_('UNLOCK_CANTCREATEDIR');
            } else {
                // Try creating a deafult .htaccess
                $htaccess = <<<END
Deny from all
END;
                $fp = @fopen(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup' . DS . '.htaccess');
                if ($fp === false) {
                    $errorStack[] = JoomlapackLangManager::_('UNLOCK_CANTCREATEHTACCESS');
                } else {
                    @fputs($fp, $htaccess);
                    @fclose($fp);
                }
            }
        }
        // Get some more HTML fragments
        echo JoomlapackCommonHTML::getAdminHeadingHTML(JoomlapackLangManager::_('CPANEL_UNLOCK'));
        ?>
		<p>
		<?php 
        if (count($errorStack) == 0) {
            echo JoomlapackLangManager::_('UNLOCK_DONE');
        } else {
            foreach ($errorStack as $error) {
                echo "<p class=\"error\">{$error}</p>";
            }
        }
        ?>
		</p>
		<?php 
    }
Пример #15
0
 /**
  * Gets the contents of a directory and flags excluded files
  *
  * @param string $root The directory to scan
  * @return array An associative array of associative arrays (use the code, Luke!)
  */
 function getDirectory($root)
 {
     // If there's no root directory specified, use the site's root
     $root = is_null($root) ? JPATH_SITE : $root;
     $isSiteRoot = JoomlapackAbstraction::TranslateWinPath($root) == JoomlapackAbstraction::TranslateWinPath(JPATH_SITE);
     // Initialize filter list
     $this->init();
     // Initialize the two arrays to be returned
     $arDirs = array();
     $arFiles = array();
     // Get directory's contents
     jpimport('classes.engine.lister.default');
     $FS = new JoomlapackListerAbstraction();
     $allFilesAndDirs = $FS->getDirContents($root);
     if (!($allFilesAndDirs === false)) {
         foreach ($allFilesAndDirs as $fileName) {
             //$fileName = basename($fileName);
             if (is_dir($fileName)) {
                 $fileName = basename($fileName);
                 if ($isSiteRoot && ($fileName == '.' || $fileName == '..') || $fileName == '.') {
                     // Don't include . and .. for site's root, or . for all dirs
                 } else {
                     if ($fileName != '.') {
                         $arDirs[] = $fileName;
                     }
                 }
             } elseif (is_file($fileName)) {
                 $fileName = basename($fileName);
                 $excluded = is_array($this->_singleFileFilters) ? in_array(JoomlapackAbstraction::TranslateWinPath($root . DS . $fileName), $this->_singleFileFilters) : false;
                 $arFiles[$fileName] = $excluded;
             }
         }
     }
     sort($arDirs);
     $ret['folders'] = $arDirs;
     unset($arDirs);
     $ret['files'] = $arFiles;
     unset($arFiles);
     return $ret;
 }
Пример #16
0
 /**
  * Displays the Control Panel (main page)
  * Accessible at index.php?option=com_joomlapack
  *
  */
 function display()
 {
     $registry =& JoomlapackModelRegistry::getInstance();
     // FIX 2.1.b2 - Disabled the nag screen because of incompatibility with some servers
     /*
     // Make sure the user has seen the license nag screen
     $nagscreen = $registry->get('nagscreen',false);
     if(!$nagscreen)
     {
     $this->setRedirect(JURI::base().'index.php?option=com_joomlapack&view=nag' );
     return;
     }
     */
     // Invalidate stale backups
     jpimport('core.cube');
     JoomlapackCUBE::reset();
     // If this is the Easy Mode, force switch to profile #1 (default profile)
     if ($registry->get('easymode', false)) {
         $session =& JFactory::getSession();
         $session->set('profile', 1, 'joomlapack');
     }
     // Display the panel
     parent::display();
 }
Пример #17
0
 /**
  * The most basic file transaction: add a single entry (file or directory) to
  * the archive.
  *
  * @param bool $isVirtual If true, the next parameter contains file data instead of a file name
  * @param string $sourceNameOrData Absolute file name to read data from or the file data itself is $isVirtual is true
  * @param string $targetName The (relative) file name under which to store the file in the archive
  * @return True on success, false otherwise
  * @since 1.2.1
  * @access protected
  * @abstract 
  */
 function _addFile($isVirtual, &$sourceNameOrData, $targetName)
 {
     static $configuration;
     if (!$configuration) {
         jpimport('models.registry', true);
         $configuration =& JoomlapackModelRegistry::getInstance();
     }
     // See if it's a directory
     $isDir = $isVirtual ? false : is_dir($sourceNameOrData);
     // Get real size before compression
     if ($isVirtual) {
         $fileSize = strlen($sourceNameOrData);
     } else {
         $fileSize = $isDir ? 0 : filesize($sourceNameOrData);
     }
     // Decide if we will compress
     if ($isDir) {
         $compressionMethod = 0;
         // don't compress directories...
     } else {
         // Do we have plenty of memory left?
         $memLimit = ini_get("memory_limit");
         if (is_numeric($memLimit) && $memLimit < 0) {
             $memLimit = "";
         }
         // 1.2a3 -- Rare case with memory_limit < 0, e.g. -1Mb!
         if ($memLimit == "" || $fileSize >= _JoomlapackPackerZIP_COMPRESSION_THRESHOLD) {
             // No memory limit, or over 1Mb files => always compress up to 1Mb files (otherwise it times out)
             $compressionMethod = $fileSize <= _JoomlapackPackerZIP_COMPRESSION_THRESHOLD ? 1 : 0;
         } elseif (function_exists("memory_get_usage")) {
             // PHP can report memory usage, see if there's enough available memory; Joomla! alone eats about 5-6Mb! This code is called on files <= 1Mb
             $memLimit = $this->_return_bytes($memLimit);
             $availableRAM = $memLimit - memory_get_usage();
             $compressionMethod = $availableRAM / 2.5 >= $fileSize ? 1 : 0;
         } else {
             // PHP can't report memory usage, compress only files up to 512Kb (conservative approach) and hope it doesn't break
             $compressionMethod = $fileSize <= 524288 ? 1 : 0;
         }
     }
     $compressionMethod = function_exists("gzcompress") ? $compressionMethod : 0;
     $storedName = $targetName;
     /* "Entity Description BLock" segment. */
     $unc_len =& $fileSize;
     // File size
     $storedName .= $isDir ? "/" : "";
     if ($compressionMethod == 1) {
         if ($isVirtual) {
             $udata =& $sourceNameOrData;
         } else {
             // Get uncompressed data
             if (function_exists("file_get_contents") && _JoomlapackPackerZIP_FORCE_FOPEN == false) {
                 $udata = @file_get_contents($sourceNameOrData);
                 // PHP > 4.3.0 saves us the trouble
             } else {
                 // Argh... the hard way!
                 $udatafp = @fopen($sourceNameOrData, "rb");
                 if (!($udatafp === false)) {
                     $udata = "";
                     while (!feof($udatafp)) {
                         // Keep-alive on file reading
                         if ($configuration->get("enableMySQLKeepalive", false)) {
                             list($usec, $sec) = explode(" ", microtime());
                             $endTime = (double) $usec + (double) $sec;
                             if ($endTime - $this->startTime > 0.5) {
                                 $this->startTime = $endTime;
                                 JoomlapackCUBETables::WriteVar('dummy', 1);
                             }
                         }
                         $udata .= fread($udatafp, JPPACK_CHUNK);
                     }
                     fclose($udatafp);
                 } else {
                     $udata = false;
                 }
             }
         }
         if ($udata === FALSE) {
             // Unreadable file, skip it.
             JoomlapackLogger::WriteLog(_JP_LOG_WARNING, JText::sprintf('CUBE_WARN_UNREADABLEFILE', $sourceNameOrData));
             return false;
         } else {
             // Proceed with compression
             $zdata = @gzcompress($udata);
             if ($zdata === false) {
                 // If compression fails, let it behave like no compression was available
                 $c_len =& $unc_len;
                 $compressionMethod = 0;
             } else {
                 unset($udata);
                 $zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2);
                 $c_len = strlen($zdata);
             }
         }
     } else {
         $c_len = $unc_len;
     }
     $this->_compressedSize += $c_len;
     // Update global data
     $this->_uncompressedSize += $fileSize;
     // Update global data
     $this->_fileCount++;
     // Get file permissions
     $perms = $isVirtual ? 0777 : @fileperms($sourceNameOrData);
     // Calculate Entity Description Block length
     $blockLength = 21 + strlen($storedName);
     // Open data file for output
     $fp = @fopen($this->_dataFileName, "ab");
     if ($fp === false) {
         $this->setError("Could not open archive file '{$this->_dataFileName}' for append!");
         return;
     }
     $this->_fwrite($fp, $this->_fileHeader);
     // Entity Description Block header
     if ($this->getError()) {
         return;
     }
     $this->_fwrite($fp, pack('v', $blockLength));
     // Entity Description Block header length
     $this->_fwrite($fp, pack('v', strlen($storedName)));
     // Length of entity path
     $this->_fwrite($fp, $storedName);
     // Entity path
     $this->_fwrite($fp, pack('C', $isDir ? 0 : 1));
     // Entity type
     $this->_fwrite($fp, pack('C', $compressionMethod));
     // Compression method
     $this->_fwrite($fp, pack('V', $c_len));
     // Compressed size
     $this->_fwrite($fp, pack('V', $unc_len));
     // Uncompressed size
     $this->_fwrite($fp, pack('V', $perms));
     // Entity permissions
     /* "File data" segment. */
     if ($compressionMethod == 1) {
         // Just dump the compressed data
         $this->_fwrite($fp, $zdata);
         if ($this->getError()) {
             return;
         }
         unset($zdata);
     } elseif (!$isDir) {
         if ($isVirtual) {
             $this->_fwrite($fp, $sourceNameOrData);
             if ($this->getError()) {
                 return;
             }
         } else {
             // Copy the file contents, ignore directories
             $zdatafp = @fopen($sourceNameOrData, "rb");
             if ($zdatafp === FALSE) {
                 JoomlapackLogger::WriteLog(_JP_LOG_WARNING, JText::sprintf('CUBE_WARN_UNREADABLEFILE', $sourceNameOrData));
                 return false;
             } else {
                 while (!feof($zdatafp)) {
                     $zdata = fread($zdatafp, JPPACK_CHUNK);
                     $this->_fwrite($fp, $zdata);
                     if ($this->getError()) {
                         return;
                     }
                 }
                 fclose($zdatafp);
             }
         }
     }
     fclose($fp);
     // ... and return TRUE = success
     return TRUE;
 }
Пример #18
0
 /**
  * Loads the exclusion filters off the db and caches them inside the object
  */
 function _loadAndCacheFilters()
 {
     jpimport('core.utility.filtermanager');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Initializing filter manager");
     $filterManager = new JoomlapackCUBEFilterManager();
     $filterManager->init();
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting Directory Exclusion Filters");
     $this->_ExcludeDirs = $filterManager->getFilters('folder');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting Single File Filters");
     $this->_ExcludeFiles = $filterManager->getFilters('singlefile');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting Contained Files Filters");
     $this->_skipContainedFiles = $filterManager->getFilters('containedfiles');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting Contained Directories Filters");
     $this->_skipContainedDirectories = $filterManager->getFilters('containeddirectories');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Done with filter manager");
     unset($filterManager);
 }
Пример #19
0
 * @since 1.3
 */
// Protect from unauthorized access
defined('_JEXEC') or die('Restricted Access');
?>
<h1><?php 
echo JText::_('BACKUP_HEADER_BACKINGUP');
?>
</h1>
<p><?php 
echo JText::_('BACKUP_TEXT_BACKINGUP');
?>
</p>
<?php 
if ($this->backupMethod == 'ajax') {
    jpimport('helpers.sajax', true);
    sajax_init();
    sajax_force_page_ajax('backup');
    sajax_export('start', 'tick', 'renderProgress');
    $description = JRequest::getString('description');
    $comment = JRequest::getString('comment');
    $baseURL = str_replace('\\', '%5c', JURI::base() . 'index.php?option=com_joomlapack&view=backup&task=');
    ?>
<!-- AJAX-powered backup method -->
<script type="text/javascript" language="Javascript">
	/**
	 * (S)AJAX JavaScript
	 */
	<?php 
    sajax_show_javascript();
    ?>
Пример #20
0
* @version		$Id$
* @license 		http://www.gnu.org/copyleft/gpl.html GNU/GPL
* @since		2.1
*
* JoomlaPack is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* 
* GZipped TAR Creation Module
*
* Creates a TAR file (originally uncompressed) using the PEAR library and the
* Archive_Tar module, then compresses it using the gzip system command
*/
defined('_JEXEC') or die('Restricted access');
jpimport('engine.packer.tar');
// Load the ancestor class
class JoomlapackPackerTARGZ extends JoomlapackPackerTAR
{
    /**
     * The final compressed archive's location
     * @var string
     */
    var $_archiveFilename;
    /**
     * The temporary uncompressed archive's location
     * @var string
     */
    var $_tempFilename;
    /**
     * Class constructor - initializes internal operating parameters
Пример #21
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';
 }
Пример #22
0
 /**
  * Retrieves an object for the specified engine. It reads the engine.ini in order to do that.
  * It will also call the _addEngineInclude to make sure the included file persists during
  * the backup session.
  *
  * @param string $engine The engine type (lister, dumper, packer)
  * @param string $item The engine class file name (e.g. deafault, jpa, etc)
  */
 function &_getAnEngine($engine, $item)
 {
     // Load engine definitions
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating {$engine} engine of type {$item}");
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to read engine setup data for {$engine}");
     // Find and parse all ini files in the given directory
     $ini_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'engine' . DS . $engine;
     jimport('joomla.filesystem.folder');
     $ini_files = JFolder::files($ini_path, '\\.ini$');
     $engineArray = array();
     if (count($ini_files)) {
         foreach ($ini_files as $sourceINI) {
             $myData = JoomlapackHelperUtils::parse_ini_file($ini_path . DS . $sourceINI, true);
             foreach ($myData as $key => $value) {
                 $engineArray[$key] = $value;
             }
         }
     }
     if (isset($engineArray[$item])) {
         $engineDescriptor = $engineArray[$item];
         $dotted = 'engine.' . $engine . '.' . $engineDescriptor['include'];
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Trying to include engine file {$dotted}");
         $this->_addEngineInclude($dotted);
         jpimport($dotted);
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Instanciating " . $engineDescriptor['class']);
         $instance = new $engineDescriptor['class']();
         // If we are getting an archiver class, also populate the _archiveExtension field
         if ($engine == 'packer') {
             $this->archiveExtension = $engineDescriptor['extension'];
         }
         return $instance;
     } else {
         $this->setError(JText::sprintf('CUBE_PROVISIONING_ENGINENOTFOUND', $engine . '.' . $item));
         return false;
     }
 }
Пример #23
0
 function _extraFiltersForTemplates($templateID, $active)
 {
     // If the template code is invalid (template doesn't exist?), quit
     $allTemplates =& $this->getTemplates();
     if (!isset($allTemplates[$templateID])) {
         return;
     }
     $tempPath = str_replace(JPATH_SITE . DS, '', $allTemplates[$templateID]['basedir']) . DS . $allTemplates[$templateID]['template'];
     // Use the DEF to apply inclusion/exclusion of template directory
     jpimport('models.def', true);
     $defModel = new JoomlapackModelDef();
     if ($active) {
         $defModel->enableFilter($tempPath);
     } else {
         $defModel->disableFilter($tempPath);
     }
 }
Пример #24
0
 /**
  * Returns the CRC32 of a file, selecting the more appropriate algorithm.
  *
  * @param string $filename Absolute path to the file being processed
  * @param integer $JoomlapackPackerZIP_CHUNK_SIZE Obsoleted
  * @return integer The CRC32 in numerical form
  */
 function crc32_file($filename, $JoomlapackPackerZIP_CHUNK_SIZE)
 {
     static $configuration;
     if (!$configuration) {
         jpimport('models.registry', true);
         $configuration =& JoomlapackModelRegistry::getInstance();
     }
     // Keep-alive before CRC32 calculation
     if ($configuration->get("enableMySQLKeepalive", false)) {
         list($usec, $sec) = explode(" ", microtime());
         $endTime = (double) $usec + (double) $sec;
         if ($endTime - $this->startTime > 0.5) {
             $this->startTime = $endTime;
             JoomlapackCUBETables::WriteVar('dummy', 1);
         }
     }
     if (function_exists("hash_file")) {
         $res = $this->crc32_file_php512($filename);
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [PHP512]");
     } else {
         if (function_exists("file_get_contents") && @filesize($filename) <= $JoomlapackPackerZIP_CHUNK_SIZE) {
             $res = $this->crc32_file_getcontents($filename);
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [GETCONTENTS]");
         } else {
             $res = $this->crc32_file_php4($filename, $JoomlapackPackerZIP_CHUNK_SIZE);
             JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "File {$filename} - CRC32 = " . dechex($res) . " [PHP4]");
         }
     }
     if ($res === FALSE) {
         $cube =& JoomlapackCUBE::getInstance();
         $cube->addWarning("File {$filename} - NOT READABLE: CRC32 IS WRONG!");
     }
     return $res;
 }
Пример #25
0
 /**
  * Loads all installer definition files
  * @return array An array of the installer names and packages
  */
 function loadAllDefinitions()
 {
     jpimport('classes.engine.lister.default');
     $FS = new JoomlapackListerAbstraction();
     $defs = array();
     $fileList = $FS->getDirContents(JPATH_COMPONENT_ADMINISTRATOR . DS . 'assets' . DS . "installers" . DS, "*.xml");
     foreach ($fileList as $file) {
         $baseName = basename($file);
         if ($this->loadDefinition($baseName)) {
             $newDef['name'] = $this->Name;
             $newDef['package'] = $this->Package;
             $newDef['meta'] = $baseName;
             $defs[] = $newDef;
         }
     }
     return $defs;
 }
Пример #26
0
 /**
  * Searches for updates and returns an object containing update information
  * @return JObject An object with members: supported, update_available,
  * 				   current_version, current_date, latest_version, latest_date,
  * 				   package_url
  */
 function &getUpdates($force = false)
 {
     jimport('joomla.utilities.date');
     $ret = new JObject();
     if (!$this->isLiveUpdateSupported()) {
         $ret->supported = false;
         $ret->update_available = false;
         return $ret;
     } else {
         $ret->supported = true;
         $update = $this->_getLatestVersion($force);
         // Check if we need to upgrade, by release date
         jimport('joomla.utilities.date');
         jpimport('helpers.utils', true);
         JoomlapackHelperUtils::getJoomlaPackVersion();
         $curdate = new JDate(_JP_DATE);
         $curdate = $curdate->toUnix(false);
         if (is_object($update->reldate)) {
             $reldate = $update->reldate->toUnix(false);
             $ret->latest_date = $update->reldate->toFormat('%Y-%m-%d');
         } else {
             $ret->latest_date = @date('Y-m-d', $update->reldate);
         }
         $ret->update_available = $reldate > $curdate;
         $ret->current_version = _JP_VERSION;
         $ret->current_date = _JP_DATE;
         $ret->latest_version = $update->version;
         $ret->status = $update->status;
         $ret->package_url = JPSPECIALEDITION ? $update->special : $update->free;
         return $ret;
     }
 }
Пример #27
0
 /**
  * Saves or updates an EFF entry
  *
  * @param object $fromObject If set, use data from this object, instead of the request
  * @access public
  * @return bool True on success
  */
 function save($fromObject = null)
 {
     jpimport('helpers.utils', true);
     // Get active profile
     $session =& JFactory::getSession();
     $profile = $session->get('profile', null, 'joomlapack');
     if (!is_object($fromObject)) {
         // Map from $_REQUEST
         $id = JRequest::getVar('id', null);
         // Create a table
         $fromObject = array('id' => $id, 'profile' => $profile, 'class' => 'eff', 'value' => JoomlapackHelperUtils::TranslateWinPath(JRequest::getVar('fsdir')));
     }
     // Load table class
     $table =& $this->getTable('Inclusion');
     // Assign from data and save the inclusion filter record
     if (!$table->save($fromObject)) {
         $this->setError($table->getError());
         return false;
     }
     return true;
 }
Пример #28
0
 /**
  * Outputs the necessary JavaScript to the browser
  *
  */
 function renderJavaScript()
 {
     jpimport('models.registry', true);
     $profile =& JoomlapackModelRegistry::getInstance();
     $method = $profile->get('backupMethod');
     if ($method == 'ajax') {
         JoomlapackHelperSkip::_renderAJAXJavaScript();
     } else {
         JoomlapackHelperSkip::_renderRedirectsJavaScript();
     }
 }
Пример #29
0
 /**
  * Initializes the array of filters. Reads the data of the filter.ini in the
  * classes/filter directory.
  */
 function init()
 {
     // Load the filter.ini
     jpimport('helpers.utils', true);
     // Find and parse all ini files in the given directory
     $ini_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'filter';
     jimport('joomla.filesystem.folder');
     $ini_files = JFolder::files($ini_path, '\\.ini$');
     $filterArray = array();
     if (count($ini_files)) {
         foreach ($ini_files as $sourceINI) {
             $myData = JoomlapackHelperUtils::parse_ini_file($ini_path . DS . $sourceINI, true);
             foreach ($myData as $key => $value) {
                 $filterArray[$key] = $value;
             }
         }
     }
     // Walk through INI file entries and add them to the filter list
     foreach ($filterArray as $filter) {
         $this->addFilter('filter.' . $filter['include'], $filter['class']);
     }
 }
Пример #30
0
 function _setProfile()
 {
     // Set profile
     $profile = JRequest::getInt('profile', 1);
     if (!JPSPECIALEDITION) {
         $profile = 1;
     }
     if (!is_numeric($profile)) {
         $profile = 1;
     }
     $session =& JFactory::getSession();
     $session->set('profile', $profile, 'joomlapack');
     // Reload registry
     jpimport('models.registry', true);
     $registry =& JoomlapackModelRegistry::getInstance();
     $registry->reload();
 }