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.
-----
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!
NOTE: I have attached a sample mysig.jpg and .htaccess file.
Attached File(s)
-
sample.zip (867bytes)
Number of downloads: 674



Help

Back to top










