PHP radio playlist

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
DJ_CARO
Forum Newbie
Posts: 2
Joined: Sun Jun 13, 2010 1:19 pm

PHP radio playlist

Post by DJ_CARO »

Hi I have a little script playlista radio and now like to add that instead of 1, 2, 3, etc. hours was shown as is the http://www.miastomuzyki.pl/play.html?id=6
I tried to add

Code: Select all

   1.
      <?php
      $czas=date("G:i");
      echo "$czas";
      ?>
but it did not help
also I want to add what is gonna play in a minute same as it is on the website above
Ok so my PHP Script is

Code: Select all

<?php

//Configuration
$radioname = "RADIO NAMEEEE";
// 
$ip = "s2.myip.pl"; // IP OR URL OF SERVER (DO NOT INCLUDE HTTP:// OR PORT)
$port = "444"; // SERVER PORT
$haslo = "iSZaDFYIOoi78"; // SERVER PASSWORD

$refreshrate = "200"; // Script/Page refresh time
$bgcolor = "#ffffff"; // page background colour, hex value, default = white, #ffffff

//End configuration 

/*Script by DJ_CARO*/
/*END*/

header('Content-type: text/html;charset=iso-8859-2');

$scfp = @fsockopen($ip, $port, &$errno, &$errstr, 30);

if (!$scfp)
{
	echo '<font face="Verdana" size="2" color="#000000"><b> The server is currently Swith OFF</b></font>';
}
else
{
	fputs($scfp,"GET /admin.cgi?pass=$haslo&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", "TIME");
	$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)
		{
			$$scphp = urldecode($$scphp);
		}

		$y++;
	}
        $czas=date("G:i");
	$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]);

		$r++;
	}

	fclose($scfp);

	$skroc = '50';

echo'<table cellspacing="0" cellpadding="0" background="" border="0" width="442">
  <tr>
    <td valign="top" height="0">
	<font face="Verdana" size="2" color="Black">
        
	<p style="margin-top: 2; margin-bottom: 0">&nbsp;&nbsp;&nbsp;&nbsp; <b>On Air Now:</b><br><i>';echo "$czas ->"; if (strlen($song[0])>$skroc) { echo substr($song[0], 0, $skroc).'...'; } else { echo $song[0]; } echo '</i></b></p>
	<p style="margin-top: 7; margin-bottom: 0">&nbsp; <b>History:</b></p>
	<p style="margin-top: 6; margin-bottom: 0">&nbsp;&nbsp;1. '; if (strlen($song[1])>$skroc) { echo substr($song[1], 0, $skroc).'...'; } else { echo $song[1]; } echo '</p>
	<p style="margin-top: 6; margin-bottom: 0">&nbsp;&nbsp;2. '; if (strlen($song[2])>$skroc) { echo substr($song[2], 0, $skroc).'...'; } else { echo $song[2]; } echo '</p> 
	<p style="margin-top: 7; margin-bottom: 0">&nbsp;&nbsp;3. '; if (strlen($song[3])>$skroc) { echo substr($song[3], 0, $skroc).'...'; } else { echo $song[3]; } echo '</p>
	<p style="margin-top: 6; margin-bottom: 0">&nbsp;&nbsp;4. '; if (strlen($song[4])>$skroc) { echo substr($song[4], 0, $skroc).'...'; } else { echo $song[4]; } echo '</p>
	<p style="margin-top: 7; margin-bottom: 0">&nbsp;&nbsp;5. '; if (strlen($song[5])>$skroc) { echo substr($song[5], 0, $skroc).'...'; } else { echo $song[5]; } echo '</p>
        <p style="margin-top: 6; margin-bottom: 0">&nbsp;&nbsp;6. '; if (strlen($song[6])>$skroc) { echo substr($song[6], 0, $skroc).'...'; } else { echo $song[6]; } echo '</p>
	
    </td>
  </tr>
</table>';
}
echo "<title>On Air now -> || $song[0] || The time is -> $czas You are listening to -> $radioname </title>";

?> 


<html>
<head>
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>
</head>
<body onload="JavaScript:timedRefresh(20000);">
</body>
</html>

DJ_CARO
Forum Newbie
Posts: 2
Joined: Sun Jun 13, 2010 1:19 pm

Re: PHP radio playlist

Post by DJ_CARO »

rfr
Post Reply