예제 #1
0
 /**
  * Modifies a filter
  *
  * @param string $root Folder where the file exists
  * @param string $file The file for which the filter is about
  * @param mixed $checked If set to on, yes or checked then the filter is activated, otherwise deactivated
  */
 function modifyFilter($root, $file, $checked)
 {
     $value = JoomlapackAbstraction::TranslateWinPath($root . "/" . $file);
     if ($checked == "on" || $checked == "yes" || $checked == "checked") {
         // Enable the filter
         JoomlapackHelperFiltertable::addExclusionFilter($this->_filterClass, $value);
     } else {
         // Disable the filter
         JoomlapackHelperFiltertable::deleteExclusionFilter($this->_filterClass, $value);
     }
 }
예제 #2
0
 /**
  * Removes the $p_remove_dir from $p_filename, while prepending it with $p_add_dir.
  * Largely based on code from the pclZip library.
  * @access private
  */
 function _addRemovePaths($p_filename, $p_remove_dir, $p_add_dir)
 {
     $p_filename = JoomlapackAbstraction::TranslateWinPath($p_filename);
     $p_remove_dir = $p_remove_dir == '' ? '' : JoomlapackAbstraction::TranslateWinPath($p_remove_dir);
     //should fix corrupt backups, fix by nicholas
     if (!($p_remove_dir == "")) {
         if (substr($p_remove_dir, -1) != '/') {
             $p_remove_dir .= "/";
         }
         if (substr($p_filename, 0, 2) == "./" || substr($p_remove_dir, 0, 2) == "./") {
             if (substr($p_filename, 0, 2) == "./" && substr($p_remove_dir, 0, 2) != "./") {
                 $p_remove_dir = "./" . $p_remove_dir;
             }
             if (substr($p_filename, 0, 2) != "./" && substr($p_remove_dir, 0, 2) == "./") {
                 $p_remove_dir = substr($p_remove_dir, 2);
             }
         }
         $v_compare = $this->_PathInclusion($p_remove_dir, $p_filename);
         if ($v_compare > 0) {
             if ($v_compare == 2) {
                 $v_stored_filename = "";
             } else {
                 $v_stored_filename = substr($p_filename, strlen($p_remove_dir));
             }
         }
     } else {
         $v_stored_filename = $p_filename;
     }
     if (!($p_add_dir == "")) {
         if (substr($p_add_dir, -1) == "/") {
             $v_stored_filename = $p_add_dir . $v_stored_filename;
         } else {
             $v_stored_filename = $p_add_dir . "/" . $v_stored_filename;
         }
     }
     return $v_stored_filename;
 }
예제 #3
0
 function _getDirContents_opendir($dirName, $shellFilter = null)
 {
     $handle = @opendir($dirName);
     // If directory is not accessible, just return FALSE
     if ($handle === FALSE) {
         $this->setWarning('Unreadable directory ' . $dirName);
         $false = false;
         return $false;
     }
     // Initialize return array
     $retArray = array();
     // FIX 1.2.1 -- Remove trailing slash
     if (substr($dirName, -1, 1) == '/' || substr($dirName, -1, 1) == '\\') {
         $dirName = substr($dirName, 0, strlen($dirName) - 1);
     }
     while (!(($filename = readdir($handle)) === false)) {
         $match = is_null($shellFilter);
         $match = !$match ? fnmatch($shellFilter, $filename) : true;
         if ($match) {
             $filename = JoomlapackAbstraction::TranslateWinPath($dirName . DIRECTORY_SEPARATOR . $filename);
             $retArray[] = $filename;
         }
     }
     @closedir($handle);
     return $retArray;
 }
