Dynamic Image Tutorial - no gif crap

Sep 10, 2004
1,069
0
0
35
Germany
#1
so i had some people asking me how my sig works and i thought i should write a little tutorial.

a single signature was a little plain for me and *.gif was not an option because it sucks (go browse gmfs and you'll notice)

my version will bring up a different picture with every load. press f5 several times and watch the changes to my sig:




first you need some webspace that can handle php and altering of the .htaccess file.
then create some pics (or choose some you already have)

as a bonus (and because i just cant do anything in a "normal" way) i split my signature in 3 pieces. that way i can have 3 seperate hyperlinks plus there are more overall sig combinations.
i created a template (the yellow frame) and can just put whatever picture i like in there


now comes the tricky part.
first create a file called ".htaccess" and paste the following into it
Code:
<Files signature.jpg>
        ForceType application/x-httpd-php
</Files>
this makes sure, that the file "signature.jpg" is handled as if it were a simple *.php file

now create a file called "signature.jpg" (or whatever else you like, but alter the .htaccess file accordingly) and paste:
Code:
<?php

$images = array(
"./image1.jpg",
"./image2.gif",
"./image3.png",
);


//leave everything below this alone
$images_total = count($images);
$mictime = microtime();
$mictime = explode(' ', $mictime);
$mictime = $mictime[1] + $mictime[0];
srand($mictime);

$random = rand(0, ($images_total - 1));

$content_type = "";

if (strtolower(substr($images[$random], -3)) == "gif")
{
	$content_type = "image/gif";
} elseif (strtolower(substr($images[$random], -3)) == "png") {
	$content_type = "image/png";
} elseif (strtolower(substr($images[$random], -3)) == "jpg" || strtolower(substr($images[$random], -4)) == "jpeg") {
	$content_type = "image/jpeg";
} else {
	// Error...
	exit();
}

@header("Expires: Mon, 12 Feb 1992 12:00:00 GMT");
@header("Cache-Control: no-cache, must-revalidate");
@header("Pragma: no-cache");
@header("Content-Type: ".$content_type);
@readfile($images[$random]);
?>
Insert the names of your images for "image1.jpg" and so on. You can add as many as you want (i have a lot :>).

After that just upload in the desired online-webspace and link to the "signature.jpg" file
img]http://your.webspace.provider/blabla/signature.jpg[/img]
 
Last edited by a moderator:
Sep 26, 2005
284
0
0
Lafayette, LA
#3
Re: Dynamic Image Tutorial - no gif crap

is there any place i can get free webspace that will actually work with this FTP? im too cheap to buy a domain, because all i would be using it for is a sig.

edit: nevermind i figured it out
 
Last edited: