Beispiel #1
0
<?php

defined('_JEXEC') or defined('_VALID_MOS') or die('Restricted Access');
/**
 * Website: www.jtips.com.au
 * @author Jeremy Roberts
 * @copyright Copyright &copy; 2009, jTips
 * @license Commercial - See website for details
 * 
 * @since 2.1 - 16/10/2008
 * @version 2.1.1
 * @package jTips
 * 
 * Description: Performs the background upgrade.
 */
require_once 'components/com_jtips/utils/update.php';
$result = updatejTipsFiles();
if (is_bool($result)) {
    //BUG 233 - have json encode the boolean/integer result
    die(json_encode(intval($result)));
} else {
    die($result);
}
Beispiel #2
0
/**
 * Automatically check for the latest version and if it is newer, upgrade
 *
 * @return bool True on success, false otherwise
 */
function autoUpgrade()
{
    global $jTips;
    $returnVal = false;
    if ($jTips['AutoUpgrade'] == 1) {
        if (getLastUpdateCheckDate() < gmdate('Y-m-d H:i:s', strtotime("-2 weeks"))) {
            $latestVersion = getLatestVersion();
            $latestVersionArray = explode('.', $latestVersion);
            $thisVersion = getFullVersion();
            $thisVersionArray = explode('.', $thisVersion);
            if (count($thisVersionArray) != count($latestVersionArray)) {
                jTipsLogger::_log('incompatible versions!', 'ERROR');
                $returnVal = false;
            } else {
                $doUpgrade = false;
                jTipsLogger::_log('comparing this version against latest version');
                for ($i = 0; $i < count($thisVersionArray); $i++) {
                    if ($latestVersionArray[$i] > $thisVersionArray[$i]) {
                        $doUpgrade = true;
                    }
                }
                if ($doUpgrade) {
                    jTipsLogger::_log('about to do auto upgrade');
                    $result = updatejTipsFiles();
                    if (is_bool($result)) {
                        //BUG 262 - AutoUpgrade to version message corrected
                        $_SESSION['jtips_upgraded_version'] = $latestVersion;
                        $returnVal = intval($result);
                    } else {
                        $returnVal = $result;
                    }
                }
            }
        }
        setLastUpdateCheckDate();
        return $returnVal;
    }
    return false;
}