SparkyRih wrote:I wanted to put my last tweet in this signature... but since my twitter account is protected it's a little bit harder
Now you're just showing off y0r l33t 5k1lls
Moderator: moderators
SparkyRih wrote:I wanted to put my last tweet in this signature... but since my twitter account is protected it's a little bit harder
<?php
//First collect some data:
$user = "UserName"; //user to monitor
$admin = "Admin UserName"; //user to get nowPlaying list
$adminpass = "Admin Password"; //pass to get nowPlaying list (plain or using enc:)
$server = "localhost:8080"; //Your subsonic server
$xml = @simplexml_load_file("http://".$server."/rest/getNowPlaying.view?u=".$admin."&p=".$adminpass."&v=1.5.0&c=signature");
if($xml==false) {
goto offline;
}
//Timestamp
//Different Timezones supported: http://phptutorial.info/?timezones
date_default_timezone_set('Europe/London');
$time = "My local time: ".date("l: D: 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) {
$math = floor($second_gen['duration']/60);
if($second_gen['username']==$user and $second_gen['minutesAgo']<=$math) {
if($second_gen['isVideo']=='false') {
goto playing;
}else{
goto watching;
}
}
}
//If user is offline, or the last file has finished playing...
nothing:
$image = imagecreatefrompng("notdoinganything.png");
$color = imagecolorallocate($image, 255, 255, 255);
$font = getcwd()."/Capture it.ttf";
$fontSize = 14;
//text location
$x = 5;
$y = 18;
$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);
//Time location
imagettftext($image, 14, 0, 5, 145, imagecolorallocate($image, 255, 255, 255), 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);
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();
//If the user is playing a music file...
playing:
$imageList = array("music1.png","music2.png","music3.png","music4.png","music5.png","music6.png","music7.png","music8.png","music9.png","music10.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
//$image = imagecreatefrompng("itunes_sig.png");
//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
$color = imagecolorallocate($image, 255, 255, 255);
$font = getcwd()."/aliee13.ttf";
$fontSize = 10;
$fontRotation = -0;
$x = 155;
$y = 97;
$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);
//Cover art location
imagecopy($image, $image2, 0, 0, 0, 0, 150, 150);
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("music1.png","music2.png","music3.png","music4.png","music5.png","music6.png","music7.png","music8.png","music9.png","music10.png");
$image = imagecreatefrompng($imageList[rand(1,count($imageList))-1]);
//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
$color = imagecolorallocate($image, 250, 250, 90);
$font = getcwd()."/aliee13.ttf";
$fontSize = 10;
$fontRotation = -0;
$x = 155;
$y = 97;
$str = "Trasfixed to the gogglebox\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, 65, 295, imagecolorallocate($image, 230, 49, 150), getcwd()."/aliee13.ttf", $time);
//Cover art location
imagecopy($image, $image2, 0, 0, 0, 0, 150, 150);
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("music1.png");
$color = imagecolorallocate($image, 255, 255, 255);
$font = getcwd()."Capture it.ttf";
$fontSize = 16;
$fontRotation = -7;
$x = 160;
$y = 65;
$str = "My server seems to be down...";
imagettftext($image, $fontSize, $fontRotation, $x, $y, $color, $font, $str);
imagettftext($image, 12, 0, 65, 295, imagecolorallocate($image, 230, 49, 150), getcwd()."/aliee13.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();
?>
dazbobaby wrote:seeing as you're better at this than me Sparky, any idea how to input and output PNG transparency?
gurutech wrote:Quick questions on this forum signature....
Can it be used on ANY forum, or only on this one?
If I post something in a forum, and the .jpg file is linked to in the image, will that image actually "change" if I am listening to another song, or to no song at all? (ie. if I am listening to "Metallica - One" when I post a message, then the following day, I go back to the thread I posted in, but am not currently listening to anything, will it still show I am listening to Metallica, or would it now say I am not listening to anything?
Thanks!
gurutech wrote:ok, I have the signature files copied to a ./signatures folder, and I modified the script, and if I browse to the URL I can see the correct image, however I do not see any text on the image at all.
I tried all three of the standard images (that came with your script), and can view each of them, but no text on any of them.
I tried going through the signature.php file and it looks like there are some x and y parameters to specify the starting point for the text, which I have left at the default (160, 65).
I did resize the actual back2.png file so it would fit within the specs on the forum I wanted to use it on (510x100 max, ended up as 434x100)
SparkyRih wrote:I see, it doesn't work... let me have a look...
Edit: This is what you wanted
http://develop.schattorie.nl/signatures ... c/test.php
//If the user is playing a music file...
playing:
$imageList = array("music1.png","music2.png","music6.png","music10.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
$color = imagecolorallocate($image, 255, 0, 0);
$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);
//Cover art location
imagecopy($image, $image2, 2, 2, 0, 0, 145, 145);
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();
dazbobaby wrote:Nice going Sparky, I'm currently working on drop shadow, something impossible in GD2 (or so I've heard).
I tried imageconvolution with Gaussian blur but failed, so instead I'm trying to replicate the text, darken it, and move it slightly to create the effect of a drop shadow.
Throw me a rope I'm going in
Return to Mods, Apps and Clients
Users browsing this forum: No registered users and 35 guests