/[drupal]/contributions/modules/coolfilter/rpc.php
ViewVC logotype

Contents of /contributions/modules/coolfilter/rpc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Feb 15 08:18:10 2007 UTC (2 years, 9 months ago) by lllkkk
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-5
Changes since 1.2: +1060 -172 lines
File MIME type: text/x-php
[coolcode] add 'actionscript',[coolplayer] add I'm vlog,RockYou,SevenLoad,MyVideo.de,Clipfish.deTuDou Video....
1 <?php
2 require_once('phprpc_server.php');
3
4 define('ENABLED_MBSTRING_PHPRPC', true);
5
6 if (defined('ENABLED_MBSTRING_PHPRPC') && ENABLED_MBSTRING_PHPRPC) {
7 require_once('phprpc_client.php');
8 $coolplayer_rpcpath = "http://www.coolcode.cn/wp-content/plugins/coolplayer/mbstring.php";
9 $rpc_client = new phprpc_client($coolplayer_rpcpath);
10 }
11
12 if (extension_loaded('mbstring')) {
13 function mb_urlencode($url, $charset) {
14 $len = mb_strlen($url, $charset);
15 $result = "";
16 for ($i = 0; $i < $len; $i++) {
17 $c = mb_substr($url, $i, 1, $charset);
18 if (strlen($c) > 1) $c = urlencode($c);
19 $result .= $c;
20 }
21 return $result;
22 }
23 }
24 else if (extension_loaded('iconv')) {
25 function mb_convert_encoding($str, $to_encoding, $from_encoding) {
26 return iconv($from_encoding, $to_encoding, $str);
27 }
28 if (version_compare(phpversion(), "5", ">=")) {
29 function mb_urlencode($url, $charset) {
30 $len = iconv_strlen($url, $charset);
31 $result = "";
32 for ($i = 0; $i < $len; $i++) {
33 $c = iconv_substr($url, $i, 1, $charset);
34 if (strlen($c) > 1) $c = urlencode($c);
35 $result .= $c;
36 }
37 return $result;
38 }
39 }
40 else if (defined('ENABLED_MBSTRING_PHPRPC') && ENABLED_MBSTRING_PHPRPC) {
41 function mb_urlencode($url, $charset) {
42 global $rpc_client;
43 $result = $rpc_client->mb_urlencode($url, $charset);
44 if (get_class($result) == "phprpc_error") {
45 return $url;
46 }
47 else {
48 return $result;
49 }
50 }
51 }
52 else {
53 function mb_urlencode($url, $charset) {
54 return $url;
55 }
56 }
57 }
58 else if (defined('ENABLED_MBSTRING_PHPRPC') && ENABLED_MBSTRING_PHPRPC) {
59 function mb_urlencode($url, $charset) {
60 global $rpc_client;
61 $result = $rpc_client->mb_urlencode($url, $charset);
62 if (get_class($result) == "phprpc_error") {
63 return $url;
64 }
65 else {
66 return $result;
67 }
68 }
69 function mb_convert_encoding($str, $to_encoding, $from_encoding) {
70 global $rpc_client;
71 $result = $rpc_client->mb_convert_encoding($str, $to_encoding, $from_encoding);
72 if (get_class($result) == "phprpc_error") {
73 return $str;
74 }
75 else {
76 return $result;
77 }
78 }
79 }
80 else {
81 function mb_urlencode($url, $charset) {
82 return $url;
83 }
84 function mb_convert_encoding($str, $to_encoding, $from_encoding) {
85 return $str;
86 }
87 }
88
89 function fetchURL($url) {
90 $url_parsed = parse_url($url);
91 $host = $url_parsed["host"];
92 if (!isset($url_parsed["port"])) {
93 $port = 80;
94 }
95 else {
96 $port = $url_parsed["port"];
97 }
98 $path = $url_parsed["path"];
99 if ($url_parsed["query"] != "") $path .= "?" . $url_parsed["query"];
100 $out = "GET $path HTTP/1.1\r\n" .
101 "Host: $host\r\n" .
102 "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1\r\n" .
103 "Connection: close\r\n\r\n";
104 $fp = fsockopen(gethostbyname($host), $port, $errno, $errstr, 30);
105 fwrite($fp, $out);
106 $body = false;
107 $in = "";
108 while (!feof($fp)) {
109 $s = fgets($fp, 1024);
110 if ($body) $in .= $s;
111 if ($s == "\r\n") $body = true;
112 }
113 fclose($fp);
114 return $in;
115 }
116
117 function to_fullpath($url) {
118 $urlparts = parse_url($url);
119 $host = "";
120 $path = "";
121 if (!isset($urlparts['host'])) {
122 if (isset($_SERVER["HTTP_HOST"])) {
123 $host = $_SERVER["HTTP_HOST"];
124 }
125 else if (isset($_SERVER["SERVER_NAME"])) {
126 $$host = $_SERVER["SERVER_NAME"];
127 }
128 else {
129 $host = "localhost";
130 }
131 if (!isset($_SERVER["HTTPS"]) ||
132 $_SERVER["HTTPS"] == "off" ||
133 $_SERVER["HTTPS"] == "") {
134 $host = "http://" . $host;
135 if ($_SERVER["SERVER_PORT"] != "80") {
136 $host .= ":" . $_SERVER["SERVER_PORT"];
137 }
138 }
139 else {
140 $host = "https://" . $host;
141 if ($_SERVER["SERVER_PORT"] != "443") {
142 $host .= ":" . $_SERVER["SERVER_PORT"];
143 }
144 }
145 }
146 if (!isset($urlparts['path'])) {
147 $path = "/";
148 }
149 else if (($urlparts['path']{0} != '/') && ($_SERVER["PHP_SELF"]{0} == '/')) {
150 $path = substr($_SERVER["PHP_SELF"], 0, strrpos($_SERVER["PHP_SELF"], '/') + 1);
151 }
152 $url = $host . $path . $url;
153 return $url;
154 }
155
156 function coolplayer_init_url(&$url, &$info, &$type, &$width, &$height, &$autoplay, &$loop, $from_charset, $to_charset, $mediatype) {
157 if (preg_match('/\<a (.*?)\>(.*?)\<\/a\>/i', $url, $match)) {
158 $info = $match[2];
159 $a_option = $match[1];
160
161 if (preg_match('/width\s*=\s*\\"(\d*?)\\"/i', $a_option, $match) or
162 preg_match("/width\s*=\s*\\'(\d*?)\\'/i", $a_option, $match)) {
163 $width = (int)$match[1];
164 }
165
166 if (preg_match('/height\s*=\s*\\"(\d*?)\\"/i', $a_option, $match) or
167 preg_match("/height\s*=\s*\\'(\d*?)\\'/i", $a_option, $match)) {
168 $height = (int)$match[1];
169 }
170
171 if (preg_match('/autoplay\s*=\s*\\"(\w*?)\\"/i', $a_option, $match) or
172 preg_match("/autoplay\s*=\s*\\'(\w*?)\\'/i", $a_option, $match)) {
173 $autoplay = (((strtolower(trim($match[1])) == "on") ||
174 (strtolower(trim($match[1])) == "yes") ||
175 (strtolower(trim($match[1])) == "true") ||
176 (strtolower(trim($match[1])) == "1"))? "1" : "0");
177 }
178
179 if (preg_match('/loop\s*=\s*\\"(\w*?)\\"/i', $a_option, $match) or
180 preg_match("/loop\s*=\s*\\'(\w*?)\\'/i", $a_option, $match)) {
181 $loop = (((strtolower(trim($match[1])) == "on") ||
182 (strtolower(trim($match[1])) == "yes") ||
183 (strtolower(trim($match[1])) == "true") ||
184 (strtolower(trim($match[1])) == "1"))? "1" : "0");
185 }
186
187 if (preg_match('/mediatype\s*=\s*\\"(\w*?)\\"/i', $a_option, $match) or
188 preg_match("/mediatype\s*=\s*\\'(\w*?)\\'/i", $a_option, $match)) {
189 $mediatype = trim($match[1]);
190 }
191 if (preg_match('/href\s*=\s*\\"(.*?)\\"/i', $a_option, $match) or
192 preg_match("/href\s*=\s*\\'(.*?)\\'/i", $a_option, $match)) {
193 $url = $match[1];
194 }
195 if (preg_match('/charset\s*=\s*\\"(\.*?)\\"/i', $options, $match) or
196 preg_match("/charset\s*=\s*\\'(\.*?)\\'/i", $options, $match)) {
197 $to_charset = trim($match[1]);
198 }
199 }
200 else {
201 $urlparts = parse_url($url);
202 if (isset($urlparts['path'])) {
203 $info = basename($urlparts['path']);
204 if ($info == "") $info = $urlparts['path'];
205 }
206 else {
207 $info = $url;
208 }
209 }
210
211 $url = to_fullpath($url);
212
213 if ($mediatype != "") {
214 $type = trim(strtolower($mediatype));
215 }
216 else {
217 $type = explode(".", $url);
218 $type = trim(strtolower($type[count($type) - 1]));
219 if (strlen($type) > 4) {
220 $type = explode("?", $url);
221 $type = explode(".", $type[0]);
222 $type = trim(strtolower($type[count($type) - 1]));
223 }
224 if (substr($url, 0, 5) == "rtmp:") {
225 $type = "rtmp";
226 }
227 else if (substr($url, 0, 4) == "mms:") {
228 $type = "mms";
229 }
230 else if (substr($url, 0, 5) == "rtsp:") {
231 $type = "rtsp";
232 }
233 }
234
235 if (in_array($type, array('mp3', 'flv', 'rtmp', 'rbs', 'xml', 'rss', 'xspf', 'atom'))) {
236 $to_charset = 'utf-8';
237 }
238 $url = mb_convert_encoding($url, $to_charset, $from_charset);
239 $url = mb_urlencode($url, $to_charset);
240 $url = str_replace(" ", "%20", $url);
241
242 }
243
244 function is_stupid_video(&$url, &$info) {
245 if ((strpos(strtolower($url), 'http://www.stupidvideos.com/player.swf') === 0) ||
246 (strpos(strtolower($url), 'http://stupidvideos.com/player.swf') === 0)) {
247 if ($info == "player.swf") {
248 $info = "Stupid Videos";
249 }
250 return true;
251 }
252 return false;
253 }
254
255 function is_evilchili_video(&$url, &$info) {
256 if ((strpos(strtolower($url), 'http://www.evilchili.com/mediaview') === 0) ||
257 (strpos(strtolower($url), 'http://evilchili.com/mediaview') === 0)) {
258 $content = fetchURL($url);
259 if (preg_match('/\"(http\:\/\/208\.100\.1\.88\/media\_content\/[^(\")]*)\"/i', $content, $match)) {
260 $url = $match[1];
261 if (preg_match('/<a class=\"main\" href=\"index\"><strong>([^<]*)<\/strong><\/a>/i', $content, $match)) {
262 $info = $match[1];
263 }
264 return true;
265 }
266 }
267 return false;
268 }
269
270 function is_wildko_video(&$url, &$info) {
271 if ((strpos(strtolower($url), 'http://www.wildko.com') === 0) ||
272 (strpos(strtolower($url), 'http://wildko.com') === 0)) {
273 $content = fetchURL($url);
274 if (preg_match('/(http\:\/\/www\.wildko\.com\/mediastream\.php\?file=[^\.]*\.flv.WMV)/i', $content, $match)) {
275 $url = $match[1];
276 if (preg_match('/<h1>([^<]*)<\/h1>/i', $content, $match)) {
277 $info = $match[1];
278 }
279 return true;
280 }
281 }
282 return false;
283 }
284
285 function is_yikers_video(&$url, &$info) {
286 if ((strpos(strtolower($url), 'http://www.yikers.com/video_') === 0) ||
287 (strpos(strtolower($url), 'http://.yikers.com/video_') === 0)) {
288 $content = fetchURL($url);
289 if (preg_match('/http\:\/\/www\.yikers\.com\/go\_away\.asx\?id=(\d*)/i', $content, $match)) {
290 $url = 'http://www.yikers.com/go_away.asx?id=' . $match[1];
291 if (preg_match('/<title>([^<]*)<\/title>/i', $content, $match)) {
292 $info = $match[1];
293 }
294 return true;
295 }
296 }
297 return false;
298 }
299
300 function is_yikers_game(&$url, &$info) {
301 if ((strpos(strtolower($url), 'http://www.yikers.com/game_') === 0) ||
302 (strpos(strtolower($url), 'http://yikers.com/game_') === 0)) {
303 $content = fetchURL($url);
304 if (preg_match('/http\:\/\/www\.yikers\.com\/games\/([^(\.)]*)\.swf/i', $content, $match)) {
305 $url = 'http://www.yikers.com/games/' . $match[1] . ".swf";
306 if (preg_match('/<title>([^<]*)<\/title>/i', $content, $match)) {
307 $info = $match[1];
308 }
309 return true;
310 }
311 }
312 return false;
313 }
314
315 function is_redbalcony_video(&$url, &$info) {
316 if ((strpos(strtolower($url), 'http://www.redbalcony.com/?vid=') === 0) ||
317 (strpos(strtolower($url), 'http://redbalcony.com/?vid=') === 0)) {
318 $content = fetchURL($url);
319 if (preg_match('/var MoviePath = \'(http\:\/\/media\.redbalcony\.com\/[^(\.)]*\.flv)\'/i', $content, $match)) {
320 $url = $match[1];
321 if (preg_match('/<title>([^<]*)<\/title>/i', $content, $match)) {
322 $info = $match[1];
323 }
324 return true;
325 }
326 }
327 return false;
328 }
329
330 function is_redbalcony_game(&$url, &$info) {
331 if ((strpos(strtolower($url), 'http://www.redbalcony.com/?pid=') === 0) ||
332 (strpos(strtolower($url), 'http://redbalcony.com/?pid=') === 0)) {
333 $content = fetchURL($url);
334 if (preg_match('/src=\'(http\:\/\/media\.redbalcony\.com\/[^(\.)]*\.swf)\'/i', $content, $match)) {
335 $url = $match[1];
336 if (preg_match('/<title>([^<]*)<\/title>/i', $content, $match)) {
337 $info = $match[1];
338 }
339 return true;
340 }
341 }
342 return false;
343 }
344
345 function is_viddler_video(&$url, &$info) {
346 if ((strpos(strtolower($url), 'http://www.viddler.com') === 0) ||
347 (strpos(strtolower($url), 'http://viddler.com') === 0)) {
348 $content = fetchURL($url);
349 if (preg_match('/so\.addVariable\(\"flashVarText\"\, \"([^(\")]*)\"/i', $content, $match)) {
350 $url = "http://www.viddler.com/flash/publisher.swf?". $match[1];
351 if (preg_match('/<h2 id=\"titleEditableHr\">([^<]*)<\/h2>/i', $content, $match)) {
352 $info = trim($match[1]);
353 }
354 return true;
355 }
356 }
357 return false;
358 }
359
360 function is_yoqoo_video(&$url, &$info) {
361 if ((strpos(strtolower($url), 'http://www.yoqoo.com/v_show/') === 0) ||
362 (strpos(strtolower($url), 'http://yoqoo.com/v_show/') === 0)) {
363 $content = fetchURL($url);
364 if (preg_match('/fo\.addVariable\(\"VideoIDS\"\,([^\)]*)\)\;/i', $content, $match)) {
365 $url = "http://www.yoqoo.com/v1.0.0023/v/swf/qplayer.swf?VideoIDS=" . $match[1];
366 if (preg_match('/<h3 class=\"f\_14 p\_5\">([^<]*)<\/h3>/i', $content, $match)) {
367 $info = $match[1];
368 }
369 return true;
370 }
371 }
372 else if ((strpos(strtolower($url), 'http://player.yoqoo.com/player.php/sid/') === 0) ||
373 (strpos(strtolower($url), 'http://www.yoqoo.com/v/swf/qplayer.swf') === 0) ||
374 (strpos(strtolower($url), 'http://yoqoo.com/v/swf/qplayer.swf') === 0)) {
375 if ((strpos($url, $info) !== false) || ($info == "qplayer.swf")) {
376 $info = "YoQoo Video";
377 }
378 return true;
379 }
380 return false;
381 }
382
383 function is_5show_video(&$url, &$info) {
384 if ((strpos(strtolower($url), 'http://www.5show.com/swf/5show_player_5.0.swf') === 0) ||
385 (strpos(strtolower($url), 'http://5show.com/swf/5show_player_5.0.swf') === 0)) {
386 if ($info == "5show_player_5.0.swf") {
387 $info = "5show Video";
388 }
389 return true;
390 }
391 else if ((strpos(strtolower($url), 'http://www.5show.com/show/show/') === 0) ||
392 (strpos(strtolower($url), 'http://5show.com/show/show/') === 0)) {
393 $content = fetchURL($url);
394 if (preg_match('/headstr4=\"([^\"]*)\"/i', $content, $match)) {
395 $url = "http://www.5show.com/swf/5show_player_5.0.swf" . $match[1];
396 if (preg_match('/<div class=\"sp\_title\_word\">([^<]*)<\/div>/i', $content, $match)) {
397 $info = $match[1];
398 }
399 return true;
400 }
401 }
402 return false;
403 }
404
405 function is_6room_video(&$url, &$info) {
406 if ((strpos(strtolower($url), 'http://www.6rooms.com/player.swf?vid=') === 0) ||
407 (strpos(strtolower($url), 'http://6rooms.com/player.swf?vid=') === 0)) {
408 if ($info == "player.swf") {
409 $info = "6Room Video";
410 }
411 return true;
412 }
413 else if ((strpos(strtolower($url), 'http://www.6rooms.com/') === 0) ||
414 (strpos(strtolower($url), 'http://6rooms.com/') === 0)) {
415 $content = fetchURL($url);
416 if (preg_match('/FlashObject\(\"(http\:\/\/www\.6rooms\.com\/player\.swf\?vid=[^(\"|\&)]*)\&/i', $content, $match)) {
417 $url = $match[1];
418 if (preg_match('/<div id=\"video-watch\">\r\n<h4>([^<]*)<\/h4>/i', $content, $match)) {
419 $info = $match[1];
420 }
421 return true;
422 }
423 }
424 return false;
425 }
426
427 function is_live_video(&$url, &$info) {
428 if ((strpos(strtolower($url), 'http://www.livevideo.com/video') === 0) ||
429 (strpos(strtolower($url), 'http://livevideo.com/video') === 0)) {
430 if (preg_match('/video\/([^(\/)]*)\/([^(\/)]*)\/([^(\.)]*)\.aspx/', $url, $match)) {
431 $video_id = $match[2];
432 $url = "http://www.livevideo.com/flvplayer/flvplayer.swf?video=" .
433 urlencode("http://www.livevideo.com/media/GetFlashVideo.ashx?cid=" . $video_id);
434 if (strpos($info, 'aspx') !== false) {
435 $info = $match[3];
436 }
437 return true;
438 }
439 else if (preg_match('/video\/([^(\/)]*)\/([^(\.)]*)\.aspx/', $url, $match)) {
440 $video_id = $match[1];
441 $url = "http://www.livevideo.com/flvplayer/flvplayer.swf?video=" .
442 urlencode("http://www.livevideo.com/media/GetFlashVideo.ashx?cid=" . $video_id);
443 if (strpos($info, 'aspx') !== false) {
444 $info = $match[2];
445 }
446 return true;
447 }
448 }
449 return false;
450 }
451
452 function is_ifilm_video(&$url, &$info) {
453 if ((strpos(strtolower($url), 'http://www.ifilm.com') === 0) ||
454 (strpos(strtolower($url), 'http://ifilm.com') === 0)) {
455 if (preg_match('/ifilm\.com\/video\/([^(\&)]*)/', $url, $match)) {
456 $video_id = $match[1];
457 $url = "http://www.ifilm.com/efp?flvbaseclip={$video_id}";
458 if (strpos($info, $video_id) !== false) {
459 $info = "IFilm Video";
460 }
461 return true;
462 }
463 }
464 return false;
465 }
466
467 function is_atomfilms_video(&$url, &$info) {
468 if ((strpos(strtolower($url), 'http://www.atomfilms.com:80/a/autoplayer/shareEmbed.swf?keyword=') === 0) ||
469 (strpos(strtolower($url), 'http://www.atomfilms.com/a/autoplayer/shareEmbed.swf?keyword=') === 0) ||
470 (strpos(strtolower($url), 'http://atomfilms.com/a/autoplayer/shareEmbed.swf?keyword=') === 0)) {
471 if ($info == "shareEmbed.swf") {
472 if (preg_match('/keyword=([^(\&|$)]*)/', $url, $match)) {
473 $info = $match[1];
474 }
475 }
476 return true;
477 }
478 else if ((strpos(strtolower($url), 'http://www.atomfilms.com/film/') === 0) ||
479 (strpos(strtolower($url), 'http://atomfilms.com/film/') === 0)) {
480 if (preg_match('/atomfilms\.com\/film\/([^(\.)]*)\.jsp/', $url, $match)) {
481 $video_id = $match[1];
482 $url = "http://www.atomfilms.com:80/a/autoplayer/shareEmbed.swf?keyword={$video_id}";
483 if (strpos($info, $video_id) !== false) {
484 $info = $video_id;
485 }
486 return true;
487 }
488 }
489 return false;
490 }
491
492 function is_gametrailers_video(&$url, &$info) {
493 if ((strpos(strtolower($url), 'http://www.gametrailers.com/umwatcher.php?id=') === 0) ||
494 (strpos(strtolower($url), 'http://gametrailers.com/umwatcher.php?id=') === 0) ||
495 (strpos(strtolower($url), 'http://www.gametrailers.com/umwatcher_gate72.swf?umid=') === 0) ||
496 (strpos(strtolower($url), 'http://gametrailers.com/umwatcher_gate72.swf?umid=') === 0) ||
497 (strpos(strtolower($url), 'http://www.gametrailers.com/remote_wrap.php?umid=') === 0) ||
498 (strpos(strtolower($url), 'http://gametrailers.com/remote_wrap.php?umid=') === 0)) {
499 if (preg_match('/id=(\d*)/', $url, $match)) {
500 $video_id = $match[1];
501 $url = "http://www.gametrailers.com/remote_wrap.php?umid={$video_id}";
502 if ($info == "umwatcher.php" || $info == "umwatcher_gate72.swf" || $info == "remote_wrap.php") {
503 $info = "GameTrailers Video";
504 }
505 return true;
506 }
507 }
508 else if ((strpos(strtolower($url), 'http://www.gametrailers.com/player.php?') === 0) ||
509 (strpos(strtolower($url), 'http://gametrailers.com/player.php?') === 0) ||
510 (strpos(strtolower($url), 'http://www.gametrailers.com/remote_wrap.php?mid=') === 0) ||
511 (strpos(strtolower($url), 'http://gametrailers.com/remote_wrap.php?mid=') === 0)) {
512 if (preg_match('/id=(\d*)/', $url, $match)) {
513 $video_id = $match[1];
514 $url = "http://www.gametrailers.com/remote_wrap.php?mid={$video_id}";
515 if ($info == "player.php" || $info == "remote_wrap.php") {
516 $info = "GameTrailers Video";
517 }
518 return true;
519 }
520 }
521 return false;
522 }
523
524 function is_vsocial_video(&$url, &$info) {
525 if ((strpos(strtolower($url), 'http://www.vsocial.com') === 0) ||
526 (strpos(strtolower($url), 'http://vsocial.com') === 0)) {
527 if (preg_match('/v=([^(\&|$)]*)/', $url, $match) ||
528 preg_match('/vsocial\.com\/v\/([^(\&|$)]*)/', $url, $match)) {
529 $video_id = $match[1];
530 $url = "http://static.vsocial.com/flash/ups.swf?d={$video_id}";
531 if ((strpos($info, $video_id) !== false) ||
532 ($info == 'e.swf') || ($info == 'vp.swf')) {
533 $info = "Vsocial Video";
534 }
535 return true;
536 }
537 else if (preg_match('/d=([^(\&|$)]*)/', $url, $match)) {
538 $docid = $match[1];
539 $url = "http://static.vsocial.com/flash/ups.swf?d={$docid}";
540 if ((strpos($info, $match[1]) !== false) ||
541 ($info == "") || ($info == "index.php")) {
542 $info = "Vsocial Video";
543 }
544 return true;
545 }
546 }
547 return false;
548 }
549
550 function is_youtube_video(&$url, &$info) {
551 if ((strpos(strtolower($url), 'http://www.youtube') === 0) ||
552 (strpos(strtolower($url), 'http://youtube') === 0)) {
553 if (preg_match('/v=([^(\&|$)]*)/', $url, $match) ||
554 preg_match('/video_id=([^(\&|$)]*)/', $url, $match) ||
555 preg_match('/youtube\.com\/v\/([^(\&|$)]*)/', $url, $match)) {
556 $video_id = $match[1];
557 $url = "http://www.youtube.com/v/$video_id";
558 if (strpos($info, $video_id) !== false) {
559 $info = "YouTube Video";
560 }
561 return true;
562 }
563 }
564 return false;
565 }
566
567 function is_tudou_video(&$url, &$info) {
568 if ((strpos(strtolower($url), 'http://www.tudou.com') === 0) ||
569 (strpos(strtolower($url), 'http://tudou.com') === 0)) {
570 if (preg_match('/\/programs\/view\/([^(\/|$)]*)/', $url, $match) ||
571 preg_match('/\/v\/([^(\/|$)]*)/', $url, $match)) {
572 $video_id = $match[1];
573 if (strpos($info, $video_id) !== false) {
574 $info = "Tudou Video";
575 }
576 $url = 'http://www.tudou.com/v/' . $video_id;
577 return true;
578 }
579 else if (preg_match('/\/playlist\/id\/([^(\/|$)]*)/', $url, $match) ||
580 preg_match('/\/playlist\/playindex\.do\?lid=([^(\&|$)]*)/', $url, $match)) {
581 $playlist_id = $match[1];
582 if (strpos($info, $playlist_id) !== false || $info == "playindex.do") {
583 $info = "Tudou Playlist Video";
584 }
585 $url = 'http://www.tudou.com/player/playlist.swf?lid=' . $playlist_id;
586 return true;
587 }
588 }
589 return false;
590 }
591
592 function is_odeo_audio(&$url, &$info) {
593 if ((strpos(strtolower($url), 'http://www.odeo.com') === 0) ||
594 (strpos(strtolower($url), 'http://odeo.com') === 0)) {
595 if (preg_match('/\/audio\/([^(\/|$)]*)/', $url, $match)) {
596 $audio_id = $match[1];
597 if (strpos($info, $audio_id) !== false || $info == "view") {
598 $info = "Odeo Audio";
599 }
600 $url = 'http://media.odeo.com/flash/odeo_player.swf?v=3&amp;type=audio&amp;id=' . $audio_id;
601 return true;
602 }
603 }
604 return false;
605 }
606
607 function is_revver_video(&$url, &$info) {
608 if (strpos(strtolower($url), 'http://one.revver.com/watch/') === 0) {
609 if (preg_match('/revver\.com\/watch\/([^(\/|$)]*)/', $url, $match)) {
610 $video_id = $match[1];
611 if (strpos($info, $video_id) !== false || $info == "flv") {
612 $info = "Revver Video";
613 }
614 $url = 'http://flash.revver.com/player/1.0/player.swf?' .
615 '&amp;mediaId=' . $video_id . '&amp;affiliateId=0&amp;javascriptContext=true' . '&amp;skinURL=http://flash.revver.com/player/1.0/skins/RevverSkin_1-1.swf' . '&amp;skinImgURL=http://flash.revver.com/player/1.0/skins/night_skin.png' . '&amp;actionBarSkinURL=http://flash.revver.com/player/1.0/skins/RevverActionBarSkin.swf' .
616 '&amp;resizeVideo=true';
617 return true;
618 }
619 }
620 return false;
621 }
622
623 function is_metacafe_video(&$url, &$info) {
624 if ((strpos(strtolower($url), 'http://www.metacafe.com/watch/') === 0) ||
625 (strpos(strtolower($url), 'http://metacafe.com/watch/') === 0)) {
626 if (preg_match('/metacafe\.com\/watch\/([^\/]*)\/([^(\/|$)]*)/', $url, $match)) {
627 $video_id = $match[1];
628 $video_name = $match[2];
629 $url = "http://www.metacafe.com/fplayer/{$video_id}/{$video_name}.swf";
630 return true;
631 }
632 }
633 return false;
634 }
635
636 function is_myspace_video(&$url, &$info) {
637 if (strpos(strtolower($url), 'http://vids.myspace.com/index.cfm') === 0) {
638 if (preg_match('/videoid=([^(\&|$)]*)/i', $url, $match)) {
639 $video_id = $match[1];
640 if ($info == "index.cfm") {
641 $info = "MySpace Video";
642 }
643 $url = "http://lads.myspace.com/videos/vplayer.swf?m={$video_id}";
644 return true;
645 }
646 }
647 return false;
648 }
649
650 function is_mofile_video(&$url, &$info) {
651 if (preg_match('/http\:\/\/tv\.mofile\.com\/([A-Za-z\d]*)/i', $url, $match)) {
652 $video_id = $match[1];
653 if ($info == $video_id) {
654 $info = "Mofile Video";
655 }
656 $url = "http://tv.mofile.com/cn/xplayer.swf?v=" . $video_id;
657 return true;
658 }
659 return false;
660 }
661
662 function is_goear_audio(&$url, &$info) {
663 if ((strpos(strtolower($url), 'http://www.goear.com/listen.php') === 0) ||
664 (strpos(strtolower($url), 'http://goear.com/listen.php') === 0)) {
665 if (preg_match('/v=([^(\&|$)]*)/i', $url, $match)) {
666 $audio_id = $match[1];
667 if ($info == "listen.php") {
668 $info = "GoEar Audio";
669 }
670 $url = "http://www.goear.com/files/localplayer.swf?file={$audio_id}";
671 return true;
672 }
673 }
674 return false;
675 }
676
677 function is_break_video(&$url, &$info) {
678 if (preg_match('/http\:\/\/embed\.break\.com\/([^(\&|$)]*)/', $url, $match)) {
679 $video_id = $match[1];
680 if ((strpos($info, $video_id) !== false)) {
681 $info = "break.com Video";
682 }
683 return true;
684 }
685 else if ((strpos(strtolower($url), 'http://www.break.com/index/') === 0) ||
686 (strpos(strtolower($url), 'http://break.com/index/') === 0)) {
687 $content = fetchURL($url);
688 if (preg_match('/(http\:\/\/embed\.break\.com\/[^(\&|$)]*)/', $content, $match)) {
689 $url = $match[1];
690 if ((strpos($info, '.html') !== false)) {
691 $info = substr($info, 0, strlen($info) - 5);
692 }
693 return true;
694 }
695 }
696 return false;
697 }
698
699 function is_dailymotion_video(&$url, &$info) {
700 if (preg_match('/dailymotion\.com\/swf\/([^(\&|$)]*)/', $url, $match)) {
701 $video_id = $match[1];
702 if ((strpos($info, $video_id) !== false)) {
703 $info = "dailymotion Video";
704 }
705 return true;
706 }
707 else if ((strpos(strtolower($url), 'http://www.dailymotion.com/') === 0) ||
708 (strpos(strtolower($url), 'http://dailymotion.com/') === 0)) {
709 $content = fetchURL($url);
710 if (preg_match('/dailymotion\.com\/swf\/([^(\&|\"|$)]*)/', $content, $match)) {
711 $url = "http://www.dailymotion.com/swf/" . $match[1];
712 if (preg_match('/<div class=\"box\_main\_title\"><h1>([^<]*)<\/h1><\/div>/i', $content, $match)) {
713 $info = $match[1];
714 }
715
716 return true;
717 }
718 }
719 return false;
720 }
721
722 function is_brightcove_video(&$url, &$info) {
723 if ((strpos(strtolower($url), 'http://www.brightcove.com/title.jsp?') === 0) ||
724 (strpos(strtolower($url), 'http://brightcove.com/title.jsp?') === 0)) {
725 if (preg_match('/title=([^(\&|$)]*)/', $url, $match)) {
726 $url = "http://admin.brightcove.com/destination/player/player.swf?" .
727 "allowFullScreen=true&amp;" .
728 "initVideoId=" . $match[1] . "&amp;" .
729 "servicesURL=http://services.brightcove.com/services&amp;" .
730 "viewerSecureGatewayURL=https://services.brightcove.com/services/amfgateway&amp;" .
731 "cdnURL=http://admin.brightcove.com";
732 if ($info == "title.jsp") {
733 $info = "BrightCove Video";
734 }
735 return true;
736 }
737 }
738 return false;
739 }
740
741 function is_imtv_vlog(&$url, &$info) {
742 $mid = "";
743 $id = "";
744 if (preg_match('/im\.tv\/vlog\/personal\/(\d*)\/(\d*)/', $url, $match)) {
745 $mid = $match[1];
746 $id = $match[2];
747 if ($info == $id) {
748 $info = "im.tv vlog";
749 }
750 }
751 if (preg_match('/myvlog\.im\.tv\/\?id=(\d*)\&mid=(\d*)/', $url, $match)) {
752 $id = $match[1];
753 $mid = $match[2];
754 if ($info == "/") {
755 $info = "im.tv vlog";
756 }
757 }
758 if (preg_match('/myvlog\.im\.tv\/index\_key2\.swf\?id=(\d*)\&mid=(\d*)/', $url, $match)) {
759 $id = $match[1];
760 $mid = $match[2];
761 if ($info == "index_key2.swf") {
762 $info = "im.tv vlog";
763 }
764 }
765 if ($id == "" && $mid == "") {
766 return false;
767 }
768 else {
769 $url = "http://myvlog.im.tv/index_key2.swf?id={$id}&amp;mid={$mid}&amp;MemberID=&amp;SessID=&amp;LoginID=&amp;inIMTV=Y&amp;album=0";
770 return true;
771 }
772 }
773
774 function is_rockyou_video(&$url, &$info) {
775 $id = "";
776 if (preg_match('/rockyou\.com\/rockyou\.swf\?instanceid=(\d*)/', $url, $match)) {
777 $id = $match[1];
778 if ($info == "rockyou.swf") {
779 $info = "RockYou Video";
780 }
781 }
782 if (preg_match('/rockyou\.com\/show\_my\_gallery\.php\?instanceid=(\d*)/', $url, $match)) {
783 $id = $match[1];
784 if ($info == "show_my_gallery.php") {
785 $info = "RockYou Video";
786 }
787 }
788 if ($id == "") {
789 return false;
790 }
791 else {
792 $url = "http://apps.rockyou.com/rockyou.swf?instanceid={$id}";
793 return true;
794 }
795 }
796
797 function is_myvideo_video(&$url, &$info) {
798 if (preg_match('/myvideo\.de\/(watch|movie)\/(\d*)/', $url, $match)) {
799 $id = $match[2];
800 $url = "http://www.myvideo.de/movie/{$id}";
801 if ($info == $id) {
802 $info = "MyVideo.de";
803 }
804 return true;
805 }
806 return false;
807 }
808
809 function is_clipfish_video(&$url, &$info) {
810 if (strpos(strtolower($url), 'http://www.clipfish.de/') === 0) {
811 if (preg_match('/videoid=([^(\&|$)]*)/i', $url, $match)) {
812 $videoid = $match[1];
813 $url = "http://www.clipfish.de/videoplayer.swf?p=0&amp;coop=clipfish&amp;videoid={$videoid}";
814 if ($info == "player.php" || $info = "videoplayer.swf") {
815 $info = "Clipfish Video";
816 }
817 return true;
818 }
819 }
820 return false;
821 }
822
823 function is_sevenload_video(&$url, &$info) {
824 if (strpos(strtolower($url), 'sevenload') !== false) {
825 if (preg_match('/videos\/([^(\/|\-|$)]*)/', $url, $match)) {
826 $videoid = $match[1];
827 if ((strpos($url, $info) !== false)) {
828 $info = "sevenload Video";
829 }
830 $url = "http://en.sevenload.com/~page/swf/en_GB/player.swf?id={$videoid}" .
831 "&amp;internal=1&amp;endScreen=1";
832 return true;
833 }
834 }
835 return false;
836 }
837
838 function is_google_video(&$url, &$info) {
839 if (strpos(strtolower($url), 'http://video.google') === 0) {
840 if (preg_match('/docid=([^(\&|$)]*)/i', $url, $match)) {
841 $docid = $match[1];
842 $url = "http://video.google.com/googleplayer.swf?docId={$docid}";
843 if ($info == "videoplay" || $info = "googleplayer.swf") {
844 $info = "Google Video";
845 }
846 return true;
847 }
848 }
849 return false;
850 }
851
852 function coolplayer_init_media(&$url, &$info, &$type,
853 &$src, &$func, &$mime,
854 &$width, &$height, &$autoplay, &$loop) {
855
856 global $coolplayer_default_pluginpath;
857 $pluginpath = $coolplayer_default_pluginpath;
858
859 //real media
860 $func = 'coolplayer_rm';
861
862 if (in_array($type, array('rm', 'rmvb', 'ra', 'rv', 'ram', 'smil', 'smi', 'rtsp'))) {
863 $src = $pluginpath . "/coolplayer.php?coolplayer_url=" . htmlentities(urlencode($url));
864 $mime = 'audio/x-pn-realaudio-plugin';
865 return true;
866 }
867
868 if ($type == 'rpm') {
869 $src = $url;
870 $mime = 'audio/x-pn-realaudio-plugin';
871 return true;
872 }
873
874 //windows media
875 $func = 'coolplayer_wm';
876
877 if (is_evilchili_video($url, $info)) {
878 $type = explode(".", $url);
879 $type = trim(strtolower($type[count($type) - 1]));
880 if ($type == 'swf') {
881 $autoplay = "1";
882 }
883 }
884
885 if (is_wildko_video($url, $info)) {
886 $type = 'wmv';
887 }
888
889 if (in_array($type, array('asf', 'wm', 'wma', 'wmv', 'wax', 'wvx', 'ogg', 'ape', 'avi', 'mid', 'midi', 'wav', 'mms', 'm3u'))) {
890 $src = $url;
891 $mime = 'application/x-mplayer2';
892 $height += 65;
893 return true;
894 }
895
896 if ($type == 'asx') {
897 $src = $url;
898 $mime = 'application/asx';
899 $height += 65;
900 return true;
901 }
902
903 if (is_yikers_video($url, $info)) {
904 $src = $url;
905 $mime = 'application/x-mplayer2';
906 $width = 320;
907 $height = 305;
908 return true;
909 }
910
911 //quicktime
912 $func = 'coolplayer_qt';
913
914 if (in_array($type, array('mov', 'qt', 'mqv', 'm4v', 'm4a', 'm4b'))) {
915 $src = $url;
916 $mime = 'video/quicktime';
917 return true;
918 }
919
920 if (in_array($type, array('mpeg', 'mpg', 'm1s', 'm1v', 'm1a', 'm75', 'm15', 'mp2', 'mpm', 'mpv', 'mpa'))) {
921 $src = $url;
922 $mime = 'video/x-mpeg';
923 return true;
924 }
925
926 if (in_array($type, array('flc', 'fli', 'cel'))) {
927 $src = $url;
928 $mime = 'video/flc';
929 return true;
930 }
931
932 if (in_array($type, array('aiff', 'aif', 'aifc', 'cdda'))) {
933 $src = $url;
934 $mime = 'audio/x-aiff';
935 return true;
936 }
937
938 if (in_array($type, array('rtsp', 'rts'))) {
939 $src = $url;
940 $mime = 'application/x-rtsp';
941 return true;
942 }
943
944 if (in_array($type, array('3gp', '3gpp'))) {
945 $src = $url;
946 $mime = 'video/3gpp';
947 return true;
948 }
949
950 if (in_array($type, array('3g2', '3gp2'))) {
951 $src = $url;
952 $mime = 'video/3gpp2';
953 return true;
954 }
955
956 if (in_array($type, array('au', 'snd', 'ulw'))) {
957 $src = $url;
958 $mime = 'audio/basic';
959 return true;
960 }
961
962 if (in_array($type, array('smf', 'kar'))) {
963 $src = $url;
964 $mime = 'audio/x-midi';
965 return true;
966 }
967
968 if ($type == 'qcp') {
969 $src = $url;
970 $mime = 'audio/vnd.qcelp';
971 return true;
972 }
973
974 if ($type == 'sdv') {
975 $src = $url;
976 $mime = 'video/sd-video';
977 return true;
978 }
979
980 if ($type == 'bwf') {
981