Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / plugins / anet_migration / ryxeo.php @ 7074cc57

Historique | Voir | Annoter | Télécharger (7,33 ko)

1 7074cc57 Eric Seigne
<?php
2
3
// ---------------------------------------------
4
// On vire les espaces ponctuations etc.
5
// agressif = 0 on est gentil - on ne fait rien
6
//          = 1 on vire les accents + tout en minuscules
7
//          = 2 on vire aussi les tirets et espaces (login / pass)
8
function anti_speciaux($t) {
9
  if(trim($t) == "")
10
  return ;
11
  $texte = strtolower($t);
12
  $texte = str_replace(" ","",$texte);
13
  $texte = str_replace("?","",$texte);
14
  $texte = str_replace("\\","",$texte);
15
  $texte = str_replace("/","",$texte);
16
  $texte = str_replace("-","",$texte);
17
  $texte = str_replace("_","",$texte);
18
  $texte = str_replace("'","",$texte);
19
  $texte = str_replace('"',"",$texte);
20
  $texte = remove_accents($texte);
21
  return $texte;
22
}
23
24
25
/**
26
 * Code from wordpress - wordpress.org
27
 * Converts all accent characters to ASCII characters.
28
 *
29
 * If there are no accent characters, then the string given is just returned.
30
 *
31
 * @since 1.2.1
32
 *
33
 * @param string $string Text that might have accent characters
34
 * @return string Filtered string with replaced "nice" characters.
35
 */
