Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account



Photo

How to make a dynamic signature (IP sig)

- - - - -

  • Please log in to reply
74 replies to this topic

#1
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
EDIT:

For everyone's benefit, I have released my original "Jeremy" signature (i.e., the source code, graphics, etc.) under a GPL license. Use it as you wish. :) Grab it here!

-----

For this tutorial, the server you will be using MUST have Apache and the GD plugin for PHP installed. You must have some experience using PHP. We will start by opening Notepad (or your favourite text editor) and creating a new file called .htaccess. The name of the signature we will be using will be mysig.jpg.

In the .htaccess file, put the following:

<Files mysig.jpg>
ForceType application/x-httpd-php
</Files>

This will tell the server to parse the mysig.jpg file as a PHP file. Save this file in a folder where you will also place the other files.

Now, open your text editor and create your signature file, mysig.jpg. Put the following in it:

<?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 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 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 = '/path/to/your/ttf/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);

?>

If you don't want the server to create the image for you, you can always create an image in Photoshop and use it as your background.

<?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 = 240;
$img_height = 25;

// 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 = '/path/to/your/ttf/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);

?>

Those are the basics. You can do so much with PHP!

Want to use a hit counter for your sig? Use this piecee of code in your signature:

// counter - CHMOD your counter file to 777
$viewss = file("/path/to/your/counter/file/views.txt");
$views = $viewss[0]; $views++;
$fp = fopen("/path/to/your/counter/file/views.txt", "w");
fwrite($fp, $views);
fclose($fp);
$counter = "$views people viewed this since 11/5/03!";

Want a different message to appear everytime your sig is loaded? Use this in your code:

// set quote file
$quotes = file('quotes.txt');
$quote = array_rand($quotes);

$joke = wordwrap($quotes[$quote], 60, "\n", 1);
$joke = explode("\n", $joke);

// this part goes where the rest of the output is done
for($i=0; $i<count($joke); $i++) {
ImageTTFText ($image, 8, 0, 14, (23+($i*15)), $white, $font, $joke[$i]);
}

Want to output someone's browser, IP, and resolved IP? Use this in your code:

// get IP and resolve IP
$ip = $REMOTE_ADDR;
$resolved = gethostbyaddr ($REMOTE_ADDR);

// check for non resolve of IP and rip domain if resolved
if ($resolved == $ip) {
$isp = ".. Can't Resolve IP";
}
else
{
$str = preg_split("/\./", $resolved);
$i = count($str);
$x = $i - 1;
$n = $i - 2;
$isp = $str[$n] . "." . $str[$x];
}

// Simple OS Detection
$os = $HTTP_USER_AGENT;
$oslist = Array (

// Windows
"Win|Windows",
"Win16|Windows",
"Win95|Windows 95",
"Win98|Windows 98",
"WinME|Windows ME",
"Win32|Windows",
"WinNT|Windows NT",
"Windows 3.1|Windows 3.1",
"Windows 95|Windows 95",
"Windows CE|Windows CE",
"Windows 98|Windows 98",
"Windows ME|Windows ME",
"Windows NT|Windows NT",
"Windows NT 5.0|Windows 2000",
"Windows NT 5.1|Windows XP",

// Macintosh
"Mac_68000|MacOS m68K",
"Mac_68K|MacOS m68K",
"Mac_PowerPC|MacOS PPC",
"Mac_PPC|MacOS PPC",
"Macintosh|MacOS",

// Unices
"X11|UNIX",
"BSD|BSD",
"SunOS|SunOS",
"IRIX|IRIX",
"HP-UX|HP-UX",
"AIX|AIX",
"QNX|QNX",
"SCO_SV|SCO UNIX",
"FreeBSD|FreeBSD",
"NetBSD|NetBSD",

// Linux
"Linux|Linux",
"Debian|Debian GNU/Linux",

// Other
"BeOS|BeOS",
"OS/2|OS/2",
"AmigaOS|AmigaOS",

);

foreach ($oslist as $osnow) {
$osnow = explode ("|", $osnow);
if (eregi ($osnow[0], $os)) {
$endos = $osnow[1];
$check = "No";
} elseif ($check != "No") {
$endos = "Unknown";
}
}

/*
to output the OS, use $endos
to output the IP, use $ip
to output the resolved IP, use $resolved
*/

Want to output someone's browser? Use this code:

