PDA

View Full Version : MSN signature (XML + GD)



Calon
13-01-2009, 05:23 AM
Hello, I was bored and experimenting with GD as I'm not too good with it, so I made this:



<?php
$sxe = new SimpleXMLElement('http://web2live.org/files/5653/stats.xml', NULL, TRUE);

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, 'Volter__28Goldfish_29.ttf', 'WLM: ' .$sxe->n .' is ' . $sxe->s . ' ([email protected])' );

imagepng($im);
imagedestroy($im);
?>


You'll need to get somewhere to generate the XML file, I used: web2live.org

IntaMedia
13-01-2009, 07:19 PM
they/we need the font aswell...

Calon
13-01-2009, 07:20 PM
they/we need the font aswell...
www.dafont.com and search Volter.

efq
13-01-2009, 07:23 PM
I need this but does someone wanna guide me in-depth for rep+ :P?

Calon
13-01-2009, 07:32 PM
I need this but does someone wanna guide me in-depth for rep+ :P?
Well..



<?php
$sxe = new SimpleXMLElement('http://web2live.org/files/5653/stats.xml', NULL, TRUE);

$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // HAS TO BE IN THE PATH OF THIS FILE, OR DEFINE THE PATH!
$message = 'WLM: ' .$sxe->n .' is ' . $sxe->s . ' ('.$email.')';

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);
?>


Quick revision to the code, more user friendly.

Goto that web2live site, install the msgplus plugin that retrieves your MSN information, "Get signature codes" -> "Advanced" -> Copy link of the XML file, update the one I allocated -> Woo, you're off.

You can define other things instead of MSN name, like song:



<?php
$sxe = new SimpleXMLElement('http://web2live.org/files/5653/stats.xml', NULL, TRUE);

$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // HAS TO BE IN THE PATH OF THIS FILE, OR DEFINE THE PATH!
$message = 'WLM: ' .$sxe->n .' is ' . $sxe->s . ' and is listening too: ' . $sxe->np;

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);
?>


(but you'll have to fiddle with the spacing etc..)

efq
13-01-2009, 07:33 PM
Well..



<?php
$sxe = new SimpleXMLElement('http://web2live.org/files/5653/stats.xml', NULL, TRUE);

$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // HAS TO BE IN THE PATH OF THIS FILE, OR DEFINE THE PATH!
$message = 'WLM: ' .$sxe->n .' is ' . $sxe->s . ' ('.$email.')';

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);
?>


Quick revision to the code, more user friendly.

Goto that web2live site, install the msgplus plugin that retrieves your MSN information, "Get signature codes" -> "Advanced" -> Copy link of the XML file, update the one I allocated -> Woo, you're off.

You can define other things instead of MSN name, like song:



<?php
$sxe = new SimpleXMLElement('http://web2live.org/files/5653/stats.xml', NULL, TRUE);

$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // HAS TO BE IN THE PATH OF THIS FILE, OR DEFINE THE PATH!
$message = 'WLM: ' .$sxe->n .' is ' . $sxe->s . ' and is listening too: ' . $sxe->np;

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);
?>


(but you'll have to fiddle with the spacing etc..)
Thanks alot, you should pass your trial!

Calon
13-01-2009, 07:34 PM
Thanks alot, you should pass your trial!
Haha, thanks (I suck at detecting sarcasm).

Cushioned
13-01-2009, 11:40 PM
Nice release Calon. Hopefully you pass the trial!

Source
14-01-2009, 01:08 PM
<?php

//basic configuration here
$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // has to be relative to the php file, or define full path

//grab the XML
$xml = @file_get_contents( "http://web2live.org/files/5653/stats.xml" );

if( $xml ){

$sxe = new SimpleXMLElement( $xml );

$message = "WLM Status: {$sxe->n} is currently {$sxe->s} ( {$email} ).";



} else {

$message = "Sorry, there was an error in creating the status image.";

}

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);

?>



Wouldn't that be better? Note I did it quickly so sorry for errors.

Calon
14-01-2009, 02:34 PM
<?php

//basic configuration here
$email = '[email protected]';
$font = 'Volter__28Goldfish_29.ttf'; // has to be relative to the php file, or define full path

//grab the XML
$xml = @file_get_contents( "http://web2live.org/files/5653/stats.xml" );

if( $xml ){

$sxe = new SimpleXMLElement( $xml );

$message = "WLM Status: {$sxe->n} is currently {$sxe->s} ( {$email} ).";



} else {

$message = "Sorry, there was an error in creating the status image.";

}

header('Content-type: image/png');

$im = imagecreatetruecolor(400, 30);

$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);

imagettftext( $im, 7, 0, 10, 20, $black, $font, $message );

imagepng($im);
imagedestroy($im);

?>



Wouldn't that be better? Note I did it quickly so sorry for errors.

I didn't bother with if statements, as it's not wanting a user's input, it's the owner of the file uploader who will process the file, so I thought there would be no point.

I prefer my code, as you've just added more, which isn't really needed.

As they say, "speed is more than beauty".

Meti
15-01-2009, 04:58 PM
Nice of you doing this Calon.
We all know you're good at coding, and I wish you all the best working for Habbox.

Want to hide these adverts? Register an account for free!