First, create an .htaccess file in the directory, and enter in the following:
Code: Select all
AddType application/x-httpd-php jpg
AddType application/x-httpd-php png
AddType application/x-httpd-php gifCode: Select all
<?php include('sig.php');?>Code: Select all
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); //Will never cache the image
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); //Set date to creation (viewing) of file
header("Cache-Control: no-store, no-cache, must-revalidate"); //Do Not Cache, Store, or otherwise view older copies of the image
header("Cache-Control: post-check=0, pre-check=0", false); //Ditto
header("Pragma: no-cache"); //Duh
Header("Content-type: image/jpeg"); //THis is to create an Image, so read it as such
// Fill in your own server information here:
$host = "radio.lethargy.ws"; //Insert your Online Radio Server IP or Host Here
$port = "8000"; //The Port the radio broadcasts on... most often, 8000 is used
$listenlink = 'http://radio.lethargy.ws:8000/listen.pls'; //make link to stream
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30); //open connection
if(!$fp) {
$success=2; //se-t if no connection
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n"); //get 7.html... this is the info page
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp); //close connection
$page = ereg_replace(".*<body>", "", $page); //extract data
$page = ereg_replace("</body>.*", ",", $page); //extract data
$numbers = explode(",",$page); //extract data
$currentlisteners=$numbers[0]; //set variable
$connected=$numbers[1]; //set variable
if($connected==1) //if DSP is connected
$wordconnected="yes"; //set variable
else //if no DSP connection
$wordconnected="no"; //set variable
$peaklisteners=$numbers[2]; //set variable
$maxlisteners=$numbers[3]; //set variable
$reportedlisteners=$numbers[4]; //set variable
$bitrate=$numbers[5]; //set variable
}
$im = ImageCreate(450,53); //300 px wide, 53px high
$background_color = ImageColorAllocateAlpha($im,255,0,255,127); //This is clear background
$text_color1 = ImageColorAllocate($im,255,0,0); //The Font Colour, to be used during image creation (see later)
$text_color2 = ImageColorAllocate($im,255,0,0); //Secondary font colour, if you want to use more than one colour
if($success!=2 && $connected==1){
$song=explode(" - ",$numbers[6]);
$string1= "Lethargy/Isyourgod Online Radio"; // Insert the first line to display... often the Radio Title
$string2= "Currently Playing: ".$song[0]; //Current Playing Artist
$string3= "Song: ".$song[1]." ".$song[2]." ".$song[3]." ".$song[4]; //Current Playing Song, and any other info about song (if title is long)
$string4= "Coming To You At ".$numbers[5]." KBPS"; //KBps The Radio Station Is Broadcasting At
}
else {
$string1= ""; //Empty String... This and the following lines are for when radio is offline
$string2= "Lethargy/Isyourgod Radio is currently"; //Second Line To Say When Offline
$string3= "Offline!."; //Ditto
$string4= ""; //Another Empty Line
}
//The following lines are the alignment and font for the lines as they are displayed... play with it for proper playing and the font you like most
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString($im,3,$px,10,$string1,$text_color1); //Easiest way to explain this is http://us3.php.net/imagestring
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString($im,2,$px,20,$string2,$text_color1); //imagestring ( resource image [use $im], int font [php built-in font], int x [Position from left side in px], int y [distance from top in px], string s, int colour)
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString($im,2,$px,30,$string3,$text_color1); //imagestring ( resource image [use $im], int font [php built-in font], int x [Position from left side in px], int y [distance from top in px], string s, int colour)
$px = (imagesx($im)-5*strlen($string4))/2;
ImageString($im,2,$px,40,$string4,$text_color1); //imagestring ( resource image [use $im], int font [php built-in font], int x [Position from left side in px], int y [distance from top in px], string s, int colour)
ImagePng($im); //Create the actual image for display
ImageDestroy($im); //Remove the image from memory
?>The nicest thing to this, is that you do NOT need admin access to the Shoutcast server to set this up... something that sets it apart from other options.
The end result:[img]http://www.isyourgod.com/NS_Sig/sig.jpg[/img]



