add('name', PLUGIN_SIDEBAR_SHOUTCAST_NAME);
$propbag->add('description', PLUGIN_SIDEBAR_SHOUTCAST_DESC);
$propbag->add('author', 'John Mann');
$propbag->add('requirements', array(
'serendipity' => '0.8.4',
'smarty' => '2.6.7',
'php' => '4.1.0'
));
$propbag->add('version', '1.05');
$propbag->add('configuration', array('title',
'server',
'port'));
$propbag->add('groups', array('FRONTEND_EXTERNAL_SERVICES'));
$propbag->add('stackable', true);
} // function
/**
* serendipity_plugin_shoutcast::introspect_config_item()
*
* @param $name
* @param $propbag
* @return
*/
function introspect_config_item($name, &$propbag)
{
switch ($name) {
case 'title':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_SIDEBAR_SHOUTCAST_TITLE);
$propbag->add('description', PLUGIN_SIDEBAR_SHOUTCAST_TITLE_BLAHBLAH);
break;
case 'server':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_SIDEBAR_SHOUTCAST_SERVER);
$propbag->add('description', PLUGIN_SIDEBAR_SHOUTCAST_SERVER_BLAHBLAH);
break;
case 'port':
$propbag->add('type', 'string');
$propbag->add('name', PLUGIN_SIDEBAR_SHOUTCAST_PORT);
$propbag->add('description', PLUGIN_SIDEBAR_SHOUTCAST_PORT_BLAHBLAH);
break;
default:
return false;
} // switch
return true;
} // function
/**
* serendipity_plugin_shoutcast::generate_content()
*
* @param $title
* @return
*/
function generate_content(&$title)
{
global $serendipity;
$title = $this->get_config('title');
$host = $this->get_config('server','localhost');
$port = $this->get_config('port','8000');
// Connect to server
$fp=@fsockopen($host,$port,$errno,$errstr,10);
if (!$fp) {
$content = PLUGIN_SIDEBAR_SHOUTCAST_UNABLE_TO_CONNECT;
$content = $content.'
(Error #'.$errno.': '.$errstr.' while making connection to '.$host.':'.$port.')';
} else {
// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");
// exit if connection broken
for($i=0; $i<1; $i++) {
if (feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}
// Strip useless junk from source data
$fp_data=ereg_replace("^.*