64 lines
1.8 KiB
PHP
64 lines
1.8 KiB
PHP
<?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(" ", " ", $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(" ", " ", $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;
|
|
}
|
|
|