Witam.
W kwestii php jestem kompletnym laikiem, a potrzebuję przerobić pewien skrypt pod siebie. O pomoc prosiłem już na oficjalnym forum supportu WBB (woltlab burning board) ale tam mi nie pomogli, tak więc zwracam się do Was z nadzieją że mnie nie zostawicie w potrzebie. Jeśli będzie taka potrzeba jestem w stanie sypnąć groszem za okazaną mi pomoc (przelew). A teraz do rzeczy.
<?php
require_once(WCF_DIR.'lib/data/message/bbcode/BBCodeParser.class.php');
require_once(WCF_DIR.'lib/data/message/bbcode/BBCode.class.php');
/**
* BBCode for [soundcloud] Tag
* examples:
* - [soundcloud]http://soundcloud.com/zedsdead/mini-mix-for-bbc-radio-1[/soundcloud]
* - [soundcloud="width=100%,height=81,show_comments=true,auto_play=false,color=ff7700"]http://soundcloud.com/zedsdead/mini-mix-for-bbc-radio-1[/soundcloud]
*
* @author Torben Brodt
* @package com.woltlab.wcf.soundcloud
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-3.0.html>
*/
class SoundcloudBBCode implements BBCode {
/**
* allowed attributes
* @var array
*/
'width' => '\d+%?',
'height' => '\d+',
'show_comments' => '(true|false)',
'auto_play' => '(false)', // no sense in thread page
'color' => '[abcdef0-9]{3,6}',
);
/**
* @return boolean
*/
protected function isValidURL($url) {
if(!isset($row['host'])) { return false;
}
return preg_match('/^(.+\.)?(((staging|sandbox)-)?soundcloud\.com$)/', $row['host']); }
/**
* @see BBCode::getParsedTag()
*/
public function getParsedTag($openingTag, $content, $closingTag, BBCodeParser $parser) {
$url = $content;
if(!$this->isValidURL($url)) {
return 'SoundCloud: invalid url';
}
'width' => '100%',
'height' => '81',
'show_comments' => 'true',
'auto_play' => 'false',
'color' => 'ff7700',
);
if(isset($openingTag['attributes']) && count($openingTag['attributes'])) { foreach($openingTag['attributes'] as $val) {
continue;
}
$key = ltrim($val[0], '"'); $val = rtrim($val[1], '"'); if(!isset(self::$allowed[$key]) || !preg_match('/^'.self::$allowed[$key].'$/', $val)) { continue;
}
$attributes[$key] = $val;
}
}
$url .= '?'.http_build_query($attributes);
if ($parser->getOutputType() == 'text/html') {
return '<object height="'.$attributes['height'].'" width="'.$attributes['width'].'"> <param name="movie" value="http://player.soundcloud.com/player.swf?url='.$encodedurl.'"></param> <param name="allowscriptaccess" value="always"></param> <embed allowscriptaccess="always" height="'.$attributes['height'].'" src="http://player.soundcloud.com/player.swf?url='.$encodedurl.'" type="application/x-shockwave-flash" width="'.$attributes['width'].'"></embed> </object>';
}
else if ($parser->getOutputType() == 'text/plain') {
return $url;
}
}
}
?>
To skrypt bbcode który ma za zadanie dodać odtwarzacz soundcloud do tematu (po wklejeniu do tematu linku piosenki w serwisie soundcloud.com)
Chcę tak przerobić ten skrypt by obsługiwał linki z hulkshare.com
Link do odtwarzacza hulkshare (wystarczy na końcu dodać kod utworu np. c42sofv99d7u)
http://www.hulkshare.com/embed_mp3.php?fn=Dodatkowe info: wysokość playera - 49px | trzeba dodać dwa atrybuty 'bg' => '000000', oraz 'fg' => '71C90C',
Za okazaną pomoc serdecznie dziękuję.
Ten post edytował Nocturnal 17.02.2012, 16:12:13