[Gelöst:] Titelliste auf PHP-Basis

Status
Für weitere Antworten geschlossen.

ThomasH

Benutzer
Moinsens,

für unser Kirchenradio (friesacker-laendchen.de) habe ich ein PHP-Script geschrieben, welches zwar im Netz ähnlich schon zu finden war, aber nicht so, wie ich das wollte. Also habe ich etwas geschraubt. Einige PHP-Enthusiasten werden bestimmt noch mehr draus machen können.
Ich habe es über den Wrapper auch in Joomla eingebunden. (Gugst Du hier)

Ich stelle es hier mal ein... nicht aus Nächstenliebe, sondern aus purem Egoismus: Wenn ich das mal verbummle und es wieder benötige, hoffe ich es hier wieder zu finden... :D

Ist für Shoutcast 2

Ich habe in der config 20 Titel als Historie angegeben. Und hier kommt der Kot... äh- Code:

Code:
<?php
$host = "localhost";
$port = "8000"; //hier Deine Portnummer eintragen
$pass = "meinpasswort"; // hier Dein Zugangspasswort eintragen
$scsuccs = 0;
$page = "";

date_default_timezone_set('Europe/Berlin');

$scfp = fsockopen($host, $port, &$errno, &$errstr, 30);
if(!$scfp) {
  $scsuccs=1;
  echo  $errno.$errstr;
  }

