php: mp3 stats
Posted: Tue Oct 14, 2003 3:55 am
I was kinda bored last weekend, and made this. This will display ur current song. You can use it for ur signature or whatever. Only for Winamp. The script will make an image, called music.png.
You need the latest php version.
mp3.php
You need the latest php version.
mp3.php
Code: Select all
<?php
/*
Winamp Real-time Song Updater
Usefull when you want a dynamic signature for a forum / website
17. dec. Added stripslashes and fixed some small bugs (den)
29. oct. Added documentation (haui)
17. oct. Added icon (den)
15. oct. Added md5 protection (haui)
10. oct. released this whole thing (den)
This script is for WinAmp only, use this plugin http://den.m00ki.de/winamp/install.exe to call this script remotely.
When called correclty (see doc) this script creates a file (defaults to music.png) in which it shows the currently played song.
Of course you can change this script for other needs, if you know what you are doing.
Getting started in seven steps:
1. It's rather easy to use this script. All you need is a php-capable webserver with GD-lib (it's default in php) installed.
2. Edit mp3.php and change your personal key '$mySecret' below to ANY RANDOM string...
-> For example '$mySecret = "idontcare75829jdd";'
3. Upload the mp3.php (this file) and the 'winampicon.png' to your webserver.
-> You can find the icon here: http://den.m00ki.de/winamp/winampicon.png
4. Run mp3.php in your webbrowser and you will see something _like_:
Use: 'http://yourhost.com/mp3.php?secret=724269l56033b8e23b179b4c29cf8248&song=' to be the master of this script
The long secret-string is important in the next step.
5. Install the WinAmp-Plugin (http://den.m00ki.de/winamp/install.exe) and tell the plugin to execute this URL everytime, when the song changes:
-> http://yourhost.com/mp3.php?secret=724269l56033b8e23b179b4c29cf8248&song=
(Note: the LONG secret-string must be taken from the display in the 4th step!)
6. Now EDIT the mp3.php again and __kill__ this line OUT:
'echo "<br/>Use: 'http://". $HTTP_HOST . $PHP_SELF ."?secret=". $internalSecret ."&song=MySong' to be the master of this script";'
-> it's the third last line in this file.
7. Upload the mp3.php again, without the line of the sixth step.
This is it... your winamp now calls the URL everytime when the song changes and uses a secret only you know.
Thus, nobody else can change the music.png and its text.
*/
$mySecret = "idontcare75829jdd"; // change for your own password pls.
$song = $_GET["song"];
$secret = $_GET["secret"];
$internalSecret = md5($mySecret . "staticsecret"); // For a bit more security
$finalsong = stripslashes($song);
$font = "2"; // Font you want to use
$outputfile = "music.png"; // Filename for the image
$bgcolor = "#FFFFFF"; // Background Color
$textcolor = "#000000"; // Font Color
$signature = " | quadaver ownz me"; // Extra text you want to add
$blank = " "; // Blank spaces for icon
$final = $blank. $finalsong. $signature; // Putting everything together
function CreatePNG($font, $outputfile, $bgcolor, $textcolor, $signature, $final) {
// Creating the image
$im = ImageCreate(ImageFontWidth($font)*strlen($final), ImageFontHeight($font));
$bgcolor2 = ImageColorAllocate($im, "0x" . substr($bgcolor, 1, 2), "0x" . substr($bgcolor, 3, 4), "0x" . substr($bgcolor, 5, 6));
$textcolor2 = ImageColorAllocate($im, "0x" . substr($textcolor, 1, 2), "0x" . substr($textcolor, 3, 4), "0x" . substr($textcolor, 5, 6));
ImageColorTransparent($im, $bgcolor2); // Comment out for no transparency
ImageString($im, $font, 0, 0, $final, $textcolor2);
ImagePNG($im, $outputfile);
ImageDestroy($im);
$oldimage = imagecreatefrompng($outputfile); // Saving it as outputfile
$icon = imagecreatefrompng("winampicon.png"); // Icon
imagecopy($oldimage, $icon, 0, 0, 0, 0, 13, 13); // Icon settings
imagepng($oldimage, $outputfile);
imagedestroy($icon);
}
if ($secret == $internalSecret) {
if(isset($song)) {
CreatePNG($font, $outputfile, $bgcolor, $textcolor, $signature, $final);
} else {
echo "No new image created. perhaps you wanna see the current one: <br/>\n".
"<img src=\"$outputfile\" alt=\"old one\" />";
}
} else {
echo "No valid key";
echo "<br/>Use: 'http://". $HTTP_HOST . $PHP_SELF ."?secret=". $internalSecret ."&song=' to be the master of this script";
}
?>