scrutariexport_libreavous/scrutariexport_libreavous_fonctions.php

64 lines
1.8 KiB
PHP
Raw Normal View History

2023-03-02 16:16:27 +01:00
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
function filtre_scrutari_attr($texte) {
$result = "";
$array = explode("\n", $texte);
for($i = 0; $i < count($array); $i++) {
$value = trim($array[$i]);
if (strlen($value) > 0) {
$result .= "<val>".$value."</val>\n";
}
}
return $result;
}
function filtre_scrutari_textebrut($texte) {
$u = $GLOBALS['meta']['pcre_u'];
$texte = str_replace("&nbsp;", " ", $texte);
$texte = preg_replace('/\s+/S' . $u, " ", $texte);
$texte = str_replace("<br/>", "\n\n", $texte);
$texte = preg_replace("/<(p|br|li|h[1-6]|dd|dt)( [^>]*)?" . ">/iS", "\n\n", $texte);
$texte = preg_replace("/^\n+/", "", $texte);
$texte = preg_replace("/\n+$/", "", $texte);
$texte = preg_replace("/\n +/", "\n", $texte);
$texte = supprimer_tags($texte);
$texte = filtrer_entites($texte);
$texte = htmlspecialchars($texte, ENT_XML1 | ENT_QUOTES);
return $texte;
}
function filtre_scrutari_liste($texte) {
$result = "";
$offset = 0;
while(true) {
$idx1 = strpos($texte, "<li", $offset);
if ($idx1 === false) {
break;
}
$idx2 = strpos($texte, ">", $idx1);
if ($idx2 === false) {
break;
}
$idx3 = strpos($texte, "</li>", $idx2);
if ($idx3 === false) {
break;
}
$value = substr($texte, $idx2 + 1, ($idx3 - $idx2 - 1));
$value = str_replace("&nbsp;", " ", $value);
$value = supprimer_tags($value);
$value = filtrer_entites($value);
$value = htmlspecialchars($value, ENT_XML1 | ENT_QUOTES);
$value = trim($value);
if (strlen($value) > 0) {
$result .= "<val>".$value."</val>\n";
}
$offset = $idx3 + 4;
}
return $result;
}