View Full Version : Code for writing radio info on a picture
luck777jojo
18th July 2005, 21:50
<?php
// Ruff Dawg's 'Now Playing Sig w/ Background v. 1.5 May 7, 2004
// Special thanks to the originator, DJ Rampage
// Modded specifically for MPC by luck777jojo
// This image you can call immediately from an html file in the image tag
// (i.e. <img src="sig.php">) easy huh?
Header("Content-type: image/png");
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////*Configurables*//////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
/////////////////////*Background Picture File*////////////////////////
/* Replace "sic_pic.png" with your own
picture file (must be a .png) */
$im = imagecreatefrompng("sic_pic.png");
/////////////////////////////*Host Information*/////////////////////////////
$host = "shoutcast.mpcforum.com"; // No 'http://' in the host
$port = "8000";
//////////////////////////////////*Text Colors*////////////////////////////////
// text colors are in RGB
$textcolor1 = ImageColorAllocate($im,145,150,161);
$textcolor2 = ImageColorAllocate($im,14,15,16);
$textcolor3 = ImageColorAllocate($im,14,15,16);
////////////////////////////////////*Text Size*/////////////////////////////////
$textsize1 = "4";
$textsize2 = "3";
$textsize3 = "3";
//////////////////////////////*Text Alignment*/////////////////////////////
//X alignment
$x1 = "20";
$x2 = "40";
$x3 = "490";
//Y alignment
$y1 = "175";
$y2 = "25";
$y3 = "25";
///////////////////////////*Offline Message*///////////////////////////////
$offline1 = "MPC Radio Is Currently Offline";
$offline2 = "Please Check Later";
$offline3 = "";
//////////////////////////////////////////////////////////////////////////////////////////////////
/////*DON'T TOUCH THE CODE BELOW UNLESS//////////
///YOU KNOW EXACTALLY WHAT YOU ARE DOING*//
///////////////////////////////////////////////////////////////////////////////////////////////
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
if(!$fp) {
$success=2;
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp);
$page = ereg_replace(".*<body>", "", $page); //extract data
$page = ereg_replace("</body>.*", ",", $page); //extract data
$numbers = explode(",",$page);
$currentlisteners=$numbers[0];
$connected=$numbers[1];
if($connected==1)
$wordconnected="yes";
else
$wordconnected="no";
$peaklisteners=$numbers[2];
$maxlisteners=$numbers[3];
$reportedlisteners=$numbers[4];
}
if($success!=2 && $connected==1){
$song=explode("<>" ,$numbers[6]);
$string1= $song[0];
$string2= $song[1];
$string3= "$currentlisteners/$maxlisteners";
}
else {
$string1= $offline1;
$string2= $offline2;
$string3= $offline3;
}
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString ($im,$textsize1,$x1,$y1,$string1,$textcolor1);
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString ($im,$textsize2,$x2,$y2,$string2,$textcolor2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString ($im,$textsize3,$x3,$y3,$string3,$textcolor3);
ImagePng($im);
imagedestroy($im);
?>
well...... that's the code, it was modded by me so there are a few things added such as 3 seperate text lines (1 for # of listners, 1 for song name, and 1 for dj name) also 2 different text colours and font sizes 1 for # of listeners and dj name, and the other for the song title.
also there are some small changes of how it figures out which part of he stream is the title, which part is the djname and which part is the # of listeners...... anyways it's all pretty simple, if anyone understand just a little bit of PHP and programming it is easy to understand how all of this works and how to change it to fit your needs.
Fell free to use this for any other forums etc. can't link to a .php file in your avatar so...... can't really use it as an avatar sorry.
landox
18th July 2005, 22:41
ty man... really appreciated...
luck777jojo
19th July 2005, 00:37
oh also almost forgot..... if you link it to something feel free to link it to www.radio.mpcforum.com
that link will take them directly to the built in radio player on this site ;)
icetray
19th July 2005, 11:46
thanks...
Virtuosofriend
19th July 2005, 21:27
great!good idea luck ;)
icetray
20th July 2005, 13:52
oh yeah one more think.....sry if i sound noobish...i know crap about php unless this can be translated into HTML or css or smth but must my pic be the same size as yours?If so which part of the code do i chnage to fix that?
luck777jojo
20th July 2005, 21:49
the pic can be any size, the only thing you have to modify is the coordinates of the text output if the file is smaller.
it's impossible to translate this into html or css simply because they are scripting languages and php is the closest thing to an actual porgramming language for the net.
shantred
21st July 2005, 00:46
call me a noob...but how do i get it to work?
Virtuosofriend
21st July 2005, 01:23
if you take a closer look to the actual code you will that the parts that need changes are all marked with comments.
luck i have changed the [code] code with [php].
st3ph3nt4n
21st July 2005, 01:58
if you take a closer look to the actual code you will that the parts that need changes are all marked with comments.
luck i have changed the [code] code with [php].
haha thnx for the tip =]
shantred
21st July 2005, 02:17
but how do u make it show in ur sig?
Virtuosofriend
21st July 2005, 11:09
You cannot make it work on mpc since you cannot use image sigs but you can use it on your website,or in your sig image on another forum.
luck777jojo
21st July 2005, 12:10
if you take a closer look to the actual code you will that the parts that need changes are all marked with comments.
luck i have changed the [code] code with [php].
woooo it's all pretty and coloufull now :P
thnx ;)
Virtuosofriend
21st July 2005, 14:29
:P
Forgot to say that everything in orange is comments or instructions that will help you to edit it.
shantred
21st July 2005, 15:02
ok i still dont get it. i have my own site that i wanna use it on. exactly what would i have to put into the signature?
icetray
22nd July 2005, 16:13
ok so i fill my img. link place with my img link rite?if im correct then why do i kep getting a message saying i cant go over 2000 chracters?
shantred
22nd July 2005, 20:30
you have to "link directly to the php file" which is what i dont get. luck tells me that but i dont get what the hell it means ><. if someone could just quote what has to be put into signature, then i would greatly appreciate it.
Dark Blaze
24th July 2005, 23:21
cool stuff luck, read my mind... heh thanks ;)
afklead
27th July 2005, 03:06
So we do [image] then [url=blah blah.php] and all that on the image?
Dark Blaze
27th July 2005, 10:21
So we do [image] then [url=blah blah.php] and all that on the image?
Well you can use it as HTML like this: <img src="sig.php">
or for forums something.something
but you'll need to remember that you cannot use images in your signature on MPC.
afklead
27th July 2005, 15:05
So I do... [img] blah blach.php [/image]?
Dark Blaze
27th July 2005, 15:47
So I do... [img] blah blach.php [/image]?
no, you do BLA.php :)
afklead
27th July 2005, 21:28
Then it doesn't work for me.. It jsut comes up as a blank thing..
Hissyfit
27th July 2005, 22:20
same here
Dark Blaze
28th July 2005, 00:36
You mean an image placement with no image showing?? If so, let me know. I think I may have a fix for you considering I managed to fix mine.
afklead
28th July 2005, 00:53
Yes, I do www.ftps1.4t.com/rado.php and it does not work.. Please show me the FIX
Hissyfit
28th July 2005, 00:58
yeah i have the same problem i place the image in my sig but then it just shows up blank
icetray
28th July 2005, 12:06
Ok wait a minute here,just let me check what if what im supposed to do is right:
1.Get a pic and upload it(jpg?)
2.make a [image]picurl[/ image](add to sig area)
3.paste the code given by luck into the sig area?
If this is wrong can someone please provide me with a detailed step by step instruction?
Greatly appreciated,
Thanks Once Again.
luck777jojo
28th July 2005, 12:58
get a pic upload it (.png)
edit the code I pasted and save it in a .php file (sig.php)
upload the .php file
link to the php file http://www.example.com/sig.php
afklead
28th July 2005, 21:21
The code does not work like I said.. Even teh revised one looks like nothing but blank space.
luck777jojo
29th July 2005, 02:36
okay I updated the code in the first post, added some things fixed 1 bug that was probably screwing everything up for you guys (not a bug in the code but a bug in how it got posted on the forums), try the new code.
Dark Blaze
29th July 2005, 10:36
Yeah... the funny thing is that I actually had to get your source directly from your file on the server to see what was wrong and sort it out :D
luck777jojo
29th July 2005, 11:57
meh it isn't really that big of a deal I mean as soon as I tested out the code I put up here and saw the error message poping up i went straight to that line and saw a bunch of spaces which shouldn't have been there.... took me a while to figure out that the forum was doing this because the line was too long so..... as soon as I did I added a space to the place where one can be put without causing errors and.... it worked ;)
also added a third variable for color and size (for the third line of text) ;)
Dark Blaze
29th July 2005, 12:03
always the MPC handyman... lol... Btw, we need a DJ on the radio, wanna get in? ;)
Check your pms in a sec I'm gonna send you something :)
icetray
29th July 2005, 15:31
hmmm....need a php uploader...any sugestions?
Hissyfit
29th July 2005, 17:40
an ftp maybe, i'm still getting errors but I think ive figured out what i did wrong
afklead
30th July 2005, 02:24
www.uploadtemple.com is a good uploader.. But I still can't get it to work lol..
icetray
30th July 2005, 06:45
php is not accepted...haiz
Dark Blaze
30th July 2005, 21:40
hmmm....need a php uploader...any sugestions?
What you need is an FTP Uploader for a server with PHP support so that it can read and understand the script we've given you. There aren't that many free PHP supported servers.
www.uploadtemple.com is a good uploader.. But I still can't get it to work lol..
Regarding Upload Temple, check this which is listed with bold on the main page...
File Types: All file types except for .php,php3,php4,mp3
Max Size per File: 30.00 MB
afklead
30th July 2005, 22:06
Sorry I wasn't really paying attention. Bravehost supports FTP but not php.. So.. we have to pay to get this really cool sig that luck and Dark Blaze made for us?
luck777jojo
30th July 2005, 23:10
http://www.free-webhosts.com/search-webhosts.php?ADV=001000000010000000000000000000000 0000000000
http://www.webhosts4free.com/search.php?ADV=00100000001000000000000000000000000 000001000
http://www.0php.com/free_PHP_hosting.php
http://www.100-best-free-webspace.com/search.php?ADV=10100000001000000000000000000000000 000000001
http://www.free-webspace.org/search.php?ADV=10100000001000000000000000000000000 000000000
remember google is your friend ;)
afklead
30th July 2005, 23:18
Ok, I've Uploaded the things VIA Ftp and yet it still doesn't work..
luck777jojo
30th July 2005, 23:29
Ok, I've Uploaded the things VIA Ftp and yet it still doesn't work..
where did you upload it to via FTP? does the host support php scripts? link me to the file please and also post the code of it here if it still doesn't work.
afklead
30th July 2005, 23:34
<?php
// Ruff Dawg's 'Now Playing Sig w/ Background v. 1.5 May 7, 2004
// Special thanks to the originator, DJ Rampage
// Modded specifically for MPC by luck777jojo
// This image you can call immediately from an html file in the image tag
// (i.e. <img src="sig.php">) easy huh?
Header("Content-type: image/png");
/////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////*Configurables*//////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////
/////////////////////*Background Picture File*////////////////////////
/* Replace "sic_pic.png" with your own
picture file (must be a .png) */
$im = imagecreatefrompng("http://www.freewebs.com/outkast119/radio.png");
/////////////////////////////*Host Information*/////////////////////////////
$host = "shoutcast.mpcforum.com"; // No 'http://' in the host
$port = "8000";
//////////////////////////////////*Text Colors*////////////////////////////////
// text colors are in RGB
$textcolor1 = ImageColorAllocate($im,145,150,161);
$textcolor2 = ImageColorAllocate($im,14,15,16);
$textcolor3 = ImageColorAllocate($im,14,15,16);
////////////////////////////////////*Text Size*/////////////////////////////////
$textsize1 = "4";
$textsize2 = "3";
$textsize3 = "3";
//////////////////////////////*Text Alignment*/////////////////////////////
//X alignment
$x1 = "20";
$x2 = "40";
$x3 = "490";
//Y alignment
$y1 = "175";
$y2 = "25";
$y3 = "25";
///////////////////////////*Offline Message*///////////////////////////////
$offline1 = "MPC Radio Is Currently Offline";
$offline2 = "Please Check Later";
$offline3 = "";
//////////////////////////////////////////////////////////////////////////////////////////////////
/////*DON'T TOUCH THE CODE BELOW UNLESS//////////
///YOU KNOW EXACTALLY WHAT YOU ARE DOING*//
///////////////////////////////////////////////////////////////////////////////////////////////
$fp = fsockopen("$host", $port, &$errno, &$errstr, 30);
if(!$fp) {
$success=2;
}
if($success!=2){ //if connection
fputs($fp,"GET /7.html HTTP/1.0\r\nUser-Agent: XML Getter (Mozilla Compatible)\r\n\r\n");
while(!feof($fp)) {
$page .= fgets($fp, 1000);
}
fclose($fp);
$page = ereg_replace(".*<body>", "", $page); //extract data
$page = ereg_replace("</body>.*", ",", $page); //extract data
$numbers = explode(",",$page);
$currentlisteners=$numbers[0];
$connected=$numbers[1];
if($connected==1)
$wordconnected="yes";
else
$wordconnected="no";
$peaklisteners=$numbers[2];
$maxlisteners=$numbers[3];
$reportedlisteners=$numbers[4];
}
if($success!=2 && $connected==1){
$song=explode("<>" ,$numbers[6]);
$string1= $song[0];
$string2= $song[1];
$string3= "$currentlisteners/$maxlisteners";
}
else {
$string1= $offline1;
$string2= $offline2;
$string3= $offline3;
}
$px = (imagesx($im)-5*strlen($string1))/2;
ImageString ($im,$textsize1,$x1,$y1,$string1,$textcolor1);
$px = (imagesx($im)-5*strlen($string2))/2;
ImageString ($im,$textsize2,$x2,$y2,$string2,$textcolor2);
$px = (imagesx($im)-5*strlen($string3))/2;
ImageString ($im,$textsize3,$x3,$y3,$string3,$textcolor3);
ImagePng($im);
imagedestroy($im);
?>
Dark Blaze
30th July 2005, 23:39
yeah strange it still doesn't work :/
afklead
30th July 2005, 23:41
You know... Maybe you guys can host it on MPC's FTP? I don't know why it's now working maybe it's the
// Ruff Dawg's 'Now Playing Sig w/ Background v. 1.5 May 7, 2004
// Special thanks to the originator, DJ Rampage
// Modded specifically for MPC by luck777jojo
// This image you can call immediately from an html file in the image tag
// (i.e. <img src="sig.php">) easy huh?
at the top?
Any ideas?
hahahaha.. Ever notice that I joined on the 4th of July?
Dark Blaze
31st July 2005, 00:20
afklead did you get my pm? I sent you a working php of your file. I'll test it in a sec on the MPC Server just in case but it should work fine.
afklead
31st July 2005, 00:24
I have my directory at outkast119.t35.com
Dark Blaze
31st July 2005, 00:30
You know... Maybe you guys can host it on MPC's FTP? I don't know why it's now working maybe it's the
// Ruff Dawg's 'Now Playing Sig w/ Background v. 1.5 May 7, 2004
// Special thanks to the originator, DJ Rampage
// Modded specifically for MPC by luck777jojo
// This image you can call immediately from an html file in the image tag
// (i.e. <img src="sig.php">) easy huh?
at the top?
Any ideas?
hahahaha.. Ever notice that I joined on the 4th of July?
I wish we could host it for you, but if we did then everyone would want to do the same :(
afklead
31st July 2005, 00:32
afklead did you get my pm? I sent you a working php of your file. I'll test it in a sec on the MPC Server just in case but it should work fine.
Yea.. I get an error which I send back to you...
I am all out of ideas.. If somehting doesn't come up soon then I am gonna scrap this project
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.