Just add it to the src/commands folder, rehash and type /np
You will need the ip:port of the shoutcast server you want to touch.
/src/commands/np.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_np extends pfcCommand
{
var $usage = "/np";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$timeout = "5"; // Number of seconds before connecton times out - a higher value will slow the page down if any servers are offline
$ip = "your.fm"; // ip or host name of the shoutcast server
$port = "8000"; //port of the shoutcast stream
$fp = @fsockopen($ip,$port,$errno,$errstr,$timeout);
if (!$fp)
{
$listeners = "0";
$msg = "<span class="red">ERROR [Connection refused / Server down]</span>";
$error = "1";
}
else
{
fputs($fp, "GET /7.html HTTP/1.0rnUser-Agent: Mozillarnrn");
while (!feof($fp))
{
$info = fgets($fp);
}
$info = str_replace('<HTML><meta http-equiv="Pragma" content="no-cache"></head><body>', "", $info);
$info = str_replace('</body></html>', "", $info);
$stats = explode(',', $info);
$title = $stats[6];
}
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc('Now Playing: %s', $title);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}
}
?>
Next, add this line of code to the end of the main.php for the languages you are using, they are located in the /i18n/ folder
example: /i18n/en_US/main.php (line 405)
- Code: Select all
//line 51 in np.class.php
$GLOBALS["i18n"]["Now Playing: %s"] = "Now Playing: %s";
enjoy!