if($scsuccs!=1){

  fputs($scfp,"GET /admin.cgi?pass=".$pass."&sid=1&mode=viewxml HTTP/1.0\r\nUser-Agent: SHOUTcast Song Status (Mozilla Compatible)\r\n\r\n");
  while(!feof($scfp)) {
  $page .= fgets($scfp, 1000);
  }

  $loop = array("STREAMSTATUS", "BITRATE", "SERVERTITLE", "CURRENTLISTENERS");
  $y=0;
  while(isset($loop[$y])!=''){
  $pageed = ereg_replace(".*<$loop[$y]>", "", $page);
  $scphp = strtolower($loop[$y]);
  $$scphp = ereg_replace("</$loop[$y]>.*", "", $pageed);
  if($loop[$y]==isset($_POST["SERVERGENRE"]) || $loop[$y]==isset($_POST["SERVERTITLE"]) || $loop[$y]==isset($_POST["SONGTITLE"]) || $loop[$y]==isset($_POST["SERVERTITLE"]))
  $$scphp = urldecode($$scphp);
  $y++;
  }

  $pageed = ereg_replace(".*<SONGHISTORY>", "", $page);
  $pageed = ereg_replace("<SONGHISTORY>.*", "", $pageed);
  $songatime = explode("<SONG>", $pageed);
  $r=1;
  while(isset($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++;
  }

  fclose($scfp);
}


if($streamstatus == "1"){
echo'
  <html>
  <head>
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <META HTTP-EQUIV="REFRESH" CONTENT="30;URL=playlist.php">
  <link rel=stylesheet href="" type="text/css">
  <title>'.isset($scdef).'</title>
  </head>

  <body text="arial,helvetica" bgcolor="">
  <font face="arial,helvetica" color="#000000" size="2">
  <p><strong>Servername: </strong>'.$servertitle.'<br />
  <strong>Anzahl H&ouml;rer: </strong>'.$currentlisteners.' / 50<br />
  <br data-mce-bogus="1" /></p>
  <p><strong>Aktuell gespieltes Lied seit '.date('H:i:s',$playedat[0]).' : </strong><span style="color:red">'.$song[0].'</span></p>

  <p><strong>Zuletzt gespielte Lieder: </strong></p>

  <table style="font-size:90%;font-family:arial,helvetica;color:black" border="0">
  <tbody>
  <tr>
  <td><b>1.</b></td>
  <td>'.date('H:i:s',$playedat[1])." - ".$song[1].'</td>
  </tr>
  <tr>
  <td><b>2.</b></td>
  <td>'.date('H:i:s',$playedat[2])." - ".$song[2].'</td>
  </tr>
  <tr>
  <td><b>3.</b></td>
  <td>'.date('H:i:s',$playedat[3])." - ".$song[3].'</td>
  </tr>
  <tr>
  <td><b>4.</b></td>
  <td>'.date('H:i:s',$playedat[4])." - ".$song[4].'</td>
  </tr>
  <tr>
  <td><b>5.</b></td>
  <td>'.date('H:i:s',$playedat[5])." - ".$song[5].'</td>
  </tr>
  <tr>
  <td><b>6.</b></td>
  <td>'.date('H:i:s',$playedat[6])." - ".$song[6].'</td>
  </tr>
  <tr>
  <td><b>7.</b></td>
  <td>'.date('H:i:s',$playedat[7])." - ".$song[7].'</td>
  </tr>
  <tr>
  <td><b>8.</b></td>
  <td>'.date('H:i:s',$playedat[8])." - ".$song[8].'</td>
  </tr>
  <tr>
  <td><b>9.</b></td>
  <td>'.date('H:i:s',$playedat[9])." - ".$song[9].'</td>
  </tr>
  <tr>
  <td><b>10.</b></td>
  <td>'.date('H:i:s',$playedat[10])." - ".$song[10].'</td>
  </tr>
  <tr>
  <td><b>11.</b></td>
  <td>'.date('H:i:s',$playedat[11])." - ".$song[11].'</td>
  </tr>
  <tr>
  <td><b>12.</b></td>
  <td>'.date('H:i:s',$playedat[12])." - ".$song[12].'</td>
  </tr>
  <tr>
  <td><b>13.</b></td>
  <td>'.date('H:i:s',$playedat[13])." - ".$song[13].'</td>
  </tr>
  <tr>
  <td><b>14.</b></td>
  <td>'.date('H:i:s',$playedat[14])." - ".$song[14].'</td>
  </tr>
  <tr>
  <td><b>15.</b></td>
  <td>'.date('H:i:s',$playedat[15])." - ".$song[15].'</td>
  </tr>
  <tr>
  <td><b>16.</b></td>
  <td>'.date('H:i:s',$playedat[16])." - ".$song[16].'</td>
  </tr>
  <tr>
  <td><b>17.</b></td>
  <td>'.date('H:i:s',$playedat[17])." - ".$song[17].'</td>
  </tr>
  <tr>
  <td><b>18.</b></td>
  <td>'.date('H:i:s',$playedat[18])." - ".$song[18].'</td>
  </tr>
  <tr>
  <td><b>19.</b></td>
  <td>'.date('H:i:s',$playedat[19])." - ".$song[19].'</td>
  </tr>
  </tbody>
  </table>
  </p></p>
</body>
</html>';
}

if($streamstatus == "0")
{
echo'
  <html>
  <head>
  <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
  <meta name="ProgId" content="FrontPage.Editor.document">
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
  <META HTTP-EQUIV="REFRESH" CONTENT="30;URL=radio_stats.php">
  <link rel=stylesheet href="" type="text/css">
  <title>Radio Server ist Offline</title>
  </head>

  <body text="" bgcolor="">
  Server Offline!
  </body>
  </html>';
}
?>

Freundliche Grütze...

Thomas_H
 
Zuletzt bearbeitet:
Versuchs mal hier mit - das ist wesentlich kürzer.

Code:
<?php


   /* Anpassen */
     $streamURL   = '';
     $port     = '';
     $shoutPW   = '';

     $stats = getShoutStat($streamURL,$port,$shoutPW );

     print '<table border=1>';
     foreach($stats as $SONG) {
       print '<tr><td>&nbsp;'. date('H:i:s',(int)$SONG->PLAYEDAT) .'&nbsp;</td><td>';
       print utf8_decode($SONG->TITLE) ;
       print '</td></tr>';
     }
     print '</table>';
  


   function getShoutStat($host,$port,$password) {
  
     $ch = curl_init ("http://$host:$port/admin.cgi?pass=$password&mode=viewxml");
     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
     $xml = curl_exec($ch);
     $xml_out = str_replace("\n", "", strstr($xml, '<SHOUTCASTSERVER>'));
     curl_close();
     $xml = simplexml_load_string($xml_out);
     return $xml->SONGHISTORY->SONG;
   }


?>
 
Zuletzt bearbeitet:
Status
Für weitere Antworten geschlossen.
Zurück
Oben