inc-admin.php3 inc-cache.php3 inc-calcul.php3 inc-public-global.php3 spip_cache.php3 spip_image.php3 spip_test_dirs.php3 1.40 1.59 1.116 1.152 1.15 1.101 1.22 1.41 1.60 1.117 1.153 1.16 1.102 1.23

Update of /home/spip-cvs/spip
In directory alan:/tmp/cvs-serv26964

Modified Files:
  inc-admin.php3 inc-cache.php3 inc-calcul.php3
  inc-public-global.php3 spip_cache.php3 spip_image.php3
  spip_test_dirs.php3
Log Message:
redefinition possible des repertoires accessibles en ecriture

Index: spip_cache.php3

RCS file: /home/spip-cvs/spip/spip_cache.php3,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- spip_cache.php3 22 Aug 2004 21:03:04 -0000 1.15
+++ spip_cache.php3 10 Oct 2004 07:02:33 -0000 1.16
@@ -7,18 +7,13 @@
include_local("inc-cache.php3");

if ($purger_cache == "oui") {
- if (verifier_action_auteur("purger_cache", $hash, $id_auteur)) {
- spip_log('vider le cache');
- include_ecrire('inc_invalideur.php3');
- supprime_invalideurs();
- purger_repertoire('CACHE', 0);
- }
+ if (verifier_action_auteur("purger_cache", $hash, $id_auteur))
+ purger_cache();
}

if ($purger_squelettes == "oui") {
   if (verifier_action_auteur("purger_squelettes", $hash, $id_auteur))
- spip_log('effacer les squelettes compiles');
- purger_repertoire('CACHE', 0, '^skel_');
+ purger_squelettes();
}

@header ("Location: ./ecrire/" . $redirect);

Index: inc-cache.php3

RCS file: /home/spip-cvs/spip/inc-cache.php3,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- inc-cache.php3 8 Oct 2004 13:01:52 -0000 1.59
+++ inc-cache.php3 10 Oct 2004 07:02:33 -0000 1.60
@@ -21,7 +21,7 @@
//
// Le format souhaite : "CACHE/a/(8400/)bout-d-url.md5(.gz)"
// Attention a modifier simultanement le sanity check de
-// la fonction retire_cache() dans ecrire/inc_invalideur.php3
+// la fonction retire_cache()
//
function generer_nom_fichier_cache($contexte='', $fond='') {
   global $delais;
@@ -55,17 +55,70 @@
   $fichier_cache .= '.'.substr($md_cache, 1, 8);

   // Sous-repertoires 0...9a..f/
- $subdir = creer_repertoire('CACHE', substr($md_cache, 0, 1));
+ $subdir = creer_repertoire(_DIR_CACHE, substr($md_cache, 0, 1));
   // Sous-sous-repertoires delais/ (inutile avec l'invalidation par 't')
   # $subdir2 = creer_repertoire("CACHE/$subdir", $delais);

- verifier_htaccess('CACHE');
+ verifier_htaccess(_DIR_CACHE);

   $gzip = $flag_gz && $compresser_cache ? '.gz' : '';

- return 'CACHE/' . $subdir.$subdir2.$fichier_cache.$gzip;
+ return _DIR_CACHE . $subdir.$subdir2.$fichier_cache.$gzip;
+}
+
+//
+// Destruction des fichiers caches invalides
+//
+// NE PAS appeler ces fonctions depuis l'espace prive
+// car openbase_dir peut leur interdire l'acces au repertoire de cache
+
+// Securite : est sur que c'est un cache
+function retire_cache($cache) {
+ if ($GLOBALS['flag_ecrire']) return;
+ # spip_log("kill $cache ?");
+ if (preg_match('|^' . _DIR_CACHE .
+ "([0-9a-f]/)?([0-9]+/)?[^.][\-_\%0-9a-z]+\.[0-9a-f]+(\.gz)?$|i",
+ $cache)) {
+ // supprimer le fichier (de facon propre)
+ supprimer_fichier($cache);
+ // et le fichier compagnon s'il existe
+ @unlink($cache.'.NEW');
+ } else
+ spip_log("Impossible de retirer $cache");
}

+// Supprimer les caches marques "x"
+function retire_caches($chemin_prioritaire = '') {
+ if ($GLOBALS['flag_ecrire']) return;
+
+ // inutile de ramer si tout est invalide, on n'est pas tout seul
+ $max = 30;
+ // mais recuperer en priorite notre chemin
+ if ($chemin_prioritaire)
+ $order = "ORDER BY fichier != '$chemin_prioritaire'";
+
+ // faire le boulot de suppression
+ $q = spip_query("SELECT DISTINCT fichier FROM spip_caches
+ WHERE type='x' $order LIMIT 0,$max");
+ if ($n = @spip_num_rows($q)) {
+ spip_log ("Retire $n caches");
+ while (list($cache) = spip_fetch_array($q)) {
+ retire_cache($cache);
+ $supprimes[] = "'$cache'";
+ }
+ spip_query("DELETE FROM spip_caches WHERE "
+ .calcul_mysql_in('fichier', join(',',$supprimes)) );
+ }
+
+ // marque comme fait
+ if (count($supprimes) < $max) {
+ effacer_meta('invalider');
+ ecrire_metas();
+ } else {
+ ecrire_meta('invalider', 'oui');
+ ecrire_metas();
+ }
+}

//
// Doit-on recalculer le cache ?
@@ -119,6 +172,20 @@
   closedir($handle);
}

+function purger_cache()
+{
+ spip_log('vider le cache');
+ include_ecrire('inc_invalideur.php3');
+ supprime_invalideurs();
+ purger_repertoire(_DIR_CACHE, 0);
+}
+
+function purger_squelettes()
+{
+ spip_log('effacer les squelettes compiles');
+ purger_repertoire(_DIR_CACHE, 0, '^skel_');
+}
+

