PageRenderTime 50ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/simplepie/library/SimplePie/Misc.php

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