$params =& JComponentHelper::getParams('com_jupdateman');
if (!$params->get('cached_update', 0)) {
    $result = downloadFile($url, $file_path);
    if (is_object($result)) {
        HTML_jupgrader::showError('Download Failed: ' . $result->message . '(' . $result->number . ')</p>');
        return false;
    }
} else {
    if (!file_exists($file_path)) {
        HTML_jupgrader::showError('File does not exist and running in cached mode. Upload the update file. <a href="' . $details->url . '" target="_blank">Download file here.</a> <br /><a href="index.php?option=com_jupdateman&task=step2">Reload Page.</a>');
        return false;
    }
}
if (strlen($md5)) {
    if (md5_file($file_path) != $md5) {
        HTML_jupgrader::showError('Error: MD5 checksum does not match! Delete and redownload file.');
        return false;
    }
} else {
    echo '<p>Warning: This file does not have an MD5 hash to validate!</p>';
}
$session->set('jupdateman_filename', $file);
?>
<p>The file '<?php 
echo $file;
?>
' has been downloaded from <a href="<?php 
echo $url;
?>
" target="_blank"><?php 
echo $url;
            HTML_jupgrader::showError('Failed to extract archive!');
            return false;
        }
        break;
    case JUPDATEMAN_EXTRACTOR_15:
        jimport('joomla.filesystem.archive');
        if (!JArchive::extract($filename, JPATH_SITE)) {
            HTML_jupgrader::showError('Failed to extract archive!');
            return false;
        }
        break;
    case JUPDATEMAN_EXTRACTOR_PEAR:
        jimport('pear.archive_tar.Archive_Tar');
        $extractor = new Archive_Tar($filename);
        if (!$extractor->extract(JPATH_SITE)) {
            HTML_jupgrader::showError('Failed to extract archive!');
            return false;
        }
        break;
}
$installation = JPATH_SITE . DS . 'installation';
if (is_dir($installation)) {
    JFolder::delete($installation);
}
$cached_update = $params->get('cached_update', 0);
// delete the left overs unless cached update
if (!$cached_update) {
    if (is_file($filename)) {
        JFile::delete($filename);
    }
    $upgrade_xml = $tmp_path . DS . 'jupgrader.xml';
}
$rootattributes = $root->attributes();
$latest = $rootattributes['release'];
if ($latest == $version) {
    echo "<p>No updates were found. <a href='index.php?option=com_jupdateman&task=step2&target=full'>Force full update &gt;&gt;&gt;</a></p><br /><br /><p>Please check again later or watch <a href='http://www.joomla.org' target='_blank'>www.joomla.org</a></p>";
    echo '</div>';
    return true;
} elseif (version_compare($latest, $version, '<')) {
    echo "<p>You are running a greater version of Joomla! than what is available for download.</p><br /><br />";
    echo "<p>Please check <a href='http://www.joomla.org' target='_blank'>www.joomla.org</a> for release information.</p>";
    echo '</div>';
    return true;
}
$updater = $root->getElementByPath('updater', 1);
if (!$updater) {
    HTML_jupgrader::showError('Failed to get updater element. Possible invalid update!');
    return false;
}
$updater_attributes = $updater->attributes();
$session =& JFactory::getSession();
$session->set('jupdateman_updateurl', $updater->data());
if (version_compare($updater_attributes['minimumversion'], getComponentVersion(), '>')) {
    echo '<p>Current updater version is lower than minimum version for this update.</p>';
    echo '<p>Please update this extension. This can be attempted automatically or you can download the update and install it yourself.</p>';
    echo '<ul>';
    echo '<li><a href="index.php?option=com_jupdateman&task=autoupdate">Automatically update &gt;&gt;&gt;</a></li>';
    echo '<li><a target="_blank" href="' . $updater->data() . '">Download package and install manually (new window) &gt;&gt;&gt;</a></li>';
    echo '</ul>';
    return false;
}
if (version_compare($updater_attributes['currentversion'], getComponentVersion(), '>')) {