View Single Post
Old 09-25-2005, 06:41 PM   #1
mcfly
teh ownji

mcfly's Avatar

Status: Offline
Join Date: Sep 2004
Member ID: 18305
Location: Germany
Age: 24
Posts: 1,104
Dynamic Image Tutorial - no gif crap
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.
click here and press F5 a couple of times



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>[/code]
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]);
?>[/code]
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]
  Reply With Quote