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