コード例 #1
0
ファイル: mise_a_jour.php プロジェクト: rhertzog/lcs
function info_maj ($dir, $file, $version){
	include_spip('inc/plugin');
	
	list($maj,$min,$rev) = preg_split('/\D+/', $version);

	$nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
	$page = !file_exists($nom) ? '' : file_get_contents($nom);
	$page = info_maj_cache($nom, $dir, $page);

	// reperer toutes les versions de numero majeur superieur ou egal
	// (a revoir quand on arrivera a SPIP V10 ...)
	$p = substr("0123456789", intval($maj));
	$p = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i';
	preg_match_all($p, $page, $m,  PREG_SET_ORDER);
	$page = '';
	foreach ($m as $v) {
		list(, $maj2, $min2,, $rev2) = $v;
		$version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
		if ((spip_version_compare($version, $version_maj, '<'))
		AND (spip_version_compare($page, $version_maj, '<')))
			$page = $version_maj;
	}

	if (!$page) return "";

	return $page;
}
コード例 #2
0
ファイル: mise_a_jour.php プロジェクト: nursit/SPIP
function info_maj($dir, $file, $version)
{
    include_spip('inc/plugin');
    list($maj, $min, $rev) = preg_split('/\\D+/', $version);
    $nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
    $page = !file_exists($nom) ? '' : file_get_contents($nom);
    $page = info_maj_cache($nom, $dir, $page);
    // reperer toutes les versions de numero majeur superieur ou egal
    // (a revoir quand on arrivera a SPIP V10 ...)
    $p = substr("0123456789", intval($maj));
    $p = ',/' . $file . '\\D+([' . $p . ']+)\\D+(\\d+)(\\D+(\\d+))?.*?[.]zip",i';
    preg_match_all($p, $page, $m, PREG_SET_ORDER);
    $page = '';
    foreach ($m as $v) {
        list(, $maj2, $min2, , $rev2) = $v;
        $version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
        if (spip_version_compare($version, $version_maj, '<') and spip_version_compare($page, $version_maj, '<')) {
            $page = $version_maj;
        }
    }
    if (!$page) {
        return "";
    }
    return "<a class='info_maj_spip' href='" . _VERSIONS_SERVEUR . "{$dir}' title='{$page}'>" . _T('nouvelle_version_spip', array('version' => $page)) . '</a>';
}
コード例 #3
0
	function info_maj_spip(){
		if (!autoriser('webmestre')) return "";
		// derniere version de SPIP
		$maj = $GLOBALS['meta']['info_maj_spip'];
		if (!$maj) return "";
		$maj = explode('|',$maj);
		// c'est une ancienne notif, on a fait la maj depuis !
		if ($GLOBALS['spip_version_branche']!==array_shift($maj)) {
			// compat_maj_spip(true);
			return "";
		}
		// derniere version de SPIP 2.?.?
		$maj = implode('|',$maj);
		if (strncmp($maj,"<a",2)==0) $maj = extraire_attribut ($maj, 'title');
		$lien = "http://www.spip.net/".$GLOBALS['spip_lang']."_download";
		$maj = _T('couteau:maj_rev_ok',array('revision'=>$maj, 'url'=>$lien, 'zip'=>''));
		// derniere version de SPIP 2.0.?
		include_spip('lib/maj_auto/distant_mise_a_jour');
		if(function_exists('info_maj_cache')) {
			list(,,$rev) = preg_split('/\D+/', $GLOBALS['spip_version_branche']);
			$nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
			$page = info_maj_cache($nom, 'spip', !file_exists($nom) ? '' : file_get_contents($nom));
			preg_match_all(',/SPIP\D+2\D+0(\D+(\d+))?.*?[.]zip",i', $page, $m,  PREG_SET_ORDER);
			$page=0;
			foreach ($m as $v) if ($v[2]>$rev && $v[2]>$page) $page = $v[2];
			if($page) {
				$lien = "http://files.spip.org/spip/archives/SPIP-v2-0-$page.zip"; // 'http://files.spip.org/spip/archives/#SPIP-v2-0-'.$page;
				$maj = _T('couteau:maj_rev_ok',array('revision'=>'2.0.'.$page, 'url'=>$lien, 'zip'=>'')) . '<br/>' . $maj;
			}
		}
		// liens morts
		return preg_replace(',\[([^[]+)->\],', '$1', $maj);
	}
コード例 #4
0
/**
 * Vérifier si une nouvelle version de SPIP est disponible
 *
 * Repérer aussi si cette version est une version majeure de SPIP.
 *
 * @param string $dir
 * @param string $file
 * @param string $version
 *      La version reçue ici est sous la forme x.y.z
 *      On la transforme par la suite pour avoir des integer ($maj, $min, $rev)
 *      et ainsi pouvoir mieux les comparer
 *
 * @return string
 */
function info_maj($dir, $file, $version)
{
    include_spip('inc/plugin');
    list($maj, $min, $rev) = preg_split('/\\D+/', $version);
    $nom = _DIR_CACHE_XML . _VERSIONS_LISTE;
    $page = !file_exists($nom) ? '' : file_get_contents($nom);
    $page = info_maj_cache($nom, $dir, $page);
    // reperer toutes les versions de numero majeur superieur ou egal
    // (a revoir quand on arrivera a SPIP V10 ...)
    $p = substr("0123456789", intval($maj));
    $p = ',/' . $file . '\\D+([' . $p . ']+)\\D+(\\d+)(\\D+(\\d+))?.*?[.]zip",i';
    preg_match_all($p, $page, $m, PREG_SET_ORDER);
    $page = $page_majeure = '';
    // branche en cours d'utilisation
    $branche = implode('.', array_slice(explode('.', $version, 3), 0, 2));
    foreach ($m as $v) {
        list(, $maj2, $min2, , $rev2) = $v;
        $branche_maj = $maj2 . '.' . $min2;
        $version_maj = $maj2 . '.' . $min2 . '.' . $rev2;
        // d'abord les mises à jour de la même branche
        if (spip_version_compare($version, $version_maj, '<') and spip_version_compare($page, $version_maj, '<') and spip_version_compare($branche, $branche_maj, '=')) {
            $page = $version_maj;
        }
        // puis les mises à jours majeures
        if (spip_version_compare($version, $version_maj, '<') and spip_version_compare($page, $version_maj, '<') and spip_version_compare($branche, $branche_maj, '<')) {
            $page_majeure = $version_maj;
        }
    }
    if (!$page and !$page_majeure) {
        return "";
    }
    $message = $page ? _T('nouvelle_version_spip', array('version' => $page)) . ($page_majeure ? ' | ' : '') : '';
    $message .= $page_majeure ? _T('nouvelle_version_spip_majeure', array('version' => $page_majeure)) : '';
    return "<a class='info_maj_spip' href='http://www.spip.net/fr_update' title='{$page}'>" . $message . '</a>';
}