Random Signature Generator:
For this tutorial I will simply show you a few ways to do each part and put one way together for you. It will be a simple random signature generator. First of all you will need some signatures I will be using these listed below. Something to note remember is that the default forum sig: 400x100
Now to start off we need to be able to find them when we need them we can either put them into an array or put them into a local directory and scan for them.
Code:<?PHP
//array of images
$sig[] = "http://i44.tinypic.com/9fqwb9.gif";
$sig[] = "http://i44.tinypic.com/ip4f8m.gif";
$sig[] = "http://i41.tinypic.com/2d5t1t.gif";Now we should all have an array of $sigs! Now to display or not to display - that is the question!Code:$files = scandir("/homepages/blainesch/htdocs/signatures/");
$ext = "gif"; //extension you want - change to anything!
$start = strlen($ext) - (strlen($ext)*2); //gets the negative number
$end = strlen($ext);
foreach($files as $file) {
if(substr($file, $start, $end) == $ext) {
$sig[] = "http://yoursite.com/signatures/".$file;
}
}
We can either go about this by forwarding the user to the address which is probably the cheaper way of doing it but will work in most forum signatures I would assume. It worked when I tried it on codecall. Or we can actually generate the page.
Code:header('Location: '.$sig[mt_rand(0, count($sig)-1)]);
So to sum it all up...Code:header('Content-type: image/gif');
$im = imagecreatefromgif($sig[mt_rand(0,count($sig)-1)]);
imagegif($im);
Code:<?PHP
//array of images
$folder = "/homepages/blainesch/htdocs/siggys/";
$files = scandir($folder);
$ext = "gif";
$start = strlen($ext) - (strlen($ext)*2);
$end = strlen($ext);
foreach($files as $file) {
if(substr($file, $start, $end) == $ext) {
$sig[] = $folder.$file;
}
}
header('Content-type: image/gif');
$im = imagecreatefromgif($sig[mt_rand(0,count($sig)-1)]);
imagegif($im);
?>![]()
Very cool, +rep!
awesome dude
i really like this kind of tutorials good work
++rep
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
www.amrosama.com | the unholy methods of javascriptCode:eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks