website logo and tag line is working. Now for the album/artist/trakc details.
It's really a cheat, but until I can figure out how gaussian blur works, it'll have to do.
Moderator: moderators
//If the user is playing a music file...
playing:
$imageList = array("music1.png","music2.png","music10.png","sony1.png","sony4.png","sony13.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
$end = imagealphablending($image, false);
$save = imagesavealpha($image, true);
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
//Get the cover art
$coverart = "http://".$server."/rest/getCoverArt.view?u=".$admin."&p=".$adminpass."&v=1.5.0&c=signature&id=".$second_gen['coverArt']."&size=150";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $coverart);
curl_setopt ($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
$rawdata = curl_exec($ch);
$image2 = imagecreatefromstring($rawdata);
curl_close($ch);
//text colour
// this part is to create the drop shadow
$color = imagecolorallocate($image, 30, 30, 30);
$font = getcwd()."/aliee13.ttf";
$fontSize = 10;
$fontRotation = -0;
$x = 156;
$y = 98;
$end = imagealphablending($image, true);
$str = "Head Bangin' while listening to\nArtist: ".$second_gen['artist']."\nTitle: ".$second_gen['title']."\nAlbum: ".$second_gen['album'];
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 12, 0, 152, 282, imagecolorallocate($image, 30, 30, 30), getcwd()."/aliee13.ttf", $time);
$strwww = "www.Mess-Hall.co.uk";
imagettftext($image, 14, 0, 154, 16, imagecolorallocate($image, 30, 30, 30), getcwd()."/Capture it.ttf", $strwww);
$strtag = "A Small Review of Almost Everything";
imagettftext($image, 9, 0, 158, 26, imagecolorallocate($image, 30, 30, 30), getcwd()."/Capture it.ttf", $strtag);
// End of drop shadow
//text colour
$color = imagecolorallocate($image, 255, 255, 255);
$font = getcwd()."/aliee13.ttf";
$fontSize = 10;
$fontRotation = -0;
$x = 155;
$y = 97;
// $image = imagealphablending($str, true);
$end = imagealphablending($image, true);
$str = "Head Bangin' while listening to\nArtist: ".$second_gen['artist']."\nTitle: ".$second_gen['title']."\nAlbum: ".$second_gen['album'];
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 12, 0, 150, 280, imagecolorallocate($image, 255, 255, 255), getcwd()."/aliee13.ttf", $time);
$strwww = "www.Mess-Hall.co.uk";
imagettftext($image, 14, 0, 152, 15, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $strwww);
$strtag = "A Small Review of Almost Everything";
imagettftext($image, 9, 0, 156, 25, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $strtag);
// End of drop shadow test
dazbobaby wrote:thanks Sparky I don't think it would have worked without out the alpha. Thanks for that.
got any samples of your updates in action?
//If user is offline, or the last file has finished playing...
nothing:
$imageList = array("graveyard.png","pushthebutton.png","worldmap.png","record.png","fantasy.png","couch.png","tron.png","eye.png","dancer.png","hifi.png","mask.png","storm.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
$end = imagealphablending($image, true);
$save = imagesavealpha($image, true);
$color = imagecolorallocate($image, 0, 0, 0);
$font = getcwd()."/Capture it.ttf";
$fontSize = 14;
//text location
$x = 7;
$y = 20;
$fontRotation = 0;
$str = "Your IP Address is $_SERVER[REMOTE_ADDR]";
//$str = "Your browser is $_SERVER[HTTP_USER_AGENT]";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
$x = 5;
$y = 18;
$color = imagecolorallocate($image, 255, 255, 255);
$fontRotation = 0;
$str = "Your IP Address is $_SERVER[REMOTE_ADDR]";
//$str = "Your browser is $_SERVER[HTTP_USER_AGENT]";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 14, 0, 8, 148, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $time);
$strnot = "Not Watching Or Listening to Anything Right Now";
imagettftext($image, 14, 0, 5, 145, imagecolorallocate($image, 0, 0, 0), getcwd()."/Capture it.ttf", $time);
$strnot = "Not Watching Or Listening to Anything Right Now";
imagettftext($image, 10, 0, 140, 78, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $strnot);
$strwww = "www.Mess-Hall.co.uk";
imagettftext($image, 14, 0, 371, 136, imagecolorallocate($image, 30, 30, 30), getcwd()."/Capture it.ttf", $strwww);
$strwww = "www.Mess-Hall.co.uk";
imagettftext($image, 14, 0, 370, 135, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $strwww);
$strtag = "A Small Review of Almost Everything";
imagettftext($image, 8, 0, 377, 146, imagecolorallocate($image, 30, 30, 30), getcwd()."/Capture it.ttf", $strtag);
$strtag = "A Small Review of Almost Everything";
imagettftext($image, 8, 0, 376, 145, imagecolorallocate($image, 255, 255, 255), getcwd()."/Capture it.ttf", $strtag);
// Uncomment the next line (remove //) to display the number of hits on your page.
//echo $hits;
//hits text location
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
imagepng($image);
imagepng($image);
imagedestroy($image);
exit();
$xml = @simplexml_load_file("http://".$server."/rest/getNowPlaying.view?u=".$admin."&p=".$adminpass."&v=1.5.0&c=signature");
if($xml==false) {
goto offline;
}
// Hitcounter
$filename = 'hitcountdayz.txt';
$handle = fopen($filename, 'r');
$hits = trim(fgets($handle)) + 1;
fclose($handle);
$handle = fopen($filename, 'w');
fwrite($handle, $hits);
fclose($handle);
dazbobaby wrote:I've yet to upgrade, but as Guru said, there's not going to be a problem.
BTW Gurutech, how come you're not showing off your signature?
<?php
//setup error log
ini_set("log_errors", 1);
ini_set("error_log", "php-error.log");
// end error log
//First collect some data:
$user = "admin"; //user to monitor
$admin = "admin"; //user to get nowPlaying list
$adminpass = "AdminPassword"; //pass to get nowPlaying list (plain or using enc:)
$server = "123.123.123.123:3060"; //Your subsonic server
$xml = @simplexml_load_file("http://".$server."/rest/getNowPlaying.view?u=".$admin."&p=".$adminpass."&v=1.16.1&c=sig_php");
if($xml==false) {
goto offline;
}
// Hitcounter
//$filename = 'hitcountdayz.txt';
//$handle = fopen($filename, 'r');
//$hits = trim(fgets($handle)) + 1;
//fclose($handle);
//$handle = fopen($filename, 'w');
//fwrite($handle, $hits);
//fclose($handle);
//Timestamp
//Different Timezones supported: http://phptutorial.info/?timezones
date_default_timezone_set('Europe/London');
$time = "Local Time: ".date(" M: d: H:i");
//If the server is online, check what the monitored user is listening or watching, and jump to the right code...
foreach( $xml->children()->children() as $second_gen) {
$duration = floor($second_gen['duration']/10);
if($second_gen['username'] == $user and $second_gen['minutesAgo']<=$duration) {
if($second_gen['contentType'] && substr( $second_gen['contentType'], 0, 5 ) == "audio") {
goto playing;
}else{
goto nothing;
}
}
}
//If user is offline, or the last file has finished playing...
nothing:
$imageList = array("notmusic1.png","notmusic2.png","music1.png","music2.png","music3.png","music4.png","music5.png","music7.png","music8.png","music10.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
$end = imagealphablending($image, true);
$save = imagesavealpha($image, true);
$color = imagecolorallocate($image, 0, 0, 0);
$font = getcwd() .DIRECTORY_SEPARATOR. "happy.ttf";
$fontSize = 14;
//text location
//Text Position x=horizontal y=vertical
$x = 7;
$y = 20;
$fontRotation = 0;
$str = "Your IP Address is $_SERVER[REMOTE_ADDR]";
//$str = "Your browser is $_SERVER[HTTP_USER_AGENT]";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
$x = 5;
$y = 18;
$color = imagecolorallocate($image, 255, 255, 255);
$fontRotation = 0;
$str = "Your IP Address is $_SERVER[REMOTE_ADDR]";
//$str = "Your browser is $_SERVER[HTTP_USER_AGENT]";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 14, 0, 572, 18, imagecolorallocate($image, 0, 0, 0), $font, $hits);
imagettftext($image, 14, 0, 570, 16, imagecolorallocate($image, 255, 255, 255), $font, $hits);
imagettftext($image, 14, 0, 7, 147, imagecolorallocate($image, 0, 0, 0), $font, $time);
imagettftext($image, 14, 0, 5, 145, imagecolorallocate($image, 255, 255, 255), $font, $time);
// Because Music Won't Play Itself
$strnot = "Because Music Won't Play Itself";
imagettftext($image, 24, 0, 74, 84, imagecolorallocate($image, 0, 0, 0), getcwd() .DIRECTORY_SEPARATOR. "cowboy.ttf", $strnot);
imagettftext($image, 24, 0, 72, 82, imagecolorallocate($image, 255, 255, 255), getcwd() .DIRECTORY_SEPARATOR. "cowboy.ttf", $strnot);
$strwww = "https://Daz-DJ.UK";
imagettftext($image, 14, 0, 386, 136, imagecolorallocate($image, 30, 30, 30), $font, $strwww);
$strwww = "https://Daz-DJ.UK";
imagettftext($image, 14, 0, 385, 135, imagecolorallocate($image, 255, 255, 255),$font, $strwww);
$strtag = "Banging House Music DJ!";
imagettftext($image, 8, 0, 415, 147, imagecolorallocate($image, 30, 30, 30),$font, $strtag);
$strtag = "Banging House Music DJ!";
imagettftext($image, 8, 0, 416, 146, imagecolorallocate($image, 255, 255, 255),$font, $strtag);
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
imagepng($image);
imagedestroy($image);
exit();
//If the user is playing a music file...
playing:
$imageList = array("balloon.png","dj-daz.png","dj-daz.png","dj-daz.png","daz-dj1.png","daz-dj2.png","daz-dj3.png","dj23.png","dj1.png","dj2.png","dj4.png","dj5.png","dj6.png","dj7.png","dj8.png","dj9.png","dj10.png","dj11.png","dj12.png","dj13.png","dj14.png","dj15.png","dj16.png","dj17.png","dj19.png","dj21.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
$end = imagealphablending($image, false);
$save = imagesavealpha($image, true);
//Get the cover art
//$imageList2 = array("ASTRONEER.gif","astroneer2.gif","astroneer3.gif");
//$image2 = imagecreatefromgif($imageList2[rand(1,count($imageList))-1]);
$coverart = "http://".$server."/rest/getCoverArt.view?u=".$admin."&p=".$adminpass."&v=1.16.1&c=signature&id=".$second_gen['coverArt']."&size=135";
file_put_contents("coverart_url.log",$coverart);
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $coverart);
curl_setopt ($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_HEADER, false);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);
$rawdata = curl_exec($ch);
if (strpos($rawdata,'status="failed"')!==false)
{
$fallback_images = array("image1.png","image2.png","image3.png","image4.png","image5.png","image6.png","image7.png");
$image2 = imagecreatefrompng($fallback_images[rand(0,count($fallback_images)-1)]);
}
else
{
$image2 = imagecreatefromstring($rawdata);
}
curl_close($ch);
//Text Position x=horizontal y=vertical
//text colour
$color = imagecolorallocate($image, 0, 205, 255);
$font = getcwd() .DIRECTORY_SEPARATOR. "trucking.ttf";
$fontSize = 10;
$fontRotation = 0;
$x = 154;
$y = 96;
// $image = imagealphablending($str, true);
$end = imagealphablending($image, true);
$str = "Listening to\nArtist: ".$second_gen['artist']."\nTitle: ".$second_gen['title']."\nAlbum: ".$second_gen['album'];
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
//imagettftext($image, 14, 0, 572, 18, imagecolorallocate($image, 0, 0, 0), getcwd() .DIRECTORY_SEPARATOR. "Capture-it.ttf", $hits);
//imagettftext($image, 14, 0, 570, 16, imagecolorallocate($image, 255, 255, 255), getcwd() .DIRECTORY_SEPARATOR. "Capture-it.ttf", $hits);
//imagettftext($image, 12, 0, 150, 280, imagecolorallocate($image, 255, 255, 255), $font, $time);
$strwww = "Daz-DJ.UK";
imagettftext($image, 16, 0, 265, 19, imagecolorallocate($image, 80, 80, 255), $font, $strwww);
$strtag = "Banging House Music DJ!";
//imagettftext($image, 10, 00, 241, 34, imagecolorallocate($image, 255, 255, 255), $font, $strtag);
imagettftext($image, 10, 00, 240, 33, imagecolorallocate($image, 80, 80, 255), $font, $strtag);
// ** IMPORTANT **
// Corodinates are as follows: 10 is font size, 0 is ROTATION, 240 is the horizontal location, 33 is the vertical //
// ** IMPORTANT **
// End of drop shadow test
//Cover art location
imagecopy($image, $image2, 8, 7, 0, 0, 135, 135);
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
imagepng($image);
imagedestroy($image);
exit();
//If the user is playing a VIDEO file...
watching:
$imageList = array("dj1.png","dj2.png","dj3.png","dj4.png","dj6.png","dj7.png","dj8.png","dj9.png","dj10.png","dj11.png","dj12.png","dj13.png","dj14.png","dj15.png","dj16.png","dj17.png","dj18.png","dj19.png","dj20.png","dj21.png","dj22.png","dj11.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
$color = imagecolorallocate($image, 255, 255, 255);
$end = imagealphablending($image, false);
$save = imagesavealpha($image, true);
$font = getcwd()."Capture-it.ttf";
$fontSize = 12;
$x = 10;
$y = 55;
$str = "Now Watching\n".$second_gen['title'];
imagealphablending($image, false);
imagesavealpha($image, true);
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
imagepng($image);
imagedestroy($image);
exit();
//If the server is offline (404)...
//offline:
//$image = imagecreatefrompng("graveyard.png");
//$color = imagecolorallocate($image, 255, 255, 255);
//$font = getcwd()."cowboy.ttf";
//$fontSize = 16;
//$fontRotation = -7;
//$x = 160;
//$y = 65;
//$str = "Aliens stole my Server. Call the feds!";
//imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
//imagettftext($image, 12, 0, 65, 295, imagecolorallocate($image, 230, 49, 150), getcwd()."/trucking.ttf", $time);
//header("Content-type: image/png");
//header("Cache-Control: no-cache, must-revalidate");
//header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
//header("Pragma: no-cache");
//imagepng($image);
//imagedestroy($image);exit();
//exit();
//If the server is offline (404)...
offline:
$image = imagecreatefrompng("graveyard1.png");
$color = imagecolorallocate($image, 255, 255, 255);
$font = getcwd()."/trucking.ttf";
$fontSize = 16;
$fontRotation = 0;
//Text Position x=horizontal y=vertical
$x = 158;
$y = 120;
$str = "The server seems to be down!";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 12, 0, 15, 295, imagecolorallocate($image, 230, 49, 150), getcwd()."/trucking.ttf", $time);
header("Content-type: image/png");
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Fri, 19 Jan 1994 05:00:00 GMT");
header("Pragma: no-cache");
imagepng($image);
imagedestroy($image);exit();
exit();
?>
Return to Mods, Apps and Clients
Users browsing this forum: No registered users and 27 guests