From c17b96bf466d606da5010d5b9f4d2331ec8d3061 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Sun, 27 May 2007 11:12:08 +0000
Subject: [PATCH] =?UTF-8?q?SPIP=5FCHMOD=20moins=20les=20bits=20d'ex=C3=A9c?=
 =?UTF-8?q?ution=20s'applique=20=C3=A0=20pr=C3=A9sent=20=C3=A0=20tous=20le?=
 =?UTF-8?q?s=20fichiers.=20Suppression=20de=20tous=20les=20ind=C3=A9finis?=
 =?UTF-8?q?=20ou=20red=C3=A9finition=20de=20constantes=20=C3=A0=20l'instal?=
 =?UTF-8?q?lation.=20Le=20fichier=20chmod.php=20=C3=A9vite=20le=20warning?=
 =?UTF-8?q?=20sur=20=5FSPIP=5FCHMOD=20par=20un=20@=20et=20l'=C3=A9crit=20e?=
 =?UTF-8?q?n=20octal,=20c'est=20plus=20clair,=20mais=20je=20doute=20de=20l?=
 =?UTF-8?q?'utilit=C3=A9=20de=20ce=20fichier:=20pour=20le=20remplir=20par?=
 =?UTF-8?q?=20autre=20chose=20que=20la=20valeur=20std,=20il=20faut=20en=20?=
 =?UTF-8?q?avoir=20mis=20une=20dans=20mes=5Foptions=20qu'on=20a=20pas=20de?=
 =?UTF-8?q?=20raison=20de=20moifier=20ensuite.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/exec/accueil.php         |  1 +
 ecrire/exec/install.php         |  8 ++++----
 ecrire/inc/filtres.php          |  2 +-
 ecrire/inc/flock.php            |  2 +-
 ecrire/inc/headers.php          |  2 +-
 ecrire/inc/lang.php             |  2 +-
 ecrire/inc/securiser_action.php |  9 ++++-----
 ecrire/inc/utils.php            | 10 ++++++----
 ecrire/index.php                |  1 +
 ecrire/install/etape_3.php      |  2 +-
 10 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/ecrire/exec/accueil.php b/ecrire/exec/accueil.php
index 1fdee25492..dc100ff6f0 100644
--- a/ecrire/exec/accueil.php
+++ b/ecrire/exec/accueil.php
@@ -382,6 +382,7 @@ function etat_base_accueil()
 // http://doc.spip.org/@accueil_liste_participants
 function accueil_liste_participants()
 {
+	global $spip_lang_left;
 	$q = spip_query("SELECT COUNT(*) AS cnt, statut FROM spip_auteurs GROUP BY statut HAVING cnt <>0 AND statut IN ('" . join("','", $GLOBALS['liste_des_statuts']) . "')");
 
 	$cpt = array();
diff --git a/ecrire/exec/install.php b/ecrire/exec/install.php
index 08e79563d5..e461ed86ab 100644
--- a/ecrire/exec/install.php
+++ b/ecrire/exec/install.php
@@ -99,7 +99,7 @@ function login_hebergeur() {
 	else if (preg_match(',(.*)\.free\.fr$,', $SERVER_NAME, $regs)) {
 		$base_hebergeur = 'sql.free.fr';
 		$login_hebergeur = $regs[1];
-	}
+	} else $login_hebergeur = '';
 
 	return array($base_hebergeur, $login_hebergeur);
 }