//browser type
   $agent = $HTTP_USER_AGENT;
   if ( strstr($agent, "MSIE 5") ) $browser = "using IE 5";
   elseif ( strstr($agent, "MSIE 6") ) $browser = "using IE 6";
   elseif ( strstr($agent, "MSIE 4") ) $browser = "using IE 4";
   elseif ( strstr($agent, "Firebird") ) $browser = "using Firebird";
   elseif ( strstr($agent, "Safari") ) $browser = "using Safari";
   elseif ( strstr($agent, "Mozilla/5") ) $browser = "using Mozilla/Netscape 5";
   elseif ( strstr($agent, "Mozilla/6") ) $browser = "using Netscape 6";
   elseif ( strstr($agent, "Mozilla/4") ) $browser = "using Netscape 4";
   elseif ( strstr($agent, "Opera") ) $browser = "using Opera";
   else $browser = "";

// to output the browser, use $browser

Want to use a different background everytime? Use this code:

// random background

$random_image = array("",
                   "bg1.jpg",
                   "bg2.jpg",
                   "bg3.jpg",
                   "bg4.jpg");

srand ((double) microtime() * 1000000);
$rnd = rand(1,4);

// create the image
$image = imagecreatefromjpeg($random_image[$rnd]);

Good luck to all coders! Any comments, suggestions, and questions are appreciated! :)

:thumbup

NOTE: I have attached a sample mysig.jpg and .htaccess file.

Attached Files




How to remove advertisement from MSFN

#2
XPerties

XPerties

    MSFN OG Senior

  • Patrons
  • 2,994 posts
  • Joined 18-August 01
  • OS:Windows 7 x64
  • Country: Country Flag
And if anyone makes any and would like to join Bob's family located here http://www.whatismy.net I'll add them to the site and list them on the forums here http://www.whatismy....ewtopic.php?t=2 with full credit to you of course.



You want some Glock with that?
★ :::: Xbox Live GamerTag = ScreamingSkulls


#3
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
Believe it or not, Bob and his friends were made with pretty much everything on this page. Even Jeremy, the guy in my sig. :) Right, Chris?

#4
XPerties

XPerties

    MSFN OG Senior

  • Patrons
  • 2,994 posts
  • Joined 18-August 01
  • OS:Windows 7 x64
  • Country: Country Flag
Yes Yes Yes oh might master, gamehead200. I learned form you and you are the original master of Bob and his entire family.



You want some Glock with that?
★ :::: Xbox Live GamerTag = ScreamingSkulls


#5
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05
Ok, first attempt, and so far no go.

The .htaccess file is inside the Signature folder, the file as you can tell is named mysig.jpg

Now I have GD plugin and the latest apache... I know this because I use GD for another part of my website... and it works perfectly...

http://www.cyberpawz...ature/mysig.jpg

As you can tell below where I placed the image tags nothing shows up... any help would be appreciated. I changed the font to

$font = '/Volumes/Server/htdocs/Signature/Caleu.ttf';

Now don't forget I'm on a Mac, but as far as I can tell if I put the font in the same folder as the signature is in, and just cut that down to:

$font = /Caleu.tiff

Wouldn't that work as well, or does the font need to be active in the system?


Posted Image

#6
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
OK, when I opened up the link in IE, I realized that all of your code was showing. The server is not parsing the file as a PHP file either because there's a configuration problem or because you did not put the .htaccess file.

If you go into your terminal and ls the Signature folder, what files show up? :}

Most of the time, it doesn't matter how you tell the server where your font file is... But, its usually better to include the whole path... :)

BTW, open up your mysig.jpg file and make sure you save it as just Text. You have random letters with accents everywhere...

Example:
$blue Ê= imagecolorallocate($image, 0, 0, 255);

Try using the sample files I just uploaded. :)

#7
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

OK, when I opened up the link in IE, I realized that all of your code was showing.  The server is not parsing the file as a PHP file either because there's a configuration problem or because you did not put the .htaccess file.

If you go into your terminal and ls the Signature folder, what files show up? :}

Most of the time, it doesn't matter how you tell the server where your font file is... But, its usually better to include the whole path... :)

BTW, open up your mysig.jpg file and make sure you save it as just Text.  You have random letters with accents everywhere...

Example:

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

Try using the sample files I just uploaded. :)

<{POST_SNAPBACK}>


I copy and pasted the information above... dang it...

