From bc3468a85bf23300cade03a6b7f7dcf2bd76f9e3 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Sat, 5 May 2007 13:44:21 +0000
Subject: [PATCH] =?UTF-8?q?Evacuation=20de=20qq=20ind=C3=A9finis=20de=20l'?=
 =?UTF-8?q?espace=20public,=20en=20particulier=20celui=20mentionn=C3=A9=20?=
 =?UTF-8?q?en=20[9142]=20qui=20empechait=20l'optimisation=20d'une=20jointu?=
 =?UTF-8?q?re.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/agenda.php          |  4 ++--
 ecrire/inc/boutons.php         |  4 ++--
 ecrire/inc/charsets.php        |  2 +-
 ecrire/inc/editer_mot.php      |  4 ++--
 ecrire/index.php               |  2 +-
 ecrire/public/boucles.php      | 10 +++++-----
 ecrire/public/compiler.php     |  7 ++-----
 ecrire/public/criteres.php     | 15 ++++++++-------
 ecrire/public/parametrer.php   | 12 ++++--------
 ecrire/public/phraser_html.php |  2 +-
 10 files changed, 28 insertions(+), 34 deletions(-)

diff --git a/ecrire/inc/agenda.php b/ecrire/inc/agenda.php
index d21624693b..0483344c3e 100644
--- a/ecrire/inc/agenda.php
+++ b/ecrire/inc/agenda.php
@@ -84,7 +84,7 @@ function calendrier_href($script, $annee, $mois, $jour, $type, $fin, $ancre, $im
 	$t = ($titre ? " title=\"$titre\"" : '');
 	$s = ($style ? " style=\"$style\"" : '');
 
-	$moi = preg_match("/exec=" . $GLOBALS['exec'] .'$/', $script);
+	$moi = preg_match("/exec=" . _request('exec') .'$/', $script);
 	if ($img) $clic =  http_img_pack($img, ($alt ? $alt : $titre), $c);
 	  // pas d'Ajax pour l'espace public pour le moment ou si indispo
 	if (_DIR_RESTREINT  || !$moi || (_SPIP_AJAX !== 1 ))
@@ -252,7 +252,7 @@ function http_calendrier_mois_navigation($annee, $mois, $premier_jour, $dernier_
 	  "\n<tr><td colspan='7'>" .
 	  http_calendrier_navigation($annee,
 				   $mois,
-				   $jour,
+				   0,
 				   $echelle,
 				   $partie_cal,
 				   $periode,
diff --git a/ecrire/inc/boutons.php b/ecrire/inc/boutons.php
index 8285ff31dd..ae7fad5045 100644
--- a/ecrire/inc/boutons.php
+++ b/ecrire/inc/boutons.php
@@ -13,8 +13,8 @@
 if (!defined("_ECRIRE_INC_VERSION")) return;
 
 define('_LARGEUR_ICONES_BANDEAU', 
-       (($GLOBALS['spip_display'] == 3) ? 60 : 80)
-       + (($GLOBALS['spip_ecran'] == 'large') ? 30 : 0)
+       ((@$GLOBALS['spip_display'] == 3) ? 60 : 80)
+       + ((@$GLOBALS['spip_ecran'] == 'large') ? 30 : 0)
        + (($GLOBALS['connect_toutes_rubriques']) ? 0 : 30));
 
 /**
diff --git a/ecrire/inc/charsets.php b/ecrire/inc/charsets.php
index 14bb788485..200c6ac465 100644
--- a/ecrire/inc/charsets.php
+++ b/ecrire/inc/charsets.php
@@ -648,7 +648,7 @@ function transcoder_page($texte, $headers='') {
 	// charset de la reponse http
 	else if (preg_match(',charset=([-_a-z0-9]+),i', $headers, $regs))
 		$charset = trim(strtolower($regs[1]));
-
+	else $charset = '';
 	// normaliser les noms du shif-jis japonais
 	if (preg_match(',^(x|shift)[_-]s?jis$,i', $charset))
 		$charset = 'shift-jis';
diff --git a/ecrire/inc/editer_mot.php b/ecrire/inc/editer_mot.php
index 8a17a94e98..493bea00c3 100644
--- a/ecrire/inc/editer_mot.php
+++ b/ecrire/inc/editer_mot.php
@@ -320,14 +320,14 @@ function formulaire_mots_cles($id_groupes_vus, $id_objet, $les_mots, $table, $ta
 		$res .= "<div style='float:$spip_lang_right; width:280px;position:relative;display:inline;'>"
 			. $ajouter
 			."</div>\n" ;
-	}
+	} else $message ='';
 
 	if (autoriser('modifier','groupemots')) {
 		$titre = _request('cherche_mot')
 			? "&titre=".rawurlencode(_request('cherche_mot')) : '';
 		$bouton_ajouter = icone_horizontale(_T('icone_creer_mot_cle'), generer_url_ecrire("mots_edit","new=oui&ajouter_id_article=$id_objet&table=$table&table_id=$table_id$titre&redirect=" . generer_url_retour($url_base, "$table_id=$id_objet")), "mot-cle-24.gif", "creer.gif", false)
 		. "\n";
-	}
+	} else $bouton_ajouter = '';
 
 	if ($message OR $bouton_ajouter) {
 		$res .= "<div style='width:170px;'>$message
diff --git a/ecrire/index.php b/ecrire/index.php
index 7da696081f..d486677867 100644
--- a/ecrire/index.php
+++ b/ecrire/index.php
@@ -118,7 +118,7 @@ AND ($GLOBALS['spip_version'] != (str_replace(',','.',$GLOBALS['meta']['version_
 // Si interruption d'une longue restauration
 // detourner le script demande pour qu'il reprenne le boulot
 // mais virer les Ajax pour eviter plusieurs restaurations en parallele
-elseif ($_COOKIE['spip_admin']
+elseif (isset($_COOKIE['spip_admin'])
 AND isset($GLOBALS['meta']["import_all"])) {
 	if (isset($var_ajaxcharset)) exit;
 	$exec = 'import_all';
diff --git a/ecrire/public/boucles.php b/ecrire/public/boucles.php
index 9fab9da069..e840cf0c2c 100644
--- a/ecrire/public/boucles.php
+++ b/ecrire/public/boucles.php
@@ -58,7 +58,7 @@ function boucle_ARTICLES_dist($id_boucle, &$boucles) {
 	$mstatut = $id_table .'.statut';
 
 	// Restreindre aux elements publies
-	if (!$boucle->modificateur['criteres']['statut']) {
+	if (!isset($boucle->modificateur['criteres']['statut'])) {
 		if (!$GLOBALS['var_preview']) {
 			$boucle->where[]= array("'='", "'$mstatut'", "'\"publie\"'");
 			if ($GLOBALS['meta']["post_dates"] == 'non')
@@ -80,7 +80,7 @@ function boucle_AUTEURS_dist($id_boucle, &$boucles) {
 	$mstatut = $id_table .'.statut';
 
 	// Restreindre aux elements publies
-	if (!$boucle->modificateur['criteres']['statut']) {
+	if (!isset($boucle->modificateur['criteres']['statut'])) {
 		// Si pas de lien avec un article, selectionner
 		// uniquement les auteurs d'un article publie
 		if (!$GLOBALS['var_preview'])
@@ -110,7 +110,7 @@ function boucle_BREVES_dist($id_boucle, &$boucles) {
 	$mstatut = $id_table .'.statut';
 
 	// Restreindre aux elements publies
-	if (!$boucle->modificateur['criteres']['statut']) {
+	if (!isset($boucle->modificateur['criteres']['statut'])) {
 		if (!$GLOBALS['var_preview'])
 			$boucle->where[]= array("'='", "'$mstatut'", "'\"publie\"'");
 		else
@@ -193,7 +193,7 @@ function boucle_RUBRIQUES_dist($id_boucle, &$boucles) {
 	$mstatut = $id_table .'.statut';
 
 	// Restreindre aux elements publies
-	if (!$boucle->modificateur['criteres']['statut']) {
+	if (!isset($boucle->modificateur['criteres']['statut'])) {
 		if (!$GLOBALS['var_preview'])
 			if (!isset($boucle->modificateur['tout']))
 				$boucle->where[]= array("'='", "'$mstatut'", "'\"publie\"'");
@@ -244,7 +244,7 @@ function boucle_SYNDICATION_dist($id_boucle, &$boucles) {
 
 	// Restreindre aux elements publies
 
-	if (!$boucle->modificateur['criteres']['statut']) {
+	if (!isset($boucle->modificateur['criteres']['statut'])) {
 		if (!$GLOBALS['var_preview']) {
 			$boucle->where[]= array("'='", "'$mstatut'", "'\"publie\"'");
 		} else
diff --git a/ecrire/public/compiler.php b/ecrire/public/compiler.php
index 8b42255f40..318a2a6f7f 100644
--- a/ecrire/public/compiler.php
+++ b/ecrire/public/compiler.php
@@ -94,14 +94,11 @@ function calculer_inclure($struct, $descr, &$boucles, $id_boucle) {
 	$_contexte = argumenter_inclure($struct, $descr, $boucles, $id_boucle);
 
 	// Critere d'inclusion {env} (et {self} pour compatibilite ascendante)
-	if (isset($_contexte['env'])
-	|| isset($_contexte['self'])
-	) {
-		$flag_env = true;
+	if ($env = (isset($_contexte['env'])|| isset($_contexte['self']))) {
 		unset($_contexte['env']);
 	}
 	$contexte = 'array(' . join(",\n\t", $_contexte) .')';
-	if ($flag_env) {
+	if ($env) {
 		$contexte = "array_merge('.spip_var_export(\$Pile[0]).',$contexte)";
 	}
 
diff --git a/ecrire/public/criteres.php b/ecrire/public/criteres.php
index d32d1da06d..9f5bc72ce9 100644
--- a/ecrire/public/criteres.php
+++ b/ecrire/public/criteres.php
@@ -547,7 +547,7 @@ function calculer_critere_parties_aux($idb, &$boucles, $param) {
 	  } else {
 	    preg_match(',^ *(([0-9]+)|n) *(- *([0-9]+)? *)?$,', $param[0]->texte, $m);
 	    $a1 = $m[1];
-	    if (!$m[3])
+	    if (!@$m[3])
 	      return array($a1, 0);
 	    elseif ($m[4])
 	      return array($a1, $m[4]);
@@ -693,7 +693,7 @@ function calculer_critere_infixe($idb, &$boucles, $crit) {
 	}
 
 	// Cas particulier : expressions de date
-	else if ($table_date[$type]
+	else if (isset($table_date[$type])
 	AND preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,",
 	$col, $regs)) {
 		list($col, $table) =
@@ -841,10 +841,11 @@ function calculer_jointure(&$boucle, $depart, $arrivee, $col='', $cond=false)
   // et operateur d'egalite (http://trac.rezo.net/trac/spip/ticket/477)
 
   if ($pk = (count($boucle->from) == 1) && !$cond) {
-    if ($pk = $a[1]['key']['PRIMARY KEY']) {
-	$pk=preg_match("/^$id_primary, *$col$/", $pk) OR
-	  preg_match("/^$col, *$id_primary$/", $pk);
-    }
+  	if ($pk = $a[1]['key']['PRIMARY KEY']) {
+		$id_primary = $ddesc['key']['PRIMARY KEY'];
+		$pk = preg_match("/^$id_primary, *$col$/", $pk) OR
+			preg_match("/^$col, *$id_primary$/", $pk);
+	}
   }
   // la clause Group by est en conflit avec ORDER BY, a completer
 
@@ -1043,7 +1044,7 @@ function calculer_critere_infixe_ops($idb, &$boucles, $crit)
 			if (count($params)==1
 					AND count($params[0]==3)
 					AND $params[0][0]->type == 'texte' 
-					AND $params[0][2]->type == 'texte' 
+					AND @$params[0][2]->type == 'texte' 
 					AND ($p=$params[0][0]->texte) == $params[0][2]->texte
 					AND (($p == "'") OR ($p == '"'))
 					AND $params[0][1]->type == 'champ' ) {
diff --git a/ecrire/public/parametrer.php b/ecrire/public/parametrer.php
index e8e1b0b151..6220dec32e 100644
--- a/ecrire/public/parametrer.php
+++ b/ecrire/public/parametrer.php
@@ -99,8 +99,7 @@ function sql_rubrique_fond($contexte) {
 		$row = spip_abstract_fetsel(array('lang'),
 					    array('spip_rubriques'),
 					    array("id_rubrique=$id"));
-		if ($row['lang'])
-			$lang = $row['lang'];
+		$lang = isset($row['lang']) ? $row['lang'] : '';
 		return array ($id, $lang);
 	}
 
@@ -110,8 +109,7 @@ function sql_rubrique_fond($contexte) {
 			array('spip_breves'), 
 			array("id_breve=$id"));
 		$id_rubrique_fond = $row['id_rubrique'];
-		if ($row['lang'])
-			$lang = $row['lang'];
+		$lang = isset($row['lang']) ? $row['lang'] : '';
 		return array($id_rubrique_fond, $lang);
 	}
 
@@ -124,8 +122,7 @@ function sql_rubrique_fond($contexte) {
 		$row = spip_abstract_fetsel(array('lang'),
 			array('spip_rubriques'),
 			array("id_rubrique='$id_rubrique_fond'"));
-		if ($row['lang'])
-			$lang = $row['lang'];
+		$lang = isset($row['lang']) ? $row['lang'] : '';
 		return array($id_rubrique_fond, $lang);
 	}
 
@@ -135,8 +132,7 @@ function sql_rubrique_fond($contexte) {
 			array('spip_articles'),
 			array("id_article=$id"));
 		$id_rubrique_fond = $row['id_rubrique'];
-		if ($row['lang'])
-			$lang = $row['lang'];
+		$lang = isset($row['lang']) ? $row['lang'] : '';
 		return array($id_rubrique_fond, $lang);
 	}
 }
diff --git a/ecrire/public/phraser_html.php b/ecrire/public/phraser_html.php
index c2bcc7bb3a..cd231e0ac6 100644
--- a/ecrire/public/phraser_html.php
+++ b/ecrire/public/phraser_html.php
@@ -468,7 +468,7 @@ function phraser_criteres($params, &$result) {
 			  } elseif (preg_match(',^(' . CHAMP_SQL_PLUS_FONC . 
 					 ')[[:space:]]*(\??)(!?)(<=?|>=?|==?|\b(?:IN|LIKE)\b)(.*)$,is', $param, $m)) {
 			    $a2 = trim($m[7]);
-			    if (($a2{0}=="'" OR $a2{0}=='"') AND ($a2{0}==substr($a2,-1)))
+			    if ($a2 AND ($a2[0]=="'" OR $a2[0]=='"') AND ($a2[0]==substr($a2,-1)))
 			      $a2 = substr($a2,1,-1);
 			    $crit = phraser_critere_infixe($m[1], $a2, $v,
 							   (($m[1] == 'lang_select') ? $m[1] : $m[6]),
-- 
GitLab