To produce this Now playing image requires two steps. This PAL executes the nowplayingimage.php file on your web host, here they are:
nowplayingimage.pal
Replace the XXXXXXXXXXX with your domain.
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
{ make the pal loop }
PAL.Loop := True;
{ Wait for a track to play }
PAL.WaitForPlayCount(1);
PAL.WaitForTime('+00:00:30');
PAL.LockExecution;
{ Configuration }
{==================================================}
{ Url of the script you are wanting to run }
const theurl = 'https://XXXXXXXXXXX.com/nowplayingimage.php';
{==================================================}
{ End Configuration }
{--------------------------------------------------}
{ Build URL to access the webpage and update stuff }
var URL : String;
URL := ''+theurl+'';
{ execute webpage }
WebToFile('c:\thedummy.txt',URL);
PAL.UnLockExecution;
nowplayingimage.php
(!empty($user->lang['CODE'])) ? $user->lang['CODE'] : ucwords(strtolower(str_replace('_', ' ', 'CODE'))):
<?php
define( "IN_5280Jazz", true );
require_once( "include/setup.php" );
$arr = array("See us at Live365","Tell a friend you heard 5280 Jazz", "Sit back and relax, We deliver!!","Free your mind and the rest will follow, slip into something more comfortable, 5280 Jazz","An oasis for your mind, stress free and relaxing, 5280 Jazz", "Free flowing and easy, 5280 Jazz, your choice for Smooth Jazz on the internet", "We play the music, how you relax to it is up to you", "Streaming Smooth Jazz from the Colorado Rockies", "Uniquely Yours", "For Playlists, Requests and the latest in Smooth Jazz News - you can find us at https://5280jazz.com");
srand((float) microtime() * 1000000);
shuffle($arr);
$rand_key = array_rand($arr);
$theQuote = $arr[$rand_key];
$result = mysqli_query( $samDB, "SELECT sum(viewers) viewers from samrelay" );
$listenersrow = mysqli_fetch_array( $result );
$tllisteners = $listenersrow['viewers'];
$result = mysqli_query( $samDB, "select * from fhr_now_playing_view" );
$nowPlayingSong = mysqli_fetch_assoc( $result );
$requestString = "";
if($nowPlayingSong["requestID"]!=0) {
$wheresong = $nowPlayingSong['requestID'];
$result = mysqli_query( $samDB, "Select userid, username, requestid from requesthistory where requesthistory.requestid = $wheresong");
$request_id = mysqli_fetch_array( $result );
if ( $request_id ) {
if ($request_id['userid'] > 0) {
$requestString = "~Requested by ".$request_id['username']."~";
}}
else
$requestString = "~By Request~";
}
if($nowPlayingSong['songtype'] == 'C')
$requestString = "Merry Christmas From 5280 Jazz";
$result = mysqli_query( $samDB, "Select * from songlist s, fhr_featured_artist f where s.fhr_artistid = f.fhr_artistid order by f.date_played desc limit 1");
$row = mysqli_fetch_assoc( $result );
$featured = $row['fhr_artistid'];
if(( $nowPlayingSong['artist_id'] == $featured ) && (date('l') != 'Tuesday'))
$requestString = "~ Today's Featured Artist ~";
$result = mysqli_query( $samDB, "SELECT text1, text2 FROM currentshow");
$nowPlayingShow = mysqli_fetch_array( $result );
if ($nowPlayingSong["rating"] == 0)
$songRating = "n/a (no votes)";
$stationString = "5280 Jazz";
$showString1 = $nowPlayingShow['text1'];
$showString2 = $nowPlayingShow['text2'];
$artistString = "Artist: ".$nowPlayingSong['artist'];
$albumString = " Album: ".$nowPlayingSong['album'];
$songString = " Song: ".$nowPlayingSong['title'];
$listenerstring = "There are currently ".$tllisteners." listeners tuned in to 5280 Jazz";
$votes = $nowPlayingSong["votes"];
if ($nowPlayingSong["votes"] == 0)
$songRatingstring = "Rating: ".$songRating;
else
$songRatingstring = "Rating: ".$nowPlayingSong["rating"]. " out of 5 by our listeners";
$maxStringSize = 0;
if (strlen($stationString) > $maxStringSize)
$maxStringSize = strlen($stationString);
if (strlen($showString1) > $maxStringSize)
$maxStringSize = strlen($showString1);
if (strlen($showString2) > $maxStringSize)
$maxStringSize = strlen($showString2);
if (strlen($artistString) > $maxStringSize)
$maxStringSize = strlen($artistString);
if (strlen($albumString) > $maxStringSize)
$maxStringSize = strlen($albumString);
if (strlen($songString) > $maxStringSize)
$maxStringSize = strlen($songString);
if (strlen($theQuote) > $maxStringSize)
$maxStringSize = strlen($theQuote);
if (strlen($songRatingstring) > $maxStringSize)
$maxStringSize = strlen($songRatingstring);
if (strlen($requestString) > $maxStringSize)
$maxStringSize = strlen($requestString);
if (strlen($listenerstring) > $maxStringSize)
$maxStringSize = strlen($listenerstring);
if(empty($nowPlayingSong["picture"])) {
$nowPlayingSong["picture"] = "na.jpg"; }
$AlbumCoverPath = "coverart/". rawurlencode($nowPlayingSong["picture"]);
$theHeight = 86;
list($coverwidth, $coverheight) = getimagesize($AlbumCoverPath);
$AlbumCoverImage = imagecreatefromjpeg($AlbumCoverPath);
$imageWidth = 5 * $maxStringSize + 110;
$x_start = 90;
$im = imagecreatetruecolor ($imageWidth, $theHeight); imagesavealpha($im, true);
$bgc = imagecolorallocatealpha ($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $bgc); $tc = imagecolorallocate ($im, 0, 0, 0);
$tcw = imagecolorallocate ($im, 255, 255, 255);
$tcr = imagecolorallocate ($im, 255, 0, 0);
$tcg = imagecolorallocate ($im, 0, 128, 0);
imagestring ($im, 1, $x_start, 0, $stationString, $tc);
imagestring ($im, 1, $x_start, 9, $showString1, $tc);
imagestring ($im, 1, $x_start, 17, $showString2, $tc);
imagestring ($im, 1, $x_start, 24, $listenerstring, $tc);
imagestring ($im, 1, $x_start, 33, $artistString, $tc);
imagestring ($im, 1, $x_start, 42, $albumString, $tc);
imagestring ($im, 1, $x_start, 51, $songString, $tc);
imagestring ($im, 1, $x_start, 60, $songRatingstring, $tc);
if($now_playing['songtype'] == 'C') {
imagestring ($im, 1, $x_start, 68, $requestString, $tcg);
} else {
imagestring ($im, 1, $x_start, 68, $requestString, $tcr);
}
imagestring ($im, 1, $x_start, 76, $theQuote, $tc);
imagecopyresized($im, $AlbumCoverImage, 2, 2, 0, 0, 80, 80, $coverwidth, $coverheight);
ImagePNG($im, 'nowplaying_image/5280jazz.png');
imagestring ($im, 1, $x_start, 0, $stationString, $tcw);
imagestring ($im, 1, $x_start, 9, $showString1, $tcw);
imagestring ($im, 1, $x_start, 17, $showString2, $tcw);
imagestring ($im, 1, $x_start, 24, $listenerstring, $tcw);
imagestring ($im, 1, $x_start, 33, $artistString, $tcw);
imagestring ($im, 1, $x_start, 42, $albumString, $tcw);
imagestring ($im, 1, $x_start, 51, $songString, $tcw);
imagestring ($im, 1, $x_start, 60, $songRatingstring, $tcw);
if($nowPlayingSong['songtype'] == 'C') {
imagestring ($im, 1, $x_start, 68, $requestString, $tcg);
} else {
imagestring ($im, 1, $x_start, 68, $requestString, $tcr);
}
imagestring ($im, 1, $x_start, 76, $theQuote, $tcw);
ImagePNG($im, 'nowplaying_image/5280jazz_w.png');
ImageGIF($im, 'forum/styles/prosilver/imageset/site_logo.gif');
imagedestroy($im);
require_once( "include/teardown.php" );
?>
Notes:
PHP nowplayingimage.php script, produces two png files, one with transparent background and one with white background (used for forums with dark backgrounds).
The scripts setup.php & teardown.php are simply files that do the open/close connection strings to the database.
fhr_now_playing_view is an mysql view that retrieves all the currently playing track fields required for the output.