Jump to content

How to make a dynamic signature (IP sig)


gamehead200

Recommended Posts

OK, I want you to try two more things...

First, put this in:

// get IP
$ip = $_SERVER['REMOTE_ADDR'];

$text = "Your IP address is $ip!";

// replace this part
ImageTTFText ($image, 8, 0, 10, 17, $white, $font, $text);

If that doesn't work, change your font to just the font name.

Example:

$font = 'verdana.ttf';

If that doesn't work, well, I really don't know what will... :wacko:

Link to comment
Share on other sites


OK, I want you to try two more things...

First, put this in:

// get IP
$ip = $_SERVER['REMOTE_ADDR'];

$text = "Your IP address is $ip!";

// replace this part
ImageTTFText ($image, 8, 0, 10, 17, $white, $font, $text);

If that doesn't work, change your font to just the font name. 

Example:

$font = 'verdana.ttf';

If that doesn't work, well, I really don't know what will... :wacko:

Should it look like this?

<?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');

// set the dimensions

$img_width = 240;

$img_height = 25;

// create the image

$image = imagecreate($img_width, $img_height);

// set the background colour

// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

imagefilledrectangle($image, 0, 0, $img_width, $img_height, $cool);

// set the font and print text

$font = TAGSXTREME.TTF;

// get IP

$ip = $_SERVER['REMOTE_ADDR'];

$text = "Your IP address is $ip!";

// replace this part

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

// the above will display your IP address

// set the colours

$cool  = imagecolorallocate($image, 81, 86, 96);

$black = imagecolorallocate($image, 0, 0, 0);

$white = imagecolorallocate($image, 255, 255, 255);

$red  = imagecolorallocate($image, 255, 0, 0);

$grey  = imagecolorallocate($image, 204, 204, 204);

$green = imagecolorallocate($image, 206, 129, 18);

$blue  = imagecolorallocate($image, 0, 0, 255);

// output and destroy

imagepng($image);

imagedestroy($image);

?>

Link to comment
Share on other sites

Should it look like this?
<?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');

// set the dimensions

$img_width = 240;

$img_height = 25;

// create the image

$image = imagecreate($img_width, $img_height);

// set the background colour

// number or is top left pixel x, top left pixel y, bottom right pixel x, bottom right pixel y

imagefilledrectangle($image, 0, 0, $img_width, $img_height, $cool);

// set the font and print text

$font = TAGSXTREME.TTF;

// get IP

$ip = $_SERVER['REMOTE_ADDR'];

$text = "Your IP address is $ip!";

// replace this part

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

// the above will display your IP address

// set the colours

$cool  = imagecolorallocate($image, 81, 86, 96);

$black = imagecolorallocate($image, 0, 0, 0);

$white = imagecolorallocate($image, 255, 255, 255);

$red  = imagecolorallocate($image, 255, 0, 0);

$grey  = imagecolorallocate($image, 204, 204, 204);

$green = imagecolorallocate($image, 206, 129, 18);

$blue  = imagecolorallocate($image, 0, 0, 255);

// output and destroy

imagepng($image);

imagedestroy($image);

?>

Just move the following up to before it says "set background colour":

// set the colours
$cool  = imagecolorallocate($image, 81, 86, 96);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red  = imagecolorallocate($image, 255, 0, 0);
$grey  = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 206, 129, 18);
$blue  = imagecolorallocate($image, 0, 0, 255);

Link to comment
Share on other sites

Still no go... can you try the code itself, so to see if it actually works?

I'm getting frustrated here, and there should be no reason why this isn't working...

The code is working fine on my machine... I will even start my Mac's webserver to see if its a Mac problem... BRB...

Link to comment
Share on other sites

If I might add, the server you are on has register_globals=off which might be causing an issue. It did for a few clients of mine. Here is a walk around to make sure it isn't....

===================

[1] Within your account in public_html folder or the directory where the script is no longer working you may find a .htaccess. If not you may need to create a .htaccess file.

[2] Open this file up or create it and add:

php_value register_globals 1

===================

Link to comment
Share on other sites

If I might add, the server you are on has register_globals=off which might be causing an issue. It did for a few clients of mine. Here is a walk around to make sure it isn't....

===================

[1] Within your account in public_html folder or the directory where the script is no longer working you may find a .htaccess. If not you may need to create a .htaccess file.

[2] Open this file up or create it and add:

php_value register_globals 1

===================

No go. I just tried this on another site, to post the .jpg as just that, and it's not being parsed right at all...

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

I have verys trange problem, when I have created my sig. It works perfectly on my test server(with Appserv installed). But when I put it on my host, it the forced me to download the image instead of showing the image. With an error inside saying that

"<b>Fatal error</b>: Call to undefined function: imagettftext() in <b>/usr/local/xxx/home/vhosts/xxx.com/httpdocs/sig/test.jpg</b> on line <b>133</b><br />"

Link to comment
Share on other sites

  • 2 weeks later...

mysig.jpg

I tried this tutorial but cant get it to work....

When i used the zip files all i got was a red x where pic should be,so tried with my own graphic but no joy.....

My sig

Heres my code,

<?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 using your own background
$image = imagecreatefromjpeg("background.jpg");

// dimensions of the image used
$img_width = 380;
$img_height = 50;

// set the colours
$cool  = imagecolorallocate($image, 81, 86, 96);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
$red   = imagecolorallocate($image, 255, 0, 0);
$grey  = imagecolorallocate($image, 204, 204, 204);
$green = imagecolorallocate($image, 206, 129, 18);
$blue  = imagecolorallocate($image, 0, 0, 255);

// set the font and print text
$font = 'verdana.ttf';

// now i will create a line with font size 8, with no angle, 10 pixels to the right, and 17 pixels down
ImageTTFText ($image, 8, 0, 10, 17, $white, $font, "Your IP Address is... ".$REMOTE_ADDR);

// the above will display your IP address

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

?>

Do you just upload the fonts from your windows fonts folder?

Link to comment
Share on other sites

mysig.jpg

I tried this tutorial but cant get it to work....

When i used the zip files all i got was a red x where pic should be,so tried with my own graphic but no joy.....

My sig

Heres my code,

[code here]

Do you just upload the fonts from your windows fonts folder?

The erroryou are getting now I used to get until I setup .htaccess correctly :P

Pretty simple to do when you have it setup right (I killed my host setting up GD2 not knowing I already had it installed :lol: )

http://www.psychoman.co.nr/test/mysig.png

;):P

Link to comment
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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...