コード例 #1
0
ファイル: pack.php プロジェクト: rlee1962/diylegalcenter
 /**
  * Implements the _prepare() abstract method
  *
  */
 function _prepare()
 {
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Starting _prepare()");
     $cube =& JoomlapackCUBE::getInstance();
     // Grab the EFF filters
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting off-site directory inclusion filters (EFF)");
     jpimport('models.eff', true);
     $effModel = new JoomlapackModelEff();
     $this->_extraDirs =& $effModel->getMapping();
     // Add the mapping text file if there are EFFs defined!
     if (count($this->_extraDirs) > 0) {
         // We add a README.txt file in our virtual directory...
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating README.txt in the EFF virtual folder");
         $virtualContents = JText::_('EFF_MAPTEXT_INTRO') . "\n\n";
         foreach ($this->_extraDirs as $dir) {
             $virtualContents .= JText::sprintf('EFF_MAPTEXT_LINE', $dir['vdir'], $dir['fsdir']) . "\n";
         }
         // Add the file to our archive
         $registry =& JoomlapackModelRegistry::getInstance();
         $provisioning =& $cube->getProvisioning();
         $archiver =& $provisioning->getArchiverEngine();
         $archiver->addVirtualFile('README.txt', $registry->get('effvfolder'), $virtualContents);
     }
     // Get the directory exclusion filters - this only needs to be done once
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting exclusion filters");
     $this->_loadAndCacheFilters();
     if ($this->getError()) {
         return false;
     }
     // FIX 1.1.0 $mosConfig_absolute_path may contain trailing slashes or backslashes incompatible with exclusion filters
     // FIX 1.2.2 Some hosts yield an empty string on realpath(JPATH_SITE)
     // FIX 2.2 On Windows, realpath might fail
     jpimport('helpers.utils', true);
     // FIX 2.4: Make an assumption (wild guess...)
     if (JPATH_BASE == '/administrator') {
         $cube->addWarning("Your site's root is an empty string. I am trying a workaround.");
         $jpath_site_real = '/';
     } else {
         // Fix 2.4: Make sure that $jpath_site_real contains something even if realpath fails
         $jpath_site_real = @realpath(trim(JPATH_SITE));
         $jpath_site_real = $jpath_site_real === false ? trim(JPATH_SITE) : $jpath_site_real;
         $jpath_site_real = JoomlapackHelperUtils::TranslateWinPath($jpath_site_real);
     }
     if ($jpath_site_real == '') {
         // The JPATH_SITE is resolved to an empty string; attempt a workaround
         // Windows hosts
         if (DIRECTORY_SEPARATOR == '\\') {
             if (trim(JPATH_SITE) != '' && trim(JPATH_SITE) != '\\' && trim(JPATH_SITE) != '/') {
                 $cube->addWarning("The site's root couldn't be normalized on a Windows host. Attempting workaround (filters might not work)");
                 $jpath_site_real = JPATH_SITE;
                 // Forcibly use the configured JPATH_SITE
             } else {
                 $cube->addWarning("The normalized path to your site's root seems to be an empty string; I will attempt a workaround (Windows host)");
                 $jpath_site_real = '/';
                 // Start scanning from filesystem root (workaround mode)
             }
         } else {
             $cube->addWarning("The normalized path to your site's root seems to be an empty string; I will attempt a workaround (*NIX host)");
             # Fix 2.1 Since JPATH_SITE is an empty string, shouldn't I begin scanning from the FS root, for crying out loud? What was I thinking putting JPATH_SITE there?
             $jpath_site_real = '/';
             // Start scanning from filesystem root (workaround mode)
         }
     }
     // Fix 2.4.b1 : Add the trailing slash
     if (substr($jpath_site_real, -1) != '/' && !empty($jpath_site_real)) {
         $jpath_site_real .= '/';
     }
     $this->_directoryList[] = $jpath_site_real;
     // Start scanning from Joomla! root, as decided above
     $this->_doneScanning = false;
     // Instruct the class to scan for files and directories
     $this->_doneSubdirectoryScanning = true;
     $this->_doneFileScanning = true;
     $this->_addPath = '';
     // No added path for main site
     // Fix 2.4.b1 -- Since JPATH_SITE might have been post-processed, used the post-processed variable instead
     $this->_removePath = $jpath_site_real;
     // Remove absolute path to site's root for main site
     $this->setState('prepared');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: prepared");
 }
