/** * Implements the init method of JoomlapackFilter * */ function init() { $configuration =& JoomlapackConfiguration::getInstance(); $this->_folderFilters = JoomlapackHelperFiltertable::getExclusionList($this->_filterClass); // Add output, temporary and installation directory to exclusion filters $this->_folderFilters[] = JoomlapackAbstraction::TranslateWinPath($configuration->get('OutputDirectory')); $this->_folderFilters[] = JoomlapackAbstraction::TranslateWinPath($configuration->get('TempDirectory')); $this->_folderFilters[] = JoomlapackAbstraction::TranslateWinPath(JPATH_SITE . DS . 'installation'); }
/** * Displays the HTML for this page * */ function echoHTML() { $nohtml = JoomlapackAbstraction::getParam('no_html', 0); if ($nohtml == 1) { JoomlapackLogger::VisualizeLogDirect(); } else { $configuration =& JoomlapackConfiguration::getInstance(); $option = JoomlapackAbstraction::getParam('option', 'com_joomlapack'); // Show top header echo JoomlapackCommonHTML::getAdminHeadingHTML(JoomlapackLangManager::_('LOG_LOGBANNER')); echo "<p><a href=\"index2.php?option={$option}&act=dllog&no_html=1\">" . JoomlapackLangManager::_('LOG_DOWNLOADTEXT') . "</a></p>"; echo '<iframe src="index2.php?option=' . $option . '&act=log&no_html=1" width="90%" height="400px">'; echo '</iframe>'; } }
/** * Initialises the archiver class, creating the archive from an existent * installer's JPA archive. * * @param string $sourceJPAPath Absolute path to an installer's JPA archive * @param string $targetArchivePath Absolute path to the generated archive * @param array $options A named key array of options (optional). This is currently not supported * @access public */ function initialize($sourceJPAPath, $targetArchivePath, $options = array()) { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerZIP :: initialize - archive {$targetArchivePath}"); // Get names of temporary files $configuration =& JoomlapackConfiguration::getInstance(); $this->_ctrlDirFileName = tempnam($configuration->get('TempDirectory'), 'jpzcd'); $this->_dataFileName = $targetArchivePath; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerZIP :: CntDir Tempfile = " . $this->_ctrlDirFileName); // Create temporary file touch($this->_ctrlDirFileName); // Try to kill the archive if it exists JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackPackerZIP :: Killing old archive"); $fp = fopen($this->_dataFileName, "wb"); if (!($fp === false)) { ftruncate($fp, 0); fclose($fp); } else { @unlink($this->_dataFileName); } touch($this->_dataFileName); // Seed the archive $this->transformJPA($sourceJPAPath); }
/** * Applies the SQL compatibility setting */ function _enforceSQLCompatibility() { $configuration = JoomlapackConfiguration::getInstance(); $db = $this->_getDB(); if ($this->hasError()) { return; } switch ($configuration->MySQLCompat) { case 'compat': $sql = "SET SESSION sql_mode='HIGH_NOT_PRECEDENCE,NO_TABLE_OPTIONS'"; break; default: $sql = "SET SESSION sql_mode=''"; break; } $db->setQuery($sql); $db->query(); }
function deleteTempFiles() { $configuration =& JoomlapackConfiguration::getInstance(); $tempFiles = JoomlapackTables::UnserializeVar('CUBETempFiles', array()); foreach ($tempFiles as $fileName) { $file = $configuration->get('TempDirectory') . DS . $fileName; if (file_exists($file)) { @unlink($file); } } JoomlapackTables::DeleteVar('CUBETempFiles'); }
/** * Displays an installer selection combobox * * @param string $strOption Selected installer's key */ function AltInstallerChooser($strOption) { $configuration =& JoomlapackConfiguration::getInstance(); $altInstallers = $configuration->AltInstaller->loadAllDefinitions(); if (!defined('_JEXEC')) { foreach ($altInstallers as $altInstaller) { $options[] = mosHTML::makeOption($altInstaller['meta'], $altInstaller['name']); } echo mosHTML::selectList($options, 'altInstaller', '', 'value', 'text', $strOption); } else { foreach ($altInstallers as $altInstaller) { $options[] = JHTML::_('select.option', $altInstaller['meta'], $altInstaller['name']); } echo JHTML::_('select.genericlist', $options, 'altInstaller', '', 'value', 'text', $strOption); } }
/** * Expands the archive's template name and returns an absolute path * * @param string $extension The extension to append, defaults to '.zip' * @return string The absolute filename of the archive file requested */ function getExpandedTarName($extension = '.zip') { $configuration =& JoomlapackConfiguration::getInstance(); // Get the proper extension $templateName = $configuration->get('TarNameTemplate'); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Archive template name: {$templateName}"); // Parse [DATE] tag $dateExpanded = strftime("%Y%m%d", time()); $templateName = str_replace("[DATE]", $dateExpanded, $templateName); // Parse [TIME] tag $timeExpanded = strftime("%H%M%S", time()); $templateName = str_replace("[TIME]", $timeExpanded, $templateName); // Parse [HOST] tag $templateName = str_replace("[HOST]", $_SERVER['SERVER_NAME'], $templateName); // Parse [RANDOM] tag $templateName = str_replace("[RANDOM]", md5(microtime()), $templateName); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Expanded template name: {$templateName}"); $path = $configuration->get('OutputDirectory') . DS . $templateName . $extension; JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Calculated archive absolute path: {$path}"); // What the hell was I thinking when I had put realpath($path) in here?!?!?! return JoomlapackAbstraction::TranslateWinPath($path); }
/** * Find where to store the backup files */ function _getBackupFilePaths() { $configuration = JoomlapackConfiguration::getInstance(); if ($this->_DBOnly) { // On DB Only backups we use different naming, no matter what's the setting JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, __CLASS__ . " :: Only dump database mode detected"); $this->_tempFile = JoomlapackAbstraction::getExpandedTarName('.sql'); $this->_saveAsName = ''; } else { if ($this->_dumpFile != '') { JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, __CLASS__ . " :: Forced filename using dumpFile found."); // If the dumpFile was set, forcibly use this value $this->_tempFile = JoomlapackCUBE::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, __CLASS__ . " :: Core database"); $this->_tempFile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $configuration->AltInstaller->BaseDump))); $this->_saveAsName = 'installation/sql/' . $configuration->AltInstaller->BaseDump; } else { // External databases, we use the database's name JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, __CLASS__ . " :: External database"); $this->_tempFile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $this->_database . '.sql'))); $this->_saveAsName = 'installation/sql/' . $this->_database . '.sql'; } } } // Get a temp file for mysqldump $this->_tempMSDfile = JoomlapackCUBE::registerTempFile(dechex(crc32(microtime() . $configuration->AltInstaller->BaseDump)) . 'msd'); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, __CLASS__ . " :: SQL temp file is " . $this->_tempFile); JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, __CLASS__ . " :: SQL file location in archive is " . $this->_saveAsName); }
/** * Check for authorized use of this file, or die with 'Access Denied' message * */ function _authenticate() { jpimport('classes.core.utility.configuration'); $JPConfiguration = JoomlapackConfiguration::getInstance(); // Check if the frontend backup option is enabled if (!$JPConfiguration->enableFrontend) { die(JoomlapackLangManager::_('FRONTEND_ACCESSDENIED')); } // Get key supplied in $_REQUEST $key1 = JoomlapackAbstraction::getParam('key', ''); $key2 = JoomlapackAbstraction::getParam('secret', ''); if ($key1 == '' && $key2 != '') { $this->key = $key2; } elseif ($key1 != '' && $key2 == '') { $this->key = $key1; } else { $this->key = ''; } // Compare keys if ($this->key != $JPConfiguration->secretWord) { die(JoomlapackLangManager::_('FRONTEND_ACCESSDENIED')); } // Check no_html (must be '1') $no_html = JoomlapackAbstraction::getParam('no_html', 0); if ($no_html != 1) { die(JoomlapackLangManager::_('FRONTEND_ACCESSDENIED')); } }
/** * @package JoomlaPack * @copyright Copyright (C) 2006-2008 JoomlaPack Developers. All rights reserved. * @version $Id$ * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @since 1.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. **/ // ensure this file is being included by a parent file - Joomla! 1.0.x and 1.5 compatible defined('_VALID_MOS') || defined('_JEXEC') or die('Direct Access to this location is not allowed.'); $config =& JoomlapackConfiguration::getInstance(); define('JPMaxFragmentSize', $config->get('mnMaxFragmentSize')); // Maximum bytes a fragment can have (default: 1Mb) define('JPMaxFragmentFiles', $config->get('mnMaxFragmentFiles')); // Maximum number of files a fragment can have (default: 50 files) /** * Packing engine. Takes care of putting gathered files (the file list) into * an archive. */ class JoomlapackDomainPack extends JoomlapackEngineParts { /** * @var array Directories to exclude */ var $_ExcludeDirs; /**
/** * Diplays a page suitable for performing a backup using AJAX calls to the * backup engine * * @access private */ function echoHTML_AJAX() { $configuration =& JoomlapackConfiguration::getInstance(); // Get translations $dompackdb = JoomlapackLangManager::_('PACK_DOMPACKDB'); $dompacking = JoomlapackLangManager::_('PACK_DOMPACKING'); // Show top header echo JoomlapackCommonHTML::getAdminHeadingHTML(JoomlapackLangManager::_('CPANEL_PACK')); echo $this->_renderJavaScript(); ?> <div id="Main"> <div id="Welcome" class="sitePack"> <p><?php echo JoomlapackLangManager::_('PACK_PROMPT'); ?> </p> <div onclick="do_Start( 0 );" class="jpbutton"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('full'); ?> " border="0" /> <p><?php echo JoomlapackLangManager::_('PACK_BUTTON'); ?> </p> </div> <div onclick="do_Start( 1 );" class="jpbutton"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('db'); ?> " border="0" /> <p><?php echo JoomlapackLangManager::_('PACK_BUTTON2'); ?> </p> </div> </div> <div id="Init" style="display:none;" class="sitePack"> <table class="stepstable" align="center"> <thead> <tr> <th width="16"></th> <th></th> </tr> </thead> <tbody> <tr id="domDB"> <td id="picDB"></td> <td><?php echo JoomlapackLangManager::_('PACK_DOMPACKDB'); ?> </td> </tr> <tr id="domPacking"> <td id="picPacking"></td> <td><?php echo JoomlapackLangManager::_('PACK_DOMPACKING'); ?> </td> </tr> <tr id="domFinished"> <td id="picFinished"></td> <td><?php echo JoomlapackLangManager::_('PACK_FINISHED'); ?> </td> </tr> </tbody> </table> <div id="Warnings" class="sitePack" style="display: none;"> <h4><?php echo JoomlapackLangManager::_('PACK_WARNINGSHEAD'); ?> </h4> <div id="WarningsContents"> </div> </div> <div id="Status"> <p id="JPStep"></p> <p id="JPSubstep"></p> </div> <div id="AllDone" style="display:none;"> <p> </p> <table border="0" cellspacing="4px;" cellpadding="0"> <tr> <td width="32"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('ok_big'); ?> " border="0" /> </td> <td> <h4><?php echo JoomlapackLangManager::_('PACK_FINISHED'); ?> </h4> <p><?php echo JoomlapackLangManager::_('PACK_FINISHEDTEXT'); ?> </p> </td> </tr> </table> <a href="<?php echo JoomlapackAbstraction::JPLink('backupadmin'); ?> "> <div class="jpbutton"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('bufa'); ?> " border="0" /> <p><?php echo JoomlapackLangManager::_('CPANEL_BUADMIN'); ?> </p> </div> </a> </div> <div id="Timeout" style="display:none; margin-top: 10px;" class="sitePack"> <table border="0" width="100%"> <tr> <td valign="top"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('error_big'); ?> " border="0" /> </td> <td> <h4><?php echo JoomlapackLangManager::_('PACK_TIMEOUTTITLE'); ?> </h4> <p><?php echo JoomlapackLangManager::_('PACK_TIMEOUT'); ?> </p> <p id="JoomlapackErrorMessage" style="display: none"> </p> </td> </tr> <tr> <td> </td> <td> <a href="<?php echo JoomlapackAbstraction::JPLink('log'); ?> "> <div class="jpbutton"> <img src="<?php echo JoomlapackCommonHTML::getImageURI('log'); ?> " border="0" /> <p><?php echo JoomlapackLangManager::_('CPANEL_LOG'); ?> </p> </div> </a> </td> </tr> </table> </div> </div> <div id="Debug"> </div> </div> <?php }
function _echoFix() { $jpconfiguration =& JoomlapackConfiguration::getInstance(); $db = JoomlapackAbstraction::getDatabase(); echo JoomlapackCommonHTML::getAdminHeadingHTML(JoomlapackLangManager::_('CPANEL_CONFIGMIGRATE')); // Catch the "nothing to do" case if ($jpconfiguration->get('siteRoot') == JPATH_SITE) { echo JoomlapackLangManager::_('CONFIGMIGRATE_NOFIXREQUIRED'); return; } // Sometimes, it is possible that the siteRoot configuration value is not set // (e.g. manually upgrading from an older version, keeping the config xml file). // This will fix it if (is_null($jpconfiguration->get('siteRoot'))) { echo JoomlapackLangManager::_('CONFIGMIGRATE_NOROOTSTORED'); $jpconfiguration->set('siteRoot', JPATH_SITE); $jpconfiguration->SaveConfiguration(); return; } // A genuine case of site location mismatch. Let's take a look at it. $oldPath = JoomlapackAbstraction::TranslateWinPath($jpconfiguration->get('siteRoot')); $newPath = JoomlapackAbstraction::TranslateWinPath(JPATH_SITE); $sql = 'SELECT * FROM ' . $db->nameQuote('#__jp_exclusion'); $db->setQuery($sql); $temparray = $db->loadAssocList(); foreach ($temparray as $row) { $value = $row['value']; if (strstr($value, $oldPath)) { $value = str_replace($oldPath, $newPath, $value); $sql = 'UPDATE ' . $db->nameQuote('#__jp_exclusion') . ' SET ' . $db->nameQuote('value') . ' = ' . $db->Quote($value) . ' WHERE ' . $db->nameQuote('id') . ' = ' . $db->Quote($row['id']); $db->setQuery($sql); $db->query(); } } echo JoomlapackLangManager::_('CONFIGMIGRATE_FIXED'); }
/** * Deletes the file specified in $filename. Meant to be used in AJAX calls. * * @param string $filename Relative filename to delete * @return boolean True if delete was succesfull, false otherwise */ function deleteBackup($filename) { $configuration =& JoomlapackConfiguration::getInstance(); // Check for blank filename if (is_null($filename)) { return false; } // Make sure the filename is OK and get absolute path to file $filename = stripslashes($filename); $filename = realpath($configuration->get('OutputDirectory') . DS . $filename); // Test for nonexistent file if ($filename === FALSE) { return false; } // Test the suffix of the file (the last four letters) to make sure this // function is not being exploited by Mallory, Oscar and their gang :) $suffix = strtolower(substr($filename, -4)); if (in_array($suffix, $this->filePatterns)) { if (file_exists($filename)) { @unlink($filename); } return true; } else { return false; } }
/** * Calculates the absolute path to the log file */ function logName() { $configuration =& JoomlapackConfiguration::getInstance(); return JoomlapackAbstraction::TranslateWinPath($configuration->get('OutputDirectory') . DS . "joomlapack.log"); }
/** * Renders the JoomlaPack's overview tabbed pane */ function _getTabsHTML() { // Get some status information $config =& JoomlapackConfiguration::getInstance(); $this->_isOutWritable = $config->isOutputWriteable(); $this->_isTempWritable = $config->isTempWriteable(); $this->_isStatusGood = $this->_isOutWritable && $this->_isTempWritable; $this->_defaultDirs = realpath($config->OutputDirectory) == realpath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup') || realpath($config->TempDirectory) == realpath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'backup'); if (defined('_JEXEC')) { jimport('joomla.html.pane'); $tabs =& JPane::getInstance('sliders'); echo $tabs->startPane('jpstatuspane'); } else { $tabs = new mosTabs(1); $tabs->startPane('jpstatuspane'); } if (defined('_JEXEC')) { echo $tabs->startPanel(JoomlapackLangManager::_('MAIN_OVERVIEW'), 'jpstatusov'); } else { $tabs->startTab(JoomlapackLangManager::_('MAIN_OVERVIEW'), 'jpstatusov'); } echo '<p class="sanityCheck">' . JoomlapackLangManager::_('MAIN_STATUS') . ': '; echo JoomlapackCommonHTML::colorizeWriteStatus($this->_isStatusGood, true, 'appgood', 'appnotgood', 'main') . '</p>'; // --- START --- Detect use of default temp directory if ($this->_defaultDirs) { echo '<p class="sanityCheck">' . JoomlapackLangManager::_('MAIN_WARNING') . '<br/>'; echo '<a href="http://www.joomlapack.net/index.php?option=com_content&id=75">' . JoomlapackLangManager::_('MAIN_WARNING_INFO') . '</a></p>'; } // --- END --- if (defined('_JEXEC')) { echo $tabs->endPanel(); echo $tabs->startPanel(JoomlapackLangManager::_('MAIN_DETAILS'), 'jpstatusdet'); } else { $tabs->endTab(); $tabs->startTab(JoomlapackLangManager::_('MAIN_DETAILS'), 'jpstatusdet'); } // Populate side panel $item = JoomlapackLangManager::_('MAIN_ITEM'); $status = JoomlapackLangManager::_('MAIN_STATUS'); $tempDir = JoomlapackLangManager::_('COMMON_TEMPDIR'); $tempStatus = JoomlapackCommonHTML::colorizeWriteStatus($this->_isTempWritable, true); $outDir = JoomlapackLangManager::_('COMMON_OUTDIR'); $outStatus = JoomlapackCommonHTML::colorizeWriteStatus($this->_isOutWritable, true); $verCheckTitle = JoomlapackLangManager::_('COMMON_VERSION_CHECK'); $verHTML = $this->checkAppStatusV(strstr(_JP_VERSION, 'SVN') ? 0 : 1); echo <<<ENDSNIPPET \t\t\t<table align="center" border="1" cellspacing="0" cellpadding="5" class="adminlist"> \t\t\t\t<thead> \t\t\t\t\t<tr> \t\t\t\t\t\t<th class="title">{$item}</th> \t\t\t\t\t\t<th>{$status}</th> \t\t\t\t\t</tr> \t\t\t\t</thead> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$tempDir}</td> \t\t\t\t\t\t<td>{$tempStatus}</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$outDir}</td> \t\t\t\t\t\t<td>{$outStatus}</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$verCheckTitle}</td> \t\t\t\t\t\t<td>{$verHTML}</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> ENDSNIPPET; if (defined('_JEXEC')) { echo $tabs->endPanel(); echo $tabs->startPanel(JoomlapackLangManager::_('MAIN_TRANSLATIONCREDITS'), 'jptranscredits'); } else { $tabs->endTab(); $tabs->startTab(JoomlapackLangManager::_('MAIN_TRANSLATIONCREDITS'), 'jptranscredits'); } $translationlanglabel = JoomlapackLangManager::_('MAIN_TRANSLATIONLANG'); $translationlang = JoomlapackLangManager::_('INFO_LANGUAGE'); $translationverlabel = JoomlapackLangManager::_('MAIN_TRANSLATIONVER'); $translationver = JoomlapackLangManager::_('INFO_JPVER'); $translationauthorlabel = JoomlapackLangManager::_('MAIN_TRANSLATIONAUTHOR'); $translationauthor = JoomlapackLangManager::_('INFO_AUTHOR'); $trasnlationurllabel = JoomlapackLangManager::_('MAIN_TRANSLATIONURL'); $trasnlationurl = JoomlapackLangManager::_('INFO_AUTHORURL'); echo <<<ENDSNIPPET \t\t\t<table align="center" border="1" cellspacing="0" cellpadding="5" class="adminlist"> \t\t\t\t<thead> \t\t\t\t\t<tr> \t\t\t\t\t\t<th class="title">{$item}</th> \t\t\t\t\t\t<th>{$status}</th> \t\t\t\t\t</tr> \t\t\t\t</thead> \t\t\t\t<tbody> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$translationlanglabel}</td> \t\t\t\t\t\t<td>{$translationlang}</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$translationverlabel}</td> \t\t\t\t\t\t<td>{$translationver}</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$translationauthorlabel}</td> \t\t\t\t\t\t<td>{$translationauthor}</td> \t\t\t\t\t</tr> \t\t\t\t\t<tr> \t\t\t\t\t\t<td>{$trasnlationurllabel}</td> \t\t\t\t\t\t<td>{$trasnlationurl}</td> \t\t\t\t\t</tr> \t\t\t\t</tbody> \t\t\t</table> ENDSNIPPET; if (defined('_JEXEC')) { echo $tabs->endPanel(); echo $tabs->endPane(); } else { $tabs->endTab(); $tabs->endPane(); } }
break; case "ajax": jpimport('helpers.ajaxtool'); break; case "test": jpackScreens::fDebug(); break; case "log": jpackScreens::fLog(); if (JoomlapackAbstraction::getParam('no_html', 0) == 1) { $skipFooter = true; } break; case "dllog": // Option to download raw log $JPConfiguration = JoomlapackConfiguration::getInstance(); @ob_end_clean(); // In case some braindead mambot spits its own HTML despite no_html=1 header('Content-type: text/plain'); header('Content-Disposition: attachment; filename="joomlapacklog.txt"'); @readfile(JoomlapackAbstraction::TranslateWinPath($JPConfiguration->get('OutputDirectory') . DS . 'joomlapack.log')); $skipFooter = true; break; case "unlock": jpackScreens::fUnlock(); break; case "multidb": jpackScreens::fMultiDB(); break; case "sff": jpackScreens::fFileExclusion();