Skip to content
Extraits de code Groupes Projets
Valider cfaea983 rédigé par Fil's avatar Fil
Parcourir les fichiers

optimisations diverses (?)

parent c94f807e
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -323,7 +323,11 @@ function unicode_to_utf_8($chaine) { ...@@ -323,7 +323,11 @@ function unicode_to_utf_8($chaine) {
function load_windows_1251() { function load_windows_1251() {
// extrait de la table // extrait de la table
// http://www.slav.helsinki.fi/atk/codepages/win1251.html // http://www.slav.helsinki.fi/atk/codepages/win1251.html
return array( static $table;
if(is_array($table))
return $table;
else
return $table = array(
chr(129)=>'Ѓ',chr(131)=>'ѓ',chr(138)=>'Љ',chr(140)=>'Њ',chr(141)=>'Ќ', chr(129)=>'Ѓ',chr(131)=>'ѓ',chr(138)=>'Љ',chr(140)=>'Њ',chr(141)=>'Ќ',
chr(142)=>'Ћ',chr(143)=>'Џ',chr(144)=>'ђ',chr(154)=>'љ',chr(156)=>'њ', chr(142)=>'Ћ',chr(143)=>'Џ',chr(144)=>'ђ',chr(154)=>'љ',chr(156)=>'њ',
chr(157)=>'ќ',chr(158)=>'ћ',chr(159)=>'џ',chr(161)=>'Ў',chr(162)=>'ў', chr(157)=>'ќ',chr(158)=>'ћ',chr(159)=>'џ',chr(161)=>'Ў',chr(162)=>'ў',
...@@ -377,10 +381,9 @@ function translitteration ($texte, $charset='AUTO') { ...@@ -377,10 +381,9 @@ function translitteration ($texte, $charset='AUTO') {
if ($charset == 'iso-8859-1') { if ($charset == 'iso-8859-1') {
$texte = translit_iso8859_1($texte); $texte = translit_iso8859_1($texte);
} else if ($charset == 'windows-1251') { } else if ($charset == 'windows-1251') {
$texte = strtolower(translit_windows_1251($texte)); $texte = translit_windows_1251($texte);
} else if ($GLOBALS['flag_iconv']) { } else if ($GLOBALS['flag_iconv']) {
@iconv_set_encoding("internal_encoding", "UTF-8"); if ($iconv = @iconv(strtoupper($charset), 'ASCII//TRANSLIT', $texte) && !ereg("^?+$",$iconv)) {
if ($iconv = @iconv($charset, 'ASCII//TRANSLIT', $texte)) {
$texte = $iconv; $texte = $iconv;
} }
} }
......
...@@ -7,10 +7,7 @@ define("_ECRIRE_INC_INDEX", "1"); ...@@ -7,10 +7,7 @@ define("_ECRIRE_INC_INDEX", "1");
function nettoyer_chaine_indexation($texte) { function nettoyer_chaine_indexation($texte) {
include_ecrire("inc_charsets.php3"); include_ecrire("inc_charsets.php3");
$texte = ereg_replace("<[^<]*>", "", $texte);
$texte = strtolower(translitteration($texte)); $texte = strtolower(translitteration($texte));
return $texte; return $texte;
} }
...@@ -31,11 +28,12 @@ function spip_split($reg, $texte) { ...@@ -31,11 +28,12 @@ function spip_split($reg, $texte) {
function indexer_chaine($texte, $val = 1, $min_long = 3) { function indexer_chaine($texte, $val = 1, $min_long = 3) {
global $index, $mots; global $index, $mots;
$texte = nettoyer_chaine_indexation($texte); $texte = supprimer_tags($texte);
$regs = separateurs_indexation(); $regs = separateurs_indexation();
$texte = strtr($texte, $regs, " "); $texte = strtr($texte, $regs, " ");
$table = spip_split(" +([^ ]{0,$min_long} +)*", ' '.$texte); $table = spip_split(" +([^ ]{0,$min_long} +)*", ' '.$texte);
while (list(, $mot) = each($table)) { while (list(, $mot) = each($table)) {
$mot = nettoyer_chaine_indexation($mot);
$h = substr(md5($mot), 0, 16); $h = substr(md5($mot), 0, 16);
$index[$h] += $val; $index[$h] += $val;
$mots .= ",(0x$h,'$mot')"; $mots .= ",(0x$h,'$mot')";
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter