PHP: Icecast Now Playing Script is Not Working

前端 未结 2 832
有刺的猬
有刺的猬 2021-01-15 19:04

I am attempting to use the Icecast Now Playing PHP script from: https://code.google.com/p/icecast-now-playing-script/

I have uploaded all the files to my web server

相关标签:
2条回答
  • 2021-01-15 19:46

    My guess is that your server is not allowing HTTP stream wrappers.

    In the icecast.php script the function getStreamInf() is being called and at the top it attempts to open the stream with:

    $str = @file_get_contents(SERVER.'/status.xsl?mount='.MOUNT);
    

    To debug this, do 2 things. First remove the @ which suppresses error output on the file_get_contents call. Then add temporary debugging output:

    $str = file_get_contents(SERVER.'/status.xsl?mount='.MOUNT);
    var_dump($str);
    

    If you get a security related error, rather than data back, then you need to look at your php.ini file for the server.

    allow_url_fopen = on
    

    Needs to be set for file_get_contents to be able to open a url, as this script attempts to do. You have to be able to change that setting on your server, if it is set to off, and you have to be able to restart your web server for those changes to take effect.

    0 讨论(0)
  • 2021-01-15 19:56

    Please note that I would strongly advice not using the "Icecast Now Playing Script"!
    tl;dr: It parses the HTML, this is horrible.

    1. The script uses regex to parse the Icecast status.xsl page, never ever should Regex be used to parse HTML, if you want to know why, read "Parsing Html The Cthulhu Way". It is very likely that it can break easily.

    2. The script parses the Icecast status.xsl page. This should never ever be done, since this page is likely to change, like it did with the latest Icecast Version 2.4. So please, please, please do not parse the HTML page!

    What to do instead?

    If this is your Icecast Server, you can easily write a custom xsl, to generate custom XML or JSON that contains the information that you need. (more info here)

    An example for this is the xml2json.xslt.

    0 讨论(0)
提交回复
热议问题