Thema: PHP => PNG
Einzelnen Beitrag anzeigen
  #36  
Alt 28.03.2005, 11:55:57
Benutzerbild von Bogi
Bogi Bogi ist offline
Anfänger
 
Registriert seit: Aug 2004
Ort: Abtenau - Austria
Alter: 37
Beiträge: 85
Bogi eine Nachricht über ICQ schicken
AW: PHP => PNG

PHP-Code:
<?php
Header
("Content-Type: image/jpeg");
// Configuration
$scdef "";             // Name of Stream if Server is down 
$scip "";             // IP or URL of your Shoutcast Server 
$scport "";          // Shoutcast Server Port
$scpass "";          // Shoutcast Server Password (means Admin Password) 
// End Configuration

// Connection    
$scfp fsockopen($scip$scport$errno$errstr30);
if(!
$scfp) { 
  
$scsuccs=1
echo
''.$scdef.' is Offline'

if(
$scsuccs!=1){ 
fputs($scfp,"GET /admin.cgi?pass=$scpass&mode=viewxml HTTP/1.0rnUser-Agent: SHOUTcast Song Status (Mozilla Compatible)rnrn"); 
while(!
feof($scfp)) { 
  
$page .= fgets($scfp1000); 

// End Connection

// Connection für Online/Offline-Anzeige
$fp = @fsockopen($scip$scport$errno$errstr30);
    
fputs($fp,"GET /7.html HTTP/1.0rnUser-Agent: XML Getter (Mozilla Compatible)rnrn");
        while(!
feof($fp))
        {
            
$datei .= fgets($fp1000);
        }
    
fclose($fp);


$datei ereg_replace(".*<body>"""$datei);
$datei ereg_replace("</body>.*"","$datei);
$eintraege explode(",",$datei);
// Connection ende

//read xml elements 
$loop = array("STREAMSTATUS""BITRATE""SERVERTITLE""CURRENTLISTENERS"); 
$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); 

  
$y++; 

// End read xml elements 


// 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); 




// Banner Configuration 
 
  // first textline


$image "banner.png"// name of the banner-picture

$img imagecreatefrompng($image);

$bg ImageColorAllocate($img000);

$white ImageColorAllocate($img255255255); // config your first textcolor (this one is white)
$black ImageColorAllocate($img000);  // config your second textcolor (this one is black)
$green ImageColorAllocate($img02550);
$red ImageColorAllocate($img2551530);
// if you need more or other colors do it like the way above

// Online oder Offline abfrage
if($eintraege[1]==1)
{
    
$status "Radio ist ON AIR";
    
$color "green";
    
$sendung=$servertitle// the name of the show
    
$titel=$song[0]; // titel of the song now playing

}

else
{
    
$status "Radio ist offline";
    
$color "red";
    
$sendung=""// Zusatztext
    
$titel=""// Zusatztext
}
// Online oder Offline abfrage ende

ImageString($img4206$status, $$color); // display, position and color of the first textline
ImageString($img22023$sendung$white); // display, position and color the name of the show
ImageString($img22038$titel$white); // display, position and color of the songtitel
// if you need more textlines do it like the way above

ImageJPEG($img);
ImageDestroy($img)
?>
die php dann in .jpg umbenennen und in den ordner noch eine .htaccess speichern mit dem inhalt:
Code:
AddType application/x-httpd-php .jpg
tja, und natürlich eine banner.png nicht vergessen (ist dann der hintergrund)

so siehts bei mir aus

mfg, bogi

p.s.: Original-Code by bigod ... edit by me ...

Geändert von Bogi (28.03.2005 um 12:03:33 Uhr)
Mit Zitat antworten