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