radio / onupdate.php /
7c9f52f 7 years ago
1 contributor
123 lines | 3.229kb
<!DOCTYPE html>
<html>
<head>
	<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
require_once('sentences.php');
$active_artist="";
$active_title="";
$active_url="resource/radio-big.png";

function print_radio_details($name, $artist, $title, $url, $big = true )
{
	$SIZE=40;
	$MAX_LEN_STR_ARTIST=26;
	$MAX_LEN_STR=28;
	$now_playing = $_GET["title"];
	$artist=sentence_case($artist);
	$title=sentence_case($title);
	if( $MAX_LEN_STR_ARTIST < strlen($artist) )
	{
		$artist=substr($artist,0,$MAX_LEN_STR_ARTIST);
		$artist.="...";
	}
	if( $MAX_LEN_STR < strlen($title) )
	{
		$title=substr($title,0,$MAX_LEN_STR);
		$title.="...";
	}
	if( true === $big )
	{
		echo "<div class=\"radio_box_list\">\n";
	}
	else
	{
		echo "<div class=\"radio_box_list_compact\">\n";
	}
	if( $now_playing == $name )
	{
		echo "\t<div class=\"radio_name_list_active\" id=\"$name\">$name</div>\n";
		$active_artist=$artist;
		$active_title=$title;
		$active_url=$url;
	}
	else
	{
		echo "\t<div class=\"radio_name_list\" id=\"$name\">$name</div>\n";
	}
	if( true === $big )
	{
		echo "\t<div class=\"radio_url_list\"><img src=\"$url\" width=\"$SIZE\" height=\"$SIZE\"></div>\n";
	}
	echo "\t<div class=\"radio_artist_list\">$artist</div>\n";
	if( ( "" != $title ) && ( "unknown" != $title ) && ( "An Error Occured" != $title ) )
	{
		echo "\t<div class=\"radio_title_list\">$title</div>\n";
	}
	else
	{
		echo "\t<div class=\"radio_title_list\"></div>\n";
	}
	echo "\t<div class=\"radio_add\"></div>\n";
	echo "</div>\n";
}

$file_contents_playlist=file_get_contents( "tags.xml" );
$xml = simplexml_load_string($file_contents_playlist);
$json = json_encode($xml);
$array = json_decode($json,TRUE);
$CPTMAX=0;
$now_playing = $_GET["title"];
$SIZE=128;
$active_artist="";
$active_title="";
$active_url="resource/radio-big.png";
if( is_array($array)) {
foreach ( $array as $channel_list )
{
	$cpt=0;
	foreach ( $channel_list as $channel )
	{
			if( $now_playing == $channel['title'] ) {
				$url_image=$channel['track_url'];
				if( true === is_array($url_image) ) {
						$url_image="resource/".$channel['shortname'].".jpg";
				} else {
					$ext=substr($url_image,strlen($url_image)-3);
					if( ("jpg" != $ext) && ( "png" != $ext ) ) {
						$url_image="resource/".$channel['shortname'].".jpg";
					}
				}
				$active_artist=$channel['track_artist'];
				$active_title=$channel['track_title'];
				if( ( "unknown" == $channel['track_artist'] ) ||
					( "An Error Occured" == $channel['track_artist'] ) ) {
					$active_artist = $channel['title'];
				}
				if( ( "unknown" == $channel['track_title'] ) ||
					( "An Error Occured" == $channel['track_title'] ) ) {
					$active_title = "";
				}
				$active_artist=sentence_case($active_artist);
				$active_title=sentence_case($active_title);
				echo "<table><tr>\n";
				echo "<td><div class=\"radio_url\"><img src=\"".$url_image."\" width=\"".$SIZE."\" height=\"".$SIZE."\"></div></td>";
				echo "<td>\n";
				echo "<div class=\"radio_artist\">".$active_artist."</div>\n";
				echo "<div class=\"radio_title\">".$active_title."</div>\n";
				echo "</td>\n";
				echo "</tr></table>\n";
				exit;
			}
			$cpt++;
	}
}
} else {
  echo "Erreur"; 
}
?>
</body>
</html>