36
function remove_accents($string) {
37
        if ( !preg_match('/[\x80-\xff]/', $string) )
38
                return $string;
39
40
        if (seems_utf8($string)) {
41
                $chars = array(
42
                // Decompositions for Latin-1 Supplement
43
                chr(195).chr(128) => 'A', chr(195).chr(129) => 'A',
44
                chr(195).chr(130) => 'A', chr(195).chr(131) => 'A',
45
                chr(195).chr(132) => 'A', chr(195).chr(133) => 'A',
46
                chr(195).chr(135) => 'C', chr(195).chr(136) => 'E',
47
                chr(195).chr(137) => 'E', chr(195).chr(138) => 'E',
48
                chr(195).chr(139) => 'E', chr(195).chr(140) => 'I',
49
                chr(195).chr(141) => 'I', chr(195).chr(142) => 'I',
50
                chr(195).chr(143) => 'I', chr(195).chr(145) => 'N',
51
                chr(195).chr(146) => 'O', chr(195).chr(147) => 'O',
52
                chr(195).chr(148) => 'O', chr(195).chr(149) => 'O',
53
                chr(195).chr(150) => 'O', chr(195).chr(153) => 'U',
54
                chr(195).chr(154) => 'U', chr(195).chr(155) => 'U',
55
                chr(195).chr(156) => 'U', chr(195).chr(157) => 'Y',
56
                chr(195).chr(159) => 's', chr(195).chr(160) => 'a',
57
                chr(195).chr(161) => 'a', chr(195).chr(162) => 'a',
58
                chr(195).chr(163) => 'a', chr(195).chr(164) => 'a',
59
                chr(195).chr(165) => 'a', chr(195).chr(167) => 'c',
60
                chr(195).chr(168) => 'e', chr(195).chr(169) => 'e',
61
                chr(195).chr(170) => 'e', chr(195).chr(171) => 'e',
62
                chr(195).chr(172) => 'i', chr(195).chr(173) => 'i',
63
                chr(195).chr(174) => 'i', chr(195).chr(175) => 'i',
64
                chr(195).chr(177) => 'n', chr(195).chr(178) => 'o',
65
                chr(195).chr(179) => 'o', chr(195).chr(180) => 'o',
66
                chr(195).chr(181) => 'o', chr(195).chr(182) => 'o',
67
                chr(195).chr(182) => 'o', chr(195).chr(185) => 'u',
68
                chr(195).chr(186) => 'u', chr(195).chr(187) => 'u',
69
                chr(195).chr(188) => 'u', chr(195).chr(189) => 'y',
70
                chr(195).chr(191) => 'y',
71
                // Decompositions for Latin Extended-A
72
                chr(196).chr(128) => 'A', chr(196).chr(129) => 'a',
73
                chr(196).chr(130) => 'A', chr(196).chr(131) => 'a',
74
                chr(196).chr(132) => 'A', chr(196).chr(133) => 'a',
75
                chr(196).chr(134) => 'C', chr(196).chr(135) => 'c',
76
                chr(196).chr(136) => 'C', chr(196).chr(137) => 'c',
77
                chr(196).chr(138) => 'C', chr(196).chr(139) => 'c',
78
                chr(196).chr(140) => 'C', chr(196).chr(141) => 'c',
79
                chr(196).chr(142) => 'D', chr(196).chr(143) => 'd',
80
                chr(196).chr(144) => 'D', chr(196).chr(145) => 'd',
81
                chr(196).chr(146) => 'E', chr(196).chr(147) => 'e',
82
                chr(196).chr(148) => 'E', chr(196).chr(149) => 'e',
83
                chr(196).chr(150) => 'E', chr(196).chr(151) => 'e',
84
                chr(196).chr(152) => 'E', chr(196).chr(153) => 'e',
85
                chr(196).chr(154) => 'E', chr(196).chr(155) => 'e',
86
                chr(196).chr(156) => 'G', chr(196).chr(157) => 'g',
87
                chr(196).chr(158) => 'G', chr(196).chr(159) => 'g',
88
                chr(196).chr(160) => 'G', chr(196).chr(161) => 'g',
89
                chr(196).chr(162) => 'G', chr(196).chr(163) => 'g',
90
                chr(196).chr(164) => 'H', chr(196).chr(165) => 'h',
91
                chr(196).chr(166) => 'H', chr(196).chr(167) => 'h',
92
                chr(196).chr(168) => 'I', chr(196).chr(169) => 'i',
93
                chr(196).chr(170) => 'I', chr(196).chr(171) => 'i',
94
                chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
95
                chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
96
                chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
97
                chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
98
                chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
99
                chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
100
                chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
101
                chr(196).chr(186) => 'l', chr(196).chr(187) => 'L',
102
                chr(196).chr(188) => 'l', chr(196).chr(189) => 'L',
103
                chr(196).chr(190) => 'l', chr(196).chr(191) => 'L',
104
                chr(197).chr(128) => 'l', chr(197).chr(129) => 'L',
105
                chr(197).chr(130) => 'l', chr(197).chr(131) => 'N',
106
                chr(197).chr(132) => 'n', chr(197).chr(133) => 'N',
107
                chr(197).chr(134) => 'n', chr(197).chr(135) => 'N',
108
                chr(197).chr(136) => 'n', chr(197).chr(137) => 'N',
109
                chr(197).chr(138) => 'n', chr(197).chr(139) => 'N',
110
                chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
111
                chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
112
                chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
113
                chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
114
                chr(197).chr(148) => 'R',chr(197).chr(149) => 'r',
115
                chr(197).chr(150) => 'R',chr(197).chr(151) => 'r',
116
                chr(197).chr(152) => 'R',chr(197).chr(153) => 'r',
117
                chr(197).chr(154) => 'S',chr(197).chr(155) => 's',
118
                chr(197).chr(156) => 'S',chr(197).chr(157) => 's',
119
                chr(197).chr(158) => 'S',chr(197).chr(159) => 's',
120
                chr(197).chr(160) => 'S', chr(197).chr(161) => 's',
121
                chr(197).chr(162) => 'T', chr(197).chr(163) => 't',
122
                chr(197).chr(164) => 'T', chr(197).chr(165) => 't',
123
                chr(197).chr(166) => 'T', chr(197).chr(167) => 't',
124
                chr(197).chr(168) => 'U', chr(197).chr(169) => 'u',
125
                chr(197).chr(170) => 'U', chr(197).chr(171) => 'u',
126
                chr(197).chr(172) => 'U', chr(197).chr(173) => 'u',
127
                chr(197).chr(174) => 'U', chr(197).chr(175) => 'u',
128
                chr(197).chr(176) => 'U', chr(197).chr(177) => 'u',
129
                chr(197).chr(178) => 'U', chr(197).chr(179) => 'u',
130
                chr(197).chr(180) => 'W', chr(197).chr(181) => 'w',
131
                chr(197).chr(182) => 'Y', chr(197).chr(183) => 'y',
132
                chr(197).chr(184) => 'Y', chr(197).chr(185) => 'Z',
133
                chr(197).chr(186) => 'z', chr(197).chr(187) => 'Z',
134
                chr(197).chr(188) => 'z', chr(197).chr(189) => 'Z',
135
                chr(197).chr(190) => 'z', chr(197).chr(191) => 's',
136
                // Euro Sign
137
                chr(226).chr(130).chr(172) => 'E',
138
                // GBP (Pound) Sign
139
                chr(194).chr(163) => '');
140
141
                $string = strtr($string, $chars);
142
        } else {
143
                // Assume ISO-8859-1 if not UTF-8
144
                $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
145
                        .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
146
                        .chr(195).chr(196).chr(197).chr(199).chr(200).chr(201).chr(202)
147
                        .chr(203).chr(204).chr(205).chr(206).chr(207).chr(209).chr(210)
148
                        .chr(211).chr(212).chr(213).chr(214).chr(216).chr(217).chr(218)
149
                        .chr(219).chr(220).chr(221).chr(224).chr(225).chr(226).chr(227)
150
                        .chr(228).chr(229).chr(231).chr(232).chr(233).chr(234).chr(235)
151
                        .chr(236).chr(237).chr(238).chr(239).chr(241).chr(242).chr(243)
152
                        .chr(244).chr(245).chr(246).chr(248).chr(249).chr(250).chr(251)
153
                        .chr(252).chr(253).chr(255);
154
155
                $chars['out'] = "EfSZszYcYuAAAAAACEEEEIIIINOOOOOOUUUUYaaaaaaceeeeiiiinoooooouuuuyy";
156
157
                $string = strtr($string, $chars['in'], $chars['out']);
158
                $double_chars['in'] = array(chr(140), chr(156), chr(198), chr(208), chr(222), chr(223), chr(230), chr(240), chr(254));
159
                $double_chars['out'] = array('OE', 'oe', 'AE', 'DH', 'TH', 'ss', 'ae', 'dh', 'th');
160
                $string = str_replace($double_chars['in'], $double_chars['out'], $string);
161
        }
162
163
        return $string;
164
}
165
166
?>
Redmine Appliance - Powered by TurnKey Linux