Example #1
0
    function processUpdate()
    {
        global $option, $mainframe;
        $allow_url_fopen = ini_get('allow_url_fopen');
        if (!$allow_url_fopen) {
            echo '<p class="yaml_msg">allow_url_fopen on PHP is disabled on your host. Please make a manual Update.</p>';
            $mainframe->close();
        } else {
            $data = JYAML::getVersionInfo(true);
            $version = $data['i-j-version'] . '-' . $data['i-j-build'];
            /* Update URL */
            $url = JYAML::getDownloadURL('updater') . '?version=' . rawurlencode($version) . '&full=1';
            $updateFiles = file_get_contents($url);
            $files = $this->getUpdateFiles($updateFiles);
        }
        $config =& JFactory::getConfig();
        $tmp_path = $config->getValue('config.tmp_path');
        jimport('joomla.filesystem.archive');
        $dataold = JYAML::getVersionInfo(true);
        /* Full Update */
        if (isset($files['full'])) {
            $extractPath = $tmp_path . DS . 'jyaml_update';
            $filename = basename($files['full']);
            /* Delete temp folder and create empty */
            if (JFolder::exists($extractPath)) {
                JFolder::delete($extractPath);
                JFolder::create($extractPath);
            }
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            $content = file_get_contents($files['full']);
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            if (!JFile::write($tmp_path . DS . $filename, $content)) {
                echo '<p class="off">' . JText::_('YAML CANT EXTRACT SAVE UPDATE FILE IN TMP') . '</p>';
            }
            if (!JArchive::extract($tmp_path . DS . $filename, $extractPath)) {
                echo '<p class="off">' . JText::_('YAML CANT EXTRACT UPDATE FILE') . '</p>';
            }
            // Call update script if available
            $update_script = $extractPath . DS . 'jyaml_update_script.php';
            if (JFile::exists($update_script)) {
                include_once $update_script;
                $update_result = new jyamlUpdateScript();
                // Delete update script
                JFile::delete($update_script);
                if (!$update_result) {
                    echo '<p class="off">' . JText::_('YAML RUN UPDATE SCRIPT FAIL') . '</p>';
                }
            }
            $files = array();
            $files = JFolder::files($extractPath, '.', true, true);
            $error_folders = array();
            $error_files = array();
            foreach ($files as $file) {
                $file_relative = str_replace($extractPath . DS, '', $file);
                $dest = JPATH_ROOT . DS . $file_relative;
                if (!JFolder::exists(dirname($dest))) {
                    if (!JFolder::create(dirname($dest))) {
                        $error_folders[] = dirname($dest);
                    }
                }
                if (!JFile::copy($file, $dest)) {
                    $error_files[] = DS . $file_relative;
                }
            }
            if ($error_folders) {
                echo '<p class="off">' . JText::_('YAML CANT CREATE DIRECTORY') . '</p>';
                echo '<ul>';
                foreach ($error_folders as $ef) {
                    echo '<li>' . $ef . '</li>';
                }
                echo '</ul>';
            }
            if ($error_files) {
                echo '<p class="off">' . JText::_('YAML CANT UPDATE-CREATE FILE') . '</p>';
                echo '<ul>';
                foreach ($error_files as $ef) {
                    echo '<li>' . $ef . '</li>';
                }
                echo '</ul>';
            }
            if (!$error_folders && !$error_files) {
                echo '<h2 class="on" style="text-align:center;">' . JText::_('YAML UPDATE SUCCESSFULLY') . '</h2>';
            }
            /* Delete temp file and folder */
            if (JFolder::exists($extractPath)) {
                JFolder::delete($extractPath);
            }
            if (JFile::exists($tmp_path . DS . $filename)) {
                JFile::delete($tmp_path . DS . $filename);
            }
            $data = JYAML::getVersionInfo(true);
            echo '<hr />';
            echo '<p class="off" style="font-weight:normal;">' . JText::_('YAML UPDATE OLD VERSION') . ': ' . $dataold['i-j-version'] . ' Build: ' . $dataold['i-j-build'] . '<p>';
            echo '<p class="on" style="font-weight:bold;">' . JText::_('YAML UPDATE NEW VERSION') . ': ' . $data['i-j-version'] . ' Build: ' . $data['i-j-build'] . '<p>';
            echo '<hr />';
            ?>
      <fieldset>
          <div align="center">
            <button onclick="window.parent.location.replace('index.php?option=<?php 
            echo $option;
            ?>
');" type="button"><?php 
            echo JText::_('YAML CLOSE UPDATE WINDOW');
            ?>
</button>
          </div>
      </fieldset>
      <?php 
        }
        $mainframe->close();
    }
Example #2
0
?>
</span>
      </div>
      <div class="content"><?php 
echo JYAML::viewExtHTMLFiles();
?>
</div>
    </div>
    
    <div class="designbox">         
      <div class="legend"><?php 
echo JText::_('YAML VERSION TITLE');
?>
</div>
      <div class="content"><?php 
echo JYAML::getVersionInfo();
?>
</div>
    </div>
    
    <div class="designbox">         
      <div class="legend"><?php 
echo JText::_('YAML TITLE SUPPORT');
?>
</div>
      <div class="content">  
        <ul>
          <li><a href="http://www.jyaml.de" target="_blank">YAML Joomla! Template</a></li>
          <li><a href="http://forum.yaml.de/index.php?board=11.0" target="_blank">Support Forum</a></li>
        </ul>
        <ul>