1 contributor
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<?php
require_once('sentences.php');
function print_radio_details($name, $artist, $title, $url, $big = true )
{
$SIZE=40;
$MAX_LEN_STR_ARTIST=26;
$MAX_LEN_STR=28;
$now_playing = "Make your choice";
if(isset($_GET["title"]) ) {
$now_playing = $_GET["title"];
}
$artist=sentence_case($artist);
$title=sentence_case($title);
$org_artist=$artist;
$org_title=$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";
}
$enc_artist=urlencode($org_artist);
$enc_title=urlencode($org_title);
$search_details="<a href=\"https://www.qwant.com/?r=music&q=$enc_artist+$enc_title\" target=\"new-$name\"><img src=\"qwant.ico\" alt=\"?\" title=\"search Qwant\" width=\"10px\" height=\"10px\"></a>";
if( $now_playing == $name )
{
echo "\t<div class=\"radio_name_list_active\" id=\"$name\">$name $search_details</div>\n";
$active_artist=$artist;
$active_title=$title;
$active_url=$url;
}
else
{
echo "\t<div class=\"radio_name_list\" id=\"$name\">$name $search_details</div>\n";
}
if( true === $big )
{
echo "\t<div class=\"radio_url_list\"><img src=\"$url\" width=\"$SIZE\" height=\"$SIZE\"></div>\n";
}
if( ( "" != $artist ) && ( "unknown" != $artist ) && ( "An Error Occured" != $artist ) )
{
echo "\t<div class=\"radio_artist_list\">$artist</div>\n";
}
else
{
echo "\t<div class=\"radio_artist_list\"></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";
}
echo "<table>\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;
if( is_array($array) ){
foreach ( $array as $channel_list )
{
$cpt=0;
foreach ( $channel_list as $channel )
{
if( 0 == ($cpt%4)) {
echo "<tr>\n<td>\n";
}
if(isset($channel['track_url']) ) {
$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";
}
}
print_radio_details($channel['title'], $channel['track_artist'], $channel['track_title'], $url_image, true );
echo "</td><td>\n";
if( 3 == ($cpt%4)) {
echo "</td>\n</tr>\n";
}
}/* else {
print_radio_details("error", "error", "error", "", true);
}*/
$cpt++;
}
}
}else{
echo "Erreur";
}
echo "</table>\n";
?>
</body>
</html>