Sign in to follow this  
Followers 0
EchoNoise

Parsing HTML into Image

15 posts in this topic

Follow my guide here:

http://www.msfn.org/board/index.php?showtopic=47730

then define the variable:

$status = file_get_contents("http://progressquest.com/robot.php?name=undeadsoldier&realm=Expodrine&style=pretty");

and output it somewhere in the image like so:

ImageTTFText ($image, 8, 0, 10, 17, $white, $font, $status);

Should work. :) It's working in my sig below... See the little green (or red) dot on the top right? That's basically giving my computer's online status by grabbing it from the text output at the Hamachi status site. :)

Edit: I just realized the file_get_contents will not work because it will grab the entire HTML of that page... Working on a solution... ;)

Edit2:

Here we go!!!

sig.jpg

<?php

Header ('Content-type: image/jpeg');
Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');
Header('Pragma: no-cache');

// create the image
$image = imagecreatefromjpeg("background.jpg");

// set the colors
$black = imagecolorallocate($image, 0, 0, 0);
$blue = imagecolorallocate($image, 63, 70, 88);
$red = imagecolorallocate($image, 255, 0, 0);

// set the font
$font = 'verdana.ttf';
$size = 8;

// grab status
$grab = file_get_contents("http://progressquest.com/robot.php?name=undeadsoldier&realm=Expodrine");

$split = preg_split("/[\n]+/", $grab);

$line1 = $split[0] . " of Expodrine (" . $split[4] . ")";
$line2 = "Level " . $split[3] . " " . $split[1] . " " . $split[2];
$line3 = $split[5] . " / " . $split[6] . " / " . $split[7];

$combine = $line1 . "\n" . $line2 . "\n" . $line3;

// put text together
ImageTTFText($image, $size, 0, 8, 16, $black, $font, $combine);

// output and destroy
imagejpeg($image);
imagedestroy($image);

?>

This is the background image used:

background.jpg

And the contents of the .htaccess file:

Options All -Indexes

<Files sig.jpg>
SetHandler application/x-httpd-php
</Files>

I used the Verdana font because I had already saved it somewhere on my machine.

Please try to host this on your own server if you're going to use it since I am now hosting it on one that isn't very reliable and because I use it for other things that usually slow it down (compiling/home music sharing/etc.)

0

Share this post


Link to post
Share on other sites

EDIT: yay!

Edited by undeadsoldier
0

Share this post


Link to post
Share on other sites
Its not working unfortunately, thanks for the info though :)

*starts to pull hair out*

:lol:

Never mind... :P

I hope that's what you wanted. :)

Also, you might have to play around with it a bit as it is too big, according to forum rules, to be used as a sig.

Edited by gamehead200
0

Share this post


Link to post
Share on other sites

It works when I test it on my own server :)

But when I go and upload it, it gives me a "Error 500"

I'm guessing its something to do with the .htaccess file...

My host is on linux :)

0

Share this post


Link to post
Share on other sites
It works when I test it on my own server :)

But when I go and upload it, it gives me a "Error 500"

I'm guessing its something to do with the .htaccess file...

My host is on linux :)

You might have to put this instead in your .htaccess file:

Options All -Indexes

<Files sig.jpg>
AddHandler application/x-httpd-php .jpg
</Files>

OR

You might not have GD enabled.

0

Share this post


Link to post
Share on other sites

GD is enabled, I've talked to the host admin people

I'll try that method above, and i'll let you know...

EDIT: nope... It doesn't seem to work... Unlesssssssssss.. *idea* (taking out "options")

Taking out the options tag, just gives me the result of whats in the address bar... Which is very odd...

Edited by undeadsoldier
0

Share this post


Link to post
Share on other sites
GD is enabled, I've talked to the host admin people

I'll try that method above, and i'll let you know...

EDIT: nope... It doesn't seem to work... Unlesssssssssss.. *idea* (taking out "options")

Taking out the options tag, just gives me the result of whats in the address bar... Which is very odd...

Hehe... This has happened to me before... Did you by any chance rename the sig.jpg file and forget to change it in the .htaccess file? :unsure:

0

Share this post


Link to post
Share on other sites

Nope... I have not changed anything at all

0

Share this post


Link to post
Share on other sites
Nope... I have not changed anything at all

Check your error log? :}

0

Share this post


Link to post
Share on other sites

*cries*... :lol:

I'll see what I can do from here, thanks for your help man :) !!

0

Share this post


Link to post
Share on other sites

I just got informed that file_get_contents is not supported :(

So is there anywhere I can put my dynamic signature that IS supported?

I have edited Gameheads files a bit, I just need somebody to upload and I'll be as good to go :)

Edited by undeadsoldier
0

Share this post


Link to post
Share on other sites
I just got informed that file_get_contents is not supported :(

So is there anywhere I can put my dynamic signature that IS supported?

I have edited Gameheads files a bit, I just need somebody to upload and I'll be as good to go :)

What version of PHP does your host have? He should upgrade to at least PHP 4.4.2 for this to work, if not, PHP 5.1.4.

0

Share this post


Link to post
Share on other sites

Ah, some new code generates this :D:

sig2.jpg

Try the following out:

<?php
Header ('Content-type: image/jpeg');Header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');Header('Expires: Thu, 19 Nov 1981 08:52:00 GMT');Header('Pragma: no-cache');
// create the image$image = imagecreatefromjpeg("background.jpg");
// set the colors$black = imagecolorallocate($image, 0, 0, 0);
// set the font$font = 'verdana.ttf';$size = 8;
// grab status and split it up$handle = @fopen("http://progressquest.com/robot.php?name=undeadsoldier&realm=Expodrine", "r");if($handle){		for( $i = 0; !feof($handle); $i++ ){				$get = fgets($handle, 4096);				$split[$i] = trim($get, "\n");		}		fclose($handle);}
$line1 = $split[0] . " of Expodrine (" . $split[4] . ")";$line2 = "Level " . $split[3] . " " . $split[1] . " " . $split[2];$line3 = $split[5] . " / " . $split[6] . " / " . $split[7];
$combine = $line1 . "\n" . $line2 . "\n" . $line3;
// put text togetherImageTTFText($image, $size, 0, 8, 16, $black, $font, $combine);
// output and destroyimagejpeg($image);imagedestroy($image);
?>
0

Share this post


Link to post
Share on other sites

My host have PHP 5.1.4 but they have disabled things for "security" purposes.... <_<

I made these changes, not major, but yeah...

<?php

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

$image = imagecreatefrompng("bck.png");
$colour = imagecolorallocate($image, 0, 0, 0);
$font = 'verdana.ttf';
$size = 8;

$grab = file_get_contents("http://progressquest.com/robot.php?name=undeadsoldier&realm=Expodrine");

$split = preg_split("/[\n]+/", $grab);

$line1 = "Name: " . $split[0] . " of expodrine (" . $split[4] . ")";
$line2 = "Level: " . $split[3];
$line3 = "Class: " . $split[1] ." ". $split[2];
$line4 = "Prized Item: " . $split[5];
$line5 = "Specialty: " . $split[6];
$line6 = "Prime Stat: " . $split[7];

$combine = $line1 . "\n" . $line2 . "\n" . $line3 . "\n" . $line4 . "\n" . $line5 . "\n" . $line6;

ImageTTFText($image, $size, 0, 8, 16, $colour, $font, $combine);

imagepng($image);
imagedestroy($image);

?>

It produces this:

sig.png

What do you think?

And I know I shouldn't ask this, but would it be ok if you could host it gamehead? Or know of a place where I can host it? Thanks :)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.