コード例 #2
0
ファイル: pack.php プロジェクト: jnvilo/tomasinasanctuary.org
 /**
  * Implements the _prepare() abstract method
  *
  */
 function _prepare()
 {
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Starting _prepare()");
     // Grab the EFF filters
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting off-site directory inclusion filters (EFF)");
     jpimport('models.eff', true);
     $effModel = new JoomlapackModelEff();
     $this->_extraDirs =& $effModel->getMapping();
     // Add the mapping text file if there are EFFs defined!
     if (count($this->_extraDirs) > 0) {
         // We add a README.txt file in our virtual directory...
         JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "Creating README.txt in the EFF virtual folder");
         $virtualContents = JText::_('EFF_MAPTEXT_INTRO') . "\n\n";
         foreach ($this->_extraDirs as $dir) {
             $virtualContents .= JText::sprintf('EFF_MAPTEXT_LINE', $dir['vdir'], $dir['fsdir']) . "\n";
         }
         // Add the file to our archive
         $registry =& JoomlapackModelRegistry::getInstance();
         $cube =& JoomlapackCUBE::getInstance();
         $provisioning =& $cube->getProvisioning();
         $archiver =& $provisioning->getArchiverEngine();
         $archiver->addVirtualFile('README.txt', $registry->get('effvfolder'), $virtualContents);
     }
     // Get the directory exclusion filters - this only needs to be done once
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: Getting exclusion filters");
     $this->_loadAndCacheFilters();
     if ($this->getError()) {
         return false;
     }
     // FIX 1.1.0 $mosConfig_absolute_path may contain trailing slashes or backslashes incompatible with exclusion filters
     // FIX 1.2.2 Some hosts yield an empty string on realpath(JPATH_SITE)
     // FIX 2.2 On Windows, realpath might fail
     if (trim(realpath(JPATH_SITE)) == '' || trim(JPATH_SITE) == '') {
         if (DIRECTORY_SEPARATOR == '\\') {
             if (trim(JPATH_SITE) != '' && trim(JPATH_SITE) != '\\' && trim(JPATH_SITE) != '/') {
                 JoomlapackLogger::WriteLog(_JP_LOG_WARNING, "The site's root couldn't be normalized on a Windows host. Attempting workaround (filters might not work)");
                 $this->_directoryList[] = JPATH_SITE;
                 // Forcibly use the configured JPATH_SITE
             } else {
                 JoomlapackLogger::WriteLog(_JP_LOG_WARNING, "The normalized path to your site's root seems to be an empty string; I will attempt a workaround (Windows host)");
                 $this->_directoryList[] = '/';
                 // Start scanning from filesystem root (workaround mode)
             }
         }
         JoomlapackLogger::WriteLog(_JP_LOG_WARNING, "The normalized path to your site's root seems to be an empty string; I will attempt a workaround (*NIX host)");
         # Fix 2.1 Since JPATH_SITE is an empty string, shouldn't I begin scanning from the FS root, for crying out loud? What was I thinking putting JPATH_SITE there?
         $this->_directoryList[] = '/';
         // Start scanning from filesystem root (workaround mode)
     } else {
         $this->_directoryList[] = realpath(JPATH_SITE);
         // Start scanning from Joomla! root (normal mode)
     }
     $this->_doneScanning = false;
     // Instruct the class to scan for files and directories
     $this->_doneSubdirectoryScanning = true;
     $this->_doneFileScanning = true;
     $this->_addPath = '';
     // No added path for main site
     $this->_removePath = JPATH_SITE;
     // Remove absolute path to site's root for main site
     $this->setState('prepared');
     JoomlapackLogger::WriteLog(_JP_LOG_DEBUG, "JoomlapackCUBEDomainPack :: prepared");
 }