예제 #4
0
    function getFileSelectionHTML($root)
    {
        // Import usefull JoomlaPack classes
        jpimport('classes.filter.sff');
        jpimport('helpers.lang');
        jpimport('classes.core.utility.filtermanager');
        // Cleanup the root folder we were passed
        $root = realpath($root);
        // Get some translation strings
        $lang_dir = JoomlapackLangManager::_('SFF_DIR');
        $lang_excluded = JoomlapackLangManager::_('SFF_EXCLUDE');
        $lang_file = JoomlapackLangManager::_('SFF_FILE');
        // Scan folder for files
        $sff = new JoomlapackFilterSFF();
        $scanResult = $sff->getDirectory($root);
        // Get the directories filters; we're not going to allow the user to enter excluded folders :)
        $filterManager = new JoomlapackFilterManager();
        $filterManager->init();
        // Produce the output
        $out = <<<END
\t\t\t<h4>{$root}</h4>
\t\t\t<table border="0" cellspacing="10">
\t\t\t\t<tr>
\t\t\t\t\t<td valign="top">
\t\t\t\t\t\t<!-- Directory Selection -->
\t\t\t\t\t\t<table class="adminlist">
\t\t\t\t\t\t\t<thead>
\t\t\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t\t\t<th>{$lang_dir}</th>
\t\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t</thead>
\t\t\t\t\t\t\t<tbody>
END;
        $dirFilters = $filterManager->getFilters('folder');
        foreach ($scanResult['folders'] as $folder) {
            if (is_array($dirFilters)) {
                $wholefolder = JoomlapackAbstraction::TranslateWinPath($root . DIRECTORY_SEPARATOR . $folder);
                $showLink = !in_array($wholefolder, $dirFilters);
            } else {
                $showLink = true;
            }
            $out .= "\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td>\n";
            if ($showLink) {
                $out .= "<a href=\"javascript:dirSelectionHTML('" . JoomlapackAbstraction::TranslateWinPath($root . DIRECTORY_SEPARATOR . $folder) . "');\">" . htmlentities($folder) . "</a>";
            } else {
                $out .= htmlentities($folder);
            }
            $out .= "\t\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t\t</tr>\n";
        }
        $out .= <<<END
\t\t\t\t\t\t\t</tbody>
\t\t\t\t\t\t</table>
\t\t\t\t\t</td>
\t\t\t\t\t<td valign="top">
\t\t\t\t\t\t<!-- File Selection -->
\t\t\t\t\t\t<table class="adminlist">
\t\t\t\t\t\t\t<thead>
\t\t\t\t\t\t\t\t<tr>
\t\t\t\t\t\t\t\t\t<th>{$lang_excluded}</th>
\t\t\t\t\t\t\t\t\t<th>{$lang_file}</th>
\t\t\t\t\t\t\t\t</tr>
\t\t\t\t\t\t\t</thead>
\t\t\t\t\t\t\t<tbody>
END;
        $id = 0;
        foreach ($scanResult['files'] as $file => $excluded) {
            $id++;
            $checked = $excluded ? " checked = \"true\" " : "";
            $out .= "\n<tr><td align=\"center\">";
            $out .= "<input type=\"checkbox\" {$checked} onclick=\"ToggleFilter('" . JoomlapackAbstraction::TranslateWinPath($root) . "', '{$file}','sff-{$id}');\" id=\"sff-{$id}\">";
            $out .= "</td><td align=\"left\">";
            $out .= htmlentities($file);
            $out .= "</td></tr>";
        }
        $out .= <<<END
\t\t\t\t\t\t\t</tbody>
\t\t\t\t\t\t</table>
\t\t\t\t\t</td>
\t\t\t\t</tr>
\t\t\t</table>
END;
        return $out;
    }
 /**
  * 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);
 }
예제 #6
0
 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');
 }
예제 #7
0
 /**
  * Calculates the absolute path to the log file
  */
 function logName()
 {
     $configuration =& JoomlapackConfiguration::getInstance();
     return JoomlapackAbstraction::TranslateWinPath($configuration->get('OutputDirectory') . DS . "joomlapack.log");
 }
예제 #8
0
    function getDirSelectionHTML($root)
    {
        jpimport('classes.filter.def');
        jpimport('helpers.lang');
        $root = realpath($root);
        $out = <<<END
\t\t\t<h4>{$root}</h4>
\t\t\t<table class="adminlist">
\t\t\t\t<tr>
\t\t\t\t\t<th align="left" width="50">
END;
        $out .= JoomlapackLangManager::_('DEF_EXCLUDE') . "\n" . "</th><th class=\"title\">" . JoomlapackLangManager::_('DEF_DIRECTORY') . "</th></tr>";
        $def = new JoomlapackFilterDEF();
        $def->init();
        $dirs = $def->getDirectory($root);
        $id = 0;
        foreach ($dirs as $dir => $excluded) {
            $id++;
            $checked = $excluded ? " checked = \"true\" " : "";
            $nocheck = $dir == "." || $dir == "..";
            $out .= "\n<tr><td align=\"center\">";
            if (!$nocheck) {
                $out .= "<input type=\"checkbox\" {$checked} onclick=\"ToggleFilter('" . JoomlapackAbstraction::TranslateWinPath($root) . "', '{$dir}','def-{$id}');\" id=\"def-{$id}\">";
            } else {
                $out .= "&nbsp;";
            }
            $out .= "</td><td align=\"left\">";
            if ($excluded) {
                $out .= htmlentities($dir);
            } else {
                $out .= "<a href=\"javascript:dirSelectionHTML('" . JoomlapackAbstraction::TranslateWinPath($root . DIRECTORY_SEPARATOR . $dir) . "');\">" . htmlentities($dir) . "</a>";
            }
            $out .= "</td></tr>";
        }
        $out .= "\n</table>";
        return $out;
    }
예제 #9
0
     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();
     break;
 case "configmigrate":
     if ($task == 'export') {
         $skipFooter = true;
     }