inc.php3 inc_auth.php3 inc_lang.php3 inc_version.php3 install.php3 1.89 1.62 1.125 1.396 1.66 1.90 1.63 1.126 1.397 1.67

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

Modified Files:
  inc.php3 inc_auth.php3 inc_lang.php3 inc_version.php3
  install.php3
Log Message:
abstraction des répertoires d'installation

Index: inc_lang.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_lang.php3,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- inc_lang.php3 22 Oct 2004 21:58:01 -0000 1.125
+++ inc_lang.php3 29 Oct 2004 16:57:45 -0000 1.126
@@ -44,23 +44,23 @@
// Charger un fichier langue
//
function charger_langue($lang, $module = 'spip', $forcer = false) {
- global $dir_ecrire, $flag_ecrire;

   $fichier_lang = 'lang/'.$module.'_'.$lang.'.php3';
- $fichier_lang_exists = @file_exists($dir_ecrire.$fichier_lang);
+ $fichier_lang_exists = @is_readable(_DIR_RESTREINT . $fichier_lang);

- // chercher dans le fichier cache ?
- if (!$flag_ecrire AND $fichier_lang_exists) {
- if (!$forcer AND @file_exists(_DIR_CACHE . 'lang_'.$module.'_'.$lang.'.php3')
- AND (@filemtime(_DIR_CACHE . 'lang_'.$module.'_'.$lang.'.php3') > @filemtime('ecrire/lang/'.$module.'_'.$lang.'.php3'))
- AND (@filemtime(_DIR_CACHE . 'lang_'.$module.'_'.$lang.'.php3') > @filemtime('ecrire/lang/perso.php3'))) {
+ if (_DIR_RESTREINT AND $fichier_lang_exists) {
+ $ficher_cache = _DIR_CACHE . 'lang_'.$module.'_'.$lang.'.php3';
+ $fichier_cache_time = is_readable($fichier_cache) ? filemtime($ficher_cache) : false;
+
+ if (!$forcer AND $ficher_cache_time
+ AND ($ficher_cache_time > filemtime(_DIR_LANG .$module.'_'.$lang.'.php3'))
+ AND ($ficher_cache_time > @filemtime(_DIR_LANG . 'perso.php3'))) {
       $GLOBALS['idx_lang'] = 'i18n_'.$module.'_'.$lang;
- if (lire_fichier(_DIR_CACHE . 'lang_'.$module.'_'.$lang.'.php3',
- $contenu, array('phpcheck' => 'oui'))) {
+ if (lire_fichier($ficher_cache, $contenu, array('phpcheck' => 'oui'))) {
         eval ('?'.'>'.$contenu);
         return;
       }
- }
+ }
     else $GLOBALS['cache_lang_modifs'][$module][$lang] = true;
   }

@@ -72,7 +72,7 @@
     // le francais, qui *par definition* doit exister, et on copie le
     // tableau 'fr' dans la var liee a la langue
     $fichier_lang = 'lang/'.$module.'_fr.php3';
- if (@file_exists($dir_ecrire.$fichier_lang)) {
+ if (@is_readable(_DIR_RESTREINT . $fichier_lang)) {
       $GLOBALS['idx_lang']='i18n_'.$module.'_fr';
       include_ecrire ($fichier_lang);
     }
@@ -80,8 +80,8 @@
   }

   // surcharge perso
- if (@file_exists($dir_ecrire.'lang/perso.php3')) {
- include($dir_ecrire.'lang/perso.php3');
+ if (@is_readable(_DIR_LANG .'perso.php3')) {
+ include(_DIR_LANG .'perso.php3');
   }

}
@@ -90,7 +90,7 @@
// Changer la langue courante
//
function changer_langue($lang) {
- global $all_langs, $spip_lang_rtl, $spip_lang_right, $spip_lang_left, $spip_lang_dir, $spip_dir_lang, $flag_ecrire;
+ global $all_langs, $spip_lang_rtl, $spip_lang_right, $spip_lang_left, $spip_lang_dir, $spip_dir_lang;

   $liste_langues = $all_langs.','.lire_meta('langues_multilingue');

Index: inc_auth.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_auth.php3,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- inc_auth.php3 29 Oct 2004 07:01:26 -0000 1.62
+++ inc_auth.php3 29 Oct 2004 16:57:45 -0000 1.63
@@ -8,7 +8,6 @@
include_ecrire ("inc_meta.php3"); // amorce la connexion MySQL
include_ecrire ("inc_session.php3");

-
//
// Fonctions de gestion de l'acces restreint aux rubriques
//
@@ -111,6 +110,7 @@

   // Si pas authentifie, demander login / mdp
   if (!$auth_login) {
+ spip_log("redirection AUTH " . _DIR_PREFIX1 . $clean_link->getUrl());
     $url = str_replace('/./', '/', _DIR_RESTREINT_ABS .$clean_link->getUrl());
     redirige_par_entete("../spip_login.php3?var_url=".urlencode($url));
   }

Index: inc.php3

RCS file: /home/spip-cvs/spip/ecrire/inc.php3,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -d -r1.89 -r1.90
--- inc.php3 23 Oct 2004 15:28:06 -0000 1.89
+++ inc.php3 29 Oct 2004 16:57:45 -0000 1.90
@@ -1,20 +1,8 @@
<?php
-# pour empecher l'acces aux sites non installes.
-# A ameliorer pour le multi-site
-
-if (!defined('_FILE_CONNECT'))
- define('_FILE_CONNECT',
- (@file_exists("inc_connect.php3") ? "inc_connect.php3" : ''));
-
-if (!_FILE_CONNECT) {
- header("Location: install.php3");
-}

if (!defined('_ECRIRE_INC_VERSION')) { include ("inc_version.php3"); }
-// SPIP est-il installe ?
-
+spip_log("version lue " . _DIR_PREFIX1);
include_ecrire("inc_auth.php3");
-
include_ecrire("inc_presentation.php3");
include_ecrire("inc_texte.php3");
include_ecrire("inc_filtres.php3");

Index: install.php3

RCS file: /home/spip-cvs/spip/ecrire/install.php3,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- install.php3 24 Oct 2004 16:22:27 -0000 1.66
+++ install.php3 29 Oct 2004 16:57:45 -0000 1.67
@@ -1,7 +1,8 @@
<?php
+if (defined("_ECRIRE_INSTALL")) return;
+define("_ECRIRE_INSTALL", "1");

include ("inc_version.php3");
-
include_ecrire ("inc_presentation.php3");

utiliser_langue_visiteur();
@@ -15,9 +16,7 @@
}

include_ecrire ("inc_base.php3");
-
define('_FILE_TMP', '_install');
-
//
// Etapes de l'installation standard
//
@@ -361,6 +360,7 @@
}
else if (!$etape) {
   $menu_langues = menu_langues('var_lang_ecrire');
+
   if (!$menu_langues)
     redirige_par_entete("../spip_test_dirs.php3");
   else {

Index: inc_version.php3

RCS file: /home/spip-cvs/spip/ecrire/inc_version.php3,v
retrieving revision 1.396
retrieving revision 1.397
diff -u -d -r1.396 -r1.397
--- inc_version.php3 28 Oct 2004 22:30:05 -0000 1.396
+++ inc_version.php3 29 Oct 2004 16:57:45 -0000 1.397
@@ -5,8 +5,47 @@
if (defined("_ECRIRE_INC_VERSION")) return;
define("_ECRIRE_INC_VERSION", "1");

-function define_once ($constant, $valeur) {
- if (!defined($constant)) define($constant, $valeur);
+// 6 constantes incontournables et prioritaires
+
+define('_EXTENSION_PHP', '.php3'); # a etendre
+define('_DIR_RESTREINT_ABS', 'ecrire/');
+define('_DIR_RESTREINT',
+ (!@is_dir(_DIR_RESTREINT_ABS) ? "" : _DIR_RESTREINT_ABS));
+
+if ($d = ($GLOBALS['HTTP_GET_VARS']['var_install']))
+ {
+ $d = substr($d,0,strrpos($d,'/')+1);
+ if (!ereg('^(.*)' . _DIR_RESTREINT_ABS . '$', $d))
+ $d .= _DIR_RESTREINT_ABS;
+ if (!@file_exists($d . 'mes_options.php3'))
+ { header("Location: install.php3?var_install=$d");
+ exit;}
+ define('_FILE_OPTIONS', $d . 'mes_options.php3');
+ define('_FILE_CONNECT_INS', ($d . "inc_connect"));
+ } else {
+ define('_FILE_OPTIONS', 'mes_options.php3');
+ define('_FILE_CONNECT_INS', (_DIR_RESTREINT . "inc_connect"));
+ }
+
+define_once('_FILE_CONNECT',
+ (@file_exists(_FILE_CONNECT_INS . _EXTENSION_PHP) ?
+ (_FILE_CONNECT_INS . _EXTENSION_PHP)
+ : false));
+
+# Si Spip n'est pas installe, redirection... sauf si justement on l'installe!
+
+if (!(_FILE_CONNECT OR defined('_ECRIRE_INSTALL') OR defined('_TEST_DIRS'))) {
+ if (!defined("_INC_PUBLIC"))
+ header("Location: install.php3");
+ else
+ {
+ $db_ok = 0;
+ include_ecrire ("inc_presentation.php3");
+ install_debut_html(_T('info_travaux_titre'));
+ echo "<P>"._T('info_travaux_texte')."</P>";
+ install_fin_html();
+ exit;
+ }
}

// *********** traiter les variables ************
@@ -198,56 +237,28 @@
// Masquer les warning
error_reporting(E_ALL ^ E_NOTICE);

-// le repértoire des images
-
/* ATTENTION CETTE VARIABLE NE FONCTIONNE PAS ENCORE */
// Extension du fichier du squelette
$extension_squelette = 'html';
/* / MERCI DE VOTRE ATTENTION */

-
-// utilise seulement à l'installation pour l'instant
-
-define('_EXTENSION_PHP', '.php3');
-
// Droits d'acces maximum par defaut
@umask(0);

//
-// *** Fin du parametrage statique ***
+// Définition des repertoires standards, mes_options ayant priorite
//

-define_once('_DIR_RESTREINT_ABS', 'ecrire/');
-
-$flag_ecrire = !@file_exists(_DIR_RESTREINT_ABS . 'inc_version.php3');
-
-# en fait flag_ecrire est une constante, equivalente a la nullite de:
-
-define_once('_DIR_RESTREINT', (!@is_dir(_DIR_RESTREINT_ABS) ? "" : _DIR_RESTREINT_ABS));
-
-/* bientot
-
-if ($d = ($GLOBALS['HTTP_GET_VARS']['var_install']))
- {
- $d = substr($d,0,strrpos($d,'/')+1);
- define_once('_DIR_PREFIX1', $d);
- define_once('_DIR_PREFIX2', $d);
+function define_once ($constant, $valeur) {
+ if (!defined($constant)) define($constant, $valeur);
+}

- } else */
-{
- define('_DIR_PREFIX1', (_DIR_RESTREINT ? "" : "../"));
- define('_DIR_PREFIX2', _DIR_RESTREINT);
+if (@file_exists(_FILE_OPTIONS)) {
+ include(_FILE_OPTIONS);
  }

-if (@file_exists(_DIR_PREFIX2 . 'mes_options.php3')) {
- include(_DIR_PREFIX2 . 'mes_options.php3');
-}
-
-define_once('_FILE_CONNECT_INS', (_DIR_PREFIX2 . "inc_connect"));
-define_once('_FILE_CONNECT',
- (@file_exists(_FILE_CONNECT_INS . _EXTENSION_PHP) ?
- (_FILE_CONNECT_INS . _EXTENSION_PHP)
- : ''));
+define_once('_DIR_PREFIX1', (_DIR_RESTREINT ? "" : "../"));
+define_once('_DIR_PREFIX2', _DIR_RESTREINT);

// les repertoires des logos, des pieces rapportees, du CACHE et des sessions

@@ -294,16 +305,22 @@
define_once('_DIR_IMG_ICONES_BARRE', _DIR_IMG . "icones_barre/");
define_once('_DIR_TeX', _DIR_IMG . "TeX/");

-// pour ceux qui n'aiment pas nos icones, tout est prevu
+// pour ceux qui n'aiment pas nos icones et notre vocabulaire, tout est prevu
// (pas tout à fait)

define_once('_DIR_IMG_PACK', (_DIR_RESTREINT . 'img_pack/'));
+define_once('_DIR_LANG', (_DIR_RESTREINT . 'lang/'));

// qq chaines standard

define_once('_ACCESS_FILE_NAME', '.htaccess');
define_once('_AUTH_USER_FILE', '.htpasswd');
-;
+
+# negation d'une constante. A remplacer.
+
+$flag_ecrire = !@file_exists(_DIR_RESTREINT_ABS . 'inc_version.php3');
+
+
// Version courante de SPIP
// Stockee sous forme de nombre decimal afin de faciliter les comparaisons
// (utilise pour les modifs de la base de donnees)
@@ -493,6 +510,7 @@
     .ereg_replace("\n*$", "\n", $message);

   $logfile = _DIR_SESSIONS . $logname . '.log';
+# $logfile = "/tmp/spip.log";
   if (@filesize($logfile) > 10*1024) {
     $rotate = true;
     $message .= "[-- rotate --]\n";
@@ -902,12 +920,11 @@
if (!defined('_DATA_META_CACHE') AND !defined('_ECRIRE_INC_META')) {
   unset($meta); # parano

- if (lire_fichier (_DIR_SESSIONS . 'meta_cache.php3', $contenu,
- array('phpcheck' => 'oui')))
- eval('?'.'>'.$contenu);
-
+ if (file_exists(_DIR_SESSIONS . 'meta_cache.php3'))
+ include(_DIR_SESSIONS . 'meta_cache.php3');
   // en cas d'echec refaire le fichier
   if (!is_array($meta) AND _FILE_CONNECT) {
+
     include_ecrire('inc_meta.php3');
     lire_metas();
     ecrire_metas();
@@ -1121,7 +1138,6 @@

function calcule_fichier_logo($on) {
   $r= ereg_replace("^" . _DIR_IMG, "", $on);
-# spip_log("calculer_fihchier_logo $on $r");
   return $r;
}

@@ -1183,13 +1199,13 @@
   if (!$base)
     $base = dirname($GLOBALS[‹ HTTP_SERVERS_VARS ›][‹ SCRIPT_NAME ›]);
   else
- $base .= ‹ / › . (_DIR_RESTREINT ? ‹  › : ‹ ecrire/ ›);
+ $base .= ‹ / › . (_DIR_RESTREINT ? ‹  › : _DIR_RESTREINT_ABS);
   if (!$charset = lire_meta(‹ charset ›)) $charset = ‹ utf-8 ›;
   @Header(« Content-Type: text/html; charset=$charset »);
   return « <!DOCTYPE HTML PUBLIC ‹ -//W3C//DTD HTML 4.01 Transitional//EN › ‹ http://www.w3.org/TR/html4/loose.dtd ›>\n » .
     « <html lang=’ ».$GLOBALS[‹ spip_lang ›]."’ dir=’".($GLOBALS[‹ spip_lang_rtl ›] ? ‹ rtl › : ‹ ltr ›)."’>\n" .
     « <head>\n » .
-# « <base href=’$base’ />\n » . # + tard
+# « <base href=’$base’ />\n » .
     « <title>$title</title>\n » .
     « <meta http-equiv=‹ Content-Type › content=‹ text/html; charset=$charset › />\n »;
}