and the .htaccess file is there, I know it is cause I can edit it...

I'll try again.

#8
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05
Still not working, hell if I know what is going on. I am using 10.4 for the Mac OS, when I save this I'm using BBEdit Light...

Unless bbedit light 6.1.2 is the reason for the bad code I'm clueless...

And for the record if I go through the terminal and look at the folder's innards... everything is there.

At least all that should be.

#9
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

Still not working, hell if I know what is going on.  I am using 10.4 for the Mac OS, when I save this I'm using BBEdit Light...

Unless bbedit light 6.1.2 is the reason for the bad code I'm clueless...

And for the record if I go through the terminal and look at the folder's innards... everything is there.

At least all that should be.

<{POST_SNAPBACK}>


OK... Do the following:

Create a PHP file called phpinfo.php and put the following code in it:

<?php phpinfo(); ?>

Then post the link to this PHP file so I can take a look at what it outputs. :)

#10
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

Still not working, hell if I know what is going on.  I am using 10.4 for the Mac OS, when I save this I'm using BBEdit Light...

Unless bbedit light 6.1.2 is the reason for the bad code I'm clueless...

And for the record if I go through the terminal and look at the folder's innards... everything is there.

At least all that should be.

<{POST_SNAPBACK}>


OK... Do the following:

Create a PHP file called phpinfo.php and put the following code in it:

<?php phpinfo(); ?>

Then post the link to this PHP file so I can take a look at what it outputs. :)

<{POST_SNAPBACK}>



already had it... www.cyberpawz.com/test.php

#11
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

already had it... www.cyberpawz.com/test.php

<{POST_SNAPBACK}>


I don't see anything wrong with your configuration... Try getting rid of those weird characters in your code... :wacko:

#12
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

already had it... www.cyberpawz.com/test.php

<{POST_SNAPBACK}>


I don't see anything wrong with your configuration... Try getting rid of those weird characters in your code... :wacko:

<{POST_SNAPBACK}>


The issue is that what I am working on the code on the computer, there are no errors... it's after it's saved... which I don't understand how since I am saving it as a generic text format...

I'm lost, and somewhat confused on what this is happening at all...

This is what I see when I edit and save it as a pure txt format...

Posted Image

#13
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
No wonder its not working! You should have your font file set as:

$font = '/Volumes/Server/htdocs/Signature/Caleu.ttf';

And not:

/Volumes/Server/htdocs/Signature/Caleu.ttf


#14
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

No wonder its not working!  You should have your font file set as:

$font = '/Volumes/Server/htdocs/Signature/Caleu.ttf';

And not:

/Volumes/Server/htdocs/Signature/Caleu.ttf

<{POST_SNAPBACK}>



Dang I thought I fixed that... hmm let me try something...

#15
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05
Ok, no go... and I downloaded the file you had on the first page to see if I made a mistake or no. And so far no go.

Posted Image

This is the code in it:

<?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 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 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 = '/Volumes/Server/htdocs/Signature/TAGSXTREME.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);

?>



#16
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
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:

#17
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

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:

<{POST_SNAPBACK}>



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

?>



#18
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

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

?>

<{POST_SNAPBACK}>



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


#19
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05
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...

#20
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag

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...

<{POST_SNAPBACK}>


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

#21
XPerties

XPerties

    MSFN OG Senior

  • Patrons
  • 2,994 posts
  • Joined 18-August 01
  • OS:Windows 7 x64
  • Country: Country Flag
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
===================



You want some Glock with that?
★ :::: Xbox Live GamerTag = ScreamingSkulls


#22
Cyberpawz

Cyberpawz

    Newbie

  • Member
  • 21 posts
  • Joined 25-May 05

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
===================

<{POST_SNAPBACK}>



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...

#23
tj007s13

tj007s13

    Newbie

  • Member
  • 23 posts
  • Joined 06-March 05
i made one...

Posted Image

#24
tj007s13

tj007s13

    Newbie

  • Member
  • 23 posts
  • Joined 06-March 05
now...u said screen resolution could only be done by incorporating javascript in right? How would i go about doing that?

#25
gamehead200

gamehead200

    SEARCH!!! SEARCH!!!

  • Super Moderator
  • 7,039 posts
  • Joined 02-September 02
  • OS:Windows 7 x64
  • Country: Country Flag
You can't really put someone's resolution in a signature without having them go to another site to store it in a cookie. :)




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users