DISQUS

DISQUS Hello! th1nk is using DISQUS, a powerful comment system, to manage its comments. Learn more.

Community Page

th1nk

Web Concepts and Analysis
Jump to original thread »
Author

How to pull statistics from Icecast with PHP

Started by Peter Oliver · 10 months ago

Update: I’ve refactored a good deal of the code here to support radio servers with multiple mount points. It now uses the SimpleXML functions in PHP5, so make sure you’ve got those enabled.
icestats.php



<?PHP


class icestats { ... Continue reading »

8 comments

  • Hey huelgueuer:

    I actually haven't tested this with multiple mount points - I just threw it together for a station I run in my personal time, so let me play with it a bit and see what I can come up with.

    As to the IP address listings, if you do a print_r($stats) on the array returned back from the get_parsed_stats() function, you'll see what fields you have available for output - listener count and such are available, but I don't see a way off-hand to get the IP addresses of listeners. It would probably entail parsing another one of the XML files on the server, but like I said, this was just a quick thing I threw together, so I'm not sure.

    I'll take a look and see what I can come up with for both issues, here, and post back.

    - John
  • hi

    it works fine, but we have 5 mountpoints in the stats
    /48
    /96
    /128
    /dump
    /live

    the listeners in the script comes from /live
    how can i change to /128 ?

    and can i list ips from

    http://......../admin/listclients.xsl?mount=/128

    mfg

    huelgueuer
  • hi john

    it works very fine. now can i read all parameter in every mount point. thanks.

    holger
  • Thanks for the code.

    I am totally new to PHP and found that it wouldn't run at first on my hosting company's server (which is running PHP 5). I found that I needed to change the line

    require_once('icestats.php');

    in the example page to

    include 'icestats.php';

    Otherwise I got a 'class declared twice' error or something like that.

    Also for those people like me who don't have a clue how to extract individual fields from the returned object, after a bit of trial and error (!) it turns out you can do it like this:

    For example, to print the current artist:

    echo $stats->artist[0];

    Basically change 'artist' above for whatever other field your are interested in..

    Thanks again for sharing your code -
    Matt
  • HI!

    I can not to manage it to work. See the error... How can I fix it?

    Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. in /home/mslino/atcbsb.com.br/icestats.php on line 16 Warning: Call-time pass-by-reference has been deprecated; If you would like to pass it by reference, modify the declaration of fsockopen(). If you would like to enable call-time pass-by-reference, you can set allow_call_time_pass_reference to true in your INI file. in /local/home/mslino/atcbsb.com.br/icestats.php on line 16 Warning: fsockopen(): unable to connect to atcbsb.com:8000 (Connection timed out) in /local/home/mslino/atcbsb.com.br/icestats.php on line 16 Warning: fputs(): supplied argument is not a valid stream resource in /local/home/mslino/atcbsb.com.br/icestats.php on line 25 Warning: fgets(): supplied argument is not a valid stream resource in /local/home/mslino/atcbsb.com.br/icestats.php on line 26 Warning: fclose(): supplied argument is not a valid stream resource in /local/home/mslino/atcbsb.com.br/icestats.php on line 27 The requested station is currently unavailable.

    Thanks!
  • I forgot to mention... I using PHP 5.2.3
  • How should I actually go with getting stats from all mountpoints? Because the demo expects that I just want to access /pirate-radio's stats. How do I get all the mountpoints so I can $r->check_station($mountpoint) them.

    Thanks
  • Oh and also, if you could help with another problem I would greatly appreciate it.
    icestats.php seems to produce an error - I believe - whenever the current song has scandinavian characters in its name (like å,ä,ö). I found out that the reason is SimpleXML can only output utf-8... possibly. I was just wondering if there was some way stop this error from happening.

    Thanks again

Add New Comment

Returning? Login