// Determination du fichier cache (si besoin)
function determiner_cache($delais, &$use_cache, &$chemin_cache) {

Index: spip_image.php3

RCS file: /home/spip-cvs/spip/spip_image.php3,v
retrieving revision 1.101
retrieving revision 1.102
diff -u -d -r1.101 -r1.102
--- spip_image.php3 8 Oct 2004 19:34:29 -0000 1.101
+++ spip_image.php3 10 Oct 2004 07:02:33 -0000 1.102
@@ -223,7 +223,7 @@
     $type = decoder_type_image($size[2], true);

     if ($type) deplacer_fichier_upload($source,
- _DIR_IMG . $dest . ".$type");
+ _DIR_DOC . $dest . ".$type");
   }
}

Index: inc-calcul.php3

RCS file: /home/spip-cvs/spip/inc-calcul.php3,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- inc-calcul.php3 25 Sep 2004 16:52:37 -0000 1.116
+++ inc-calcul.php3 10 Oct 2004 07:02:33 -0000 1.117
@@ -62,7 +62,7 @@
   if (function_exists($nom))
     return $nom;

- $phpfile = 'CACHE/skel_' . $nom . '.php';
+ $phpfile = _DIR_CACHE . 'skel_' . $nom . '.php';

   // le squelette est-il deja compile et perenne ?
   if (!squelette_obsolete($phpfile, $sourcefile)

Index: spip_test_dirs.php3

RCS file: /home/spip-cvs/spip/spip_test_dirs.php3,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- spip_test_dirs.php3 18 Sep 2004 14:30:09 -0000 1.22
+++ spip_test_dirs.php3 10 Oct 2004 07:02:33 -0000 1.23
@@ -21,17 +21,16 @@
}

//
-// teste les droits sur les repertoires
+// teste les droits sur les repertoires $test_dirs declares dans inc_version
//

-$install = !@file_exists("ecrire/inc_connect.php3");
+// rajouter celui passer dans l'url ou celui du source (a l'installation)

if ($test_dir)
   $test_dirs[] = $test_dir;
else {
- $test_dirs = array("CACHE", "IMG", "ecrire/data");
- if ($install)
- $test_dirs[] = "ecrire";
+ if (!_FILE_CONNECT)
+ $test_dirs[] = _DIR_RESTREINT;
}

unset($bad_dirs);
@@ -57,7 +56,7 @@
if ($bad_dirs OR $absent_dirs) {
   install_debut_html();

- if ($install) {
+ if (!_FILE_CONNECT) {
     $titre = _T('dirs_preliminaire');
     $continuer = ' '._T('dirs_commencer');
   } else
@@ -94,7 +93,7 @@
   install_fin_html();

} else {
- if ($install)
+ if (!_FILE_CONNECT)
     header("Location: ./ecrire/install.php3?etape=1");
   else
     header("Location: ./ecrire/");

Index: inc-admin.php3

RCS file: /home/spip-cvs/spip/inc-admin.php3,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- inc-admin.php3 4 Oct 2004 21:39:08 -0000 1.40
+++ inc-admin.php3 10 Oct 2004 07:02:33 -0000 1.41
@@ -161,12 +161,12 @@
// avec son code d'erreur
//
function erreur_requete_boucle($query, $id_boucle, $type) {
- global $auteur_session, $HTTP_COOKIE_VARS, $dir_ecrire;
+
   include_ecrire("inc_presentation.php3");

   // Calmer le jeu avec MySQL (si jamais on est en saturation)
- @touch($dir_ecrire.'data/mysql_out'); // pour spip_cron
- @touch($dir_ecrire.'data/lock'); // lock hebergeur
+ @touch(_FILE_MYSQL_OUT); // pour spip_cron
+ @touch(_FILE_LOCK); // lock hebergeur
   spip_log('Erreur MySQL: on limite les acces quelques minutes');
   $GLOBALS['bouton_admin_debug'] = true;

Index: inc-public-global.php3

RCS file: /home/spip-cvs/spip/inc-public-global.php3,v
retrieving revision 1.152
retrieving revision 1.153
diff -u -d -r1.152 -r1.153
--- inc-public-global.php3 8 Oct 2004 13:01:52 -0000 1.152
+++ inc-public-global.php3 10 Oct 2004 07:02:33 -0000 1.153
@@ -126,7 +126,6 @@

   // Faut-il effacer des pages invalidees ?
   if (lire_meta('invalider')) {
- include_ecrire('inc_invalideur.php3');
     include_ecrire('inc_meta.php3');
     lire_metas();
     if (lire_meta('invalider'))
@@ -288,13 +287,13 @@
// (on mettra 30 s quand on aura prevu la preemption par une image-cron)
function taches_de_fond() {
   
- verifier_htaccess('ecrire/data');
- if (!@file_exists('ecrire/data/cron.lock')
- OR (time() - @filemtime('ecrire/data/cron.lock') > 5)) {
+ verifier_htaccess(_DIR_SESSIONS);
+ if (!@file_exists(_FILE_CRON_LOCK)
+ OR (time() - @filemtime(_FILE_CRON_LOCK) > 5)) {

     // Si MySQL est out, laisser souffler
- if (!@file_exists('ecrire/data/mysql_out')
- OR (time() - @filemtime('ecrire/data/mysql_out') > 300)) {
+ if (!@file_exists(_FILE_MYSQL_OUT)
+ OR (time() - @filemtime(_FILE_MYSQL_OUT) > 300)) {
# spip_log("cron");
       include_ecrire('inc_cron.php3');