hi, i am very new, and trying to understand how all this works. i am on the staff of an internet radio station, and i want to make a dynamic image to display the stats of the radio station.
the station administrator made a file very similar to the "7.html" that is used with the original script i used. i want to modify it to use the information from the new location rather than 7.html.
<?php
// thanks to Trek and BWP for helping me out with this
// Edit the next two lines with your server information
$host = "209.142.3.9";
$port = "8100";
// Connect to server
$fp=@fsockopen($host,$port,&$errno,&$errstr,10);
if (!$fp) {
echo "Unable to connect to server";
} else {
// Get data from server
fputs($fp,"GET /7 HTTP/1.1\nUser-Agent:Mozilla\n\n");
// exit if connection broken
for($i=0; $i<1; $i++) {
if(feof($fp)) break;
$fp_data=fread($fp,31337);
usleep(500000);
}
// Strip useless junk from source data
$fp_data=ereg_replace("^.*<body>","",$fp_data);
$fp_data=ereg_replace("</body>.*","",$fp_data);
// Place values from source into variable names
list($current,$status,$peak,$max,$reported,$bit,$song) = explode(",", $fp_data, 7);
header ("Content-type: image/png");
$img_handle = ImageCreate (500, 15) or die ("Cannot Create image");
ImageInterlace($img_handle, 1);
$trans = ImageColorAllocate($img_handle, 1, 1, 1);
ImageColorTransparent($img_handle, $trans);
$txt_color = ImageColorAllocate ($img_handle, 0, 0, 0);
ImageString ($img_handle, 2, 1, 1, "Now Playing @ [url]www.RTDS.org:[/url] $song", $txt_color);
ImagePng ($img_handle);
if ($status == "1") {
// To use any of the outputs below just uncomment (remove the double forward slashes) that line.
// Below is an example of all data available in the 7.html file made by the Shoutcast server
// **ON BY DEFAULT - COMMENT OUT (put to forwards slashes in front of it) TO HIDE
echo "<html>\n<head>\n<title></title>\n</head>\n<body>\nCurrent Listeners: $current<br>\nServer Status: $status<br>\nListener Peak: $peak<br>\nMaximum Listener: $max<br>\nReported Listeners: $reported<br>\nBroadcast Bitrate: $bit<br>\nCurrent Song: $song\n</body>\n</html>";
// Below is a basic one line value of the current song, perfect for front pages of sites
// echo "<html>\n<head>\n<title></title>\n</head>\n<body>\nCurrently Playing: <a href=\"http://$host:$port/listen.pls\">$song</a>\r\n</body>\n</html>";
} else {
echo "The radio station is currently down";
} }
?>
that is the original code, using 7.html directly from the shoutcast server. what id like to do is used the data from the file named "publicdata.txt" located at http://rtds.org/publicdata.txt and insert that data into the image.
when the administrator was talking to me he said that the data may not always be in that order, so he gave each value a name before the actual value. he said "if you code it right, it won't matter what line it's on. just read a line, check the line and see if it has "Title=" in it. if it does, set the varible title with that value. That way you can be sure it'll always work" but i have no idea what it means.
i would greatly appreciate help with this.
thanks,
fury