How to get your signature to randomize.
I do not know where to put this, so I will stash it here for now. I have been asked a lot on how I get my signature to randomize like it does, so I will tell you.
First - You need access to a web server with PHP support. This is where you will put all the signatures, and the PHP file to have it all randomize. Upload your images into a folder that will be your randomizing set. [Example - website.com/signature]
Second - Create a PHP file with any name you want, I just went with a simple "image.php" And uploaded it to the folder than images images are in. [Only have images you want randomized in this folder.]
Third - The following code is what should be in the PHP file.
PHP Code:
<?php
$folder = '.';
$extList = array();
$extList['gif'] = 'image/gif';
$extList['jpg'] = 'image/jpeg';
$extList['jpeg'] = 'image/jpeg';
$extList['png'] = 'image/png';
$img = null;
if (substr($folder,-1) != '/') {
$folder = $folder.'/';
}
if (isset($_GET['img'])) {
$imageInfo = pathinfo($_GET['img']);
if (
isset( $extList[ strtolower( $imageInfo['extension'] ) ] ) &&
file_exists( $folder.$imageInfo['basename'] )
) {
$img = $folder.$imageInfo['basename'];
}
} else {
$fileList = array();
$handle = opendir($folder);
while ( false !== ( $file = readdir($handle) ) ) {
$file_info = pathinfo($file);
if (
isset( $extList[ strtolower( $file_info['extension'] ) ] )
) {
$fileList[] = $file;
}
}
closedir($handle);
if (count($fileList) > 0) {
$imageNumber = time() % count($fileList);
$img = $folder.$fileList[$imageNumber];
}
}
if ($img!=null) {
$imageInfo = pathinfo($img);
$contentType = 'Content-type: '.$extList[ $imageInfo['extension'] ];
header ($contentType);
readfile($img);
} else {
if ( function_exists('imagecreate') ) {
header ("Content-type: image/png");
$im = @imagecreate (100, 100)
or die ("Cannot initialize new GD image stream");
$background_color = imagecolorallocate ($im, 255, 255, 255);
$text_color = imagecolorallocate ($im, 0,0,0);
imagestring ($im, 2, 5, 5, "IMAGE ERROR", $text_color);
imagepng ($im);
imagedestroy($im);
}
}
?>
Forth - Now that the PHP file is done, and all the images are uploaded, how to put this in your signature. Under Signature, put the image tags, and inside of that put the link to the PHP file, as if it was an image.
example -
HTML Code:
[IMG]http://www.website.com/signature/image.php[/IMG]
And you are done. If this is on a website that doesn't allow PHP in a signature like this, just add "/image.jpg" to the end to disguise it as a normal JPEG picture.
example -
HTML Code:
[IMG]http://www.website.com/signature/image.php/image.jpg[/IMG]