This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /** |
||
4 | * Evgeny Muravjev Typograph, http://mdash.ru |
||
5 | * Version: 3.4 Gold Master |
||
6 | * Release Date: September 20, 2014 |
||
7 | * Authors: Evgeny Muravjev & Alexander Drutsa |
||
8 | */ |
||
9 | |||
10 | namespace Fenrizbes\TypographBundle\EMT; |
||
11 | |||
12 | class EMTLib |
||
13 | { |
||
14 | const LAYOUT_STYLE = 1; |
||
15 | const LAYOUT_CLASS = 2; |
||
16 | |||
17 | const INTERNAL_BLOCK_OPEN = '%%%INTBLOCKO235978%%%'; |
||
18 | const INTERNAL_BLOCK_CLOSE = '%%%INTBLOCKC235978%%%'; |
||
19 | /** |
||
20 | * Таблица символов |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | public static $_charsTable = array( |
||
25 | '"' => array('html' => array('«', '»', '“', '‘', '„', '“', '"', '«', '»'), |
||
26 | 'utf8' => array(0x201E, 0x201C, 0x201F, 0x201D, 0x00AB, 0x00BB)), |
||
27 | ' ' => array('html' => array(' ', ' ', ' '), |
||
28 | 'utf8' => array(0x00A0, 0x2002, 0x2003, 0x2008, 0x2009)), |
||
29 | '-' => array('html' => array(/*'—',*/ '–', '−', '—', '—', '–'), |
||
30 | 'utf8' => array(0x002D, /*0x2014,*/ 0x2010, 0x2012, 0x2013)), |
||
31 | '—' => array('html' => array('—'), |
||
32 | 'utf8' => array(0x2014)), |
||
33 | '==' => array('html' => array('≡'), |
||
34 | 'utf8' => array(0x2261)), |
||
35 | '...' => array('html' => array('…', '…'), |
||
36 | 'utf8' => array(0x2026)), |
||
37 | '!=' => array('html' => array('≠', '≠'), |
||
38 | 'utf8' => array(0x2260)), |
||
39 | '<=' => array('html' => array('≤', '≤'), |
||
40 | 'utf8' => array(0x2264)), |
||
41 | '>=' => array('html' => array('≥', '≥'), |
||
42 | 'utf8' => array(0x2265)), |
||
43 | '1/2' => array('html' => array('½', '½'), |
||
44 | 'utf8' => array(0x00BD)), |
||
45 | '1/4' => array('html' => array('¼', '¼'), |
||
46 | 'utf8' => array(0x00BC)), |
||
47 | '3/4' => array('html' => array('¾', '¾'), |
||
48 | 'utf8' => array(0x00BE)), |
||
49 | '+-' => array('html' => array('±', '±'), |
||
50 | 'utf8' => array(0x00B1)), |
||
51 | '&' => array('html' => array('&', '&')), |
||
52 | '(tm)' => array('html' => array('™', '™'), |
||
53 | 'utf8' => array(0x2122)), |
||
54 | //'(r)' => array('html' => array('<sup>®</sup>', '®', '®'), |
||
0 ignored issues
–
show
|
|||
55 | '(r)' => array('html' => array('®', '®'), |
||
56 | 'utf8' => array(0x00AE)), |
||
57 | '(c)' => array('html' => array('©', '©'), |
||
58 | 'utf8' => array(0x00A9)), |
||
59 | '§' => array('html' => array('§', '§'), |
||
60 | 'utf8' => array(0x00A7)), |
||
61 | '`' => array('html' => array('́')), |
||
62 | '\'' => array('html' => array('’', '’')), |
||
63 | 'x' => array('html' => array('×', '×'), |
||
64 | 'utf8' => array('×') /* какой же у него может быть код? */), |
||
65 | |||
66 | ); |
||
67 | |||
68 | /** |
||
69 | * Добавление к тегам атрибута 'id', благодаря которому |
||
70 | * при повторном типографирование текста будут удалены теги, |
||
71 | * расставленные данным типографом |
||
72 | * |
||
73 | * @var array |
||
74 | */ |
||
75 | protected static $_typographSpecificTagId = false; |
||
76 | |||
77 | |||
78 | /** |
||
79 | * Костыли для работы с символами UTF-8 |
||
80 | * |
||
81 | * @author somebody? |
||
82 | * @param int $c код символа в кодировке UTF-8 (например, 0x00AB) |
||
83 | * @return bool|string |
||
84 | */ |
||
85 | public static function _getUnicodeChar($c) |
||
86 | { |
||
87 | if ($c <= 0x7F) { |
||
88 | return chr($c); |
||
89 | } else if ($c <= 0x7FF) { |
||
90 | return chr(0xC0 | $c >> 6) |
||
91 | . chr(0x80 | $c & 0x3F); |
||
92 | } else if ($c <= 0xFFFF) { |
||
93 | return chr(0xE0 | $c >> 12) |
||
94 | . chr(0x80 | $c >> 6 & 0x3F) |
||
95 | . chr(0x80 | $c & 0x3F); |
||
96 | } else if ($c <= 0x10FFFF) { |
||
97 | return chr(0xF0 | $c >> 18) |
||
98 | . chr(0x80 | $c >> 12 & 0x3F) |
||
99 | . chr(0x80 | $c >> 6 & 0x3F) |
||
100 | . chr(0x80 | $c & 0x3F); |
||
101 | } else { |
||
102 | return false; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | |||
107 | /** |
||
108 | * Удаление кодов HTML из текста |
||
109 | * |
||
110 | * <code> |
||
111 | * // Remove UTF-8 chars: |
||
112 | * $str = EMTLib::clear_special_chars('your text', 'utf8'); |
||
113 | * // ... or HTML codes only: |
||
114 | * $str = EMTLib::clear_special_chars('your text', 'html'); |
||
115 | * // ... or combo: |
||
116 | * $str = EMTLib::clear_special_chars('your text'); |
||
117 | * </code> |
||
118 | * |
||
119 | * @param string $text |
||
120 | * @param mixed $mode |
||
121 | * @return string|bool |
||
122 | */ |
||
123 | public static function clear_special_chars($text, $mode = null) |
||
124 | { |
||
125 | if(is_string($mode)) $mode = array($mode); |
||
126 | if(is_null($mode)) $mode = array('utf8', 'html'); |
||
127 | if(!is_array($mode)) return false; |
||
128 | $moder = array(); |
||
129 | foreach($mode as $mod) if(in_array($mod, array('utf8','html'))) $moder[] = $mod; |
||
130 | if(count($moder)==0) return false; |
||
131 | |||
132 | foreach (self::$_charsTable as $char => $vals) |
||
133 | { |
||
134 | foreach ($mode as $type) |
||
135 | { |
||
136 | if (isset($vals[$type])) |
||
137 | { |
||
138 | foreach ($vals[$type] as $v) |
||
139 | { |
||
140 | if ('utf8' === $type && is_int($v)) |
||
141 | { |
||
142 | $v = self::_getUnicodeChar($v); |
||
143 | } |
||
144 | if ('html' === $type) |
||
145 | { |
||
146 | if(preg_match("/<[a-z]+>/i",$v)) |
||
147 | { |
||
148 | $v = self::safe_tag_chars($v, true); |
||
149 | } |
||
150 | } |
||
151 | $text = str_replace($v, $char, $text); |
||
152 | } |
||
153 | } |
||
154 | } |
||
155 | } |
||
156 | |||
157 | return $text; |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Удаление тегов HTML из текста |
||
162 | * Тег <br /> будет преобразов в перенос строки \n, сочетание тегов </p><p> - |
||
163 | * в двойной перенос |
||
164 | * |
||
165 | * @param string $text |
||
166 | * @param array $allowableTag массив из тегов, которые будут проигнорированы |
||
167 | * @return string |
||
168 | */ |
||
169 | public static function remove_html_tags($text, $allowableTag = null) |
||
170 | { |
||
171 | $ignore = null; |
||
172 | |||
173 | if (null !== $allowableTag) |
||
174 | { |
||
175 | if (is_string($allowableTag)) |
||
176 | { |
||
177 | $allowableTag = array($allowableTag); |
||
178 | } |
||
179 | if (is_array($allowableTag)) |
||
180 | { |
||
181 | $tags = array(); |
||
182 | foreach ($allowableTag as $tag) |
||
183 | { |
||
184 | if ('<' !== substr($tag, 0, 1) || '>' !== substr($tag, -1, 1)) continue; |
||
185 | if ('/' === substr($tag, 1, 1)) continue; |
||
186 | $tags [] = $tag; |
||
187 | } |
||
188 | $ignore = implode('', $tags); |
||
189 | } |
||
190 | } |
||
191 | $text = preg_replace(array('/\<br\s*\/?>/i', '/\<\/p\>\s*\<p\>/'), array("\n","\n\n"), $text); |
||
192 | $text = strip_tags($text, $ignore); |
||
193 | return $text; |
||
194 | } |
||
195 | |||
196 | /** |
||
197 | * Сохраняем содержимое тегов HTML |
||
198 | * |
||
199 | * Тег 'a' кодируется со специальным префиксом для дальнейшей |
||
200 | * возможности выносить за него кавычки. |
||
201 | * |
||
202 | * @param string $text |
||
203 | * @param bool $safe |
||
0 ignored issues
–
show
There is no parameter named
$safe . Was it maybe removed?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. Consider the following example. The parameter /**
* @param array $germany
* @param array $island
* @param array $italy
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was removed, but the annotation was not. ![]() |
|||
204 | * @return string |
||
205 | */ |
||
206 | public static function safe_tag_chars($text, $way) |
||
207 | { |
||
208 | if ($way) |
||
209 | $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 1) === "a" ? "%%___" : "" ) . \Fenrizbes\TypographBundle\EMT\EMTLib::encrypt_tag(trim($m[2])) . $m[3];'), $text); |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
210 | else |
||
211 | $text = preg_replace_callback('/(\<\/?)(.+?)(\>)/s', create_function('$m','return $m[1].( substr(trim($m[2]), 0, 3) === "%%___" ? \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(substr(trim($m[2]), 4)) : \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag(trim($m[2])) ) . $m[3];'), $text); |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
212 | return $text; |
||
213 | } |
||
214 | |||
215 | |||
216 | /** |
||
217 | * Декодриует спец блоки |
||
218 | * |
||
219 | * @param string $text |
||
220 | * @return string |
||
221 | */ |
||
222 | public static function decode_internal_blocks($text) |
||
223 | { |
||
224 | $text = preg_replace_callback('/'.EMTLib::INTERNAL_BLOCK_OPEN.'([a-zA-Z0-9\/=]+?)'.EMTLib::INTERNAL_BLOCK_CLOSE.'/s', create_function('$m','return \Fenrizbes\TypographBundle\EMT\EMTLib::decrypt_tag($m[1]);'), $text); |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
225 | return $text; |
||
226 | } |
||
227 | |||
228 | /** |
||
229 | * Кодирует спец блок |
||
230 | * |
||
231 | * @param string $text |
||
232 | * @return string |
||
233 | */ |
||
234 | public static function iblock($text) |
||
235 | { |
||
236 | return EMTLib::INTERNAL_BLOCK_OPEN. EMTLib::encrypt_tag($text).EMTLib::INTERNAL_BLOCK_CLOSE; |
||
237 | } |
||
238 | |||
239 | |||
240 | /** |
||
241 | * Создание тега с защищенным содержимым |
||
242 | * |
||
243 | * @param string $content текст, который будет обрамлен тегом |
||
244 | * @param string $tag тэг |
||
245 | * @param array $attribute список атрибутов, где ключ - имя атрибута, а значение - само значение данного атрибута |
||
246 | * @return string |
||
247 | */ |
||
248 | public static function build_safe_tag($content, $tag = 'span', $attribute = array(), $layout = EMTLib::LAYOUT_STYLE ) |
||
249 | { |
||
250 | $htmlTag = $tag; |
||
251 | |||
252 | if (self::$_typographSpecificTagId) |
||
0 ignored issues
–
show
The expression
self::$_typographSpecificTagId of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
253 | { |
||
254 | if(!isset($attribute['id'])) |
||
255 | { |
||
256 | $attribute['id'] = 'emt-2' . mt_rand(1000,9999); |
||
257 | } |
||
258 | } |
||
259 | |||
260 | $classname = ""; |
||
261 | if (count($attribute)) |
||
262 | { |
||
263 | |||
264 | if($layout & EMTLib::LAYOUT_STYLE) |
||
265 | { |
||
266 | if(isset($attribute['__style']) && $attribute['__style']) |
||
267 | { |
||
268 | if(isset($attribute['style']) && $attribute['style']) |
||
269 | { |
||
270 | $st = trim($attribute['style']); |
||
271 | if(mb_substr($st, -1) != ";") $st .= ";"; |
||
272 | $st .= $attribute['__style']; |
||
273 | $attribute['style'] = $st; |
||
274 | } else { |
||
275 | $attribute['style'] = $attribute['__style']; |
||
276 | } |
||
277 | unset($attribute['__style']); |
||
278 | } |
||
279 | |||
280 | } |
||
281 | foreach ($attribute as $attr => $value) |
||
282 | { |
||
283 | if($attr == "__style") continue; |
||
284 | if($attr == "class") { |
||
285 | $classname = "$value"; |
||
286 | continue; |
||
287 | } |
||
288 | $htmlTag .= " $attr=\"$value\""; |
||
289 | } |
||
290 | |||
291 | } |
||
292 | |||
293 | if( ($layout & EMTLib::LAYOUT_CLASS ) && $classname) { |
||
294 | $htmlTag .= " class=\"$classname\""; |
||
295 | } |
||
296 | |||
297 | return "<" . self::encrypt_tag($htmlTag) . ">$content</" . self::encrypt_tag($tag) . ">"; |
||
298 | } |
||
299 | |||
300 | /** |
||
301 | * Метод, осуществляющий кодирование (сохранение) информации |
||
302 | * с целью невозможности типографировать ее |
||
303 | * |
||
304 | * @param string $text |
||
305 | * @return string |
||
306 | */ |
||
307 | public static function encrypt_tag($text) |
||
308 | { |
||
309 | return base64_encode($text)."="; |
||
310 | } |
||
311 | |||
312 | /** |
||
313 | * Метод, осуществляющий декодирование информации |
||
314 | * |
||
315 | * @param string $text |
||
316 | * @return string |
||
317 | */ |
||
318 | public static function decrypt_tag($text) |
||
319 | { |
||
320 | return base64_decode(substr($text,0,-1)); |
||
321 | } |
||
322 | |||
323 | |||
324 | |||
325 | public static function strpos_ex(&$haystack, $needle, $offset = null) |
||
326 | { |
||
327 | if(is_array($needle)) |
||
328 | { |
||
329 | $m = false; |
||
330 | $w = false; |
||
331 | foreach($needle as $n) |
||
332 | { |
||
333 | $p = strpos($haystack, $n , $offset); |
||
334 | if($p===false) continue; |
||
335 | if($m === false) |
||
336 | { |
||
337 | $m = $p; |
||
338 | $w = $n; |
||
339 | continue; |
||
340 | } |
||
341 | if($p < $m) |
||
342 | { |
||
343 | $m = $p; |
||
344 | $w = $n; |
||
345 | } |
||
346 | } |
||
347 | if($m === false) return false; |
||
348 | return array('pos' => $m, 'str' => $w); |
||
349 | } |
||
350 | return strpos($haystack, $needle, $offset); |
||
351 | } |
||
352 | |||
353 | public static function _process_selector_pattern(&$pattern) |
||
354 | { |
||
355 | if($pattern===false) return; |
||
356 | $pattern = preg_quote($pattern , '/'); |
||
357 | $pattern = str_replace("\\*", "[a-z0-9_\-]*", $pattern); |
||
358 | $pattern = "/".$pattern."/i"; |
||
359 | } |
||
360 | public static function _test_pattern($pattern, $text) |
||
361 | { |
||
362 | if($pattern === false) return true; |
||
363 | return preg_match($pattern, $text); |
||
364 | } |
||
365 | |||
366 | public static function strtolower($string) |
||
367 | { |
||
368 | $convert_to = array( |
||
369 | "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", |
||
370 | "v", "w", "x", "y", "z", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", |
||
371 | "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "ø", "ù", "ú", "û", "ü", "ý", "а", "б", "в", "г", "д", "е", "ё", "ж", |
||
372 | "з", "и", "й", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "х", "ц", "ч", "ш", "щ", "ъ", "ы", |
||
373 | "ь", "э", "ю", "я" |
||
374 | ); |
||
375 | $convert_from = array( |
||
376 | "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", |
||
377 | "V", "W", "X", "Y", "Z", "À", "Á", "Â", "Ã", "Ä", "Å", "Æ", "Ç", "È", "É", "Ê", "Ë", "Ì", "Í", "Î", "Ï", |
||
378 | "Ð", "Ñ", "Ò", "Ó", "Ô", "Õ", "Ö", "Ø", "Ù", "Ú", "Û", "Ü", "Ý", "А", "Б", "В", "Г", "Д", "Е", "Ё", "Ж", |
||
379 | "З", "И", "Й", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Х", "Ц", "Ч", "Ш", "Щ", "Ъ", "Ъ", |
||
380 | "Ь", "Э", "Ю", "Я" |
||
381 | ); |
||
382 | |||
383 | return str_replace($convert_from, $convert_to, $string); |
||
384 | } |
||
385 | |||
386 | // взято с http://www.w3.org/TR/html4/sgml/entities.html |
||
387 | protected static $html4_char_ents = array( |
||
388 | 'nbsp' => 160, |
||
389 | 'iexcl' => 161, |
||
390 | 'cent' => 162, |
||
391 | 'pound' => 163, |
||
392 | 'curren' => 164, |
||
393 | 'yen' => 165, |
||
394 | 'brvbar' => 166, |
||
395 | 'sect' => 167, |
||
396 | 'uml' => 168, |
||
397 | 'copy' => 169, |
||
398 | 'ordf' => 170, |
||
399 | 'laquo' => 171, |
||
400 | 'not' => 172, |
||
401 | 'shy' => 173, |
||
402 | 'reg' => 174, |
||
403 | 'macr' => 175, |
||
404 | 'deg' => 176, |
||
405 | 'plusmn' => 177, |
||
406 | 'sup2' => 178, |
||
407 | 'sup3' => 179, |
||
408 | 'acute' => 180, |
||
409 | 'micro' => 181, |
||
410 | 'para' => 182, |
||
411 | 'middot' => 183, |
||
412 | 'cedil' => 184, |
||
413 | 'sup1' => 185, |
||
414 | 'ordm' => 186, |
||
415 | 'raquo' => 187, |
||
416 | 'frac14' => 188, |
||
417 | 'frac12' => 189, |
||
418 | 'frac34' => 190, |
||
419 | 'iquest' => 191, |
||
420 | 'Agrave' => 192, |
||
421 | 'Aacute' => 193, |
||
422 | 'Acirc' => 194, |
||
423 | 'Atilde' => 195, |
||
424 | 'Auml' => 196, |
||
425 | 'Aring' => 197, |
||
426 | 'AElig' => 198, |
||
427 | 'Ccedil' => 199, |
||
428 | 'Egrave' => 200, |
||
429 | 'Eacute' => 201, |
||
430 | 'Ecirc' => 202, |
||
431 | 'Euml' => 203, |
||
432 | 'Igrave' => 204, |
||
433 | 'Iacute' => 205, |
||
434 | 'Icirc' => 206, |
||
435 | 'Iuml' => 207, |
||
436 | 'ETH' => 208, |
||
437 | 'Ntilde' => 209, |
||
438 | 'Ograve' => 210, |
||
439 | 'Oacute' => 211, |
||
440 | 'Ocirc' => 212, |
||
441 | 'Otilde' => 213, |
||
442 | 'Ouml' => 214, |
||
443 | 'times' => 215, |
||
444 | 'Oslash' => 216, |
||
445 | 'Ugrave' => 217, |
||
446 | 'Uacute' => 218, |
||
447 | 'Ucirc' => 219, |
||
448 | 'Uuml' => 220, |
||
449 | 'Yacute' => 221, |
||
450 | 'THORN' => 222, |
||
451 | 'szlig' => 223, |
||
452 | 'agrave' => 224, |
||
453 | 'aacute' => 225, |
||
454 | 'acirc' => 226, |
||
455 | 'atilde' => 227, |
||
456 | 'auml' => 228, |
||
457 | 'aring' => 229, |
||
458 | 'aelig' => 230, |
||
459 | 'ccedil' => 231, |
||
460 | 'egrave' => 232, |
||
461 | 'eacute' => 233, |
||
462 | 'ecirc' => 234, |
||
463 | 'euml' => 235, |
||
464 | 'igrave' => 236, |
||
465 | 'iacute' => 237, |
||
466 | 'icirc' => 238, |
||
467 | 'iuml' => 239, |
||
468 | 'eth' => 240, |
||
469 | 'ntilde' => 241, |
||
470 | 'ograve' => 242, |
||
471 | 'oacute' => 243, |
||
472 | 'ocirc' => 244, |
||
473 | 'otilde' => 245, |
||
474 | 'ouml' => 246, |
||
475 | 'divide' => 247, |
||
476 | 'oslash' => 248, |
||
477 | 'ugrave' => 249, |
||
478 | 'uacute' => 250, |
||
479 | 'ucirc' => 251, |
||
480 | 'uuml' => 252, |
||
481 | 'yacute' => 253, |
||
482 | 'thorn' => 254, |
||
483 | 'yuml' => 255, |
||
484 | 'fnof' => 402, |
||
485 | 'Alpha' => 913, |
||
486 | 'Beta' => 914, |
||
487 | 'Gamma' => 915, |
||
488 | 'Delta' => 916, |
||
489 | 'Epsilon' => 917, |
||
490 | 'Zeta' => 918, |
||
491 | 'Eta' => 919, |
||
492 | 'Theta' => 920, |
||
493 | 'Iota' => 921, |
||
494 | 'Kappa' => 922, |
||
495 | 'Lambda' => 923, |
||
496 | 'Mu' => 924, |
||
497 | 'Nu' => 925, |
||
498 | 'Xi' => 926, |
||
499 | 'Omicron' => 927, |
||
500 | 'Pi' => 928, |
||
501 | 'Rho' => 929, |
||
502 | 'Sigma' => 931, |
||
503 | 'Tau' => 932, |
||
504 | 'Upsilon' => 933, |
||
505 | 'Phi' => 934, |
||
506 | 'Chi' => 935, |
||
507 | 'Psi' => 936, |
||
508 | 'Omega' => 937, |
||
509 | 'alpha' => 945, |
||
510 | 'beta' => 946, |
||
511 | 'gamma' => 947, |
||
512 | 'delta' => 948, |
||
513 | 'epsilon' => 949, |
||
514 | 'zeta' => 950, |
||
515 | 'eta' => 951, |
||
516 | 'theta' => 952, |
||
517 | 'iota' => 953, |
||
518 | 'kappa' => 954, |
||
519 | 'lambda' => 955, |
||
520 | 'mu' => 956, |
||
521 | 'nu' => 957, |
||
522 | 'xi' => 958, |
||
523 | 'omicron' => 959, |
||
524 | 'pi' => 960, |
||
525 | 'rho' => 961, |
||
526 | 'sigmaf' => 962, |
||
527 | 'sigma' => 963, |
||
528 | 'tau' => 964, |
||
529 | 'upsilon' => 965, |
||
530 | 'phi' => 966, |
||
531 | 'chi' => 967, |
||
532 | 'psi' => 968, |
||
533 | 'omega' => 969, |
||
534 | 'thetasym' => 977, |
||
535 | 'upsih' => 978, |
||
536 | 'piv' => 982, |
||
537 | 'bull' => 8226, |
||
538 | 'hellip' => 8230, |
||
539 | 'prime' => 8242, |
||
540 | 'Prime' => 8243, |
||
541 | 'oline' => 8254, |
||
542 | 'frasl' => 8260, |
||
543 | 'weierp' => 8472, |
||
544 | 'image' => 8465, |
||
545 | 'real' => 8476, |
||
546 | 'trade' => 8482, |
||
547 | 'alefsym' => 8501, |
||
548 | 'larr' => 8592, |
||
549 | 'uarr' => 8593, |
||
550 | 'rarr' => 8594, |
||
551 | 'darr' => 8595, |
||
552 | 'harr' => 8596, |
||
553 | 'crarr' => 8629, |
||
554 | 'lArr' => 8656, |
||
555 | 'uArr' => 8657, |
||
556 | 'rArr' => 8658, |
||
557 | 'dArr' => 8659, |
||
558 | 'hArr' => 8660, |
||
559 | 'forall' => 8704, |
||
560 | 'part' => 8706, |
||
561 | 'exist' => 8707, |
||
562 | 'empty' => 8709, |
||
563 | 'nabla' => 8711, |
||
564 | 'isin' => 8712, |
||
565 | 'notin' => 8713, |
||
566 | 'ni' => 8715, |
||
567 | 'prod' => 8719, |
||
568 | 'sum' => 8721, |
||
569 | 'minus' => 8722, |
||
570 | 'lowast' => 8727, |
||
571 | 'radic' => 8730, |
||
572 | 'prop' => 8733, |
||
573 | 'infin' => 8734, |
||
574 | 'ang' => 8736, |
||
575 | 'and' => 8743, |
||
576 | 'or' => 8744, |
||
577 | 'cap' => 8745, |
||
578 | 'cup' => 8746, |
||
579 | 'int' => 8747, |
||
580 | 'there4' => 8756, |
||
581 | 'sim' => 8764, |
||
582 | 'cong' => 8773, |
||
583 | 'asymp' => 8776, |
||
584 | 'ne' => 8800, |
||
585 | 'equiv' => 8801, |
||
586 | 'le' => 8804, |
||
587 | 'ge' => 8805, |
||
588 | 'sub' => 8834, |
||
589 | 'sup' => 8835, |
||
590 | 'nsub' => 8836, |
||
591 | 'sube' => 8838, |
||
592 | 'supe' => 8839, |
||
593 | 'oplus' => 8853, |
||
594 | 'otimes' => 8855, |
||
595 | 'perp' => 8869, |
||
596 | 'sdot' => 8901, |
||
597 | 'lceil' => 8968, |
||
598 | 'rceil' => 8969, |
||
599 | 'lfloor' => 8970, |
||
600 | 'rfloor' => 8971, |
||
601 | 'lang' => 9001, |
||
602 | 'rang' => 9002, |
||
603 | 'loz' => 9674, |
||
604 | 'spades' => 9824, |
||
605 | 'clubs' => 9827, |
||
606 | 'hearts' => 9829, |
||
607 | 'diams' => 9830, |
||
608 | 'quot' => 34, |
||
609 | 'amp' => 38, |
||
610 | 'lt' => 60, |
||
611 | 'gt' => 62, |
||
612 | 'OElig' => 338, |
||
613 | 'oelig' => 339, |
||
614 | 'Scaron' => 352, |
||
615 | 'scaron' => 353, |
||
616 | 'Yuml' => 376, |
||
617 | 'circ' => 710, |
||
618 | 'tilde' => 732, |
||
619 | 'ensp' => 8194, |
||
620 | 'emsp' => 8195, |
||
621 | 'thinsp' => 8201, |
||
622 | 'zwnj' => 8204, |
||
623 | 'zwj' => 8205, |
||
624 | 'lrm' => 8206, |
||
625 | 'rlm' => 8207, |
||
626 | 'ndash' => 8211, |
||
627 | 'mdash' => 8212, |
||
628 | 'lsquo' => 8216, |
||
629 | 'rsquo' => 8217, |
||
630 | 'sbquo' => 8218, |
||
631 | 'ldquo' => 8220, |
||
632 | 'rdquo' => 8221, |
||
633 | 'bdquo' => 8222, |
||
634 | 'dagger' => 8224, |
||
635 | 'Dagger' => 8225, |
||
636 | 'permil' => 8240, |
||
637 | 'lsaquo' => 8249, |
||
638 | 'rsaquo' => 8250, |
||
639 | 'euro' => 8364, |
||
640 | ); |
||
641 | /** |
||
642 | * Вернуть уникод символ по html entinty |
||
643 | * |
||
644 | * @param string $entity |
||
645 | * @return string |
||
646 | */ |
||
647 | public static function html_char_entity_to_unicode($entity) |
||
648 | { |
||
649 | if(isset(self::$html4_char_ents[$entity])) return self::_getUnicodeChar(self::$html4_char_ents[$entity]); |
||
650 | return false; |
||
651 | } |
||
652 | |||
653 | /** |
||
654 | * Сконвериторвать все html entity в соответсвующие юникод символы |
||
655 | * |
||
656 | * @param string $text |
||
657 | */ |
||
658 | public static function convert_html_entities_to_unicode(&$text) |
||
659 | { |
||
660 | $text = preg_replace_callback("/\&#([0-9]+)\;/", |
||
661 | create_function('$m', 'return \Fenrizbes\TypographBundle\EMT\EMTLib::_getUnicodeChar(intval($m[1]));') |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
662 | , $text); |
||
663 | $text = preg_replace_callback("/\&#x([0-9A-F]+)\;/", |
||
664 | create_function('$m', 'return \Fenrizbes\TypographBundle\EMT\EMTLib::_getUnicodeChar(hexdec($m[1]));') |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
665 | , $text); |
||
666 | $text = preg_replace_callback("/\&([a-zA-Z0-9]+)\;/", |
||
667 | create_function('$m', '$r = \Fenrizbes\TypographBundle\EMT\EMTLib::html_char_entity_to_unicode($m[1]); return $r ? $r : $m[0];') |
||
0 ignored issues
–
show
The use of
create_function is highly discouraged, better use a closure.
// Instead of
$function = create_function('$a, $b', 'return $a + $b');
// Better use
$function = function($a, $b) { return $a + $b; }
![]() |
|||
668 | , $text); |
||
669 | } |
||
670 | |||
671 | public static function rstrpos ($haystack, $needle, $offset = 0){ |
||
672 | |||
673 | if(trim($haystack) != "" && trim($needle) != "" && $offset <= mb_strlen($haystack)) |
||
674 | { |
||
675 | $last_pos = $offset; |
||
676 | $found = false; |
||
677 | while(($curr_pos = mb_strpos($haystack, $needle, $last_pos)) !== false) |
||
678 | { |
||
679 | $found = true; |
||
680 | $last_pos = $curr_pos + 1; |
||
681 | } |
||
682 | if($found) |
||
683 | { |
||
684 | return $last_pos - 1; |
||
685 | } |
||
686 | else |
||
687 | { |
||
688 | return false; |
||
689 | } |
||
690 | } |
||
691 | else |
||
692 | { |
||
693 | return false; |
||
694 | } |
||
695 | } |
||
696 | |||
697 | public static function ifop($cond, $true, $false) { |
||
698 | return $cond ? $true : $false; |
||
699 | } |
||
700 | |||
701 | } |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.