Skip to content
Extraits de code Groupes Projets
Valider 54a71b3d rédigé par cerdic's avatar cerdic
Parcourir les fichiers

Report de [15440] [15441] [15442]

parent 1ab1aa0c
Branches
Étiquettes
Aucune requête de fusion associée trouvée
......@@ -199,6 +199,7 @@ ecrire/exec/upgrade.php -text
ecrire/exec/valider_xml.php -text
ecrire/exec/virtualiser.php -text
ecrire/genie/maintenance.php -text
ecrire/genie/mise_a_jour.php -text
ecrire/genie/syndic.php -text
ecrire/inc/actions.php -text
ecrire/inc/afficher_objets.php -text
......
<?php
/***************************************************************************\
* SPIP, Systeme de publication pour l'internet *
* *
* Copyright (c) 2001-2010 *
* Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
* Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
if (!defined("_ECRIRE_INC_VERSION")) return;
/**
* Verifier si une mise a jour est disponible
*
* @param int $t
* @return int
*/
function genie_mise_a_jour_dist($t) {
include_spip('inc/meta');
$maj = info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche']);
ecrire_meta('info_maj_spip',$maj?($GLOBALS['spip_version_branche']."|$maj"):"",'non');
spip_log("Verification version SPIP : ".($maj?$maj:"version a jour"),"verifie_maj");
return 1;
}
// Determiner si une nouvelle version de SPIP est disponible
// sans demander tout le temps au serveur de versions si leur liste a change'.
define('_VERSIONS_SERVEUR', 'http://files.spip.org/');
define('_VERSIONS_LISTE', 'archives.xml');
function info_maj ($dir, $file, $version){
list($maj,$min,$rev) = preg_split('/\D+/', $version);
# list($maj,$min,$rev) = preg_split('/\D+/', '1.9.2i'); # pour test
# list($maj,$min,$rev) = preg_split('/\D+/', '2.0.8'); # pour test
$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;
if (($maj2 > $maj)
OR (($maj2 == $maj)
AND (($min2 > $min)
OR (($min2 == $min)
AND ($rev2 > $rev))))) {
$page .= $maj2 . '.' . $min2 . '.' . $rev2 . ' ';
}
}
if (!$page) return "";
return "<a class='info_maj_spip' href='$dir' title='$page'>" .
_T('nouvelles_versions') .
'</a>';
}
// Verifie que la liste $page des versions dans le fichier $nom est a jour
// Ce fichier rajoute dans ce fichier l'alea ephemere courant;
// on teste la nouveaute par If-Modified-Since,
// et seulement quand celui-ci a change' pour limiter les acces HTTP
function info_maj_cache($nom, $dir, $page='')
{
$re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">';
if (preg_match("/$re/", $page)) return $page;
$url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE;
$a = file_exists($nom) ? filemtime($nom) : '';
include_spip('inc/distant');
$res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a);
// Si rien de neuf (ou inaccessible), garder l'ancienne
if ($res) list(, $page) = $res;
// Placer l'indicateur de fraicheur
$page = preg_replace('/^<archives.*?>/', $re, $page);
sous_repertoire(_DIR_CACHE_XML);
ecrire_fichier($nom, $page);
return $page;
}
?>
\ No newline at end of file
......@@ -123,6 +123,9 @@ function taches_generales($taches_generales = array()) {
// maintenance (ajax, verifications diverses)
$taches_generales['maintenance'] = 3600 * 2;
// verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
$taches_generales['mise_a_jour'] = 3*24*3600;
return pipeline('taches_generales_cron',$taches_generales);
}
......
......@@ -17,7 +17,7 @@ function inc_log_dist($message, $logname=NULL, $logdir=NULL, $logsuf=NULL) {
static $compteur = array();
global $nombre_de_logs, $taille_des_logs;
if (is_null($logname))
if (is_null($logname) OR !is_string($logname))
$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
if (!isset($compteur[$logname])) $compteur[$logname] = 0;
if ($logname != 'maj'
......
......@@ -338,7 +338,7 @@ function fin_page()
. "</a></div>")
: ("<div id='copyright'>"
. info_maj ('spip', 'SPIP', $GLOBALS['spip_version_branche'])
. info_maj_spip()
. info_copyright()
. "<br />"
. _T('info_copyright_doc',
......@@ -358,6 +358,26 @@ function fin_page()
. "</body></html>\n";
}
function info_maj_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']!==reset($maj))
return "";
if (!autoriser('webmestre'))
return "";
array_shift($maj);
$maj = implode('|',$maj);
return "<br />$maj</br>";
}
// http://doc.spip.org/@info_copyright
function info_copyright() {
global $spip_version_affichee, $spip_lang;
......@@ -387,43 +407,6 @@ function info_copyright() {
}
define('_VERSIONS_SERVEUR', 'http://files.spip.org/');
define('_VERSIONS_LISTE', 'archives.xml');
function info_maj ($dir, $file, $version)
{
if (!autoriser('webmestre')) return '';
list($maj,$min,$rev) = preg_split('/\D+/', $version);
# list($maj,$min,$rev) = preg_split('/\D+/', '1.9.2i'); # pour test
include_spip('inc/distant');
$dir = _VERSIONS_SERVEUR . $dir . '/';
$liste = $dir . _VERSIONS_LISTE;
if (!$page = copie_locale($liste, 'modif')) return '';
$page = file_get_contents(_DIR_RACINE . $page);
// reperer toutes les versions de numero majeur superieur ou egal
// (a revoir quand on arrivera a SPIP V10 ...)
$p = substr("0123456789", intval($maj));
$re = ',/' . $file . '\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?.*?[.]zip",i';
preg_match_all($re, $page, $m, PREG_SET_ORDER);
$new = '';
foreach ($m as $v) {
list(, $maj2, $min2,, $rev2) = $v;
if (($maj2 > $maj)
OR (($maj2 == $maj)
AND (($min2 > $min)
OR (($min2 == $min)
AND ($rev2 > $rev))))) {
$new = $v[0];
break;
}
}
if (!$new) return "";
return "<br /><a style='color: red' href='$dir'>" .
_L('De nouvelles_versions_de_SPIP_sont_disponibles') .
'</a><br />';
}
// http://doc.spip.org/@debloquer_article
function debloquer_article($arg, $texte) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter