![]() |
#1 | |
Senior Member
Join Date: Nov 2010
Posts: 152
|
php sc_serv 2 status class
fully works and returns array of standard stats from sc_serv 2
use this function anywhere in while() { etc /** * SHOUTCAST - NULL NUKE * get shoutcast server info * $in_host = 127.0.0.1 * $in_port = 8000 * $in_sid = 1 [ DNAS stream id 1-7] * $in_timeout = 1sec timeout to get stats */ function shoutcast($in_host, $in_port = 8000, $in_sid = 1, $in_timeout = 1) { global $phpEx; // /* // RETURN/s // $array['status'] // $array['listener'] // $array['maxlisteners'] // $array['peak'] // $array['title'] // $array['content_type'] // $array['genre'] // $array['url'] // $array['track'] // */ include_once "core_ShoutcastInfo.php"; $_SERVER['shoutcast'] = new ShoutcastInfo( '', '', '', ''); return $_SERVER['shoutcast'] -> ShoutcastInfo($in_host, $in_port, $in_sid, $in_timeout); } save the following code as core_ShoutcastInfo.php Quote:
|
|
![]() |
![]() |
![]() |
#2 |
Join Date: Sep 2003
Posts: 27,873
|
right, so you've posted a script which appears to scrape the stream summary pages instead of going the far simpler (and supported options) /stats or other admin.cgi?sid=#&mode=viewxml&page=# to get that information.
/me shakes head in dismay. -daz |
![]() |
![]() |
![]() |
#3 | ||
Senior Member
Join Date: Nov 2010
Posts: 152
|
nope... you add the code to your website.. sc_serv is on a remote box...
on your web page for your site.. $scinfo = shoutcast( "server_ip", "8000", "streamid"); which will return an array, so then anywhere on your website you : if ($scinfo ['status']) { echo "status : <font color=\"lime\">Online</font><br />"; echo "Current Track : ". $scinfo ['track'] ."<br />"; echo "Listers : ". $scinfo ['listener'] ."/".$shoutcast['maxlisteners']."<br />"; echo "Genre : ". $scinfo ['genre'] ."<br />"; } else { echo "status : <font color=\"red\">Offline</font><br />"; } ->cannot find the edit button, original class code has a table cell glitch and will destroy the layout of any page iit is used on.. so in core_ShoutcastInfo.php you need to replace : Quote:
Quote:
|
||
![]() |
![]() |
![]() |
#4 |
Join Date: Sep 2003
Posts: 27,873
|
you're not reading what i said - the script is scraping the pages (which can and has changed between versions of the v2 DNAS i.e. it could break easily) rather than using the api pages (which are public facing) for getting the same information in a clean and proper manner.
if you prefer to do it in a hackish way then so be it, but recommending it to other people is not a good thing to do. -daz |
![]() |
![]() |
![]() |
#5 |
Senior Member
Join Date: Nov 2010
Posts: 152
|
its the way all sites have always used, you cannot access admin panel from a remote site and would be worthless. the class is to display the status of the server to the public embedded anywhere on your webpage, instead of having to access the http://server/index.html backend of sc_serv
|
![]() |
![]() |
![]() |
#6 |
Join Date: Sep 2003
Posts: 27,873
|
/me bangs head on desk
the whole point of the v2 tools is to do things better from the start which the v1 DNAS didn't do (or eventually allowed in later versions). you've contradicted yourself as you're saying not having to access the http://server/index.html backend even though that is what the script you've posted is doing i.e. scraping the information from the public pages. as i'm trying to tell you, there is no need to do that and (as you've not read the documentation), use http://server/stats?sid=# directly to get that information i.e. via another public page just like http://server/index.html also is. just because that's how it's been done before doesn't mean doing it the same for the new tools is the correct way (which it isn't) but i get the feeling you're going to do whatever you want, so i'm going to leave you to it as clearly you know more than me. -daz |
![]() |
![]() |
![]() |
#7 |
Senior Member
Join Date: Nov 2010
Posts: 152
|
![]() |
![]() |
![]() |
![]() |
#8 |
Senior Member
Join Date: Nov 2010
Posts: 152
|
xml version of the above, its all kind of the same. but returns the xml from stats?sid# as an array
/** * SHOUTCAST - NULL NUKE * get shoutcast server info * $in_host = 127.0.0.1 * $in_port = 8000 * $in_sid = 1 [ DNAS stream id 1-7] * $in_timeout = 1sec timeout to get stats */ function shoutcast($in_host, $in_port = 8000, $in_sid = 1) { global $phpEx; // /* // RETURN/s // $array['CURRENTLISTENERS'] // $array['STREAMSTATUS'] // $array['PEAKLISTENERS'] // $array['MAXLISTENERS'] // $array['UNIQUELISTENERS'] // $array['AVERAGETIME'] // $array['SERVERGENRE'] // $array['SERVERURL'] // $array['SERVERTITLE'] // $array['SONGTITLE'] // $array['NEXTTITLE'] // $array['BITRATE'] // $array['VERSION'] // $array['CONTENT'] // */ include_once "core_Get_Functions_shoutcast2info.php"; $feed = new sc2info; $feed->sc2info(); return $feed->getsc2info( $in_host, $in_port, $in_sid ); } save the following as core_Get_Functions_shoutcast2info.php and replace _DP_CACHE_PAR with the tmp or cache dir you use to store junk files Last edited by p0rt; 21st September 2011 at 02:55. |
![]() |
![]() |
![]() |
#9 | |
Senior Member
Join Date: Nov 2010
Posts: 152
|
fixes cache not working, and long wait time while page loads if sc_serv is not running
Quote:
|
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|