]*)\]/', '<$1$2$3>', $texte); } else // Sécurité maximum, recommandé pour forums, wiki etc... / Maximum security { $tags = array('span', 'kbd', 'var', 'del', 'div', 'strong', 'em', 'dfn', 'cite', 'q', 'blockquote', 'p', 'br', 'a', 'ol', 'ul', 'li', 'abbr', 'acronym', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'h7', 'h8', 'img', 'tr', 'th', 'td', 'table', 'caption', 'thead', 'tfoot', 'tbody', 'dl', 'dd', 'dt', 'map', 'area', 'code', 'sub', 'sup'); // array_push($tags, 'script', 'object'); peuvent être ajouté (-sécurité) / can be added (-security) $attributes = array('class', 'id', 'dir', 'title', 'lang', 'style', 'href', 'hreflang', 'rel', 'rev', 'tabindex', 'type', 'accesskey', 'charset', 'datetime', 'cite', 'alt', 'longdesc', 'usemap', 'src', 'coords', 'shape', 'nohref'); // array_push($attributes, 'onclick', 'ondblclick', 'onkeydown', 'onkeypress', 'onkeyup', 'onload', 'onmousedown', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onunload', 'onblur', 'onfocus', 'defer'); peuvent être ajouté (-sécurité) / can be added (-security) foreach($attributes as $attribute) { $texte=preg_replace('/ ' . $attribute . '=([^"\=\]]+) ([a-z0-9]+)=/', ' ' . $attribute . '="$1" $2=', $texte); $texte=preg_replace('/\[([^\]]+) ' . $attribute . '=([^"\]]+) \/\]/', '[$1 ' . $attribute . '="$2" /]', $texte); $texte=preg_replace('/\[([^\]]+) ' . $attribute . '=([^"\]]+)\]/', '[$1 ' . $attribute . '="$2"]', $texte); /*$texte = preg_replace('/\[([^\]]+) ' . $attribute . '=([^"\]]+) ([^\s][a-z0-9]+)=(.)/', '[$1 ' . $attribute . '="$2" $3=$4', $texte); $texte = preg_replace('/\[([^\]]+) ' . $attribute . '=([^"\]]+) \/\]/', '[$1 ' . $attribute . '="$2" /]', $texte); $texte = preg_replace('/\[([^\]]+) ' . $attribute . '=([^"\]]+)\]/', '[$1 ' . $attribute . '="$2"]', $texte);*/ } $texte=preg_replace('/ (?:[a-z0-9]+)=(?:[^"\]]+)/', '', $texte); foreach($tags as $tag) { $texte = preg_replace('/\[([\/]?)' . $tag . '([^\]>]*)\]/', '<$1' . $tag . '$2>', $texte); } } if($nettoyache) { // Kohnshita : Nettoyer / Clean-up ! $texte=preg_replace('/\[(?:[^\]]+)\]/i', '', $texte); } return $texte; } ?>