PageRenderTime 60ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

/Functions.php

https://bitbucket.org/corpsee/nameless-framework
PHP | 353 lines | 237 code | 15 blank | 101 comment | 3 complexity | 8ce277b3210b07be6d41025b41507993 MD5 | raw file
  1. <?php
  2. /*function utf8_chr($dec)
  3. {
  4. if ($dec < 128)
  5. return chr($dec);
  6. if ($dec < 2048)
  7. return chr(($dec >> 6) + 192) . chr(($dec & 63) + 128);
  8. if ($dec < 65536)
  9. return chr(($dec >> 12) + 224) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
  10. if ($dec < 2097152)
  11. return chr(($dec >> 18) + 240) . chr((($dec >> 12) & 63) + 128) . chr((($dec >> 6) & 63) + 128) . chr(($dec & 63) + 128);
  12. return '';
  13. }
  14. function utf8_ord($str)
  15. {
  16. if (ord($str{0}) >= 0 && ord($str{0}) <= 127)
  17. return ord($str{0});
  18. if (ord($str{0}) >= 192 && ord($str{0}) <= 223)
  19. return (ord($str{0})-192)*64 + (ord($str{1})-128);
  20. if (ord($str{0}) >= 224 && ord($str{0}) <= 239)
  21. return (ord($str{0})-224)*4096 + (ord($str{1})-128)*64 + (ord($str{2})-128);
  22. if (ord($str{0}) >= 240 && ord($str{0}) <= 247)
  23. return (ord($str{0})-240)*262144 + (ord($str{1})-128)*4096 + (ord($str{2})-128)*64 + (ord($str{3})-128);
  24. if (ord($str{0}) >= 248 && ord($str{0}) <= 251)
  25. return (ord($str{0})-248)*16777216 + (ord($str{1})-128)*262144 + (ord($str{2})-128)*4096 + (ord($str{3})-128)*64 + (ord($str{4})-128);
  26. if (ord($str{0}) >= 252 && ord($str{0}) <= 253)
  27. return (ord($str{0})-252)*1073741824 + (ord($str{1})-128)*16777216 + (ord($str{2})-128)*262144 + (ord($str{3})-128)*4096 + (ord($str{4})-128)*64 + (ord($str{5})-128);
  28. if (ord($str{0}) >= 254 && ord($str{0}) <= 255) //error
  29. return false;
  30. return 0;
  31. }
  32. function utf8_decode_entities($str)
  33. {
  34. $str = preg_replace_callback('~&#x([0-9a-f]+);~i', 'utf8_hexchr_callback', $str);
  35. $str = preg_replace_callback('~&#([0-9]+);~', 'utf8_chr_callback', $str);
  36. return $str;
  37. }
  38. function utf8_chr_callback($matches)
  39. {
  40. return utf8_chr($matches[1]);
  41. }
  42. function utf8_hexchr_callback($matches)
  43. {
  44. return utf8_chr(hexdec($matches[1]));
  45. }
  46. function utf8_convert_encoding ($str, $to, $from = NULL)
  47. {
  48. mb_substitute_character('none');
  49. return mb_convert_encoding($str, $to, $from);
  50. }*/
  51. /**
  52. * @param string $value
  53. * @param int $rounds
  54. *
  55. * @return string
  56. */
  57. function hashMake($value, $rounds = 10)
  58. {
  59. $work_rounds = str_pad($rounds, 2, '0', STR_PAD_LEFT);
  60. $salt = substr(str_shuffle(str_repeat('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ', 5)), 0, 40);
  61. $salt = substr(strtr(base64_encode($salt), '+', '.'), 0 , 22);
  62. return crypt($value, '$2a$' . $work_rounds . '$' . $salt);
  63. }
  64. /**
  65. * @param string $value
  66. * @param string $hash
  67. *
  68. * @return boolean
  69. */
  70. function hashCheck($value, $hash)
  71. {
  72. return crypt($value, $hash) === $hash;
  73. }
  74. /**
  75. * @param string $path
  76. *
  77. * @return string
  78. */
  79. function pathToURL ($path)
  80. {
  81. return str_replace(array(FILE_PATH, DS, '\\'), array(FILE_PATH_URL, '/', '/'), $path);
  82. }
  83. /**
  84. * @param string $path
  85. *
  86. * @return string
  87. */
  88. function URLToPath ($path)
  89. {
  90. return str_replace(array(FILE_PATH_URL, '/'), array(FILE_PATH, DS), $path);
  91. }
  92. /**
  93. * @param string $str
  94. *
  95. * @return string
  96. */
  97. function romanize ($str)
  98. {
  99. $romanize = array
  100. (
  101. // Lower accents
  102. 'à'=>'a','ô'=>'o','?'=>'d','?'=>'f','ë'=>'e','š'=>'s','?'=>'o','ß'=>'ss','?'=>'a','?'=>'r',
  103. '?'=>'t','?'=>'n','?'=>'a','?'=>'k','?'=>'s','?'=>'y','?'=>'n','?'=>'l','?'=>'h','?'=>'p',
  104. 'ó'=>'o','ú'=>'u','?'=>'e','é'=>'e','ç'=>'c','?'=>'w','?'=>'c','õ'=>'o','?'=>'s','ø'=>'o',
  105. '?'=>'g','?'=>'t','?'=>'s','?'=>'e','?'=>'c','?'=>'s','î'=>'i','?'=>'u','?'=>'c','?'=>'e',
  106. '?'=>'w','?'=>'t','?'=>'u','?'=>'c','ö'=>'oe','è'=>'e','?'=>'y','?'=>'a','?'=>'l','?'=>'u',
  107. '?'=>'u','?'=>'s','?'=>'g','?'=>'l','ƒ'=>'f','ž'=>'z','?'=>'w','?'=>'b','å'=>'a','ì'=>'i',
  108. 'ï'=>'i','?'=>'d','?'=>'t','?'=>'r','ä'=>'ae','í'=>'i','?'=>'r','ê'=>'e','ü'=>'ue','ò'=>'o',
  109. '?'=>'e','ñ'=>'n','?'=>'n','?'=>'h','?'=>'g','?'=>'d','?'=>'j','ÿ'=>'y','?'=>'u','?'=>'u',
  110. '?'=>'u','?'=>'t','ý'=>'y','?'=>'o','â'=>'a','?'=>'l','?'=>'w','?'=>'z','?'=>'i','ã'=>'a',
  111. '?'=>'g','?'=>'m','?'=>'o','?'=>'i','ù'=>'u','?'=>'i','?'=>'z','á'=>'a','û'=>'u','þ'=>'th',
  112. 'ð'=>'dh','æ'=>'ae','µ'=>'u','?'=>'e',
  113. // Upper accents
  114. 'À'=>'A','Ô'=>'O','?'=>'D','?'=>'F','Ë'=>'E','Š'=>'S','?'=>'O','?'=>'A','?'=>'R','?'=>'T',
  115. '?'=>'N','?'=>'A','?'=>'K','?'=>'S','?'=>'Y','?'=>'N','?'=>'L','?'=>'H','?'=>'P','Ó'=>'O',
  116. 'Ú'=>'U','?'=>'E','É'=>'E','Ç'=>'C','?'=>'W','?'=>'C','Õ'=>'O','?'=>'S','Ø'=>'O','?'=>'G',
  117. '?'=>'T','?'=>'S','?'=>'E','?'=>'C','?'=>'S','Î'=>'I','?'=>'U','?'=>'C','?'=>'E','?'=>'W',
  118. '?'=>'T','?'=>'U','?'=>'C','Ö'=>'Oe','È'=>'E','?'=>'Y','?'=>'A','?'=>'L','?'=>'U','?'=>'U',
  119. '?'=>'S','?'=>'G','?'=>'L','?'=>'F','Ž'=>'Z','?'=>'W','?'=>'B','Å'=>'A','Ì'=>'I','Ï'=>'I',
  120. '?'=>'D','?'=>'T','?'=>'R','Ä'=>'Ae','Í'=>'I','?'=>'R','Ê'=>'E','Ü'=>'Ue','Ò'=>'O','?'=>'E',
  121. 'Ñ'=>'N','?'=>'N','?'=>'H','?'=>'G','?'=>'D','?'=>'J','Ÿ'=>'Y','?'=>'U','?'=>'U','?'=>'U',
  122. '?'=>'T','Ý'=>'Y','?'=>'O','Â'=>'A','?'=>'L','?'=>'W','?'=>'Z','?'=>'I','Ã'=>'A','?'=>'G',
  123. '?'=>'M','?'=>'O','?'=>'I','Ù'=>'U','?'=>'I','?'=>'Z','Á'=>'A','Û'=>'U','Þ'=>'Th','Ð'=>'Dh',
  124. 'Æ'=>'Ae','?'=>'E',
  125. // Russian cyrillic
  126. '?'=>'a','?'=>'A','?'=>'b','?'=>'B','?'=>'v','?'=>'V','?'=>'g','?'=>'G','?'=>'d','?'=>'D',
  127. '?'=>'e','?'=>'E','?'=>'jo','?'=>'Jo','?'=>'zh','?'=>'Zh','?'=>'z','?'=>'Z','?'=>'i','?'=>'I',
  128. '?'=>'j','?'=>'J','?'=>'k','?'=>'K','?'=>'l','?'=>'L','?'=>'m','?'=>'M','?'=>'n','?'=>'N',
  129. '?'=>'o','?'=>'O','?'=>'p','?'=>'P','?'=>'r','?'=>'R','?'=>'s','?'=>'S','?'=>'t','?'=>'T',
  130. '?'=>'u','?'=>'U','?'=>'f','?'=>'F','?'=>'x','?'=>'X','?'=>'c','?'=>'C','?'=>'ch','?'=>'Ch',
  131. '?'=>'sh','?'=>'Sh','?'=>'sch','?'=>'Sch','?'=>'','?'=>'','?'=>'y','?'=>'Y','?'=>'','?'=>'',
  132. '?'=>'eh','?'=>'Eh','?'=>'ju','?'=>'Ju','?'=>'ja','?'=>'Ja',
  133. // Ukrainian cyrillic
  134. '?'=>'Gh','?'=>'gh','?'=>'Je','?'=>'je','?'=>'I','?'=>'i','?'=>'Ji','?'=>'ji',
  135. // Georgian
  136. '?'=>'a','?'=>'b','?'=>'g','?'=>'d','?'=>'e','?'=>'v','?'=>'z','?'=>'th','?'=>'i','?'=>'p',
  137. '?'=>'l','?'=>'m','?'=>'n','?'=>'o','?'=>'p','?'=>'zh','?'=>'r','?'=>'s','?'=>'t','?'=>'u',
  138. '?'=>'ph','?'=>'kh','?'=>'gh','?'=>'q','?'=>'sh','?'=>'ch','?'=>'c','?'=>'dh','?'=>'w','?'=>'j',
  139. '?'=>'x','?'=>'jh','?'=>'xh',
  140. // Sanskrit
  141. '?'=>'a','?'=>'ah','?'=>'i','?'=>'ih','?'=>'u','?'=>'uh','?'=>'ry','?'=>'ryh','?'=>'ly','?'=>'lyh',
  142. '?'=>'e','?'=>'ay','?'=>'o','?'=>'aw','??'=>'amh','??'=>'aq','?'=>'k','?'=>'kh','?'=>'g','?'=>'gh',
  143. '?'=>'nh','?'=>'c','?'=>'ch','?'=>'j','?'=>'jh','?'=>'ny','?'=>'tq','?'=>'tqh','?'=>'dq','?'=>'dqh',
  144. '?'=>'nq','?'=>'t','?'=>'th','?'=>'d','?'=>'dh','?'=>'n','?'=>'p','?'=>'ph','?'=>'b','?'=>'bh',
  145. '?'=>'m','?'=>'z','?'=>'r','?'=>'l','?'=>'v','?'=>'sh','?'=>'sqh','?'=>'s','?'=>'x',
  146. // Hebrew
  147. '?'=>'a', '?'=>'b','?'=>'g','?'=>'d','?'=>'h','?'=>'v','?'=>'z','?'=>'kh','?'=>'th','?'=>'y',
  148. '?'=>'h','?'=>'k','?'=>'l','?'=>'m','?'=>'m','?'=>'n','?'=>'n','?'=>'s','?'=>'ah','?'=>'f',
  149. '?'=>'p','?'=>'c','?'=>'c','?'=>'q','?'=>'r','?'=>'sh','?'=>'t',
  150. // Arabic
  151. '?'=>'a','?'=>'b','?'=>'t','?'=>'th','?'=>'g','?'=>'xh','?'=>'x','?'=>'d','?'=>'dh','?'=>'r',
  152. '?'=>'z','?'=>'s','?'=>'sh','?'=>'s\'','?'=>'d\'','?'=>'t\'','?'=>'z\'','?'=>'y','?'=>'gh',
  153. '?'=>'f','?'=>'q','?'=>'k','?'=>'l','?'=>'m','?'=>'n','?'=>'x\'','?'=>'u','?'=>'i',
  154. // Japanese hiragana
  155. '?'=>'a','?'=>'e','?'=>'i','?'=>'o','?'=>'u','?'=>'ba','?'=>'be','?'=>'bi','?'=>'bo','?'=>'bu',
  156. '?'=>'ci','?'=>'da','?'=>'de','?'=>'di','?'=>'do','?'=>'du','??'=>'fa','??'=>'fe','??'=>'fi','??'=>'fo',
  157. '?'=>'fu','?'=>'ga','?'=>'ge','?'=>'gi','?'=>'go','?'=>'gu','?'=>'ha','?'=>'he','?'=>'hi','?'=>'ho',
  158. '?'=>'hu','??'=>'ja','??'=>'je','?'=>'ji','??'=>'jo','??'=>'ju','?'=>'ka','?'=>'ke','?'=>'ki','?'=>'ko',
  159. '?'=>'ku','?'=>'la','?'=>'le','?'=>'li','?'=>'lo','?'=>'lu','?'=>'ma','?'=>'me','?'=>'mi','?'=>'mo',
  160. '?'=>'mu','?'=>'na','?'=>'ne','?'=>'ni','?'=>'no','?'=>'nu','?'=>'pa','?'=>'pe','?'=>'pi','?'=>'po',
  161. '?'=>'pu','?'=>'ra','?'=>'re','?'=>'ri','?'=>'ro','?'=>'ru','?'=>'sa','?'=>'se','?'=>'si','?'=>'so',
  162. '?'=>'su','?'=>'ta','?'=>'te','?'=>'ti','?'=>'to','?'=>'tu','??'=>'va','??'=>'ve','??'=>'vi','??'=>'vo',
  163. '?'=>'vu','?'=>'wa','??'=>'we','??'=>'wi','?'=>'wo','?'=>'ya','??'=>'ye','?'=>'yi','?'=>'yo','?'=>'yu',
  164. '?'=>'za','?'=>'ze','?'=>'zi','?'=>'zo','?'=>'zu','??'=>'bya','??'=>'bye','??'=>'byi','??'=>'byo','??'=>'byu',
  165. '??'=>'cha','??'=>'che','?'=>'chi','??'=>'cho','??'=>'chu','??'=>'cya','??'=>'cye','??'=>'cyi','??'=>'cyo',
  166. '??'=>'cyu','??'=>'dha','??'=>'dhe','??'=>'dhi','??'=>'dho','??'=>'dhu','??'=>'dwa','??'=>'dwe','??'=>'dwi',
  167. '??'=>'dwo','??'=>'dwu','??'=>'dya','??'=>'dye','??'=>'dyi','??'=>'dyo','??'=>'dyu','?'=>'dzi','??'=>'fwa',
  168. '??'=>'fwe','??'=>'fwi','??'=>'fwo','??'=>'fwu','??'=>'fya','??'=>'fye','??'=>'fyi','??'=>'fyo','??'=>'fyu',
  169. '??'=>'gya','??'=>'gye','??'=>'gyi','??'=>'gyo','??'=>'gyu','??'=>'hya','??'=>'hye','??'=>'hyi','??'=>'hyo',
  170. '??'=>'hyu','??'=>'jya','??'=>'jye','??'=>'jyi','??'=>'jyo','??'=>'jyu','??'=>'kya','??'=>'kye','??'=>'kyi',
  171. '??'=>'kyo','??'=>'kyu','??'=>'lya','??'=>'lye','??'=>'lyi','??'=>'lyo','??'=>'lyu','??'=>'mya','??'=>'mye',
  172. '??'=>'myi','??'=>'myo','??'=>'myu','?'=>'n','??'=>'nya','??'=>'nye','??'=>'nyi','??'=>'nyo','??'=>'nyu',
  173. '??'=>'pya','??'=>'pye','??'=>'pyi','??'=>'pyo','??'=>'pyu','??'=>'rya','??'=>'rye','??'=>'ryi','??'=>'ryo',
  174. '??'=>'ryu','??'=>'sha','??'=>'she','?'=>'shi','??'=>'sho','??'=>'shu','??'=>'swa','??'=>'swe','??'=>'swi',
  175. '??'=>'swo','??'=>'swu','??'=>'sya','??'=>'sye','??'=>'syi','??'=>'syo','??'=>'syu','??'=>'tha','??'=>'the',
  176. '??'=>'thi','??'=>'tho','??'=>'thu','??'=>'tsa','??'=>'tse','??'=>'tsi','??'=>'tso','?'=>'tsu','??'=>'twa',
  177. '??'=>'twe','??'=>'twi','??'=>'two','??'=>'twu','??'=>'tya','??'=>'tye','??'=>'tyi','??'=>'tyo','??'=>'tyu',
  178. '??'=>'vya','??'=>'vye','??'=>'vyi','??'=>'vyo','??'=>'vyu','??'=>'wha','??'=>'whe','??'=>'whi','??'=>'who',
  179. '??'=>'whu','?'=>'wye','?'=>'wyi','??'=>'zha','??'=>'zhe','??'=>'zhi','??'=>'zho','??'=>'zhu','??'=>'zya',
  180. '??'=>'zye','??'=>'zyi','??'=>'zyo','??'=>'zyu',
  181. // Japanese katakana
  182. '?'=>'a','?'=>'e','?'=>'i','?'=>'o','?'=>'u','?'=>'ba','?'=>'be','?'=>'bi','?'=>'bo','?'=>'bu',
  183. '?'=>'ci','?'=>'da','?'=>'de','?'=>'di','?'=>'do','?'=>'du','??'=>'fa','??'=>'fe','??'=>'fi','??'=>'fo',
  184. '?'=>'fu','?'=>'ga','?'=>'ge','?'=>'gi','?'=>'go','?'=>'gu','?'=>'ha','?'=>'he','?'=>'hi','?'=>'ho',
  185. '?'=>'hu','??'=>'ja','??'=>'je','?'=>'ji','??'=>'jo','??'=>'ju','?'=>'ka','?'=>'ke','?'=>'ki','?'=>'ko',
  186. '?'=>'ku','?'=>'la','?'=>'le','?'=>'li','?'=>'lo','?'=>'lu','?'=>'ma','?'=>'me','?'=>'mi','?'=>'mo',
  187. '?'=>'mu','?'=>'na','?'=>'ne','?'=>'ni','?'=>'no','?'=>'nu','?'=>'pa','?'=>'pe','?'=>'pi','?'=>'po',
  188. '?'=>'pu','?'=>'ra','?'=>'re','?'=>'ri','?'=>'ro','?'=>'ru','?'=>'sa','?'=>'se','?'=>'si','?'=>'so',
  189. '?'=>'su','?'=>'ta','?'=>'te','?'=>'ti','?'=>'to','?'=>'tu','??'=>'va','??'=>'ve','??'=>'vi','??'=>'vo',
  190. '?'=>'vu','?'=>'wa','??'=>'we','??'=>'wi','?'=>'wo','?'=>'ya','??'=>'ye','?'=>'yi','?'=>'yo','?'=>'yu',
  191. '?'=>'za','?'=>'ze','?'=>'zi','?'=>'zo','?'=>'zu','??'=>'bya','??'=>'bye','??'=>'byi','??'=>'byo',
  192. '??'=>'byu','??'=>'cha','??'=>'che','?'=>'chi','??'=>'cho','??'=>'chu','??'=>'cya','??'=>'cye','??'=>'cyi',
  193. '??'=>'cyo','??'=>'cyu','??'=>'dha','??'=>'dhe','??'=>'dhi','??'=>'dho','??'=>'dhu','??'=>'dwa','??'=>'dwe',
  194. '??'=>'dwi','??'=>'dwo','??'=>'dwu','??'=>'dya','??'=>'dye','??'=>'dyi','??'=>'dyo','??'=>'dyu','?'=>'dzi',
  195. '??'=>'fwa','??'=>'fwe','??'=>'fwi','??'=>'fwo','??'=>'fwu','??'=>'fya','??'=>'fye','??'=>'fyi','??'=>'fyo',
  196. '??'=>'fyu','??'=>'gya','??'=>'gye','??'=>'gyi','??'=>'gyo','??'=>'gyu','??'=>'hya','??'=>'hye','??'=>'hyi',
  197. '??'=>'hyo','??'=>'hyu','??'=>'jya','??'=>'jye','??'=>'jyi','??'=>'jyo','??'=>'jyu','??'=>'kya','??'=>'kye',
  198. '??'=>'kyi','??'=>'kyo','??'=>'kyu','??'=>'lya','??'=>'lye','??'=>'lyi','??'=>'lyo','??'=>'lyu','??'=>'mya',
  199. '??'=>'mye','??'=>'myi','??'=>'myo','??'=>'myu','?'=>'n','??'=>'nya','??'=>'nye','??'=>'nyi','??'=>'nyo',
  200. '??'=>'nyu','??'=>'pya','??'=>'pye','??'=>'pyi','??'=>'pyo','??'=>'pyu','??'=>'rya','??'=>'rye','??'=>'ryi',
  201. '??'=>'ryo','??'=>'ryu','??'=>'sha','??'=>'she','?'=>'shi','??'=>'sho','??'=>'shu','??'=>'swa','??'=>'swe',
  202. '??'=>'swi','??'=>'swo','??'=>'swu','??'=>'sya','??'=>'sye','??'=>'syi','??'=>'syo','??'=>'syu','??'=>'tha',
  203. '??'=>'the','??'=>'thi','??'=>'tho','??'=>'thu','??'=>'tsa','??'=>'tse','??'=>'tsi','??'=>'tso','?'=>'tsu',
  204. '??'=>'twa','??'=>'twe','??'=>'twi','??'=>'two','??'=>'twu','??'=>'tya','??'=>'tye','??'=>'tyi','??'=>'tyo',
  205. '??'=>'tyu','??'=>'vya','??'=>'vye','??'=>'vyi','??'=>'vyo','??'=>'vyu','??'=>'wha','??'=>'whe','??'=>'whi',
  206. '??'=>'who','??'=>'whu','?'=>'wye','?'=>'wyi','??'=>'zha','??'=>'zhe','??'=>'zhi','??'=>'zho','??'=>'zhu',
  207. '??'=>'zya','??'=>'zye','??'=>'zyi','??'=>'zyo','??'=>'zyu',
  208. // Greek
  209. '?'=>'G','?'=>'E','?'=>'Th','?'=>'L','?'=>'X','?'=>'P','?'=>'S','?'=>'F','?'=>'Ps','?'=>'g',
  210. '?'=>'e','?'=>'th','?'=>'l','?'=>'x','?'=>'p','?'=>'s','?'=>'f','?'=>'ps',
  211. // Thai
  212. '?'=>'k','?'=>'kh','?'=>'kh','?'=>'kh','?'=>'kh','?'=>'kh','?'=>'ng','?'=>'ch','?'=>'ch','?'=>'ch',
  213. '?'=>'s','?'=>'ch','?'=>'y','?'=>'d','?'=>'t','?'=>'th','?'=>'d','?'=>'th','?'=>'n','?'=>'d',
  214. '?'=>'t','?'=>'th','?'=>'th','?'=>'th','?'=>'n','?'=>'b','?'=>'p','?'=>'ph','?'=>'f','?'=>'ph',
  215. '?'=>'f','?'=>'ph','?'=>'m','?'=>'y','?'=>'r','?'=>'rue','??'=>'rue','?'=>'l','?'=>'lue','??'=>'lue',
  216. '?'=>'w','?'=>'s','?'=>'s','?'=>'s','?'=>'h','?'=>'l','?'=>'h','?'=>'a','–?'=>'a','??'=>'a','?'=>'a',
  217. '??'=>'an','?'=>'am','–?'=>'i','–?'=>'i','–?'=>'ue','–?'=>'ue','–?'=>'u','–?'=>'u','??'=>'e',
  218. '?–?'=>'e','?'=>'e','??'=>'ae','?'=>'ae','??'=>'o','?'=>'o','???'=>'o','?'=>'o','???'=>'oe','?–?'=>'oe',
  219. '??'=>'oe','?–???'=>'ia','?–??'=>'ia','?–???'=>'uea','?–??'=>'uea','–???'=>'ua','–??'=>'ua',
  220. '?'=>'ua','?'=>'ai','?'=>'ai','–??'=>'ai','??'=>'ai','??'=>'ai','??'=>'ao','??'=>'ao','–??'=>'ui',
  221. '??'=>'oi','??'=>'oi','??'=>'oei','?–???'=>'ueai','??'=>'uai','–??'=>'io','?–??'=>'eo','??'=>'eo',
  222. '?–??'=>'aeo','??'=>'aeo','?–???'=>'iao',
  223. // Korean
  224. '?'=>'k','?'=>'kh','?'=>'kk','?'=>'t','?'=>'th','?'=>'tt','?'=>'p','?'=>'ph','?'=>'pp','?'=>'c','?'=>'ch',
  225. '?'=>'cc','?'=>'s','?'=>'ss','?'=>'h','?'=>'ng','?'=>'n','?'=>'l','?'=>'m', '?'=>'a','?'=>'e','?'=>'o',
  226. '?'=>'wu','?'=>'u','?'=>'i','?'=>'ay','?'=>'ey','?'=>'oy','?'=>'wa','?'=>'we','?'=>'wi','?'=>'way',
  227. '?'=>'wey','?'=>'uy','?'=>'ya','?'=>'ye','?'=>'oy','?'=>'yu','?'=>'yay','?'=>'yey'
  228. );
  229. return strtr($str, $romanize);
  230. }
  231. /*function utf8_ucfirst($str)
  232. {
  233. $str = mb_strtoupper(mb_substr($str, 0, 1)) . mb_substr($str, 1);
  234. return $str;
  235. }*/
  236. // ?????????? ?????? ? ???????? + _
  237. /**
  238. * @param string $str
  239. *
  240. * @return string
  241. */
  242. function standardize ($str)
  243. {
  244. return standardize_unicode(romanize($str));
  245. }
  246. // ?????????? ?????? ? ?????? + ?????? + _
  247. /**
  248. * @param string $str
  249. *
  250. * @return string
  251. */
  252. function standardize_unicode ($str)
  253. {
  254. $pattern = array('#[- \\/+\.,:;=]#iu', '#[^\p{L}\p{Nd}_]+#iu');
  255. $replace = array('_', '');
  256. $str = preg_replace($pattern, $replace, $str);
  257. return mb_strtolower(trim($str));
  258. }
  259. /**
  260. * @param string $first
  261. * @param string $second
  262. *
  263. * @return integer
  264. */
  265. function PicturesSort ($first, $second)
  266. {
  267. $first_date = \DateTime::createFromFormat('d.m.Y:H.i.s', $first['create_date'] . ':00.00.00');
  268. $second_date = \DateTime::createFromFormat('d.m.Y:H.i.s', $second['create_date'] . ':00.00.00');
  269. if ($first_date == $second_date)
  270. {
  271. return 0;
  272. }
  273. return ($first_date > $second_date) ? -1 : 1;
  274. }
  275. /**
  276. * @param string $string
  277. * @param string $delimiter
  278. *
  279. * @return array
  280. */
  281. function stringToArray ($string, $delimiter = ',')
  282. {
  283. $array = explode($delimiter, $string);
  284. foreach ($array as &$item) { $item = trim($item); }
  285. unset($item);
  286. return $array;
  287. }
  288. /**
  289. * @param $array
  290. * @param string $delimiter
  291. *
  292. * @return string
  293. */
  294. function arrayToString (array $array, $delimiter = ', ')
  295. {
  296. $string = '';
  297. if ($array)
  298. {
  299. $last_item = array_pop($array);
  300. foreach ($array as $item) { $string .= $item . $delimiter; }
  301. $string .= $last_item;
  302. }
  303. return $string;
  304. }