View Single Post
Old 24th October 2017, 16:46   #5
BeatFlexx
Junior Member
 
Join Date: Oct 2017
Posts: 10
I think that my hoster does not support fsockopen because i still have a
HTTP ERROR 500

I made a new script a that one is working for me.

code:

<?php
$sIP = "127.0.0.1";
$sPort = "8000";
$sID = "1";
$sPass = "CHANGEME";
$imgKey = "MYAPI";

$a = 0;
$b = 0;

function truncate($string, $length, $dots = "...") {
return (strlen($string) > $length) ? substr($string, 0, $length - strlen($dots)) . $dots : $string;
}

$url = file_get_contents("http://$sIP:$sPort/admin.cgi?pass=$sPass&mode=viewxml&page=4&sid=$sID");

$xml = simplexml_load_string($url);
foreach( $xml -> SONGHISTORY -> SONG as $Key => $Value ) {

list ($artist, $title) = explode(" - ", $Value -> TITLE);

$row_color = ($a++ % 2) ? "#fafafa" : "#f5f5f5";
$nowplaying = ($b++ % 20) ? "" : "<font style='color:#b2b2b2;font-size:10px;'><strong>NOW PLAYING</strong></font>";

$LastFM = simplexml_load_file("http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist=$artist&api_key=$imgKey");
$trackimg = $LastFM->artist->image[2];

if ($trackimg == "") {
$trackimg = "noIMG.png";
}

if ($trackimg == "https://lastfm-img2.akamaized.net/i/u/174s/62ed6ff00329486d8f56656ef783d1aa.png") {
$trackimg = "noIMG.png";
}

if ($artist == "LIVE" AND $title == "-=ON AIR=-") {
$trackimg = "live.png";
}

$ts = $Value -> PLAYEDAT;
$date = new DateTime("@$ts");

echo'
<div style="background-color: '.$row_color.';>
<p style="width: 65px;"><img style="margin-top:5px; margin-left:5px; border-radius: 100%; border: 1px solid #ff1190; width: 60px; height: 60px;" src="'.$trackimg.'" /></p>
<div style="display:block; margin: -66px 0px 0px 80px; float:left;">
<font style="font-size:15px;"><i class="fa fa-microphone"></i> <strong>'.truncate($artist, 100).'</strong></font><br />
<font style="color:#ff1190;font-size:13px;"><i class="fa fa-headphones"></i> '.truncate($title, 100).'</font><br />' . $nowplaying . '
</div>
<div style="display:block; margin: -55px 10px 0px 0px; float:right;">
<font style="color:#b2b2b2;font-size:10px;"><i class="fa fa-clock-o"></i> ' . $date->format('g:i:s A') . '</font>
</div>
</div>';
}
?>

BeatFlexx is offline   Reply With Quote