@@ -151,9 +151,9 @@ function fieldset($legend, $champs = array(), $horchamps='') {
 	$fieldset = "<fieldset>\n" .
 	($legend ? "<legend>".$legend."</legend>\n" : '');
 	foreach ($champs as $nom => $contenu) {
-		$type = $contenu['hidden'] ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
-		$class = $contenu['hidden'] ? '' : "class='formo' size='40' ";
-		if(is_array($contenu['alternatives'])) {
+		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
+		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
+		if(isset($contenu['alternatives'])) {
 			$fieldset .= $contenu['label'] ."\n";
 			foreach($contenu['alternatives'] as $valeur => $label) {
 				$fieldset .= "<input type='radio' name='".$nom .
diff --git a/ecrire/inc/filtres.php b/ecrire/inc/filtres.php
index 9cc9b801cf..e3d652c436 100644
--- a/ecrire/inc/filtres.php
+++ b/ecrire/inc/filtres.php
@@ -387,7 +387,7 @@ function echapper_tags($texte, $rempl = "") {
 // Convertit un texte HTML en texte brut
 // http://doc.spip.org/@textebrut
 function textebrut($texte) {
-	$u = ($GLOBALS['meta']['charset']=='utf-8' && test_pcre_unicode()) ? 'u':'';
+	$u = (@$GLOBALS['meta']['charset']=='utf-8' && test_pcre_unicode()) ? 'u':'';
 	$texte = preg_replace('/\s+/'.$u.'S', " ", $texte);
 	$texte = preg_replace("/<(p|br)( [^>]*)?".">/iS", "\n\n", $texte);
 	$texte = preg_replace("/^\n+/", "", $texte);
diff --git a/ecrire/inc/flock.php b/ecrire/inc/flock.php
index 6c8400e497..f529696652 100644
--- a/ecrire/inc/flock.php
+++ b/ecrire/inc/flock.php
@@ -107,7 +107,7 @@ function ecrire_fichier ($fichier, $contenu, $ecrire_quand_meme = false, $trunca
 	// liberer le verrou et fermer le fichier
 	@flock($fp, LOCK_UN);
 	@fclose($fp);
-
+	@chmod($fichier, _SPIP_CHMOD & 0666);
 	if (!$ok) {
 		spip_log("echec ecriture fichier $fichier");
 		@unlink($fichier);
diff --git a/ecrire/inc/headers.php b/ecrire/inc/headers.php
index 93d0bdb2b1..37e2805aea 100644
--- a/ecrire/inc/headers.php
+++ b/ecrire/inc/headers.php
@@ -82,7 +82,7 @@ function http_status($status) {
 // http://doc.spip.org/@http_no_cache
 function http_no_cache() {
 	if (headers_sent()) return;
-	if (!$charset = $GLOBALS['meta']['charset']) $charset = 'utf-8';
+	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
 
 	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
 	// il faudrait aussi pour Safari
diff --git a/ecrire/inc/lang.php b/ecrire/inc/lang.php
index fa7f731609..594bdc2f06 100644
--- a/ecrire/inc/lang.php
+++ b/ecrire/inc/lang.php
@@ -224,7 +224,7 @@ function verifier_lang_url() {
 //
 // http://doc.spip.org/@utiliser_langue_site
 function utiliser_langue_site() {
-	return changer_langue($GLOBALS['meta']['langue_site']);
+	return changer_langue(@$GLOBALS['meta']['langue_site']);//@:install
 }
 
 // http://doc.spip.org/@utiliser_langue_visiteur
diff --git a/ecrire/inc/securiser_action.php b/ecrire/inc/securiser_action.php
index bcd6740503..36ad9bba07 100644
--- a/ecrire/inc/securiser_action.php
+++ b/ecrire/inc/securiser_action.php
@@ -60,10 +60,9 @@ function caracteriser_auteur() {
 
 	if ($caracterisation) return $caracterisation;
 
-	$id_auteur = $auteur_session['id_auteur'];
-	if (!$id_auteur) {
+	if (!isset($auteur_session['id_auteur'])) {
   // si l'auteur courant n'est pas connu alors qu'il peut demander une action
-  // c'est une connexion par php_auth, on se rabat sur le cookie.
+  // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie.
   // S'il n'avait pas le droit de realiser cette action, le hash sera faux.
 		if (isset($_COOKIE['spip_session'])
 		AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) {
@@ -73,7 +72,7 @@ function caracteriser_auteur() {
 		} else return array('',''); 	  
 	}
 	// Eviter l'acces SQL si le pass est connu de PHP
-
+	$id_auteur = $auteur_session['id_auteur'];
 	if (isset($auteur_session['pass']) AND $auteur_session['pass'])
 		return $caracterisation = array($id_auteur, $auteur_session['pass']); 
 	else {
@@ -88,7 +87,7 @@ function caracteriser_auteur() {
 
 // http://doc.spip.org/@_action_auteur
 function _action_auteur($action, $id_auteur, $pass, $nom_alea) {
-	return md5($action.$id_auteur.$pass .$GLOBALS['meta'][$nom_alea]);
+	return md5($action.$id_auteur.$pass .@$GLOBALS['meta'][$nom_alea]);
 }
 
 // http://doc.spip.org/@calculer_action_auteur
diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index 9936056d21..c2f5f992ed 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -1125,10 +1125,12 @@ function spip_initialisation($pi=NULL, $pa=NULL, $ti=NULL, $ta=NULL) {
 	:	false));
 
 	// Definition des droits d'acces en ecriture
-	if(!_FILE_CHMOD)
-		define('_SPIP_CHMOD', 0777);
-	else
-		include_once _FILE_CHMOD;
+	if (!defined('_SPIP_CHMOD')) {
+		if(_FILE_CHMOD)
+			include_once _FILE_CHMOD;
+		else
+			define('_SPIP_CHMOD', 0777);
+	}
 
 	// la taille maxi des logos (0 : pas de limite)
 	define('_LOGO_MAX_SIZE', 0); # poids en ko
diff --git a/ecrire/index.php b/ecrire/index.php
index d1a0769e51..a6c9870914 100644
--- a/ecrire/index.php
+++ b/ecrire/index.php
@@ -141,6 +141,7 @@ AND isset($GLOBALS['meta']["import_all"])) {
 // Verification des plugins
 // (ne pas interrompre une restauration ou un upgrade)
 elseif ($exec!='upgrade'
+AND !$var_auth
 AND $GLOBALS['auteur_session']['statut']=='0minirezo'
 AND !_DIR_RESTREINT
 AND lire_fichier(_DIR_TMP.'verifier_plugins.txt',$l)
diff --git a/ecrire/install/etape_3.php b/ecrire/install/etape_3.php
index 78c6104bf5..95899cb781 100644
--- a/ecrire/install/etape_3.php
+++ b/ecrire/install/etape_3.php
@@ -128,7 +128,7 @@ function install_bases(){
 	if($chmod) {
 		$conn = "<"."?php\n";
 		$conn .= "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n";
-		$conn .= "define('_SPIP_CHMOD', ".$chmod.");\n";
+		$conn .= "@define('_SPIP_CHMOD', ". sprintf('0%3o',$chmod).");\n";
 		$conn .= "?".">";
 		if (!ecrire_fichier(_FILE_CHMOD_INS . _FILE_TMP . '.php',
 		$conn))
-- 
GitLab