| 1 |
<?php
|
| 2 |
/*
|
| 3 |
Modules Name: Coolfilter
|
| 4 |
Modules URI: http://drupal.org/node/61357
|
| 5 |
Description: display all kinds of media in drupal
|
| 6 |
Version: 2.9
|
| 7 |
Author: andot,liukan transplant to drupal
|
| 8 |
Author URI: http://www.kylinx.net/ & coolcode.cn
|
| 9 |
*/
|
| 10 |
|
| 11 |
//================================================================================
|
| 12 |
// real player
|
| 13 |
//================================================================================
|
| 14 |
|
| 15 |
if (isset($_GET['coolplayer_src'])) {
|
| 16 |
$src = (get_magic_quotes_gpc() ? stripslashes($_GET['coolplayer_src']) : $_GET['coolplayer_src']);
|
| 17 |
$width = (get_magic_quotes_gpc() ? stripslashes($_GET['width']) : $_GET['width']);
|
| 18 |
$height = (get_magic_quotes_gpc() ? stripslashes($_GET['height']) : $_GET['height']);
|
| 19 |
$autoplay = (get_magic_quotes_gpc() ? stripslashes($_GET['autoplay']) : $_GET['autoplay']);
|
| 20 |
$loop = (get_magic_quotes_gpc() ? stripslashes($_GET['loop']) : $_GET['loop']);
|
| 21 |
$clip = "clip" . rand();
|
| 22 |
echo "document.writeln('<object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" " .
|
| 23 |
"width=\"$width\" height=\"$height\">" .
|
| 24 |
"<param name=\"src\" value=\"$src\" />" .
|
| 25 |
"<param name=\"controls\" value=\"Imagewindow\" />" .
|
| 26 |
"<param name=\"console\" value=\"$clip\" />" .
|
| 27 |
"<param name=\"autostart\" value=\"$autoplay\" />" .
|
| 28 |
"<param name=\"loop\" value=\"$loop\" />" .
|
| 29 |
"<embed src=\"$src\" type=\"audio/x-pn-realaudio-plugin\" " .
|
| 30 |
"autostart=\"$autoplay\" loop=\"$loop\" console=\"$clip\" " .
|
| 31 |
"width=\"$width\" height=\"$height\" controls=\"Imagewindow\"></embed><br />" .
|
| 32 |
"</object><object classid=\"clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA\" " .
|
| 33 |
"width=\"$width\" height=\"42\">" .
|
| 34 |
"<param name=\"src\" value=\"$src\" />" .
|
| 35 |
"<param name=\"controls\" value=\"ControlPanel\" />" .
|
| 36 |
"<param name=\"console\" value=\"$clip\" />" .
|
| 37 |
"<param name=\"autostart\" value=\"$autoplay\" />" .
|
| 38 |
"<param name=\"loop\" value=\"$loop\" />" .
|
| 39 |
"<embed src=\"$src\" type=\"audio/x-pn-realaudio-plugin\" " .
|
| 40 |
"autostart=\"$autoplay\" loop=\"$loop\" console=\"$clip\" " .
|
| 41 |
"width=\"$width\" height=\"42\" controls=\"ControlPanel\"></embed>" .
|
| 42 |
"</object>');";
|
| 43 |
exit();
|
| 44 |
}
|
| 45 |
|
| 46 |
//================================================================================
|
| 47 |
// coolplayer_url
|
| 48 |
//================================================================================
|
| 49 |
if (isset($_GET['coolplayer_url'])) {
|
| 50 |
$url = (get_magic_quotes_gpc() ? stripslashes($_GET['coolplayer_url']) : $_GET['coolplayer_url']);
|
| 51 |
echo $url;
|
| 52 |
exit();
|
| 53 |
}
|
| 54 |
|
| 55 |
class CoolPlayer {
|
| 56 |
var $width;
|
| 57 |
var $height;
|
| 58 |
var $autoplay;
|
| 59 |
var $loop;
|
| 60 |
var $charset;
|
| 61 |
var $download;
|
| 62 |
var $mediatype;
|
| 63 |
var $rpcurl;
|
| 64 |
|
| 65 |
var $pluginpath = "modules/coolfilter";
|
| 66 |
var $blocks = array();
|
| 67 |
|
| 68 |
function CoolPlayer() {
|
| 69 |
include("coolplayer_config.php");
|
| 70 |
$this->width = $coolplayer_width;
|
| 71 |
$this->height = $coolplayer_height;
|
| 72 |
$this->autoplay = $coolplayer_autoplay;
|
| 73 |
$this->loop = $coolplayer_loop;
|
| 74 |
$this->charset = $coolplayer_charset;
|
| 75 |
$this->download = $coolplayer_download;
|
| 76 |
$this->mediatype = "";
|
| 77 |
$this->rpcurl = $coolplayer_rpcurl;
|
| 78 |
|
| 79 |
$this->pluginpath = $this->pluginpath;
|
| 80 |
}
|
| 81 |
|
| 82 |
function part_one($content) {
|
| 83 |
$content = preg_replace('#\<coolplayer(.*?)\>(.*?)\</coolplayer\>#sie', '$this->do_CoolPlayer($content, \'\\2\', \'\\1\');', $content);
|
| 84 |
$content = preg_replace('#\[coolplayer(.*?)\](.*?)\[/coolplayer\]#sie', '$this->do_CoolPlayer($content, \'\\2\', \'\\1\');', $content);
|
| 85 |
return $content;
|
| 86 |
}
|
| 87 |
|
| 88 |
function part_two($content) {
|
| 89 |
if (count($this->blocks)) {
|
| 90 |
$content = str_replace(array_keys($this->blocks), array_values($this->blocks), $content);
|
| 91 |
$this->blocks = array();
|
| 92 |
}
|
| 93 |
|
| 94 |
return $content;
|
| 95 |
}
|
| 96 |
|
| 97 |
function getBlockID($content)
|
| 98 |
{
|
| 99 |
static $num = 0;
|
| 100 |
|
| 101 |
// Just do a check to make sure the user
|
| 102 |
// hasn't (however unlikely) input block replacements
|
| 103 |
// as legit text
|
| 104 |
do
|
| 105 |
{
|
| 106 |
++$num;
|
| 107 |
$blockID = "<p>++CoolPlayer_BLOCK_$num++</p>";
|
| 108 |
}
|
| 109 |
while(strpos($content, $blockID) !== false);
|
| 110 |
|
| 111 |
return $blockID;
|
| 112 |
}
|
| 113 |
|
| 114 |
function init_option(&$url, &$options, &$width, &$height, &$autoplay, &$loop, &$charset, &$download, &$mediatype) {
|
| 115 |
|
| 116 |
$url = str_replace(array("\\\"", "\\\'"), array("\"", "\'"), $url);
|
| 117 |
$options = str_replace(array("\\\"", "\\\'"), array("\"", "\'"), $options);
|
| 118 |
|
| 119 |
if (preg_match('/width\s*=\s*"(\d*?)"/i', $options, $match) or
|
| 120 |
preg_match("/width\s*=\s*'(\d*?)'/i", $options, $match)) {
|
| 121 |
$width = (int)$match[1];
|
| 122 |
}
|
| 123 |
else {
|
| 124 |
$width = $this->width;
|
| 125 |
}
|
| 126 |
|
| 127 |
if (preg_match('/height\s*=\s*"(\d*?)"/i', $options, $match) or
|
| 128 |
preg_match("/height\s*=\s*'(\d*?)'/i", $options, $match)) {
|
| 129 |
$height = (int)$match[1];
|
| 130 |
}
|
| 131 |
else {
|
| 132 |
$height = $this->height;
|
| 133 |
}
|
| 134 |
|
| 135 |
if (preg_match('/autoplay\s*=\s*"(\w*?)"/i', $options, $match) or
|
| 136 |
preg_match("/autoplay\s*=\s*'(\w*?)'/i", $options, $match)) {
|
| 137 |
$autoplay = (((strtolower(trim($match[1])) == "on") ||
|
| 138 |
(strtolower(trim($match[1])) == "yes") ||
|
| 139 |
(strtolower(trim($match[1])) == "true") ||
|
| 140 |
(strtolower(trim($match[1])) == "1"))? "1" : "0");
|
| 141 |
} else {
|
| 142 |
$autoplay = $this->autoplay;
|
| 143 |
}
|
| 144 |
|
| 145 |
if (preg_match('/download\s*=\s*"(\w*?)"/i', $options, $match) or
|
| 146 |
preg_match("/download\s*=\s*'(\w*?)'/i", $options, $match)) {
|
| 147 |
$download = (((strtolower(trim($match[1])) == "on") ||
|
| 148 |
(strtolower(trim($match[1])) == "yes") ||
|
| 149 |
(strtolower(trim($match[1])) == "true") ||
|
| 150 |
(strtolower(trim($match[1])) == "show") ||
|
| 151 |
(strtolower(trim($match[1])) == "1"))? "block" : "none");
|
| 152 |
}
|
| 153 |
else {
|
| 154 |
$download = $this->download;
|
| 155 |
}
|
| 156 |
|
| 157 |
if (preg_match('/loop\s*=\s*"(\w*?)"/i', $options, $match) or
|
| 158 |
preg_match("/loop\s*=\s*'(\w*?)'/i", $options, $match)) {
|
| 159 |
$loop = (((strtolower(trim($match[1])) == "on") ||
|
| 160 |
(strtolower(trim($match[1])) == "yes") ||
|
| 161 |
(strtolower(trim($match[1])) == "true") ||
|
| 162 |
(strtolower(trim($match[1])) == "1"))? "1" : "0");
|
| 163 |
} else {
|
| 164 |
$loop = $this->loop;
|
| 165 |
}
|
| 166 |
|
| 167 |
if (preg_match('/mediatype\s*=\s*"(\w*?)"/i', $options, $match) or
|
| 168 |
preg_match("/mediatype\s*=\s*'(\w*?)'/i", $options, $match)) {
|
| 169 |
$mediatype = trim($match[1]);
|
| 170 |
}
|
| 171 |
else {
|
| 172 |
$mediatype = $this->mediatype;
|
| 173 |
}
|
| 174 |
|
| 175 |
if (preg_match('/charset\s*=\s*"(\.*?)"/i', $options, $match) or
|
| 176 |
preg_match("/charset\s*=\s*'(\.*?)'/i", $options, $match)) {
|
| 177 |
$charset = trim($match[1]);
|
| 178 |
}
|
| 179 |
else {
|
| 180 |
$charset = $this->charset;
|
| 181 |
}
|
| 182 |
|
| 183 |
}
|
| 184 |
|
| 185 |
|
| 186 |
function do_CoolPlayer($content, $url, $options) {
|
| 187 |
$this->init_option($url, $options,
|
| 188 |
$default_width,
|
| 189 |
$default_height,
|
| 190 |
$default_autoplay,
|
| 191 |
$default_loop,
|
| 192 |
$charset,
|
| 193 |
$download,
|
| 194 |
$mediatype);
|
| 195 |
|
| 196 |
$id = rand();
|
| 197 |
$url = preg_replace("/<br\s*\/?>/i", "\n", $url);
|
| 198 |
$url = trim(strip_tags($url, '<a>'));
|
| 199 |
$url = str_replace("\r\n", "\n", $url);
|
| 200 |
$url = str_replace("\r", "\n", $url);
|
| 201 |
$url = explode("\n", $url);
|
| 202 |
|
| 203 |
$result = "<span class=\"coolplayer_wrapper\">";
|
| 204 |
|
| 205 |
if (count($url) > 1) {
|
| 206 |
$result .= "<span class=\"coolplayer_playlist\" id=\"coolplayer_playlist_$id\" style=\"width: " . ($default_width - 2) . "px\">";
|
| 207 |
for ($i = 0; $i < count($url); $i++) {
|
| 208 |
if (preg_match('/\<a (.*?)\>(.*?)\<\/a\>/i', $url[$i], $match)) {
|
| 209 |
$info = $match[2];
|
| 210 |
}
|
| 211 |
else {
|
| 212 |
$urlparts = parse_url($url[$i]);
|
| 213 |
if (isset($urlparts['path'])) {
|
| 214 |
$info = basename($urlparts['path']);
|
| 215 |
if ($info == "") $info = $urlparts['path'];
|
| 216 |
}
|
| 217 |
else {
|
| 218 |
$info = $url[$i];
|
| 219 |
}
|
| 220 |
}
|
| 221 |
$result .= "<a href=\"javascript: coolplayer('" .
|
| 222 |
htmlspecialchars($url[$i]) .
|
| 223 |
"', '$id', '$default_width', '$default_height', " .
|
| 224 |
"'$default_autoplay', '$default_loop', '$charset', '$mediatype');\" title=\"$info\">" . ($i + 1) . "</a> ";
|
| 225 |
}
|
| 226 |
$result .= "</span>";
|
| 227 |
}
|
| 228 |
|
| 229 |
$result .= "<span id=\"coolplayer_container_$id\">";
|
| 230 |
$result .= "<script type=\"text/javascript\"><!--\nload_coolplayer('" .
|
| 231 |
addcslashes($url[0], "\0..\037\042\047\134") .
|
| 232 |
"', '$id', '$default_width', '$default_height', " .
|
| 233 |
"'$default_autoplay', '$default_loop', '$charset', '$mediatype');\n//--></script>";
|
| 234 |
$result .= "</span>";
|
| 235 |
|
| 236 |
$result .= "<span class=\"coolplayer_info\" id=\"coolplayer_info_$id\" style=\"width: " . ($default_width - 2) . "px;" .
|
| 237 |
"display: $download;\" ondblclick=\"coolplayer_input(this, " .
|
| 238 |
"'$default_width', '$default_height', '$default_autoplay', '$default_loop', '$charset', '$mediatype');\" " .
|
| 239 |
"title=\"" .
|
| 240 |
"Double click to input your media URL, and press enter to play it.".
|
| 241 |
"\">" .
|
| 242 |
"Loading..." .
|
| 243 |
"</span>";
|
| 244 |
|
| 245 |
$result .= "</span>";
|
| 246 |
|
| 247 |
$blockID = $this->getBlockID($content);
|
| 248 |
$this->blocks[$blockID] = $result;
|
| 249 |
return $blockID;
|
| 250 |
}
|
| 251 |
|
| 252 |
}
|
| 253 |
?>
|