PageRenderTime 60ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/SimplePie/Misc.php

https://github.com/louieDA/bestilblomster
PHP | 2247 lines | 2184 code | 8 blank | 55 comment | 12 complexity | cecde679c62dd50207d8d25ece1a4b89 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, GPL-3.0, BSD-3-Clause, AGPL-1.0
  1. <?php
  2. /**
  3. * SimplePie
  4. *
  5. * A PHP-Based RSS and Atom Feed Framework.
  6. * Takes the hard work out of managing a complete RSS/Atom solution.
  7. *
  8. * Copyright (c) 2004-2012, Ryan Parman, Geoffrey Sneddon, Ryan McCue, and contributors
  9. * All rights reserved.
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification, are
  12. * permitted provided that the following conditions are met:
  13. *
  14. * * Redistributions of source code must retain the above copyright notice, this list of
  15. * conditions and the following disclaimer.
  16. *
  17. * * Redistributions in binary form must reproduce the above copyright notice, this list
  18. * of conditions and the following disclaimer in the documentation and/or other materials
  19. * provided with the distribution.
  20. *
  21. * * Neither the name of the SimplePie Team nor the names of its contributors may be used
  22. * to endorse or promote products derived from this software without specific prior
  23. * written permission.
  24. *
  25. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  26. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  27. * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  28. * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  29. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  31. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  32. * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  33. * POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. * @package SimplePie
  36. * @version 1.3.1
  37. * @copyright 2004-2012 Ryan Parman, Geoffrey Sneddon, Ryan McCue
  38. * @author Ryan Parman
  39. * @author Geoffrey Sneddon
  40. * @author Ryan McCue
  41. * @link http://simplepie.org/ SimplePie
  42. * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  43. */
  44. /**
  45. * Miscellanous utilities
  46. *
  47. * @package SimplePie
  48. */
  49. class SimplePie_Misc
  50. {
  51. public static function time_hms($seconds)
  52. {
  53. $time = '';
  54. $hours = floor($seconds / 3600);
  55. $remainder = $seconds % 3600;
  56. if ($hours > 0)
  57. {
  58. $time .= $hours.':';
  59. }
  60. $minutes = floor($remainder / 60);
  61. $seconds = $remainder % 60;
  62. if ($minutes < 10 && $hours > 0)
  63. {
  64. $minutes = '0' . $minutes;
  65. }
  66. if ($seconds < 10)
  67. {
  68. $seconds = '0' . $seconds;
  69. }
  70. $time .= $minutes.':';
  71. $time .= $seconds;
  72. return $time;
  73. }
  74. public static function absolutize_url($relative, $base)
  75. {
  76. $iri = SimplePie_IRI::absolutize(new SimplePie_IRI($base), $relative);
  77. if ($iri === false)
  78. {
  79. return false;
  80. }
  81. return $iri->get_uri();
  82. }
  83. /**
  84. * Get a HTML/XML element from a HTML string
  85. *
  86. * @deprecated Use DOMDocument instead (parsing HTML with regex is bad!)
  87. * @param string $realname Element name (including namespace prefix if applicable)
  88. * @param string $string HTML document
  89. * @return array
  90. */
  91. public static function get_element($realname, $string)
  92. {
  93. $return = array();
  94. $name = preg_quote($realname, '/');
  95. if (preg_match_all("/<($name)" . SIMPLEPIE_PCRE_HTML_ATTRIBUTE . "(>(.*)<\/$name>|(\/)?>)/siU", $string, $matches, PREG_SET_ORDER | PREG_OFFSET_CAPTURE))
  96. {
  97. for ($i = 0, $total_matches = count($matches); $i < $total_matches; $i++)
  98. {
  99. $return[$i]['tag'] = $realname;
  100. $return[$i]['full'] = $matches[$i][0][0];
  101. $return[$i]['offset'] = $matches[$i][0][1];
  102. if (strlen($matches[$i][3][0]) <= 2)
  103. {
  104. $return[$i]['self_closing'] = true;
  105. }
  106. else
  107. {
  108. $return[$i]['self_closing'] = false;
  109. $return[$i]['content'] = $matches[$i][4][0];
  110. }
  111. $return[$i]['attribs'] = array();
  112. if (isset($matches[$i][2][0]) && preg_match_all('/[\x09\x0A\x0B\x0C\x0D\x20]+([^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x2F\x3D\x3E]*)(?:[\x09\x0A\x0B\x0C\x0D\x20]*=[\x09\x0A\x0B\x0C\x0D\x20]*(?:"([^"]*)"|\'([^\']*)\'|([^\x09\x0A\x0B\x0C\x0D\x20\x22\x27\x3E][^\x09\x0A\x0B\x0C\x0D\x20\x3E]*)?))?/', ' ' . $matches[$i][2][0] . ' ', $attribs, PREG_SET_ORDER))
  113. {
  114. for ($j = 0, $total_attribs = count($attribs); $j < $total_attribs; $j++)
  115. {
  116. if (count($attribs[$j]) === 2)
  117. {
  118. $attribs[$j][2] = $attribs[$j][1];
  119. }
  120. $return[$i]['attribs'][strtolower($attribs[$j][1])]['data'] = SimplePie_Misc::entities_decode(end($attribs[$j]));
  121. }
  122. }
  123. }
  124. }
  125. return $return;
  126. }
  127. public static function element_implode($element)
  128. {
  129. $full = "<$element[tag]";
  130. foreach ($element['attribs'] as $key => $value)
  131. {
  132. $key = strtolower($key);
  133. $full .= " $key=\"" . htmlspecialchars($value['data']) . '"';
  134. }
  135. if ($element['self_closing'])
  136. {
  137. $full .= ' />';
  138. }
  139. else
  140. {
  141. $full .= ">$element[content]</$element[tag]>";
  142. }
  143. return $full;
  144. }
  145. public static function error($message, $level, $file, $line)
  146. {
  147. if ((ini_get('error_reporting') & $level) > 0)
  148. {
  149. switch ($level)
  150. {
  151. case E_USER_ERROR:
  152. $note = 'PHP Error';
  153. break;
  154. case E_USER_WARNING:
  155. $note = 'PHP Warning';
  156. break;
  157. case E_USER_NOTICE:
  158. $note = 'PHP Notice';
  159. break;
  160. default:
  161. $note = 'Unknown Error';
  162. break;
  163. }
  164. $log_error = true;
  165. if (!function_exists('error_log'))
  166. {
  167. $log_error = false;
  168. }
  169. $log_file = @ini_get('error_log');
  170. if (!empty($log_file) && ('syslog' !== $log_file) && !@is_writable($log_file))
  171. {
  172. $log_error = false;
  173. }
  174. if ($log_error)
  175. {
  176. @error_log("$note: $message in $file on line $line", 0);
  177. }
  178. }
  179. return $message;
  180. }
  181. public static function fix_protocol($url, $http = 1)
  182. {
  183. $url = SimplePie_Misc::normalize_url($url);
  184. $parsed = SimplePie_Misc::parse_url($url);
  185. if ($parsed['scheme'] !== '' && $parsed['scheme'] !== 'http' && $parsed['scheme'] !== 'https')
  186. {
  187. return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['authority'], $parsed['path'], $parsed['query'], $parsed['fragment']), $http);
  188. }
  189. if ($parsed['scheme'] === '' && $parsed['authority'] === '' && !file_exists($url))
  190. {
  191. return SimplePie_Misc::fix_protocol(SimplePie_Misc::compress_parse_url('http', $parsed['path'], '', $parsed['query'], $parsed['fragment']), $http);
  192. }
  193. if ($http === 2 && $parsed['scheme'] !== '')
  194. {
  195. return "feed:$url";
  196. }
  197. elseif ($http === 3 && strtolower($parsed['scheme']) === 'http')
  198. {
  199. return substr_replace($url, 'podcast', 0, 4);
  200. }
  201. elseif ($http === 4 && strtolower($parsed['scheme']) === 'http')
  202. {
  203. return substr_replace($url, 'itpc', 0, 4);
  204. }
  205. else
  206. {
  207. return $url;
  208. }
  209. }
  210. public static function parse_url($url)
  211. {
  212. $iri = new SimplePie_IRI($url);
  213. return array(
  214. 'scheme' => (string) $iri->scheme,
  215. 'authority' => (string) $iri->authority,
  216. 'path' => (string) $iri->path,
  217. 'query' => (string) $iri->query,
  218. 'fragment' => (string) $iri->fragment
  219. );
  220. }
  221. public static function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '')
  222. {
  223. $iri = new SimplePie_IRI('');
  224. $iri->scheme = $scheme;
  225. $iri->authority = $authority;
  226. $iri->path = $path;
  227. $iri->query = $query;
  228. $iri->fragment = $fragment;
  229. return $iri->get_uri();
  230. }
  231. public static function normalize_url($url)
  232. {
  233. $iri = new SimplePie_IRI($url);
  234. return $iri->get_uri();
  235. }
  236. public static function percent_encoding_normalization($match)
  237. {
  238. $integer = hexdec($match[1]);
  239. if ($integer >= 0x41 && $integer <= 0x5A || $integer >= 0x61 && $integer <= 0x7A || $integer >= 0x30 && $integer <= 0x39 || $integer === 0x2D || $integer === 0x2E || $integer === 0x5F || $integer === 0x7E)
  240. {
  241. return chr($integer);
  242. }
  243. else
  244. {
  245. return strtoupper($match[0]);
  246. }
  247. }
  248. /**
  249. * Converts a Windows-1252 encoded string to a UTF-8 encoded string
  250. *
  251. * @static
  252. * @param string $string Windows-1252 encoded string
  253. * @return string UTF-8 encoded string
  254. */
  255. public static function windows_1252_to_utf8($string)
  256. {
  257. static $convert_table = array("\x80" => "\xE2\x82\xAC", "\x81" => "\xEF\xBF\xBD", "\x82" => "\xE2\x80\x9A", "\x83" => "\xC6\x92", "\x84" => "\xE2\x80\x9E", "\x85" => "\xE2\x80\xA6", "\x86" => "\xE2\x80\xA0", "\x87" => "\xE2\x80\xA1", "\x88" => "\xCB\x86", "\x89" => "\xE2\x80\xB0", "\x8A" => "\xC5\xA0", "\x8B" => "\xE2\x80\xB9", "\x8C" => "\xC5\x92", "\x8D" => "\xEF\xBF\xBD", "\x8E" => "\xC5\xBD", "\x8F" => "\xEF\xBF\xBD", "\x90" => "\xEF\xBF\xBD", "\x91" => "\xE2\x80\x98", "\x92" => "\xE2\x80\x99", "\x93" => "\xE2\x80\x9C", "\x94" => "\xE2\x80\x9D", "\x95" => "\xE2\x80\xA2", "\x96" => "\xE2\x80\x93", "\x97" => "\xE2\x80\x94", "\x98" => "\xCB\x9C", "\x99" => "\xE2\x84\xA2", "\x9A" => "\xC5\xA1", "\x9B" => "\xE2\x80\xBA", "\x9C" => "\xC5\x93", "\x9D" => "\xEF\xBF\xBD", "\x9E" => "\xC5\xBE", "\x9F" => "\xC5\xB8", "\xA0" => "\xC2\xA0", "\xA1" => "\xC2\xA1", "\xA2" => "\xC2\xA2", "\xA3" => "\xC2\xA3", "\xA4" => "\xC2\xA4", "\xA5" => "\xC2\xA5", "\xA6" => "\xC2\xA6", "\xA7" => "\xC2\xA7", "\xA8" => "\xC2\xA8", "\xA9" => "\xC2\xA9", "\xAA" => "\xC2\xAA", "\xAB" => "\xC2\xAB", "\xAC" => "\xC2\xAC", "\xAD" => "\xC2\xAD", "\xAE" => "\xC2\xAE", "\xAF" => "\xC2\xAF", "\xB0" => "\xC2\xB0", "\xB1" => "\xC2\xB1", "\xB2" => "\xC2\xB2", "\xB3" => "\xC2\xB3", "\xB4" => "\xC2\xB4", "\xB5" => "\xC2\xB5", "\xB6" => "\xC2\xB6", "\xB7" => "\xC2\xB7", "\xB8" => "\xC2\xB8", "\xB9" => "\xC2\xB9", "\xBA" => "\xC2\xBA", "\xBB" => "\xC2\xBB", "\xBC" => "\xC2\xBC", "\xBD" => "\xC2\xBD", "\xBE" => "\xC2\xBE", "\xBF" => "\xC2\xBF", "\xC0" => "\xC3\x80", "\xC1" => "\xC3\x81", "\xC2" => "\xC3\x82", "\xC3" => "\xC3\x83", "\xC4" => "\xC3\x84", "\xC5" => "\xC3\x85", "\xC6" => "\xC3\x86", "\xC7" => "\xC3\x87", "\xC8" => "\xC3\x88", "\xC9" => "\xC3\x89", "\xCA" => "\xC3\x8A", "\xCB" => "\xC3\x8B", "\xCC" => "\xC3\x8C", "\xCD" => "\xC3\x8D", "\xCE" => "\xC3\x8E", "\xCF" => "\xC3\x8F", "\xD0" => "\xC3\x90", "\xD1" => "\xC3\x91", "\xD2" => "\xC3\x92", "\xD3" => "\xC3\x93", "\xD4" => "\xC3\x94", "\xD5" => "\xC3\x95", "\xD6" => "\xC3\x96", "\xD7" => "\xC3\x97", "\xD8" => "\xC3\x98", "\xD9" => "\xC3\x99", "\xDA" => "\xC3\x9A", "\xDB" => "\xC3\x9B", "\xDC" => "\xC3\x9C", "\xDD" => "\xC3\x9D", "\xDE" => "\xC3\x9E", "\xDF" => "\xC3\x9F", "\xE0" => "\xC3\xA0", "\xE1" => "\xC3\xA1", "\xE2" => "\xC3\xA2", "\xE3" => "\xC3\xA3", "\xE4" => "\xC3\xA4", "\xE5" => "\xC3\xA5", "\xE6" => "\xC3\xA6", "\xE7" => "\xC3\xA7", "\xE8" => "\xC3\xA8", "\xE9" => "\xC3\xA9", "\xEA" => "\xC3\xAA", "\xEB" => "\xC3\xAB", "\xEC" => "\xC3\xAC", "\xED" => "\xC3\xAD", "\xEE" => "\xC3\xAE", "\xEF" => "\xC3\xAF", "\xF0" => "\xC3\xB0", "\xF1" => "\xC3\xB1", "\xF2" => "\xC3\xB2", "\xF3" => "\xC3\xB3", "\xF4" => "\xC3\xB4", "\xF5" => "\xC3\xB5", "\xF6" => "\xC3\xB6", "\xF7" => "\xC3\xB7", "\xF8" => "\xC3\xB8", "\xF9" => "\xC3\xB9", "\xFA" => "\xC3\xBA", "\xFB" => "\xC3\xBB", "\xFC" => "\xC3\xBC", "\xFD" => "\xC3\xBD", "\xFE" => "\xC3\xBE", "\xFF" => "\xC3\xBF");
  258. return strtr($string, $convert_table);
  259. }
  260. /**
  261. * Change a string from one encoding to another
  262. *
  263. * @param string $data Raw data in $input encoding
  264. * @param string $input Encoding of $data
  265. * @param string $output Encoding you want
  266. * @return string|boolean False if we can't convert it
  267. */
  268. public static function change_encoding($data, $input, $output)
  269. {
  270. $input = SimplePie_Misc::encoding($input);
  271. $output = SimplePie_Misc::encoding($output);
  272. // We fail to fail on non US-ASCII bytes
  273. if ($input === 'US-ASCII')
  274. {
  275. static $non_ascii_octects = '';
  276. if (!$non_ascii_octects)
  277. {
  278. for ($i = 0x80; $i <= 0xFF; $i++)
  279. {
  280. $non_ascii_octects .= chr($i);
  281. }
  282. }
  283. $data = substr($data, 0, strcspn($data, $non_ascii_octects));
  284. }
  285. // This is first, as behaviour of this is completely predictable
  286. if ($input === 'windows-1252' && $output === 'UTF-8')
  287. {
  288. return SimplePie_Misc::windows_1252_to_utf8($data);
  289. }
  290. // This is second, as behaviour of this varies only with PHP version (the middle part of this expression checks the encoding is supported).
  291. elseif (function_exists('mb_convert_encoding') && ($return = SimplePie_Misc::change_encoding_mbstring($data, $input, $output)))
  292. {
  293. return $return;
  294. }
  295. // This is last, as behaviour of this varies with OS userland and PHP version
  296. elseif (function_exists('iconv') && ($return = SimplePie_Misc::change_encoding_iconv($data, $input, $output)))
  297. {
  298. return $return;
  299. }
  300. // If we can't do anything, just fail
  301. else
  302. {
  303. return false;
  304. }
  305. }
  306. protected static function change_encoding_mbstring($data, $input, $output)
  307. {
  308. if ($input === 'windows-949')
  309. {
  310. $input = 'EUC-KR';
  311. }
  312. if ($output === 'windows-949')
  313. {
  314. $output = 'EUC-KR';
  315. }
  316. if ($input === 'Windows-31J')
  317. {
  318. $input = 'SJIS';
  319. }
  320. if ($output === 'Windows-31J')
  321. {
  322. $output = 'SJIS';
  323. }
  324. // Check that the encoding is supported
  325. if (@mb_convert_encoding("\x80", 'UTF-16BE', $input) === "\x00\x80")
  326. {
  327. return false;
  328. }
  329. if (!in_array($input, mb_list_encodings()))
  330. {
  331. return false;
  332. }
  333. // Let's do some conversion
  334. if ($return = @mb_convert_encoding($data, $output, $input))
  335. {
  336. return $return;
  337. }
  338. return false;
  339. }
  340. protected static function change_encoding_iconv($data, $input, $output)
  341. {
  342. return @iconv($input, $output, $data);
  343. }
  344. /**
  345. * Normalize an encoding name
  346. *
  347. * This is automatically generated by create.php
  348. *
  349. * To generate it, run `php create.php` on the command line, and copy the
  350. * output to replace this function.
  351. *
  352. * @param string $charset Character set to standardise
  353. * @return string Standardised name
  354. */
  355. public static function encoding($charset)
  356. {
  357. // Normalization from UTS #22
  358. switch (strtolower(preg_replace('/(?:[^a-zA-Z0-9]+|([^0-9])0+)/', '\1', $charset)))
  359. {
  360. case 'adobestandardencoding':
  361. case 'csadobestandardencoding':
  362. return 'Adobe-Standard-Encoding';
  363. case 'adobesymbolencoding':
  364. case 'cshppsmath':
  365. return 'Adobe-Symbol-Encoding';
  366. case 'ami1251':
  367. case 'amiga1251':
  368. return 'Amiga-1251';
  369. case 'ansix31101983':
  370. case 'csat5001983':
  371. case 'csiso99naplps':
  372. case 'isoir99':
  373. case 'naplps':
  374. return 'ANSI_X3.110-1983';
  375. case 'arabic7':
  376. case 'asmo449':
  377. case 'csiso89asmo449':
  378. case 'iso9036':
  379. case 'isoir89':
  380. return 'ASMO_449';
  381. case 'big5':
  382. case 'csbig5':
  383. return 'Big5';
  384. case 'big5hkscs':
  385. return 'Big5-HKSCS';
  386. case 'bocu1':
  387. case 'csbocu1':
  388. return 'BOCU-1';
  389. case 'brf':
  390. case 'csbrf':
  391. return 'BRF';
  392. case 'bs4730':
  393. case 'csiso4unitedkingdom':
  394. case 'gb':
  395. case 'iso646gb':
  396. case 'isoir4':
  397. case 'uk':
  398. return 'BS_4730';
  399. case 'bsviewdata':
  400. case 'csiso47bsviewdata':
  401. case 'isoir47':
  402. return 'BS_viewdata';
  403. case 'cesu8':
  404. case 'cscesu8':
  405. return 'CESU-8';
  406. case 'ca':
  407. case 'csa71':
  408. case 'csaz243419851':
  409. case 'csiso121canadian1':
  410. case 'iso646ca':
  411. case 'isoir121':
  412. return 'CSA_Z243.4-1985-1';
  413. case 'csa72':
  414. case 'csaz243419852':
  415. case 'csiso122canadian2':
  416. case 'iso646ca2':
  417. case 'isoir122':
  418. return 'CSA_Z243.4-1985-2';
  419. case 'csaz24341985gr':
  420. case 'csiso123csaz24341985gr':
  421. case 'isoir123':
  422. return 'CSA_Z243.4-1985-gr';
  423. case 'csiso139csn369103':
  424. case 'csn369103':
  425. case 'isoir139':
  426. return 'CSN_369103';
  427. case 'csdecmcs':
  428. case 'dec':
  429. case 'decmcs':
  430. return 'DEC-MCS';
  431. case 'csiso21german':
  432. case 'de':
  433. case 'din66003':
  434. case 'iso646de':
  435. case 'isoir21':
  436. return 'DIN_66003';
  437. case 'csdkus':
  438. case 'dkus':
  439. return 'dk-us';
  440. case 'csiso646danish':
  441. case 'dk':
  442. case 'ds2089':
  443. case 'iso646dk':
  444. return 'DS_2089';
  445. case 'csibmebcdicatde':
  446. case 'ebcdicatde':
  447. return 'EBCDIC-AT-DE';
  448. case 'csebcdicatdea':
  449. case 'ebcdicatdea':
  450. return 'EBCDIC-AT-DE-A';
  451. case 'csebcdiccafr':
  452. case 'ebcdiccafr':
  453. return 'EBCDIC-CA-FR';
  454. case 'csebcdicdkno':
  455. case 'ebcdicdkno':
  456. return 'EBCDIC-DK-NO';
  457. case 'csebcdicdknoa':
  458. case 'ebcdicdknoa':
  459. return 'EBCDIC-DK-NO-A';
  460. case 'csebcdices':
  461. case 'ebcdices':
  462. return 'EBCDIC-ES';
  463. case 'csebcdicesa':
  464. case 'ebcdicesa':
  465. return 'EBCDIC-ES-A';
  466. case 'csebcdicess':
  467. case 'ebcdicess':
  468. return 'EBCDIC-ES-S';
  469. case 'csebcdicfise':
  470. case 'ebcdicfise':
  471. return 'EBCDIC-FI-SE';
  472. case 'csebcdicfisea':
  473. case 'ebcdicfisea':
  474. return 'EBCDIC-FI-SE-A';
  475. case 'csebcdicfr':
  476. case 'ebcdicfr':
  477. return 'EBCDIC-FR';
  478. case 'csebcdicit':
  479. case 'ebcdicit':
  480. return 'EBCDIC-IT';
  481. case 'csebcdicpt':
  482. case 'ebcdicpt':
  483. return 'EBCDIC-PT';
  484. case 'csebcdicuk':
  485. case 'ebcdicuk':
  486. return 'EBCDIC-UK';
  487. case 'csebcdicus':
  488. case 'ebcdicus':
  489. return 'EBCDIC-US';
  490. case 'csiso111ecmacyrillic':
  491. case 'ecmacyrillic':
  492. case 'isoir111':
  493. case 'koi8e':
  494. return 'ECMA-cyrillic';
  495. case 'csiso17spanish':
  496. case 'es':
  497. case 'iso646es':
  498. case 'isoir17':
  499. return 'ES';
  500. case 'csiso85spanish2':
  501. case 'es2':
  502. case 'iso646es2':
  503. case 'isoir85':
  504. return 'ES2';
  505. case 'cseucpkdfmtjapanese':
  506. case 'eucjp':
  507. case 'extendedunixcodepackedformatforjapanese':
  508. return 'EUC-JP';
  509. case 'cseucfixwidjapanese':
  510. case 'extendedunixcodefixedwidthforjapanese':
  511. return 'Extended_UNIX_Code_Fixed_Width_for_Japanese';
  512. case 'gb18030':
  513. return 'GB18030';
  514. case 'chinese':
  515. case 'cp936':
  516. case 'csgb2312':
  517. case 'csiso58gb231280':
  518. case 'gb2312':
  519. case 'gb231280':
  520. case 'gbk':
  521. case 'isoir58':
  522. case 'ms936':
  523. case 'windows936':
  524. return 'GBK';
  525. case 'cn':
  526. case 'csiso57gb1988':
  527. case 'gb198880':
  528. case 'iso646cn':
  529. case 'isoir57':
  530. return 'GB_1988-80';
  531. case 'csiso153gost1976874':
  532. case 'gost1976874':
  533. case 'isoir153':
  534. case 'stsev35888':
  535. return 'GOST_19768-74';
  536. case 'csiso150':
  537. case 'csiso150greekccitt':
  538. case 'greekccitt':
  539. case 'isoir150':
  540. return 'greek-ccitt';
  541. case 'csiso88greek7':
  542. case 'greek7':
  543. case 'isoir88':
  544. return 'greek7';
  545. case 'csiso18greek7old':
  546. case 'greek7old':
  547. case 'isoir18':
  548. return 'greek7-old';
  549. case 'cshpdesktop':
  550. case 'hpdesktop':
  551. return 'HP-DeskTop';
  552. case 'cshplegal':
  553. case 'hplegal':
  554. return 'HP-Legal';
  555. case 'cshpmath8':
  556. case 'hpmath8':
  557. return 'HP-Math8';
  558. case 'cshppifont':
  559. case 'hppifont':
  560. return 'HP-Pi-font';
  561. case 'cshproman8':
  562. case 'hproman8':
  563. case 'r8':
  564. case 'roman8':
  565. return 'hp-roman8';
  566. case 'hzgb2312':
  567. return 'HZ-GB-2312';
  568. case 'csibmsymbols':
  569. case 'ibmsymbols':
  570. return 'IBM-Symbols';
  571. case 'csibmthai':
  572. case 'ibmthai':
  573. return 'IBM-Thai';
  574. case 'cp37':
  575. case 'csibm37':
  576. case 'ebcdiccpca':
  577. case 'ebcdiccpnl':
  578. case 'ebcdiccpus':
  579. case 'ebcdiccpwt':
  580. case 'ibm37':
  581. return 'IBM037';
  582. case 'cp38':
  583. case 'csibm38':
  584. case 'ebcdicint':
  585. case 'ibm38':
  586. return 'IBM038';
  587. case 'cp273':
  588. case 'csibm273':
  589. case 'ibm273':
  590. return 'IBM273';
  591. case 'cp274':
  592. case 'csibm274':
  593. case 'ebcdicbe':
  594. case 'ibm274':
  595. return 'IBM274';
  596. case 'cp275':
  597. case 'csibm275':
  598. case 'ebcdicbr':
  599. case 'ibm275':
  600. return 'IBM275';
  601. case 'csibm277':
  602. case 'ebcdiccpdk':
  603. case 'ebcdiccpno':
  604. case 'ibm277':
  605. return 'IBM277';
  606. case 'cp278':
  607. case 'csibm278':
  608. case 'ebcdiccpfi':
  609. case 'ebcdiccpse':
  610. case 'ibm278':
  611. return 'IBM278';
  612. case 'cp280':
  613. case 'csibm280':
  614. case 'ebcdiccpit':
  615. case 'ibm280':
  616. return 'IBM280';
  617. case 'cp281':
  618. case 'csibm281':
  619. case 'ebcdicjpe':
  620. case 'ibm281':
  621. return 'IBM281';
  622. case 'cp284':
  623. case 'csibm284':
  624. case 'ebcdiccpes':
  625. case 'ibm284':
  626. return 'IBM284';
  627. case 'cp285':
  628. case 'csibm285':
  629. case 'ebcdiccpgb':
  630. case 'ibm285':
  631. return 'IBM285';
  632. case 'cp290':
  633. case 'csibm290':
  634. case 'ebcdicjpkana':
  635. case 'ibm290':
  636. return 'IBM290';
  637. case 'cp297':
  638. case 'csibm297':
  639. case 'ebcdiccpfr':
  640. case 'ibm297':
  641. return 'IBM297';
  642. case 'cp420':
  643. case 'csibm420':
  644. case 'ebcdiccpar1':
  645. case 'ibm420':
  646. return 'IBM420';
  647. case 'cp423':
  648. case 'csibm423':
  649. case 'ebcdiccpgr':
  650. case 'ibm423':
  651. return 'IBM423';
  652. case 'cp424':
  653. case 'csibm424':
  654. case 'ebcdiccphe':
  655. case 'ibm424':
  656. return 'IBM424';
  657. case '437':
  658. case 'cp437':
  659. case 'cspc8codepage437':
  660. case 'ibm437':
  661. return 'IBM437';
  662. case 'cp500':
  663. case 'csibm500':
  664. case 'ebcdiccpbe':
  665. case 'ebcdiccpch':
  666. case 'ibm500':
  667. return 'IBM500';
  668. case 'cp775':
  669. case 'cspc775baltic':
  670. case 'ibm775':
  671. return 'IBM775';
  672. case '850':
  673. case 'cp850':
  674. case 'cspc850multilingual':
  675. case 'ibm850':
  676. return 'IBM850';
  677. case '851':
  678. case 'cp851':
  679. case 'csibm851':
  680. case 'ibm851':
  681. return 'IBM851';
  682. case '852':
  683. case 'cp852':
  684. case 'cspcp852':
  685. case 'ibm852':
  686. return 'IBM852';
  687. case '855':
  688. case 'cp855':
  689. case 'csibm855':
  690. case 'ibm855':
  691. return 'IBM855';
  692. case '857':
  693. case 'cp857':
  694. case 'csibm857':
  695. case 'ibm857':
  696. return 'IBM857';
  697. case 'ccsid858':
  698. case 'cp858':
  699. case 'ibm858':
  700. case 'pcmultilingual850euro':
  701. return 'IBM00858';
  702. case '860':
  703. case 'cp860':
  704. case 'csibm860':
  705. case 'ibm860':
  706. return 'IBM860';
  707. case '861':
  708. case 'cp861':
  709. case 'cpis':
  710. case 'csibm861':
  711. case 'ibm861':
  712. return 'IBM861';
  713. case '862':
  714. case 'cp862':
  715. case 'cspc862latinhebrew':
  716. case 'ibm862':
  717. return 'IBM862';
  718. case '863':
  719. case 'cp863':
  720. case 'csibm863':
  721. case 'ibm863':
  722. return 'IBM863';
  723. case 'cp864':
  724. case 'csibm864':
  725. case 'ibm864':
  726. return 'IBM864';
  727. case '865':
  728. case 'cp865':
  729. case 'csibm865':
  730. case 'ibm865':
  731. return 'IBM865';
  732. case '866':
  733. case 'cp866':
  734. case 'csibm866':
  735. case 'ibm866':
  736. return 'IBM866';
  737. case 'cp868':
  738. case 'cpar':
  739. case 'csibm868':
  740. case 'ibm868':
  741. return 'IBM868';
  742. case '869':
  743. case 'cp869':
  744. case 'cpgr':
  745. case 'csibm869':
  746. case 'ibm869':
  747. return 'IBM869';
  748. case 'cp870':
  749. case 'csibm870':
  750. case 'ebcdiccproece':
  751. case 'ebcdiccpyu':
  752. case 'ibm870':
  753. return 'IBM870';
  754. case 'cp871':
  755. case 'csibm871':
  756. case 'ebcdiccpis':
  757. case 'ibm871':
  758. return 'IBM871';
  759. case 'cp880':
  760. case 'csibm880':
  761. case 'ebcdiccyrillic':
  762. case 'ibm880':
  763. return 'IBM880';
  764. case 'cp891':
  765. case 'csibm891':
  766. case 'ibm891':
  767. return 'IBM891';
  768. case 'cp903':
  769. case 'csibm903':
  770. case 'ibm903':
  771. return 'IBM903';
  772. case '904':
  773. case 'cp904':
  774. case 'csibbm904':
  775. case 'ibm904':
  776. return 'IBM904';
  777. case 'cp905':
  778. case 'csibm905':
  779. case 'ebcdiccptr':
  780. case 'ibm905':
  781. return 'IBM905';
  782. case 'cp918':
  783. case 'csibm918':
  784. case 'ebcdiccpar2':
  785. case 'ibm918':
  786. return 'IBM918';
  787. case 'ccsid924':
  788. case 'cp924':
  789. case 'ebcdiclatin9euro':
  790. case 'ibm924':
  791. return 'IBM00924';
  792. case 'cp1026':
  793. case 'csibm1026':
  794. case 'ibm1026':
  795. return 'IBM1026';
  796. case 'ibm1047':
  797. return 'IBM1047';
  798. case 'ccsid1140':
  799. case 'cp1140':
  800. case 'ebcdicus37euro':
  801. case 'ibm1140':
  802. return 'IBM01140';
  803. case 'ccsid1141':
  804. case 'cp1141':
  805. case 'ebcdicde273euro':
  806. case 'ibm1141':
  807. return 'IBM01141';
  808. case 'ccsid1142':
  809. case 'cp1142':
  810. case 'ebcdicdk277euro':
  811. case 'ebcdicno277euro':
  812. case 'ibm1142':
  813. return 'IBM01142';
  814. case 'ccsid1143':
  815. case 'cp1143':
  816. case 'ebcdicfi278euro':
  817. case 'ebcdicse278euro':
  818. case 'ibm1143':
  819. return 'IBM01143';
  820. case 'ccsid1144':
  821. case 'cp1144':
  822. case 'ebcdicit280euro':
  823. case 'ibm1144':
  824. return 'IBM01144';
  825. case 'ccsid1145':
  826. case 'cp1145':
  827. case 'ebcdices284euro':
  828. case 'ibm1145':
  829. return 'IBM01145';
  830. case 'ccsid1146':
  831. case 'cp1146':
  832. case 'ebcdicgb285euro':
  833. case 'ibm1146':
  834. return 'IBM01146';
  835. case 'ccsid1147':
  836. case 'cp1147':
  837. case 'ebcdicfr297euro':
  838. case 'ibm1147':
  839. return 'IBM01147';
  840. case 'ccsid1148':
  841. case 'cp1148':
  842. case 'ebcdicinternational500euro':
  843. case 'ibm1148':
  844. return 'IBM01148';
  845. case 'ccsid1149':
  846. case 'cp1149':
  847. case 'ebcdicis871euro':
  848. case 'ibm1149':
  849. return 'IBM01149';
  850. case 'csiso143iecp271':
  851. case 'iecp271':
  852. case 'isoir143':
  853. return 'IEC_P27-1';
  854. case 'csiso49inis':
  855. case 'inis':
  856. case 'isoir49':
  857. return 'INIS';
  858. case 'csiso50inis8':
  859. case 'inis8':
  860. case 'isoir50':
  861. return 'INIS-8';
  862. case 'csiso51iniscyrillic':
  863. case 'iniscyrillic':
  864. case 'isoir51':
  865. return 'INIS-cyrillic';
  866. case 'csinvariant':
  867. case 'invariant':
  868. return 'INVARIANT';
  869. case 'iso2022cn':
  870. return 'ISO-2022-CN';
  871. case 'iso2022cnext':
  872. return 'ISO-2022-CN-EXT';
  873. case 'csiso2022jp':
  874. case 'iso2022jp':
  875. return 'ISO-2022-JP';
  876. case 'csiso2022jp2':
  877. case 'iso2022jp2':
  878. return 'ISO-2022-JP-2';
  879. case 'csiso2022kr':
  880. case 'iso2022kr':
  881. return 'ISO-2022-KR';
  882. case 'cswindows30latin1':
  883. case 'iso88591windows30latin1':
  884. return 'ISO-8859-1-Windows-3.0-Latin-1';
  885. case 'cswindows31latin1':
  886. case 'iso88591windows31latin1':
  887. return 'ISO-8859-1-Windows-3.1-Latin-1';
  888. case 'csisolatin2':
  889. case 'iso88592':
  890. case 'iso885921987':
  891. case 'isoir101':
  892. case 'l2':
  893. case 'latin2':
  894. return 'ISO-8859-2';
  895. case 'cswindows31latin2':
  896. case 'iso88592windowslatin2':
  897. return 'ISO-8859-2-Windows-Latin-2';
  898. case 'csisolatin3':
  899. case 'iso88593':
  900. case 'iso885931988':
  901. case 'isoir109':
  902. case 'l3':
  903. case 'latin3':
  904. return 'ISO-8859-3';
  905. case 'csisolatin4':
  906. case 'iso88594':
  907. case 'iso885941988':
  908. case 'isoir110':
  909. case 'l4':
  910. case 'latin4':
  911. return 'ISO-8859-4';
  912. case 'csisolatincyrillic':
  913. case 'cyrillic':
  914. case 'iso88595':
  915. case 'iso885951988':
  916. case 'isoir144':
  917. return 'ISO-8859-5';
  918. case 'arabic':
  919. case 'asmo708':
  920. case 'csisolatinarabic':
  921. case 'ecma114':
  922. case 'iso88596':
  923. case 'iso885961987':
  924. case 'isoir127':
  925. return 'ISO-8859-6';
  926. case 'csiso88596e':
  927. case 'iso88596e':
  928. return 'ISO-8859-6-E';
  929. case 'csiso88596i':
  930. case 'iso88596i':
  931. return 'ISO-8859-6-I';
  932. case 'csisolatingreek':
  933. case 'ecma118':
  934. case 'elot928':
  935. case 'greek':
  936. case 'greek8':
  937. case 'iso88597':
  938. case 'iso885971987':
  939. case 'isoir126':
  940. return 'ISO-8859-7';
  941. case 'csisolatinhebrew':
  942. case 'hebrew':
  943. case 'iso88598':
  944. case 'iso885981988':
  945. case 'isoir138':
  946. return 'ISO-8859-8';
  947. case 'csiso88598e':
  948. case 'iso88598e':
  949. return 'ISO-8859-8-E';
  950. case 'csiso88598i':
  951. case 'iso88598i':
  952. return 'ISO-8859-8-I';
  953. case 'cswindows31latin5':
  954. case 'iso88599windowslatin5':
  955. return 'ISO-8859-9-Windows-Latin-5';
  956. case 'csisolatin6':
  957. case 'iso885910':
  958. case 'iso8859101992':
  959. case 'isoir157':
  960. case 'l6':
  961. case 'latin6':
  962. return 'ISO-8859-10';
  963. case 'iso885913':
  964. return 'ISO-8859-13';
  965. case 'iso885914':
  966. case 'iso8859141998':
  967. case 'isoceltic':
  968. case 'isoir199':
  969. case 'l8':
  970. case 'latin8':
  971. return 'ISO-8859-14';
  972. case 'iso885915':
  973. case 'latin9':
  974. return 'ISO-8859-15';
  975. case 'iso885916':
  976. case 'iso8859162001':
  977. case 'isoir226':
  978. case 'l10':
  979. case 'latin10':
  980. return 'ISO-8859-16';
  981. case 'iso10646j1':
  982. return 'ISO-10646-J-1';
  983. case 'csunicode':
  984. case 'iso10646ucs2':
  985. return 'ISO-10646-UCS-2';
  986. case 'csucs4':
  987. case 'iso10646ucs4':
  988. return 'ISO-10646-UCS-4';
  989. case 'csunicodeascii':
  990. case 'iso10646ucsbasic':
  991. return 'ISO-10646-UCS-Basic';
  992. case 'csunicodelatin1':
  993. case 'iso10646':
  994. case 'iso10646unicodelatin1':
  995. return 'ISO-10646-Unicode-Latin1';
  996. case 'csiso10646utf1':
  997. case 'iso10646utf1':
  998. return 'ISO-10646-UTF-1';
  999. case 'csiso115481':
  1000. case 'iso115481':
  1001. case 'isotr115481':
  1002. return 'ISO-11548-1';
  1003. case 'csiso90':
  1004. case 'isoir90':
  1005. return 'iso-ir-90';
  1006. case 'csunicodeibm1261':
  1007. case 'isounicodeibm1261':
  1008. return 'ISO-Unicode-IBM-1261';
  1009. case 'csunicodeibm1264':
  1010. case 'isounicodeibm1264':
  1011. return 'ISO-Unicode-IBM-1264';
  1012. case 'csunicodeibm1265':
  1013. case 'isounicodeibm1265':
  1014. return 'ISO-Unicode-IBM-1265';
  1015. case 'csunicodeibm1268':
  1016. case 'isounicodeibm1268':
  1017. return 'ISO-Unicode-IBM-1268';
  1018. case 'csunicodeibm1276':
  1019. case 'isounicodeibm1276':
  1020. return 'ISO-Unicode-IBM-1276';
  1021. case 'csiso646basic1983':
  1022. case 'iso646basic1983':
  1023. case 'ref':
  1024. return 'ISO_646.basic:1983';
  1025. case 'csiso2intlrefversion':
  1026. case 'irv':
  1027. case 'iso646irv1983':
  1028. case 'isoir2':
  1029. return 'ISO_646.irv:1983';
  1030. case 'csiso2033':
  1031. case 'e13b':
  1032. case 'iso20331983':
  1033. case 'isoir98':
  1034. return 'ISO_2033-1983';
  1035. case 'csiso5427cyrillic':
  1036. case 'iso5427':
  1037. case 'isoir37':
  1038. return 'ISO_5427';
  1039. case 'iso5427cyrillic1981':
  1040. case 'iso54271981':
  1041. case 'isoir54':
  1042. return 'ISO_5427:1981';
  1043. case 'csiso5428greek':
  1044. case 'iso54281980':
  1045. case 'isoir55':
  1046. return 'ISO_5428:1980';
  1047. case 'csiso6937add':
  1048. case 'iso6937225':
  1049. case 'isoir152':
  1050. return 'ISO_6937-2-25';
  1051. case 'csisotextcomm':
  1052. case 'iso69372add':
  1053. case 'isoir142':
  1054. return 'ISO_6937-2-add';
  1055. case 'csiso8859supp':
  1056. case 'iso8859supp':
  1057. case 'isoir154':
  1058. case 'latin125':
  1059. return 'ISO_8859-supp';
  1060. case 'csiso10367box':
  1061. case 'iso10367box':
  1062. case 'isoir155':
  1063. return 'ISO_10367-box';
  1064. case 'csiso15italian':
  1065. case 'iso646it':
  1066. case 'isoir15':
  1067. case 'it':
  1068. return 'IT';
  1069. case 'csiso13jisc6220jp':
  1070. case 'isoir13':
  1071. case 'jisc62201969':
  1072. case 'jisc62201969jp':
  1073. case 'katakana':
  1074. case 'x2017':
  1075. return 'JIS_C6220-1969-jp';
  1076. case 'csiso14jisc6220ro':
  1077. case 'iso646jp':
  1078. case 'isoir14':
  1079. case 'jisc62201969ro':
  1080. case 'jp':
  1081. return 'JIS_C6220-1969-ro';
  1082. case 'csiso42jisc62261978':
  1083. case 'isoir42':
  1084. case 'jisc62261978':
  1085. return 'JIS_C6226-1978';
  1086. case 'csiso87jisx208':
  1087. case 'isoir87':
  1088. case 'jisc62261983':
  1089. case 'jisx2081983':
  1090. case 'x208':
  1091. return 'JIS_C6226-1983';
  1092. case 'csiso91jisc62291984a':
  1093. case 'isoir91':
  1094. case 'jisc62291984a':
  1095. case 'jpocra':
  1096. return 'JIS_C6229-1984-a';
  1097. case 'csiso92jisc62991984b':
  1098. case 'iso646jpocrb':
  1099. case 'isoir92':
  1100. case 'jisc62291984b':
  1101. case 'jpocrb':
  1102. return 'JIS_C6229-1984-b';
  1103. case 'csiso93jis62291984badd':
  1104. case 'isoir93':
  1105. case 'jisc62291984badd':
  1106. case 'jpocrbadd':
  1107. return 'JIS_C6229-1984-b-add';
  1108. case 'csiso94jis62291984hand':
  1109. case 'isoir94':
  1110. case 'jisc62291984hand':
  1111. case 'jpocrhand':
  1112. return 'JIS_C6229-1984-hand';
  1113. case 'csiso95jis62291984handadd':
  1114. case 'isoir95':
  1115. case 'jisc62291984handadd':
  1116. case 'jpocrhandadd':
  1117. return 'JIS_C6229-1984-hand-add';
  1118. case 'csiso96jisc62291984kana':
  1119. case 'isoir96':
  1120. case 'jisc62291984kana':
  1121. return 'JIS_C6229-1984-kana';
  1122. case 'csjisencoding':
  1123. case 'jisencoding':
  1124. return 'JIS_Encoding';
  1125. case 'cshalfwidthkatakana':
  1126. case 'jisx201':
  1127. case 'x201':
  1128. return 'JIS_X0201';
  1129. case 'csiso159jisx2121990':
  1130. case 'isoir159':
  1131. case 'jisx2121990':
  1132. case 'x212':
  1133. return 'JIS_X0212-1990';
  1134. case 'csiso141jusib1002':
  1135. case 'iso646yu':
  1136. case 'isoir141':
  1137. case 'js':
  1138. case 'jusib1002':
  1139. case 'yu':
  1140. return 'JUS_I.B1.002';
  1141. case 'csiso147macedonian':
  1142. case 'isoir147':
  1143. case 'jusib1003mac':
  1144. case 'macedonian':
  1145. return 'JUS_I.B1.003-mac';
  1146. case 'csiso146serbian':
  1147. case 'isoir146':
  1148. case 'jusib1003serb':
  1149. case 'serbian':
  1150. return 'JUS_I.B1.003-serb';
  1151. case 'koi7switched':
  1152. return 'KOI7-switched';
  1153. case 'cskoi8r':
  1154. case 'koi8r':
  1155. return 'KOI8-R';
  1156. case 'koi8u':
  1157. return 'KOI8-U';
  1158. case 'csksc5636':
  1159. case 'iso646kr':
  1160. case 'ksc5636':
  1161. return 'KSC5636';
  1162. case 'cskz1048':
  1163. case 'kz1048':
  1164. case 'rk1048':
  1165. case 'strk10482002':
  1166. return 'KZ-1048';
  1167. case 'csiso19latingreek':
  1168. case 'isoir19':
  1169. case 'latingreek':
  1170. return 'latin-greek';
  1171. case 'csiso27latingreek1':
  1172. case 'isoir27':
  1173. case 'latingreek1':
  1174. return 'Latin-greek-1';
  1175. case 'csiso158lap':
  1176. case 'isoir158':
  1177. case 'lap':
  1178. case 'latinlap':
  1179. return 'latin-lap';
  1180. case 'csmacintosh':
  1181. case 'mac':
  1182. case 'macintosh':
  1183. return 'macintosh';
  1184. case 'csmicrosoftpublishing':
  1185. case 'microsoftpublishing':
  1186. return 'Microsoft-Publishing';
  1187. case 'csmnem':
  1188. case 'mnem':
  1189. return 'MNEM';
  1190. case 'csmnemonic':
  1191. case 'mnemonic':
  1192. return 'MNEMONIC';
  1193. case 'csiso86hungarian':
  1194. case 'hu':
  1195. case 'iso646hu':
  1196. case 'isoir86':
  1197. case 'msz77953':
  1198. return 'MSZ_7795.3';
  1199. case 'csnatsdano':
  1200. case 'isoir91':
  1201. case 'natsdano':
  1202. return 'NATS-DANO';
  1203. case 'csnatsdanoadd':
  1204. case 'isoir92':
  1205. case 'natsdanoadd':
  1206. return 'NATS-DANO-ADD';
  1207. case 'csnatssefi':
  1208. case 'isoir81':
  1209. case 'natssefi':
  1210. return 'NATS-SEFI';
  1211. case 'csnatssefiadd':
  1212. case 'isoir82':
  1213. case 'natssefiadd':
  1214. return 'NATS-SEFI-ADD';
  1215. case 'csiso151cuba':
  1216. case 'cuba':
  1217. case 'iso646cu':
  1218. case 'isoir151':
  1219. case 'ncnc1081':
  1220. return 'NC_NC00-10:81';
  1221. case 'csiso69french':
  1222. case 'fr':
  1223. case 'iso646fr':
  1224. case 'isoir69':
  1225. case 'nfz62010':
  1226. return 'NF_Z_62-010';
  1227. case 'csiso25french':
  1228. case 'iso646fr1':
  1229. case 'isoir25':
  1230. case 'nfz620101973':
  1231. return 'NF_Z_62-010_(1973)';
  1232. case 'csiso60danishnorwegian':
  1233. case 'csiso60norwegian1':
  1234. case 'iso646no':
  1235. case 'isoir60':
  1236. case 'no':
  1237. case 'ns45511':
  1238. return 'NS_4551-1';
  1239. case 'csiso61norwegian2':
  1240. case 'iso646no2':
  1241. case 'isoir61':
  1242. case 'no2':
  1243. case 'ns45512':
  1244. return 'NS_4551-2';
  1245. case 'osdebcdicdf3irv':
  1246. return 'OSD_EBCDIC_DF03_IRV';
  1247. case 'osdebcdicdf41':
  1248. return 'OSD_EBCDIC_DF04_1';
  1249. case 'osdebcdicdf415':
  1250. return 'OSD_EBCDIC_DF04_15';
  1251. case 'cspc8danishnorwegian':
  1252. case 'pc8danishnorwegian':
  1253. return 'PC8-Danish-Norwegian';
  1254. case 'cspc8turkish':
  1255. case 'pc8turkish':
  1256. return 'PC8-Turkish';
  1257. case 'csiso16portuguese':
  1258. case 'iso646pt':
  1259. case 'isoir16':
  1260. case 'pt':
  1261. return 'PT';
  1262. case 'csiso84portuguese2':
  1263. case 'iso646pt2':
  1264. case 'isoir84':
  1265. case 'pt2':
  1266. return 'PT2';
  1267. case 'cp154':
  1268. case 'csptcp154':
  1269. case 'cyrillicasian':
  1270. case 'pt154':
  1271. case 'ptcp154':
  1272. return 'PTCP154';
  1273. case 'scsu':
  1274. return 'SCSU';
  1275. case 'csiso10swedish':
  1276. case 'fi':
  1277. case 'iso646fi':
  1278. case 'iso646se':
  1279. case 'isoir10':
  1280. case 'se':
  1281. case 'sen850200b':
  1282. return 'SEN_850200_B';
  1283. case 'csiso11swedishfornames':
  1284. case 'iso646se2':
  1285. case 'isoir11':
  1286. case 'se2':
  1287. case 'sen850200c':
  1288. return 'SEN_850200_C';
  1289. case 'csiso102t617bit':
  1290. case 'isoir102':
  1291. case 't617bit':
  1292. return 'T.61-7bit';
  1293. case 'csiso103t618bit':
  1294. case 'isoir103':
  1295. case 't61':
  1296. case 't618bit':
  1297. return 'T.61-8bit';
  1298. case 'csiso128t101g2':
  1299. case 'isoir128':
  1300. case 't101g2':
  1301. return 'T.101-G2';
  1302. case 'cstscii':
  1303. case 'tscii':
  1304. return 'TSCII';
  1305. case 'csunicode11':
  1306. case 'unicode11':
  1307. return 'UNICODE-1-1';
  1308. case 'csunicode11utf7':
  1309. case 'unicode11utf7':
  1310. return 'UNICODE-1-1-UTF-7';
  1311. case 'csunknown8bit':
  1312. case 'unknown8bit':
  1313. return 'UNKNOWN-8BIT';
  1314. case 'ansix341968':
  1315. case 'ansix341986':
  1316. case 'ascii':
  1317. case 'cp367':
  1318. case 'csascii':
  1319. case 'ibm367':
  1320. case 'iso646irv1991':
  1321. case 'iso646us':
  1322. case 'isoir6':
  1323. case 'us':
  1324. case 'usascii':
  1325. return 'US-ASCII';
  1326. case 'csusdk':
  1327. case 'usdk':
  1328. return 'us-dk';
  1329. case 'utf7':
  1330. return 'UTF-7';
  1331. case 'utf8':
  1332. return 'UTF-8';
  1333. case 'utf16':
  1334. return 'UTF-16';
  1335. case 'utf16be':
  1336. return 'UTF-16BE';
  1337. case 'utf16le':
  1338. return 'UTF-16LE';
  1339. case 'utf32':
  1340. return 'UTF-32';
  1341. case 'utf32be':
  1342. return 'UTF-32BE';
  1343. case 'utf32le':
  1344. return 'UTF-32LE';
  1345. case 'csventurainternational':
  1346. case 'venturainternational':
  1347. return 'Ventura-International';
  1348. case 'csventuramath':
  1349. case 'venturamath':
  1350. return 'Ventura-Math';
  1351. case 'csventuraus':
  1352. case 'venturaus':
  1353. return 'Ventura-US';
  1354. case 'csiso70videotexsupp1':
  1355. case 'isoir70':
  1356. case 'videotexsuppl':
  1357. return 'videotex-suppl';
  1358. case 'csviqr':
  1359. case 'viqr':
  1360. return 'VIQR';
  1361. case 'csviscii':
  1362. case 'viscii':
  1363. return 'VISCII';
  1364. case 'csshiftjis':
  1365. case 'cswindows31j':
  1366. case 'mskanji':
  1367. case 'shiftjis':
  1368. case 'windows31j':
  1369. return 'Windows-31J';
  1370. case 'iso885911':
  1371. case 'tis620':
  1372. return 'windows-874';
  1373. case 'cseuckr':
  1374. case 'csksc56011987':
  1375. case 'euckr':
  1376. case 'isoir149':
  1377. case 'korean':
  1378. case 'ksc5601':
  1379. case 'ksc56011987':
  1380. case 'ksc56011989':
  1381. case 'windows949':
  1382. return 'windows-949';
  1383. case 'windows1250':
  1384. return 'windows-1250';
  1385. case 'windows1251':
  1386. return 'windows-1251';
  1387. case 'cp819':
  1388. case 'csisolatin1':
  1389. case 'ibm819':
  1390. case 'iso88591':
  1391. case 'iso885911987':
  1392. case 'isoir100':
  1393. case 'l1':
  1394. case 'latin1':
  1395. case 'windows1252':
  1396. return 'windows-1252';
  1397. case 'windows1253':
  1398. return 'windows-1253';
  1399. case 'csisolatin5':
  1400. case 'iso88599':
  1401. case 'iso885991989':
  1402. case 'isoir148':
  1403. case 'l5':
  1404. case 'latin5':
  1405. case 'windows1254':
  1406. return 'windows-1254';
  1407. case 'windows1255':
  1408. return 'windows-1255';
  1409. case 'windows1256':
  1410. return 'windows-1256';
  1411. case 'windows1257':
  1412. return 'windows-1257';
  1413. case 'windows1258':
  1414. return 'windows-1258';
  1415. default:
  1416. return $charset;
  1417. }
  1418. }
  1419. public static function get_curl_version()
  1420. {
  1421. if (is_array($curl = curl_version()))
  1422. {
  1423. $curl = $curl['version'];
  1424. }
  1425. elseif (substr($curl, 0, 5) === 'curl/')
  1426. {
  1427. $curl = substr($curl, 5, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 5));
  1428. }
  1429. elseif (substr($curl, 0, 8) === 'libcurl/')
  1430. {
  1431. $curl = substr($curl, 8, strcspn($curl, "\x09\x0A\x0B\x0C\x0D", 8));
  1432. }
  1433. else
  1434. {
  1435. $curl = 0;
  1436. }
  1437. return $curl;
  1438. }
  1439. /**
  1440. * Strip HTML comments
  1441. *
  1442. * @param string $data Data to strip comments from
  1443. * @return string Comment stripped string
  1444. */
  1445. public static function strip_comments($data)
  1446. {
  1447. $output = '';
  1448. while (($start = strpos($data, '<!--')) !== false)
  1449. {
  1450. $output .= substr($data, 0, $start);
  1451. if (($end = strpos($data, '-->', $start)) !== false)
  1452. {
  1453. $data = substr_replace($data, '', 0, $end + 3);
  1454. }
  1455. else
  1456. {
  1457. $data = '';
  1458. }
  1459. }
  1460. return $output . $data;
  1461. }
  1462. public static function parse_date($dt)
  1463. {
  1464. $parser = SimplePie_Parse_Date::get();
  1465. return $parser->parse($dt);
  1466. }
  1467. /**
  1468. * Decode HTML entities
  1469. *
  1470. * @deprecated Use DOMDocument instead
  1471. * @param string $data Input data
  1472. * @return string Output data
  1473. */
  1474. public static function entities_decode($data)
  1475. {
  1476. $decoder = new SimplePie_Decode_HTML_Entities($data);
  1477. return $decoder->parse();
  1478. }
  1479. /**
  1480. * Remove RFC822 comments
  1481. *
  1482. * @param string $data Data to strip comments from
  1483. * @return string Comment stripped string
  1484. */
  1485. public static function uncomment_rfc822($string)
  1486. {
  1487. $string = (string) $string;
  1488. $position = 0;
  1489. $length = strlen($string);
  1490. $depth = 0;
  1491. $output = '';
  1492. while ($position < $length && ($pos = strpos($string, '(', $position)) !== false)
  1493. {
  1494. $output .= substr($string, $position, $pos - $position);
  1495. $position = $pos + 1;
  1496. if ($string[$pos - 1] !== '\\')
  1497. {
  1498. $depth++;
  1499. while ($depth && $position < $length)
  1500. {
  1501. $position += strcspn($string, '()', $position);
  1502. if ($string[$position - 1] === '\\')
  1503. {
  1504. $position++;
  1505. continue;
  1506. }
  1507. elseif (isset($string[$position]))
  1508. {
  1509. switch ($string[$position])
  1510. {
  1511. case '(':
  1512. $depth++;
  1513. break;
  1514. case ')':
  1515. $depth--;
  1516. break;
  1517. }
  1518. $position++;
  1519. }
  1520. else
  1521. {
  1522. break;
  1523. }
  1524. }
  1525. }
  1526. else
  1527. {
  1528. $output .= '(';
  1529. }
  1530. }
  1531. $output .= substr($string, $position);
  1532. return $output;
  1533. }
  1534. public static function parse_mime($mime)
  1535. {
  1536. if (($pos = strpos($mime, ';')) === false)
  1537. {
  1538. return trim($mime);
  1539. }
  1540. else
  1541. {
  1542. return trim(substr($mime, 0, $pos));
  1543. }
  1544. }
  1545. public static function atom_03_construct_type($attribs)
  1546. {
  1547. if (isset($attribs['']['mode']) && strtolower(trim($attribs['']['mode']) === 'base64'))
  1548. {
  1549. $mode = SIMPLEPIE_CONSTRUCT_BASE64;
  1550. }
  1551. else
  1552. {
  1553. $mode = SIMPLEPIE_CONSTRUCT_NONE;
  1554. }
  1555. if (isset($attribs['']['type']))
  1556. {
  1557. switch (strtolower(trim($attribs['']['type'])))
  1558. {
  1559. case 'text':
  1560. case 'text/plain':
  1561. return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
  1562. case 'html':
  1563. case 'text/html':
  1564. return SIMPLEPIE_CONSTRUCT_HTML | $mode;
  1565. case 'xhtml':
  1566. case 'application/xhtml+xml':
  1567. return SIMPLEPIE_CONSTRUCT_XHTML | $mode;
  1568. default:
  1569. return SIMPLEPIE_CONSTRUCT_NONE | $mode;
  1570. }
  1571. }
  1572. else
  1573. {
  1574. return SIMPLEPIE_CONSTRUCT_TEXT | $mode;
  1575. }
  1576. }
  1577. public static function atom_10_construct_type($attribs)
  1578. {
  1579. if (isset($attribs['']['type']))
  1580. {
  1581. switch (strtolower(trim($attribs['']['type'])))
  1582. {
  1583. case 'text':
  1584. return SIMPLEPIE_CONSTRUCT_TEXT;
  1585. case 'html':
  1586. return SIMPLEPIE_CONSTRUCT_HTML;
  1587. case 'xhtml':
  1588. return SIMPLEPIE_CONSTRUCT_XHTML;
  1589. default:
  1590. return SIMPLEPIE_CONSTRUCT_NONE;
  1591. }
  1592. }
  1593. return SIMPLEPIE_CONSTRUCT_TEXT;
  1594. }
  1595. public static function atom_10_content_construct_type($attribs)
  1596. {
  1597. if (isset($attribs['']['type']))
  1598. {
  1599. $type = strtolower(trim($attribs['']['type']));
  1600. switch ($type)
  1601. {
  1602. case 'text':
  1603. return SIMPLEPIE_CONSTRUCT_TEXT;
  1604. case 'html':
  1605. return SIMPLEPIE_CONSTRUCT_HTML;
  1606. case 'xhtml':
  1607. return SIMPLEPIE_CONSTRUCT_XHTML;
  1608. }
  1609. if (in_array(substr($type, -4), array('+xml', '/xml')) || substr($type, 0, 5) === 'text/')
  1610. {
  1611. return SIMPLEPIE_CONSTRUCT_NONE;
  1612. }
  1613. else
  1614. {
  1615. return SIMPLEPIE_CONSTRUCT_BASE64;
  1616. }
  1617. }
  1618. else
  1619. {
  1620. return SIMPLEPIE_CONSTRUCT_TEXT;
  1621. }
  1622. }
  1623. public static function is_isegment_nz_nc($string)
  1624. {
  1625. return (bool) preg_match('/^([A-Za-z0-9\-._~\x{A0}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFEF}\x{10000}-\x{1FFFD}\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}\x{40000}-\x{4FFFD}\x{50000}-\x{5FFFD}\x{60000}-\x{6FFFD}\x{70000}-\x{7FFFD}\x{80000}-\x{8FFFD}\x{90000}-\x{9FFFD}\x{A0000}-\x{AFFFD}\x{B0000}-\x{BFFFD}\x{C0000}-\x{CFFFD}\x{D0000}-\x{DFFFD}\x{E1000}-\x{EFFFD}!$&\'()*+,;=@]|(%[0-9ABCDEF]{2}))+$/u', $string);
  1626. }
  1627. public static function space_seperated_tokens($string)
  1628. {
  1629. $space_characters = "\x20\x09\x0A\x0B\x0C\x0D";
  1630. $string_length = strlen($string);
  1631. $position = strspn($string, $space_characters);
  1632. $tokens = array();
  1633. while ($position < $string_length)
  1634. {
  1635. $len = strcspn($string, $space_characters, $position);
  1636. $tokens[] = substr($string, $position, $len);
  1637. $position += $len;
  1638. $position += strspn($string, $space_characters, $position);
  1639. }
  1640. return $tokens;
  1641. }
  1642. /**
  1643. * Converts a unicode codepoint to a UTF-8 character
  1644. *
  1645. * @static
  1646. * @param int $codepoint Unicode codepoint
  1647. * @return string UTF-8 character
  1648. */
  1649. public static function codepoint_to_utf8($codepoint)
  1650. {
  1651. $codepoint = (int) $codepoint;
  1652. if ($codepoint < 0)
  1653. {
  1654. return false;
  1655. }
  1656. else if ($codepoint <= 0x7f)
  1657. {
  1658. return chr($codepoint);
  1659. }
  1660. else if ($codepoint <= 0x7ff)
  1661. {
  1662. return chr(0xc0 | ($codepoint >> 6)) . chr(0x80 | ($codepoint & 0x3f));
  1663. }
  1664. else if ($codepoint <= 0xffff)
  1665. {
  1666. return chr(0xe0 | ($codepoint >> 12)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
  1667. }
  1668. else if ($codepoint <= 0x10ffff)
  1669. {
  1670. return chr(0xf0 | ($codepoint >> 18)) . chr(0x80 | (($codepoint >> 12) & 0x3f)) . chr(0x80 | (($codepoint >> 6) & 0x3f)) . chr(0x80 | ($codepoint & 0x3f));
  1671. }
  1672. else
  1673. {
  1674. // U+FFFD REPLACEMENT CHARACTER
  1675. return "\xEF\xBF\xBD";
  1676. }
  1677. }
  1678. /**
  1679. * Similar to parse_str()
  1680. *
  1681. * Returns an associative array of name/value pairs, where the value is an
  1682. * array of values that have used the same name
  1683. *
  1684. * @static
  1685. * @param string $str The input string.
  1686. * @return array
  1687. */
  1688. public static function parse_str($str)
  1689. {
  1690. $return = array();
  1691. $str = explode('&', $str);
  1692. foreach ($str as $section)
  1693. {
  1694. if (strpos($section, '=') !== false)
  1695. {
  1696. list($name, $value) = explode('=', $section, 2);
  1697. $return[urldecode($name)][] = urldecode($value);
  1698. }
  1699. else
  1700. {
  1701. $return[urldecode($section)][] = null;
  1702. }
  1703. }
  1704. return $return;
  1705. }
  1706. /**
  1707. * Detect XML encoding, as per XML 1.0 Appendix F.1
  1708. *
  1709. * @todo Add support for EBCDIC
  1710. * @param string $data XML data
  1711. * @param SimplePie_Registry $registry Class registry
  1712. * @return array Possible encodings
  1713. */
  1714. public static function xml_encoding($data, $registry)
  1715. {
  1716. // UTF-32 Big Endian BOM
  1717. if (substr($data, 0, 4) === "\x00\x00\xFE\xFF")
  1718. {
  1719. $encoding[] = 'UTF-32BE';
  1720. }
  1721. // UTF-32 Little Endian BOM
  1722. elseif (substr($data, 0, 4) === "\xFF\xFE\x00\x00")
  1723. {
  1724. $encoding[] = 'UTF-32LE';
  1725. }
  1726. // UTF-16 Big Endian BOM
  1727. elseif (substr($data, 0, 2) === "\xFE\xFF")
  1728. {
  1729. $encoding[] = 'UTF-16BE';
  1730. }
  1731. // UTF-16 Little Endian BOM
  1732. elseif (substr($data, 0, 2) === "\xFF\xFE")
  1733. {
  1734. $encoding[] = 'UTF-16LE';
  1735. }
  1736. // UTF-8 BOM
  1737. elseif (substr($data, 0, 3) === "\xEF\xBB\xBF")
  1738. {
  1739. $encoding[] = 'UTF-8';
  1740. }
  1741. // UTF-32 Big Endian Without BOM
  1742. elseif (substr($data, 0, 20) === "\x00\x00\x00\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C")
  1743. {
  1744. if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E"))
  1745. {
  1746. $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')));
  1747. if ($parser->parse())
  1748. {
  1749. $encoding[] = $parser->encoding;
  1750. }
  1751. }
  1752. $encoding[] = 'UTF-32BE';
  1753. }
  1754. // UTF-32 Little Endian Without BOM
  1755. elseif (substr($data, 0, 20) === "\x3C\x00\x00\x00\x3F\x00\x00\x00\x78\x00\x00\x00\x6D\x00\x00\x00\x6C\x00\x00\x00")
  1756. {
  1757. if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00"))
  1758. {
  1759. $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')));
  1760. if ($parser->parse())
  1761. {
  1762. $encoding[] = $parser->encoding;
  1763. }
  1764. }
  1765. $encoding[] = 'UTF-32LE';
  1766. }
  1767. // UTF-16 Big Endian Without BOM
  1768. elseif (substr($data, 0, 10) === "\x00\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C")
  1769. {
  1770. if ($pos = strpos($data, "\x00\x3F\x00\x3E"))
  1771. {
  1772. $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')));
  1773. if ($parser->parse())
  1774. {
  1775. $encoding[] = $parser->encoding;
  1776. }
  1777. }
  1778. $encoding[] = 'UTF-16BE';
  1779. }
  1780. // UTF-16 Little Endian Without BOM
  1781. elseif (substr($data, 0, 10) === "\x3C\x00\x3F\x00\x78\x00\x6D\x00\x6C\x00")
  1782. {
  1783. if ($pos = strpos($data, "\x3F\x00\x3E\x00"))
  1784. {
  1785. $parser = $registry->create('XML_Declaration_Parser', array(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')));
  1786. if ($parser->parse())
  1787. {
  1788. $encoding[] = $parser->encoding;
  1789. }
  1790. }
  1791. $encoding[] = 'UTF-16LE';
  1792. }
  1793. // US-ASCII (or superset)
  1794. elseif (substr($data, 0, 5) === "\x3C\x3F\x78\x6D\x6C")
  1795. {
  1796. if ($pos = strpos($data, "\x3F\x3E"))
  1797. {
  1798. $parser = $registry->create('XML_Declaration_Parser', array(substr($data, 5, $pos - 5)));
  1799. if ($parser->parse())
  1800. {
  1801. $encoding[] = $parser->encoding;
  1802. }
  1803. }
  1804. $encoding[] = 'UTF-8';
  1805. }
  1806. // Fallback to UTF-8
  1807. else
  1808. {
  1809. $encoding[] = 'UTF-8';
  1810. }
  1811. return $encoding;
  1812. }
  1813. public static function output_javascript()
  1814. {
  1815. if (function_exists('ob_gzhandler'))
  1816. {
  1817. ob_start('ob_gzhandler');
  1818. }
  1819. header('Content-type: text/javascript; charset: UTF-8');
  1820. header('Cache-Control: must-revalidate');
  1821. header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 604800) . ' GMT'); // 7 days
  1822. ?>
  1823. function embed_quicktime(type, bgcolor, width, height, link, placeholder, loop) {
  1824. if (placeholder != '') {
  1825. document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" href="'+link+'" src="'+placeholder+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="false" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  1826. }
  1827. else {
  1828. document.writeln('<embed type="'+type+'" style="cursor:hand; cursor:pointer;" src="'+link+'" width="'+width+'" height="'+height+'" autoplay="false" target="myself" controller="true" loop="'+loop+'" scale="aspect" bgcolor="'+bgcolor+'" pluginspage="http://www.apple.com/quicktime/download/"></embed>');
  1829. }
  1830. }
  1831. function embed_flash(bgcolor, width, height, link, loop, type) {
  1832. document.writeln('<embed src="'+link+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="'+type+'" quality="high" width="'+width+'" height="'+height+'" bgcolor="'+bgcolor+'" loop="'+loop+'"></embed>');
  1833. }
  1834. function embed_flv(width, height, link, placeholder, loop, player) {
  1835. document.writeln('<embed src="'+player+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" quality="high" width="'+width+'" height="'+height+'" wmode="transparent" flashvars="file='+link+'&autostart=false&repeat='+loop+'&showdigits=true&showfsbutton=false"></embed>');
  1836. }
  1837. function embed_wmedia(width, height, link) {
  1838. document.writeln('<embed type="application/x-mplayer2" src="'+link+'" autosize="1" width="'+width+'" height="'+height+'" showcontrols="1" showstatusbar="0" showdisplay="0" autostart="0"></embed>');
  1839. }
  1840. <?php
  1841. }
  1842. /**
  1843. * Get the SimplePie build timestamp
  1844. *
  1845. * Uses the git index if it exists, otherwise uses the modification time
  1846. * of the newest file.
  1847. */
  1848. public static function get_build()
  1849. {
  1850. $root = dirname(dirname(__FILE__));
  1851. if (file_exists($root . '/.git/index'))
  1852. {
  1853. return filemtime($root . '/.git/index');
  1854. }
  1855. elseif (file_exists($root . '/SimplePie'))
  1856. {
  1857. $time = 0;
  1858. foreach (glob($root . '/SimplePie/*.php') as $file)
  1859. {
  1860. if (($mtime = filemtime($file)) > $time)
  1861. {
  1862. $time = $mtime;
  1863. }
  1864. }
  1865. return $time;
  1866. }
  1867. elseif (file_exists(dirname(__FILE__) . '/Core.php'))
  1868. {
  1869. return filemtime(dirname(__FILE__) . '/Core.php');
  1870. }
  1871. else
  1872. {
  1873. return filemtime(__FILE__);
  1874. }
  1875. }
  1876. /**
  1877. * Format debugging information
  1878. */
  1879. public static function debug(&$sp)
  1880. {
  1881. $info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n";
  1882. $info .= 'PHP ' . PHP_VERSION . "\n";
  1883. if ($sp->error() !== null)
  1884. {
  1885. $info .= 'Error occurred: ' . $sp->error() . "\n";
  1886. }
  1887. else
  1888. {
  1889. $info .= "No error found.\n";
  1890. }
  1891. $info .= "Extensions:\n";
  1892. $extensions = array('pcre', 'curl', 'zlib', 'mbstring', 'iconv', 'xmlreader', 'xml');
  1893. foreach ($extensions as $ext)
  1894. {
  1895. if (extension_loaded($ext))
  1896. {
  1897. $info .= " $ext loaded\n";
  1898. switch ($ext)
  1899. {
  1900. case 'pcre':
  1901. $info .= ' Version ' . PCRE_VERSION . "\n";
  1902. break;
  1903. case 'curl':
  1904. $version = curl_version();
  1905. $info .= ' Version ' . $version['version'] . "\n";
  1906. break;
  1907. case 'mbstring':
  1908. $info .= ' Overloading: ' . mb_get_info('func_overload') . "\n";
  1909. break;
  1910. case 'iconv':
  1911. $info .= ' Version ' . ICONV_VERSION . "\n";
  1912. break;
  1913. case 'xml':
  1914. $info .= ' Version ' . LIBXML_DOTTED_VERSION . "\n";
  1915. break;
  1916. }
  1917. }
  1918. else
  1919. {
  1920. $info .= " $ext not loaded\n";
  1921. }
  1922. }
  1923. return $info;
  1924. }
  1925. public static function silence_errors($num, $str)
  1926. {
  1927. // No-op
  1928. }
  1929. }