hi all
i want to have a web banner that i can ad to forum signatures and it displays information about my shoutcast stream!
i have created a sig folder and put a .htaccess file with the following code
i then have a php script in a .png file... infact i have 2
the first 1 works in the forum but doesnt contain a varible for if the streams offline! If the stream is online then great shows up title and stream info etc but if the streams offline i just get the banner with the radio name text!
the second one is how i want the banner to look and function!
it shows the stream is offline etc and shows wen its online with listener count etc! BUT this script does not work in the forum! it works great in a web browser = http://www.djhicks.co.uk/sig/testbanner.png
i have been told that the second script doesnt work because it contains and uses html!
can some please help me i have tried alsorts but i have very lil or no php knowledge and after tryin for ages can not get this to work!
basically i need the html written in php.... from looking at the workin 1st script i need to use strings etc, but i have tried alsots and its just not working!
N.B the banner is white so may just look like an image to the right of the text but its not!
the working script is here
http://www.djhicks.co.uk/sig/oldbanner.png
the second banner works in a web broswer but no the forum but is how i want the end results to be!
http://www.djhicks.co.uk/sig/testbanner.png
Again Please help - this is drivin me nuts!
Thank you all!
DJHicks
i want to have a web banner that i can ad to forum signatures and it displays information about my shoutcast stream!
i have created a sig folder and put a .htaccess file with the following code
| Code: |
| <FilesMatch "^.*\.png">
SetHandler application/x-httpd-php </FilesMatch> |
i then have a php script in a .png file... infact i have 2
the first 1 works in the forum but doesnt contain a varible for if the streams offline! If the stream is online then great shows up title and stream info etc but if the streams offline i just get the banner with the radio name text!
the second one is how i want the banner to look and function!
it shows the stream is offline etc and shows wen its online with listener count etc! BUT this script does not work in the forum! it works great in a web browser = http://www.djhicks.co.uk/sig/testbanner.png
i have been told that the second script doesnt work because it contains and uses html!
can some please help me i have tried alsorts but i have very lil or no php knowledge and after tryin for ages can not get this to work!
basically i need the html written in php.... from looking at the workin 1st script i need to use strings etc, but i have tried alsots and its just not working!
N.B the banner is white so may just look like an image to the right of the text but its not!
the working script is here
http://www.djhicks.co.uk/sig/oldbanner.png
| Code: |
| <?php
$announce_colour = $_REQUEST['announce']; $song_colour = $_REQUEST['song']; if ( !$announce_colour ) { $announce_colour="0,0,0"; } if ( !$song_colour ) { $song_colour="0,0,0"; } $announce_colour=check_colour_specific( $announce_colour ); $song_colour=check_colour_specific( $song_colour ); $ip="72.29.82.28"; $port="8006"; $url="http://www.djhicks.co.uk/banner.jpg"; $sp=@fsockopen($ip,$port,&$errno,&$errstr,10); if ($sp) { set_socket_blocking($sp,false); fputs($sp,"GET /index.html HTTP/1.1\nUser-Agent:Mozilla\n\n"); for($i=0; $i<30; $i++) { if(feof($sp)) break; // exit if connection broken $sp_data.=fread($sp,1024); usleep(500000); } $lines=split("/\n",$sp_data); foreach ($lines as $line) { if ( preg_match("/SHOUTcast/",$line ) ) { $cast_found=1; } } } else { print "Not found\n"; exit(0); } if ($cast_found) { $lines =split("<tr>",$sp_data); foreach ($lines as $line) { if ( preg_match("/Stream Title:/",$line ) ) { $data_block['stream_title']= retrieve_data ( "Stream Title:", $line ,"<b>" ,1, 1, 0, 1, "</b>"); } if ( preg_match("/Current Song:/",$line ) ) { $data_block['current_song']= retrieve_data ( "Current Song:", $line ,"<b>" ,1, 1, 0 ,1 ,"</b>"); } } } # if you want to use a jpeg do $im = imagecreatefromjpeg ($url); /* Attempt to open */ # if you want to use a png do #$im = imagecreatefrompng ($url); /* Attempt to open */ # if you want to use a gif do #$im = @imagecreatefromgif ($url); /* Attempt to open */ if (!$im) { print "no image\n"; exit(0); } Header("Content-type: image/png"); $colour_array = split (",",$announce_colour ); $text_colour1 = ImageColorAllocate($im,$colour_array[0],$colour_array[1],$colour_array[2]); $colour_array = split (",",$song_colour ); $text_colour2 = ImageColorAllocate($im,$colour_array[0],$colour_array[1],$colour_array[2]); $string1= "Ganja Beats Net Radio"; $string3= $data_block['stream_title']; # this is image pointer,1,xpos, ypos, string, colour ImageString($im,2,50,10,$string1,$text_colour1); ImageString($im,1,50,35,$string2,$text_colour2); ImageString($im,2,50,50,$string3,$text_colour2); ImageGif($im); ImageDestroy($im); exit(0); function retrieve_data ( $match, $string, $split, $pos1, $pos2, $white, $chop, $chopper ) { $array = split($match,$string); $array = split ($split,$array[$pos1]); if ( $white ) { $array[$pos2] = ereg_replace(" ", "", $array[$pos2]); } if ( $chop ) { $array = split ($chopper, $array[$pos2] ); } else { $array[0]=$array[$pos2]; } $version = $array[0]; return $version; } function check_colour_specific ( $colour_string ) { $colour_array= split (",",$colour_string ); $colour_count =0; foreach ( $colour_array as $colour ) { if ( $colour<0 || $colour>255 ) { $colour_array[$colour_count]="0"; } $colour_count++; } if ( $colour_count<2 ) { return "0,0,0"; } return ( $colour_array[0].",".$colour_array[1].",".$colour_array[2] ); } ?> |
the second banner works in a web broswer but no the forum but is how i want the end results to be!
http://www.djhicks.co.uk/sig/testbanner.png
| Code: |
| <?php
include('test/broadcast_config.php'); $scfp = fsockopen("$scip", $scport, &$errno, &$errstr, 30); if(!$scfp) { $scsuccs=1; echo''.$scdef.' is Offline'; } if($scsuccs!=1){ fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n"); while(!feof($scfp)) { $page .= fgets($scfp, 1000); } ###################################################################################################################### /////////////////////////part 1 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ //define xml elements $loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS", "MAXLISTENERS", "BITRATE"); $y=0; while($loop[$y]!=''){ $pageed = ereg_replace(".*<$loop[$y]>", "", $page); $scphp = strtolower($loop[$y]); $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed); if($loop[$y]==SERVERGENRE || $loop[$y]==SERVERTITLE || $loop[$y]==SONGTITLE || $loop[$y]==SERVERTITLE) $$scphp = urldecode($$scphp); // uncomment the next line to see all variables //echo'$'.$scphp.' = '.$$scphp.'<br>'; $y++; } //end intro xml elements ###################################################################################################################### ###################################################################################################################### /////////////////////////part 2\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ //get song info and history $pageed = ereg_replace(".*<SONGHISTORY>", "", $page); $pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed); $songatime = explode("<SONG>", $pageed); $r=1; while($songatime[$r]!=""){ $t=$r-1; $playedat[$t] = ereg_replace(".*<PLAYEDAT>", "", $songatime[$r]); $playedat[$t] = ereg_replace("</PLAYEDAT>.*", "", $playedat[$t]); $song[$t] = ereg_replace(".*<TITLE>", "", $songatime[$r]); $song[$t] = ereg_replace("</TITLE>.*", "", $song[$t]); $song[$t] = urldecode($song[$t]); $dj[$t] = ereg_replace(".*<SERVERTITLE>", "", $page); $dj[$t] = ereg_replace("</SERVERTITLE>.*", "", $pageed); $r++; } //end song info fclose($scfp); } //display stats if($streamstatus == "1"){ //you may edit the html below, make sure to keep variable intact echo"<html>" . "" . "<head>" . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />" . "<title>Untitled Document</title>" . "<style type=\"text/css\">" . "<!--" . ".style1 {color: #006600}" . "-->" . "</style>" . "</head>" . "" . "<body>" . "<table width=\"465\" height=\"70\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" . " <tr>" . " <td valign=\"top\" background=\"test/banner.jpg\"><strong>Ganja Beats Net Radio - <a href=\"www.ganjabeats.co.uk\" target=\"_blank\" class=\"style1\">www.ganjabeats.co.uk </a></strong><br />" . " <strong>Server Status : <img src=\"test/online.jpg\" width=\"60\" height=\"15\" /><br />" . " <b>Listeners:</b> '.$currentlisteners.' / '.$maxlisteners.'</strong></td>" . " </tr>" . "</table>" . "</body>" . "</html>" .""; } if($streamstatus == "0") { //you may edit the html below, make sure to keep variable intact echo"<html>" . "" . "<head>" . "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />" . "<title>Untitled Document</title>" . "<style type=\"text/css\">" . "<!--" . ".style1 {color: #006600}" . "-->" . "</style>" . "</head>" . "" . "<body>" . "<table width=\"465\" height=\"70\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">" . " <tr>" . " <td valign=\"top\" background=\"test/banner.jpg\"><strong>Ganja Beats Net Radio - <a href=\"http://www.ganjabeats.co.uk\" target=\"_blank\" class=\"style1\">www.ganjabeats.co.uk </a></strong><br />" . " <strong>Server Status : <img src=\"test/offline.jpg\" width=\"60\" height=\"15\" /><br />" . " Click <a href=\"http://www.ganjabeats.co.uk/timetable.php\" target=\"_blank\" class=\"style1\">here</a> to view the timetable. </strong></td>" . " </tr>" . "</table>" . "</body>" . "</html>" .""; } ?> |
Again Please help - this is drivin me nuts!
Thank you all!
DJHicks
