diff --git a/ecrire/inc_documents.php3 b/ecrire/inc_documents.php3 index 082540f040fb235b5852a6f63421b5b240bf8e70..dcb8d692aefbc49a1d631f488bbdde0aeb4fe30d 100644 --- a/ecrire/inc_documents.php3 +++ b/ecrire/inc_documents.php3 @@ -122,8 +122,8 @@ function embed_document($id_document, $les_parametres="", $afficher_titre=true) for ($i = 0; $i < count($parametres); $i++) { $parametre = $parametres[$i]; - if (eregi("^left|right|center$", $parametre)) { - $align = $parametre; + if (eregi("^(left|right|center)$", $parametre)) { + $align = strtolower($parametre); } else { $params[] = $parametre; @@ -131,7 +131,9 @@ function embed_document($id_document, $les_parametres="", $afficher_titre=true) } } - if (!($row = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))))) + $s = spip_query("SELECT * FROM spip_documents + WHERE id_document = " . intval($id_document)); + if (!($row = spip_fetch_array($s))) return ''; $id_document = $row['id_document']; $id_type = $row['id_type']; @@ -208,9 +210,13 @@ function embed_document($id_document, $les_parametres="", $afficher_titre=true) if ($largeur_vignette < 120) $largeur_vignette = 120; $forcer_largeur = " width = '$largeur_vignette'"; - if ($align != 'center') $float = " style='float: $align;'"; + if ($align) { + $class_align = " spip_documents_".$align; + if ($align <> 'center') + $float = " style='float: $align;'"; + } - $retour .= "<div class='spip_documents spip_documents_$align'$float>\n"; + $retour .= "<div class='spip_documents$class_align'$float>\n"; $retour .= $vignette; if ($titre) $retour .= "<div class='spip_doc_titre'><strong>$titre</strong></div>"; @@ -234,7 +240,10 @@ function integre_image($id_document, $align, $type_aff) { $id_doublons['documents'] .= ",$id_document"; - if (!($row = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))))) return ""; + $s = spip_query("SELECT * FROM spip_documents + WHERE id_document = " . intval($id_document)); + if (!($row = spip_fetch_array($s))) + return ''; $id_document = $row['id_document']; $id_type = $row['id_type']; $titre = typo($row['titre']); @@ -313,12 +322,24 @@ function integre_image($id_document, $align, $type_aff) { } // Passer un DIV pour les images centrees et, dans tous les cas, les <DOC> + if (preg_match(',^(left|center|right)$,i', $align)) + $align = strtolower($align); + else + $align = ''; if ($align == 'center' OR $type_aff =='DOC') { $span = "div"; } else { $span = "span"; } + if ($align) { + $class_align = " spip_documents_".$align; + if ($align <> 'center') + $float = "float: $align; "; + } + + $retour .= "<div class='spip_documents$class_align'$float>\n"; + if ($align != 'center') { // Largeur de la div = celle de l'image ; mais s'il y a une legende // mettre au moins 120px @@ -326,11 +347,11 @@ function integre_image($id_document, $align, $type_aff) { if (strlen($txt) AND $width < 120) $width = 120; $width = 'width: '.$width.'px;'; - $style = " style='float: $align; $width'"; + $style = " style='$float$width'"; } return - "<$span class='spip_documents spip_documents_$align' $style>" + "<$span class='spip_documents$class_align'$style>" . $vignette . $txt . "</$span>\n"; diff --git a/ecrire/inc_texte.php3 b/ecrire/inc_texte.php3 index f46286f3f51d2cbe78c72032b8921fd304b538b5..de17870625a6e7c6fc6df50b395129ab72190f43 100644 --- a/ecrire/inc_texte.php3 +++ b/ecrire/inc_texte.php3 @@ -368,7 +368,7 @@ function couper_intro($texte, $long) { $intro = couper($texte, $long); // supprimer un eventuel chapo redirecteur =http:/..... - $intro = ereg_replace("^=[^[:space:]]+","",$intro); + $intro = preg_replace(',^=[^[:space:]]+,','',$intro); return $intro; } @@ -378,12 +378,23 @@ function couper_intro($texte, $long) { // Les elements de propre() // -// Securite : empecher l'execution de code PHP +// Securite : empecher l'execution de code PHP ou javascript ou autre malice function interdire_scripts($source) { $source = preg_replace(",<(\%|\?|[[:space:]]*(script|base)),ims", "<\\1", $source); return $source; } +// Securite : utiliser SafeHTML s'il est present dans ecrire/safehtml/ +function safehtml($t) { + static $a; + define_once('XML_HTMLSAX3', _DIR_RESTREINT."safehtml/classes/"); + if (@file_exists(XML_HTMLSAX3.'safehtml.php')) { + include_local(XML_HTMLSAX3.'safehtml.php'); + $a =& new safehtml(); + $t = $a->parse($t); + } + return $t; +} // Correction typographique francaise function typo_fr($letexte) {