We would appreciate any comments or improvements you may have conserning this script. Please email us at scripts@thetestpattern.com. If you decide to use this script on your site, we would appreciate a note.
This simple script can be called to return the status of a Shoutcast or compatible streaming .mp3 server.
First include the status file in whatever php page you'd like to use it with:
include "/path/to/status.php";
The function you'll use is server_status(ip, port) where ip is a string containing the ip address of the stream and port is a string containing its port. The function returns a number indicating status and also sets a variable, $online, to a string communicating status.
Here's an example of how we use the function and $online variable.
server_status("66.28.48.73",10480);
echo "The broadband server is: $online";
server_status("66.28.48.80",10400);
echo "The modem server is: $online";
The status is returned in two ways: through a return code as a part of the function and through the $online variable.
The function returns '1' if the stream is online, '0' if the stream is offline with an ICY 404 message, and a '2' if the stream could not be contacted at all. A '0' usually means that the stream is available but no data is being sent to the stream to broadcast.
If you want a simplified text display of your server's status, call the function and use the $online variable where you'd like the status message to appear.
View php source for this script
Download this script in a .zip archive
Return to the scripts home page.